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) {
savedStateHandle[LINKED_NEWS_RESOURCE_ID] = null
}
analyticsHelper.logEvent(
AnalyticsEvent(
type = "news_deep_link_opened",
extras = listOf(
Param(
key = LINKED_NEWS_RESOURCE_ID,
value = newsResourceId,
),
),
),
)
analyticsHelper.logNewsDeepLinkOpen(newsResourceId = newsResourceId)
viewModelScope.launch {
userDataRepository.setNewsResourceViewed(
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