Move analytics tracking of news deep link to an extension method

Change-Id: Id3d1a30d86634b9176067696db5ecfd4d02854a5
pull/824/head
TJ Dahunsi 1 year ago
parent c4686cfa54
commit 4af86580eb

@ -131,17 +131,7 @@ class ForYouViewModel @Inject constructor(
if (newsResourceId == deepLinkedNewsResource.value?.id) { if (newsResourceId == deepLinkedNewsResource.value?.id) {
savedStateHandle[LINKED_NEWS_RESOURCE_ID] = null savedStateHandle[LINKED_NEWS_RESOURCE_ID] = null
} }
analyticsHelper.logEvent( analyticsHelper.logNewsDeepLinkOpen(newsResourceId = newsResourceId)
AnalyticsEvent(
type = "news_deep_link_opened",
extras = listOf(
Param(
key = LINKED_NEWS_RESOURCE_ID,
value = newsResourceId,
),
),
),
)
viewModelScope.launch { viewModelScope.launch {
userDataRepository.setNewsResourceViewed( userDataRepository.setNewsResourceViewed(
newsResourceId = newsResourceId, newsResourceId = newsResourceId,
@ -156,3 +146,16 @@ class ForYouViewModel @Inject constructor(
} }
} }
} }
private fun AnalyticsHelper.logNewsDeepLinkOpen(newsResourceId: String) =
logEvent(
AnalyticsEvent(
type = "news_deep_link_opened",
extras = listOf(
Param(
key = LINKED_NEWS_RESOURCE_ID,
value = newsResourceId,
),
),
),
)

Loading…
Cancel
Save