Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add year property to End of Year analytics #3163

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import au.com.shiftyjelly.pocketcasts.referrals.ReferralsGuestPassFragment
import au.com.shiftyjelly.pocketcasts.repositories.bumpstats.BumpStatsTask
import au.com.shiftyjelly.pocketcasts.repositories.di.ApplicationScope
import au.com.shiftyjelly.pocketcasts.repositories.di.NotificationPermissionChecker
import au.com.shiftyjelly.pocketcasts.repositories.endofyear.EndOfYearManager
import au.com.shiftyjelly.pocketcasts.repositories.notification.NotificationHelper
import au.com.shiftyjelly.pocketcasts.repositories.opml.OpmlImportTask
import au.com.shiftyjelly.pocketcasts.repositories.playback.PlaybackManager
Expand Down Expand Up @@ -725,7 +726,10 @@ class MainActivity :
showStoriesOrAccount(StoriesSource.MODAL.value)
},
onExpanded = {
analyticsTracker.track(AnalyticsEvent.END_OF_YEAR_MODAL_SHOWN)
analyticsTracker.track(
AnalyticsEvent.END_OF_YEAR_MODAL_SHOWN,
mapOf("year" to EndOfYearManager.YEAR_TO_SYNC.value),
)
settings.setEndOfYearShowModal(false)
viewModel.updateStoriesModalShowState(false)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,47 +230,60 @@ class EndOfYearViewModel @AssistedInject constructor(
}

internal fun trackFailedToLoad() {
analyticsTracker.track(AnalyticsEvent.END_OF_YEAR_STORIES_FAILED_TO_LOAD)
trackEvent(AnalyticsEvent.END_OF_YEAR_STORIES_FAILED_TO_LOAD)
}

internal fun trackStoriesShown() {
analyticsTracker.track(
trackEvent(
AnalyticsEvent.END_OF_YEAR_STORIES_SHOWN,
mapOf("source" to source.value),
)
}

internal fun trackStoriesClosed(source: String) {
analyticsTracker.track(
trackEvent(
AnalyticsEvent.END_OF_YEAR_STORIES_DISMISSED,
mapOf("source" to source),
)
}

internal fun trackStoriesAutoFinished() {
analyticsTracker.track(
trackEvent(
AnalyticsEvent.END_OF_YEAR_STORIES_DISMISSED,
mapOf("source" to "auto_progress"),
)
}

internal fun trackStoryShown(story: Story) {
analyticsTracker.track(
trackEvent(
AnalyticsEvent.END_OF_YEAR_STORY_SHOWN,
mapOf("story" to story.analyticsValue),
)
}

internal fun trackReplayStoriesTapped() {
analyticsTracker.track(AnalyticsEvent.END_OF_YEAR_STORY_REPLAY_BUTTON_TAPPED)
trackEvent(AnalyticsEvent.END_OF_YEAR_STORY_REPLAY_BUTTON_TAPPED)
}

internal fun trackUpsellShown() {
analyticsTracker.track(AnalyticsEvent.END_OF_YEAR_UPSELL_SHOWN)
trackEvent(AnalyticsEvent.END_OF_YEAR_UPSELL_SHOWN)
}

internal fun trackLearnRatingsShown() {
analyticsTracker.track(AnalyticsEvent.END_OF_YEAR_LEARN_RATINGS_SHOWN)
trackEvent(AnalyticsEvent.END_OF_YEAR_LEARN_RATINGS_SHOWN)
}

private fun trackEvent(
event: AnalyticsEvent,
properties: Map<String, Any> = emptyMap(),
) {
analyticsTracker.track(
event,
buildMap {
putAll(properties)
put("year", year.value)
},
)
}

private fun getRandomShowIds(stats: EndOfYearStats): RandomShowIds? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import au.com.shiftyjelly.pocketcasts.profile.cloud.CloudFilesFragment
import au.com.shiftyjelly.pocketcasts.profile.databinding.FragmentProfileBinding
import au.com.shiftyjelly.pocketcasts.referrals.ReferralsClaimGuestPassBannerCard
import au.com.shiftyjelly.pocketcasts.referrals.ReferralsIconWithTooltip
import au.com.shiftyjelly.pocketcasts.repositories.endofyear.EndOfYearManager
import au.com.shiftyjelly.pocketcasts.repositories.podcast.PodcastManager
import au.com.shiftyjelly.pocketcasts.repositories.user.UserManager
import au.com.shiftyjelly.pocketcasts.settings.HelpFragment
Expand Down Expand Up @@ -277,7 +278,10 @@ class ProfileFragment : BaseFragment() {
AppTheme(theme.activeTheme) {
EndOfYearPromptCard(
onClick = {
analyticsTracker.track(AnalyticsEvent.END_OF_YEAR_PROFILE_CARD_TAPPED)
analyticsTracker.track(
AnalyticsEvent.END_OF_YEAR_PROFILE_CARD_TAPPED,
mapOf("year" to EndOfYearManager.YEAR_TO_SYNC.value),
)
// once stories prompt card is tapped, we don't want to show stories launch modal if not already shown
if (settings.getEndOfYearShowModal()) {
settings.setEndOfYearShowModal(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ class SharingClient(
val pendingIntent = ItemSharedReceiver.intent(
context = context,
event = AnalyticsEvent.END_OF_YEAR_STORY_SHARED,
values = mapOf("story" to data.story.analyticsValue),
values = mapOf(
"story" to data.story.analyticsValue,
"year" to data.year.value,
),
)
Intent()
.setAction(Intent.ACTION_SEND)
Expand Down Expand Up @@ -393,6 +396,7 @@ data class SharingRequest internal constructor(
) = Builder(Data.EndOfYearStory(story, year, screenshot))
.setAnalyticsEvent(AnalyticsEvent.END_OF_YEAR_STORY_SHARE)
.addAnalyticsProperty("story", story.analyticsValue)
.addAnalyticsProperty("year", year.value)
}

class Builder internal constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ class SharingAnalyticsTest {
"story" to "number_of_shows",
"source" to "unknown",
"action" to "system_sheet",
"year" to 1000,
),
)
}
Expand Down Expand Up @@ -514,6 +515,7 @@ class SharingAnalyticsTest {
"story" to "top_1_show",
"source" to "unknown",
"action" to "system_sheet",
"year" to 1000,
),
)
}
Expand All @@ -536,6 +538,7 @@ class SharingAnalyticsTest {
"story" to "top_5_shows",
"source" to "unknown",
"action" to "system_sheet",
"year" to 1000,
),
)
}
Expand Down Expand Up @@ -563,6 +566,7 @@ class SharingAnalyticsTest {
"story" to "ratings",
"source" to "unknown",
"action" to "system_sheet",
"year" to 1000,
),
)
}
Expand All @@ -584,6 +588,7 @@ class SharingAnalyticsTest {
"story" to "total_time",
"source" to "unknown",
"action" to "system_sheet",
"year" to 1000,
),
)
}
Expand Down Expand Up @@ -612,6 +617,7 @@ class SharingAnalyticsTest {
"story" to "longest_episode",
"source" to "unknown",
"action" to "system_sheet",
"year" to 1000,
),
)
}
Expand All @@ -635,6 +641,7 @@ class SharingAnalyticsTest {
"story" to "year_vs_year",
"source" to "unknown",
"action" to "system_sheet",
"year" to 1000,
),
)
}
Expand All @@ -658,6 +665,7 @@ class SharingAnalyticsTest {
"story" to "completion_rate",
"source" to "unknown",
"action" to "system_sheet",
"year" to 1000,
),
)
}
Expand Down