Skip to content

Commit

Permalink
Tracks Audit: Add new subscriptions events (#3410)
Browse files Browse the repository at this point in the history
  • Loading branch information
mebarbosa authored Jan 8, 2025
1 parent b4f7aac commit 934a2c9
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ private const val UNKNOWN_TIER = "unknown_tier"
@Composable
fun OnboardingUpgradeBottomSheet(
onClickSubscribe: () -> Unit,
onPrivacyPolicyClick: () -> Unit = {},
onTermsAndConditionsClick: () -> Unit = {},
) {
// The keyboard sometimes gets opened when returning from the Google payment flow.
// This is keeps it closed while on this screen.
Expand Down Expand Up @@ -219,6 +221,8 @@ fun OnboardingUpgradeBottomSheet(
OnboardingUpgradeHelper.PrivacyPolicy(
color = Color.White,
textAlign = TextAlign.Center,
onPrivacyPolicyClick = onPrivacyPolicyClick,
onTermsAndConditionsClick = onTermsAndConditionsClick,
)

Spacer(Modifier.height(16.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package au.com.shiftyjelly.pocketcasts.account.onboarding.upgrade
import androidx.activity.SystemBarStyle
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
Expand Down Expand Up @@ -139,6 +138,7 @@ internal fun OnboardingUpgradeFeaturesPage(
state = loadedState,
onNotNowPressed = onNotNowPressed,
onClickSubscribe = { onClickSubscribe(true) },
onRateUsPressed = { viewModel.onRateUsPressed() },
canUpgrade = canUpgrade,
)
}
Expand All @@ -153,6 +153,8 @@ internal fun OnboardingUpgradeFeaturesPage(
onFeatureCardChanged = { viewModel.onFeatureCardChanged(loadedState.featureCardsState.featureCards[it]) },
onClickSubscribe = { onClickSubscribe(false) },
canUpgrade = canUpgrade,
onPrivacyPolicyClick = { viewModel.onPrivacyPolicyPressed() },
onTermsAndConditionsClick = { viewModel.onTermsAndConditionsPressed() },
)
}
}
Expand All @@ -177,6 +179,8 @@ private fun UpgradeLayoutOriginal(
onSubscriptionFrequencyChanged: (SubscriptionFrequency) -> Unit,
onFeatureCardChanged: (Int) -> Unit,
onClickSubscribe: () -> Unit,
onPrivacyPolicyClick: () -> Unit = {},
onTermsAndConditionsClick: () -> Unit = {},
canUpgrade: Boolean,
modifier: Modifier = Modifier,
) {
Expand Down Expand Up @@ -274,6 +278,8 @@ private fun UpgradeLayoutOriginal(
state = state,
upgradeButton = state.currentUpgradeButton,
onFeatureCardChanged = onFeatureCardChanged,
onPrivacyPolicyClick = onPrivacyPolicyClick,
onTermsAndConditionsClick = onTermsAndConditionsClick,
)
}

Expand All @@ -291,12 +297,13 @@ private fun UpgradeLayoutOriginal(
}
}

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun FeatureCards(
state: OnboardingUpgradeFeaturesState.Loaded,
upgradeButton: UpgradeButton,
onFeatureCardChanged: (Int) -> Unit,
onPrivacyPolicyClick: () -> Unit = {},
onTermsAndConditionsClick: () -> Unit = {},
) {
val featureCardsState = state.featureCardsState
val currentSubscriptionFrequency = state.currentSubscriptionFrequency
Expand All @@ -313,6 +320,8 @@ fun FeatureCards(
card = featureCardsState.featureCards[index],
subscriptionFrequency = currentSubscriptionFrequency,
upgradeButton = upgradeButton,
onPrivacyPolicyClick = onPrivacyPolicyClick,
onTermsAndConditionsClick = onTermsAndConditionsClick,
modifier = if (pagerHeight > 0) {
Modifier.height(pagerHeight.pxToDp(LocalContext.current).dp)
} else {
Expand All @@ -329,6 +338,8 @@ private fun FeatureCard(
subscription: Subscription,
subscriptionFrequency: SubscriptionFrequency,
modifier: Modifier = Modifier,
onPrivacyPolicyClick: () -> Unit = {},
onTermsAndConditionsClick: () -> Unit = {},
) {
Card(
shape = RoundedCornerShape(24.dp),
Expand Down Expand Up @@ -415,6 +426,8 @@ private fun FeatureCard(
color = Color.Black.copy(alpha = .5f),
textAlign = TextAlign.Start,
lineHeight = 18.sp,
onPrivacyPolicyClick = onPrivacyPolicyClick,
onTermsAndConditionsClick = onTermsAndConditionsClick,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ fun OnboardingUpgradeFlow(
LogBuffer.e(LogBuffer.TAG_SUBSCRIPTIONS, NULL_ACTIVITY_ERROR)
}
},
onPrivacyPolicyClick = {
mainSheetViewModel.onPrivacyPolicyPressed()
},
onTermsAndConditionsClick = {
mainSheetViewModel.onTermsAndConditionsPressed()
},
)
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ object OnboardingUpgradeHelper {
textAlign: TextAlign,
modifier: Modifier = Modifier,
lineHeight: TextUnit = 16.sp,
onPrivacyPolicyClick: () -> Unit = {},
onTermsAndConditionsClick: () -> Unit = {},
) {
val privacyPolicyText = stringResource(LR.string.onboarding_plus_privacy_policy)
val termsAndConditionsText = stringResource(LR.string.onboarding_plus_terms_and_conditions)
Expand All @@ -402,12 +404,14 @@ object OnboardingUpgradeHelper {
Clickable(
text = privacyPolicyText,
onClick = {
onPrivacyPolicyClick()
uriHandler.openUri(Settings.INFO_PRIVACY_URL)
},
),
Clickable(
text = termsAndConditionsText,
onClick = {
onTermsAndConditionsClick()
uriHandler.openUri(Settings.INFO_TOS_URL)
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fun UpgradeLayoutReviews(
state: OnboardingUpgradeFeaturesState.Loaded,
onNotNowPressed: () -> Unit,
onClickSubscribe: () -> Unit,
onRateUsPressed: () -> Unit,
canUpgrade: Boolean,
modifier: Modifier = Modifier,
data: List<ReviewData> = reviews,
Expand Down Expand Up @@ -153,6 +154,7 @@ fun UpgradeLayoutReviews(
item {
Button(
onClick = {
onRateUsPressed()
rateUs(context)
},
colors = ButtonDefaults.buttonColors(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class OnboardingUpgradeFeaturesViewModel @Inject constructor(
frequency = frequency,
)
settings.setLastSelectedSubscriptionFrequency(frequency)
analyticsTracker.track(AnalyticsEvent.PLUS_PROMOTION_SUBSCRIPTION_FREQUENCY_CHANGED, mapOf("value" to frequency.name.lowercase()))
currentSubscription?.let {
_state.update {
loadedState.copy(
Expand All @@ -196,6 +197,7 @@ class OnboardingUpgradeFeaturesViewModel @Inject constructor(
tier = upgradeFeatureCard.subscriptionTier,
frequency = loadedState.currentSubscriptionFrequency,
)
analyticsTracker.track(AnalyticsEvent.PLUS_PROMOTION_SUBSCRIPTION_TIER_CHANGED, mapOf("value" to upgradeFeatureCard.subscriptionTier.name.lowercase()))
settings.setLastSelectedSubscriptionTier(upgradeFeatureCard.subscriptionTier)
currentSubscription?.let {
_state.update {
Expand Down Expand Up @@ -274,6 +276,18 @@ class OnboardingUpgradeFeaturesViewModel @Inject constructor(
}
}

fun onRateUsPressed() {
analyticsTracker.track(AnalyticsEvent.RATE_US_TAPPED, mapOf("source" to OnboardingUpgradeSource.PLUS_DETAILS.analyticsValue))
}

fun onPrivacyPolicyPressed() {
analyticsTracker.track(AnalyticsEvent.PLUS_PROMOTION_PRIVACY_POLICY_TAPPED)
}

fun onTermsAndConditionsPressed() {
analyticsTracker.track(AnalyticsEvent.PLUS_PROMOTION_TERMS_AND_CONDITIONS_TAPPED)
}

companion object {
private fun analyticsProps(flow: OnboardingFlow, source: OnboardingUpgradeSource) =
mapOf("flow" to flow.analyticsValue, "source" to source.analyticsValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class AccountDetailsFragment : BaseFragment() {
OnboardingLauncher.openOnboardingFlow(activity, onboardingFlow)
},
onFeatureCardChanged = { featureCard ->
analyticsTracker.track(AnalyticsEvent.PLUS_PROMOTION_SUBSCRIPTION_TIER_CHANGED, mapOf("value" to featureCard.subscriptionTier.name.lowercase()))
upgradeBannerViewModel.onFeatureCardChanged(featureCard)
},
onChangeAvatar = { email ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ enum class AnalyticsEvent(val key: String) {
PLUS_PROMOTION_DISMISSED("plus_promotion_dismissed"),
PLUS_PROMOTION_NOT_NOW_BUTTON_TAPPED("plus_promotion_not_now_button_tapped"),
PLUS_PROMOTION_UPGRADE_BUTTON_TAPPED("plus_promotion_upgrade_button_tapped"),
PLUS_PROMOTION_SUBSCRIPTION_TIER_CHANGED("plus_promotion_subscription_tier_changed"),
PLUS_PROMOTION_SUBSCRIPTION_FREQUENCY_CHANGED("plus_promotion_subscription_frequency_changed"),
PLUS_PROMOTION_PRIVACY_POLICY_TAPPED("plus_promotion_privacy_policy_tapped"),
PLUS_PROMOTION_TERMS_AND_CONDITIONS_TAPPED("plus_promotion_terms_and_conditions_tapped"),

/* Pull to refresh */
PULLED_TO_REFRESH("pulled_to_refresh"),
Expand Down

0 comments on commit 934a2c9

Please sign in to comment.