From 2d46beccc9efd17569695af435b3daab6e43f1d0 Mon Sep 17 00:00:00 2001 From: Nikita Kulikov Date: Tue, 19 Sep 2023 15:58:49 +0400 Subject: [PATCH] Add faphub metric (#700) **Background** Right now we can't understand how many users use faphub catalog **Changes** Add faphub metrics **Test plan** Test each metric event --- .github/workflows/internal.yml | 2 ++ CHANGELOG.md | 2 +- .../com/flipperdevices/metric/api/MetricApi.kt | 2 +- .../metric/api/events/SimpleEvent.kt | 8 +++++++- .../metric/impl/api/MetricApiImpl.kt | 6 +++--- .../metric/impl/clickhouse/ClickhouseApi.kt | 2 +- .../impl/clickhouse/ClickhouseApiImpl.kt | 13 ++++++++++++- .../analytics/metric/impl/src/main/proto | 2 +- .../metric/noop/NoopMetricApiImpl.kt | 2 +- .../faphub/category/impl/build.gradle.kts | 2 ++ .../category/impl/api/FapHubCategoryApiImpl.kt | 6 +++++- .../faphub/fapscreen/impl/build.gradle.kts | 2 ++ .../impl/viewmodel/FapScreenViewModel.kt | 9 ++++++++- .../installation/queue/impl/build.gradle.kts | 2 ++ .../queue/impl/api/FapQueueRunner.kt | 18 +++++++++++++++++- components/faphub/main/impl/build.gradle.kts | 2 ++ .../main/impl/api/FapHubMainScreenApiImpl.kt | 9 ++++++++- components/faphub/search/impl/build.gradle.kts | 2 ++ .../impl/api/FapHubSearchEntryApiImpl.kt | 6 +++++- components/hub/impl/build.gradle.kts | 1 + .../hub/impl/api/HubFeatureEntryImpl.kt | 6 +++++- 21 files changed, 88 insertions(+), 16 deletions(-) diff --git a/.github/workflows/internal.yml b/.github/workflows/internal.yml index 65f3d249bd..b4763a57e4 100644 --- a/.github/workflows/internal.yml +++ b/.github/workflows/internal.yml @@ -78,6 +78,8 @@ jobs: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} ORG_GRADLE_PROJECT_version_code: ${{ steps.vars.outputs.minor_version }} ORG_GRADLE_PROJECT_version_name: "${{ steps.vars.outputs.major_version }}.${{ steps.vars.outputs.minor_version }}" + ORG_GRADLE_PROJECT_countly_url: ${{ secrets.COUNTLY_URL_PROD }} + ORG_GRADLE_PROJECT_countly_app_key: ${{ secrets.COUNTLY_APP_KEY_PROD }} run: | export $(cat .github/workflows/targets/${{ matrix.target }}.env | xargs) ./gradlew :instances:app:assembleInternal :instances:app:bundleInternal diff --git a/CHANGELOG.md b/CHANGELOG.md index 74d412f823..bd184f9e46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - [Feature] Scroll on Infrared Screen - [Feature] Check Self Update App in Options (only for github) - [Feature] Fap Catalog save sort -- [Feature] Check Self Update App in Optiond (only for github) +- [Feature] Add metrics for faphub - [FIX] Use by default dark theme in Wear OS - [FIX] Use default splashscreen in Wear OS - [FIX] Fix compose layout in Wear OS diff --git a/components/analytics/metric/api/src/main/java/com/flipperdevices/metric/api/MetricApi.kt b/components/analytics/metric/api/src/main/java/com/flipperdevices/metric/api/MetricApi.kt index f78a4e9f12..e92e5a7d35 100644 --- a/components/analytics/metric/api/src/main/java/com/flipperdevices/metric/api/MetricApi.kt +++ b/components/analytics/metric/api/src/main/java/com/flipperdevices/metric/api/MetricApi.kt @@ -4,6 +4,6 @@ import com.flipperdevices.metric.api.events.ComplexEvent import com.flipperdevices.metric.api.events.SimpleEvent interface MetricApi { - fun reportSimpleEvent(simpleEvent: SimpleEvent) + fun reportSimpleEvent(simpleEvent: SimpleEvent, arg: String? = null) fun reportComplexEvent(complexEvent: ComplexEvent) } diff --git a/components/analytics/metric/api/src/main/java/com/flipperdevices/metric/api/events/SimpleEvent.kt b/components/analytics/metric/api/src/main/java/com/flipperdevices/metric/api/events/SimpleEvent.kt index a06558b3b3..ad0c7ff895 100644 --- a/components/analytics/metric/api/src/main/java/com/flipperdevices/metric/api/events/SimpleEvent.kt +++ b/components/analytics/metric/api/src/main/java/com/flipperdevices/metric/api/events/SimpleEvent.kt @@ -13,5 +13,11 @@ enum class SimpleEvent(val id: String) { SHARE_FILE("share_file"), SAVE_DUMP("save_dump"), MFKEY32("mfkey32"), - OPEN_NFC_DUMP_EDITOR("open_nfc_dump_editor") + OPEN_NFC_DUMP_EDITOR("open_nfc_dump_editor"), + OPEN_FAPHUB("open_faphub"), + OPEN_FAPHUB_CATEGORY("open_faphub_category"), + OPEN_FAPHUB_SEARCH("open_faphub_search"), + OPEN_FAPHUB_APP("open_faphub_app"), + INSTALL_FAPHUB_APP("install_faphub_app"), + HIDE_FAPHUB_APP("hide_faphub_app"), } diff --git a/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/api/MetricApiImpl.kt b/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/api/MetricApiImpl.kt index d0760c26ad..17d2b6fd10 100644 --- a/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/api/MetricApiImpl.kt +++ b/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/api/MetricApiImpl.kt @@ -18,14 +18,14 @@ class MetricApiImpl @Inject constructor( ) : MetricApi, LogTagProvider { override val TAG = "MetricApi" - override fun reportSimpleEvent(simpleEvent: SimpleEvent) { + override fun reportSimpleEvent(simpleEvent: SimpleEvent, arg: String?) { try { - countlyApi.reportEvent(simpleEvent.id) + countlyApi.reportEvent(simpleEvent.id, params = mapOf("arg" to arg)) } catch (e: Exception) { error(e) { "Failed to report to Countly simple event: ${simpleEvent.id}" } } try { - clickhouseApi.reportSimpleEvent(simpleEvent) + clickhouseApi.reportSimpleEvent(simpleEvent, simpleEventArg = arg) } catch (e: Exception) { error(e) { "Failed to report to Clickhouse simple event: ${simpleEvent.id}" } } diff --git a/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/clickhouse/ClickhouseApi.kt b/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/clickhouse/ClickhouseApi.kt index 285c251a70..e06cf223d7 100644 --- a/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/clickhouse/ClickhouseApi.kt +++ b/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/clickhouse/ClickhouseApi.kt @@ -4,6 +4,6 @@ import com.flipperdevices.metric.api.events.ComplexEvent import com.flipperdevices.metric.api.events.SimpleEvent interface ClickhouseApi { - fun reportSimpleEvent(simpleEvent: SimpleEvent) + fun reportSimpleEvent(simpleEvent: SimpleEvent, simpleEventArg: String?) fun reportComplexEvent(complexEvent: ComplexEvent) } diff --git a/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/clickhouse/ClickhouseApiImpl.kt b/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/clickhouse/ClickhouseApiImpl.kt index 5734e47d25..59dc86eda3 100644 --- a/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/clickhouse/ClickhouseApiImpl.kt +++ b/components/analytics/metric/impl/src/main/java/com/flipperdevices/metric/impl/clickhouse/ClickhouseApiImpl.kt @@ -62,7 +62,8 @@ class ClickhouseApiImpl @Inject constructor( private val scope = CoroutineScope(SupervisorJob()) private val sessionUUID by lazy { UUID.randomUUID() } - override fun reportSimpleEvent(simpleEvent: SimpleEvent) { + @Suppress("CyclomaticComplexMethod") + override fun reportSimpleEvent(simpleEvent: SimpleEvent, simpleEventArg: String?) { val openTarget = when (simpleEvent) { SimpleEvent.APP_OPEN -> OpenOuterClass.Open.OpenTarget.APP SimpleEvent.OPEN_SAVE_KEY -> OpenOuterClass.Open.OpenTarget.SAVE_KEY @@ -79,12 +80,22 @@ class ClickhouseApiImpl @Inject constructor( SimpleEvent.SAVE_DUMP -> OpenOuterClass.Open.OpenTarget.SAVE_DUMP SimpleEvent.MFKEY32 -> OpenOuterClass.Open.OpenTarget.MFKEY32 SimpleEvent.OPEN_NFC_DUMP_EDITOR -> OpenOuterClass.Open.OpenTarget.OPEN_NFC_DUMP_EDITOR + SimpleEvent.OPEN_FAPHUB -> OpenOuterClass.Open.OpenTarget.OPEN_FAPHUB + SimpleEvent.OPEN_FAPHUB_CATEGORY -> OpenOuterClass.Open.OpenTarget.OPEN_FAPHUB_CATEGORY + SimpleEvent.OPEN_FAPHUB_SEARCH -> OpenOuterClass.Open.OpenTarget.OPEN_FAPHUB_SEARCH + SimpleEvent.OPEN_FAPHUB_APP -> OpenOuterClass.Open.OpenTarget.OPEN_FAPHUB_APP + SimpleEvent.INSTALL_FAPHUB_APP -> OpenOuterClass.Open.OpenTarget.INSTALL_FAPHUB_APP + SimpleEvent.HIDE_FAPHUB_APP -> OpenOuterClass.Open.OpenTarget.HIDE_FAPHUB_APP } + scope.launch(Dispatchers.Default) { reportToServerSafe( metricEventsCollection { open = open { target = openTarget + if (simpleEventArg != null) { + this.arg = simpleEventArg + } } } ) diff --git a/components/analytics/metric/impl/src/main/proto b/components/analytics/metric/impl/src/main/proto index 6aa64c9f8b..6c660a7d5f 160000 --- a/components/analytics/metric/impl/src/main/proto +++ b/components/analytics/metric/impl/src/main/proto @@ -1 +1 @@ -Subproject commit 6aa64c9f8b62ebf40a042f14aada4cf05fc39922 +Subproject commit 6c660a7d5f3e7109b5c90a88828d1f06532ec288 diff --git a/components/analytics/metric/noop/src/main/java/com/flipperdevices/metric/noop/NoopMetricApiImpl.kt b/components/analytics/metric/noop/src/main/java/com/flipperdevices/metric/noop/NoopMetricApiImpl.kt index 68259260e5..8791d164ad 100644 --- a/components/analytics/metric/noop/src/main/java/com/flipperdevices/metric/noop/NoopMetricApiImpl.kt +++ b/components/analytics/metric/noop/src/main/java/com/flipperdevices/metric/noop/NoopMetricApiImpl.kt @@ -9,7 +9,7 @@ import javax.inject.Inject @ContributesBinding(AppGraph::class, MetricApi::class) class NoopMetricApiImpl @Inject constructor() : MetricApi { - override fun reportSimpleEvent(simpleEvent: SimpleEvent) = Unit + override fun reportSimpleEvent(simpleEvent: SimpleEvent, arg: String?) = Unit override fun reportComplexEvent(complexEvent: ComplexEvent) = Unit } diff --git a/components/faphub/category/impl/build.gradle.kts b/components/faphub/category/impl/build.gradle.kts index ab2d2ada7a..9a1ca4169f 100644 --- a/components/faphub/category/impl/build.gradle.kts +++ b/components/faphub/category/impl/build.gradle.kts @@ -25,6 +25,8 @@ dependencies { implementation(projects.components.faphub.target.api) implementation(projects.components.faphub.errors.api) + implementation(projects.components.analytics.metric.api) + implementation(projects.components.bridge.dao.api) // Compose diff --git a/components/faphub/category/impl/src/main/java/com/flipperdevices/faphub/category/impl/api/FapHubCategoryApiImpl.kt b/components/faphub/category/impl/src/main/java/com/flipperdevices/faphub/category/impl/api/FapHubCategoryApiImpl.kt index 6333525756..7e11d8dac1 100644 --- a/components/faphub/category/impl/src/main/java/com/flipperdevices/faphub/category/impl/api/FapHubCategoryApiImpl.kt +++ b/components/faphub/category/impl/src/main/java/com/flipperdevices/faphub/category/impl/api/FapHubCategoryApiImpl.kt @@ -16,6 +16,8 @@ import com.flipperdevices.faphub.installation.button.api.FapButtonSize import com.flipperdevices.faphub.installation.button.api.FapInstallationUIApi import com.flipperdevices.faphub.installation.button.api.toFapButtonConfig import com.flipperdevices.faphub.search.api.FapHubSearchEntryApi +import com.flipperdevices.metric.api.MetricApi +import com.flipperdevices.metric.api.events.SimpleEvent import com.squareup.anvil.annotations.ContributesBinding import com.squareup.anvil.annotations.ContributesMultibinding import kotlinx.serialization.encodeToString @@ -30,7 +32,8 @@ class FapHubCategoryApiImpl @Inject constructor( private val searchEntryApi: FapHubSearchEntryApi, private val fapScreenApi: FapScreenApi, private val fapInstallationUIApi: FapInstallationUIApi, - private val errorsRenderer: FapHubComposableErrorsRenderer + private val errorsRenderer: FapHubComposableErrorsRenderer, + private val metricApi: MetricApi ) : FapHubCategoryApi { private val categoryArguments = listOf( navArgument(CATEGORY_OPEN_PATH_KEY) { @@ -52,6 +55,7 @@ class FapHubCategoryApiImpl @Inject constructor( onBack = navController::popBackStack, onOpenSearch = { navController.navigate(searchEntryApi.start()) }, onOpenFapItem = { + metricApi.reportSimpleEvent(SimpleEvent.OPEN_FAPHUB_APP, it.applicationAlias) navController.navigate(fapScreenApi.getFapScreen(it.id)) }, errorsRenderer = errorsRenderer, diff --git a/components/faphub/fapscreen/impl/build.gradle.kts b/components/faphub/fapscreen/impl/build.gradle.kts index 314d6eb976..e8586e8e85 100644 --- a/components/faphub/fapscreen/impl/build.gradle.kts +++ b/components/faphub/fapscreen/impl/build.gradle.kts @@ -23,6 +23,8 @@ dependencies { implementation(projects.components.core.ui.navigation) implementation(projects.components.core.ui.dialog) + implementation(projects.components.analytics.metric.api) + implementation(projects.components.bridge.dao.api) // Compose diff --git a/components/faphub/fapscreen/impl/src/main/java/com/flipperdevices/faphub/fapscreen/impl/viewmodel/FapScreenViewModel.kt b/components/faphub/fapscreen/impl/src/main/java/com/flipperdevices/faphub/fapscreen/impl/viewmodel/FapScreenViewModel.kt index e8ad02d00f..c88fbee243 100644 --- a/components/faphub/fapscreen/impl/src/main/java/com/flipperdevices/faphub/fapscreen/impl/viewmodel/FapScreenViewModel.kt +++ b/components/faphub/fapscreen/impl/src/main/java/com/flipperdevices/faphub/fapscreen/impl/viewmodel/FapScreenViewModel.kt @@ -20,6 +20,8 @@ import com.flipperdevices.faphub.report.api.FapReportFeatureEntry import com.flipperdevices.faphub.target.api.FlipperTargetProviderApi import com.flipperdevices.inappnotification.api.InAppNotificationStorage import com.flipperdevices.inappnotification.api.model.InAppNotification +import com.flipperdevices.metric.api.MetricApi +import com.flipperdevices.metric.api.events.SimpleEvent import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -46,7 +48,8 @@ class FapScreenViewModel @VMInject constructor( private val targetProviderApi: FlipperTargetProviderApi, private val fapReportFeatureEntry: FapReportFeatureEntry, private val fapHubHideApi: FapHubHideItemApi, - private val inAppNotificationStorage: InAppNotificationStorage + private val inAppNotificationStorage: InAppNotificationStorage, + private val metricApi: MetricApi ) : ViewModel(), LogTagProvider { override val TAG = "FapScreenViewModel" @@ -85,6 +88,10 @@ class FapScreenViewModel @VMInject constructor( warn { "#onPressHide calls when fapScreenLoadingStateFlow is null or not loaded" } return } + metricApi.reportSimpleEvent( + SimpleEvent.HIDE_FAPHUB_APP, + loadingState.fapItem.applicationAlias + ) viewModelScope.launch(Dispatchers.Default) { if (isHidden) { fapHubHideApi.unHideItem(loadingState.fapItem.id) diff --git a/components/faphub/installation/queue/impl/build.gradle.kts b/components/faphub/installation/queue/impl/build.gradle.kts index 38e28f8895..ace7b45c1f 100644 --- a/components/faphub/installation/queue/impl/build.gradle.kts +++ b/components/faphub/installation/queue/impl/build.gradle.kts @@ -19,6 +19,8 @@ dependencies { implementation(projects.components.faphub.target.api) implementation(projects.components.faphub.installation.manifest.api) + implementation(projects.components.analytics.metric.api) + implementation(projects.components.bridge.api) implementation(projects.components.bridge.pbutils) implementation(projects.components.bridge.service.api) diff --git a/components/faphub/installation/queue/impl/src/main/java/com/flipperdevices/faphub/installation/queue/impl/api/FapQueueRunner.kt b/components/faphub/installation/queue/impl/src/main/java/com/flipperdevices/faphub/installation/queue/impl/api/FapQueueRunner.kt index 0efccba435..05b501fcd2 100644 --- a/components/faphub/installation/queue/impl/src/main/java/com/flipperdevices/faphub/installation/queue/impl/api/FapQueueRunner.kt +++ b/components/faphub/installation/queue/impl/src/main/java/com/flipperdevices/faphub/installation/queue/impl/api/FapQueueRunner.kt @@ -8,6 +8,8 @@ import com.flipperdevices.core.log.info import com.flipperdevices.faphub.installation.queue.api.model.FapActionRequest import com.flipperdevices.faphub.installation.queue.impl.executor.FapActionExecutor import com.flipperdevices.faphub.installation.queue.impl.model.FapInternalQueueState +import com.flipperdevices.metric.api.MetricApi +import com.flipperdevices.metric.api.events.SimpleEvent import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -25,7 +27,8 @@ import kotlinx.coroutines.withContext import javax.inject.Inject class FapQueueRunner @Inject constructor( - private val fapActionExecutor: FapActionExecutor + private val fapActionExecutor: FapActionExecutor, + private val metricApi: MetricApi ) : LogTagProvider { override val TAG = "FapQueueRunner" @@ -51,6 +54,7 @@ class FapQueueRunner @Inject constructor( } suspend fun enqueueSync(actionRequest: FapActionRequest) { + reportMetric(actionRequest) if (actionRequest is FapActionRequest.Cancel) { cancelTasksForApplicationUid(actionRequest) } else { @@ -63,6 +67,18 @@ class FapQueueRunner @Inject constructor( } } + private fun reportMetric(actionRequest: FapActionRequest) { + when (actionRequest) { + is FapActionRequest.Cancel, + is FapActionRequest.Delete, + is FapActionRequest.Update -> {} + is FapActionRequest.Install -> metricApi.reportSimpleEvent( + SimpleEvent.INSTALL_FAPHUB_APP, + actionRequest.applicationAlias + ) + } + } + private suspend fun loop() { info { "Start loop" } val currentJob = takeJobForLoop() ?: return diff --git a/components/faphub/main/impl/build.gradle.kts b/components/faphub/main/impl/build.gradle.kts index 18ed033ed2..2da0d2c25d 100644 --- a/components/faphub/main/impl/build.gradle.kts +++ b/components/faphub/main/impl/build.gradle.kts @@ -23,6 +23,8 @@ dependencies { implementation(projects.components.faphub.category.api) implementation(projects.components.faphub.fapscreen.api) + implementation(projects.components.analytics.metric.api) + // Compose implementation(libs.compose.ui) implementation(libs.compose.tooling) diff --git a/components/faphub/main/impl/src/main/java/com/flipperdevices/main/impl/api/FapHubMainScreenApiImpl.kt b/components/faphub/main/impl/src/main/java/com/flipperdevices/main/impl/api/FapHubMainScreenApiImpl.kt index f056644d07..e4408ecabe 100644 --- a/components/faphub/main/impl/src/main/java/com/flipperdevices/main/impl/api/FapHubMainScreenApiImpl.kt +++ b/components/faphub/main/impl/src/main/java/com/flipperdevices/main/impl/api/FapHubMainScreenApiImpl.kt @@ -15,6 +15,8 @@ import com.flipperdevices.faphub.main.api.FapHubHandleDeeplink import com.flipperdevices.faphub.main.api.FapHubMainScreenApi import com.flipperdevices.faphub.search.api.FapHubSearchEntryApi import com.flipperdevices.main.impl.composable.ComposableFapHubMainScreen +import com.flipperdevices.metric.api.MetricApi +import com.flipperdevices.metric.api.events.SimpleEvent import com.squareup.anvil.annotations.ContributesBinding import com.squareup.anvil.annotations.ContributesMultibinding import javax.inject.Inject @@ -29,7 +31,8 @@ class FapHubMainScreenApiImpl @Inject constructor( private val searchEntryApi: FapHubSearchEntryApi, private val categoryEntryApi: FapHubCategoryApi, private val fapScreenApi: FapScreenApi, - private val installedApi: FapInstalledApi + private val installedApi: FapInstalledApi, + private val metricApi: MetricApi ) : FapHubMainScreenApi, FapHubHandleDeeplink { private fun start(): String = "@${ROUTE.name}" @@ -48,19 +51,23 @@ class FapHubMainScreenApiImpl @Inject constructor( catalogTabComposable = { catalogTabApi.ComposableCatalogTab( onOpenFapItem = { + metricApi.reportSimpleEvent(SimpleEvent.OPEN_FAPHUB_APP, it.applicationAlias) navController.navigate(fapScreenApi.getFapScreen(it.id)) }, onCategoryClick = { + metricApi.reportSimpleEvent(SimpleEvent.OPEN_FAPHUB_CATEGORY, it.name) navController.navigate(categoryEntryApi.open(it)) } ) }, installedTabComposable = { installedApi.ComposableInstalledTab(onOpenFapItem = { + metricApi.reportSimpleEvent(SimpleEvent.OPEN_FAPHUB_APP, it) navController.navigate(fapScreenApi.getFapScreen(it)) }) }, onOpenSearch = { + metricApi.reportSimpleEvent(SimpleEvent.OPEN_FAPHUB_SEARCH) navController.navigate(searchEntryApi.start()) }, installedNotificationCount = readyToUpdateCount diff --git a/components/faphub/search/impl/build.gradle.kts b/components/faphub/search/impl/build.gradle.kts index 795c6ba5ba..1517b8b2e6 100644 --- a/components/faphub/search/impl/build.gradle.kts +++ b/components/faphub/search/impl/build.gradle.kts @@ -22,6 +22,8 @@ dependencies { implementation(projects.components.faphub.target.api) implementation(projects.components.faphub.errors.api) + implementation(projects.components.analytics.metric.api) + implementation(projects.components.bridge.dao.api) // Compose diff --git a/components/faphub/search/impl/src/main/java/com/flipperdevices/faphub/search/impl/api/FapHubSearchEntryApiImpl.kt b/components/faphub/search/impl/src/main/java/com/flipperdevices/faphub/search/impl/api/FapHubSearchEntryApiImpl.kt index f95f749f98..797d8abae9 100644 --- a/components/faphub/search/impl/src/main/java/com/flipperdevices/faphub/search/impl/api/FapHubSearchEntryApiImpl.kt +++ b/components/faphub/search/impl/src/main/java/com/flipperdevices/faphub/search/impl/api/FapHubSearchEntryApiImpl.kt @@ -14,6 +14,8 @@ import com.flipperdevices.faphub.installation.button.api.FapInstallationUIApi import com.flipperdevices.faphub.installation.button.api.toFapButtonConfig import com.flipperdevices.faphub.search.api.FapHubSearchEntryApi import com.flipperdevices.faphub.search.impl.composable.ComposableSearchScreen +import com.flipperdevices.metric.api.MetricApi +import com.flipperdevices.metric.api.events.SimpleEvent import com.squareup.anvil.annotations.ContributesBinding import com.squareup.anvil.annotations.ContributesMultibinding import javax.inject.Inject @@ -24,7 +26,8 @@ import javax.inject.Provider class FapHubSearchEntryApiImpl @Inject constructor( fapScreenApiProvider: Provider, private val fapInstallationUIApi: FapInstallationUIApi, - private val errorsRenderer: FapHubComposableErrorsRenderer + private val errorsRenderer: FapHubComposableErrorsRenderer, + private val metricApi: MetricApi ) : FapHubSearchEntryApi { private val fapScreenApi by fapScreenApiProvider @@ -36,6 +39,7 @@ class FapHubSearchEntryApiImpl @Inject constructor( ComposableSearchScreen( onBack = { navController.popBackStack() }, onFapItemClick = { + metricApi.reportSimpleEvent(SimpleEvent.OPEN_FAPHUB_APP, it.name) navController.navigate(fapScreenApi.getFapScreen(it.id)) }, errorsRenderer = errorsRenderer, diff --git a/components/hub/impl/build.gradle.kts b/components/hub/impl/build.gradle.kts index 46c544c478..51b08a39b4 100644 --- a/components/hub/impl/build.gradle.kts +++ b/components/hub/impl/build.gradle.kts @@ -9,6 +9,7 @@ dependencies { implementation(projects.components.hub.api) implementation(projects.components.faphub.maincard.api) implementation(projects.components.faphub.main.api) + implementation(projects.components.analytics.metric.api) implementation(projects.components.core.di) implementation(projects.components.core.preference) diff --git a/components/hub/impl/src/main/java/com/flipperdevices/hub/impl/api/HubFeatureEntryImpl.kt b/components/hub/impl/src/main/java/com/flipperdevices/hub/impl/api/HubFeatureEntryImpl.kt index e39b75acbf..c4dcc039c6 100644 --- a/components/hub/impl/src/main/java/com/flipperdevices/hub/impl/api/HubFeatureEntryImpl.kt +++ b/components/hub/impl/src/main/java/com/flipperdevices/hub/impl/api/HubFeatureEntryImpl.kt @@ -17,6 +17,8 @@ import com.flipperdevices.faphub.main.api.FapHubMainScreenApi import com.flipperdevices.faphub.maincard.api.MainCardApi import com.flipperdevices.hub.api.HubFeatureEntry import com.flipperdevices.hub.impl.composable.ComposableHub +import com.flipperdevices.metric.api.MetricApi +import com.flipperdevices.metric.api.events.SimpleEvent import com.flipperdevices.nfc.attack.api.NFCAttackFeatureEntry import com.flipperdevices.screenstreaming.api.ScreenStreamingFeatureEntry import com.squareup.anvil.annotations.ContributesBinding @@ -29,7 +31,8 @@ class HubFeatureEntryImpl @Inject constructor( private val nfcAttackFeatureEntry: NFCAttackFeatureEntry, private val mainCardApi: MainCardApi, private val screenStreamingFeatureEntry: ScreenStreamingFeatureEntry, - private val fapHubMainScreenApi: FapHubMainScreenApi + private val fapHubMainScreenApi: FapHubMainScreenApi, + private val metricApi: MetricApi ) : HubFeatureEntry { override fun start() = "@${ROUTE.name}" @@ -62,6 +65,7 @@ class HubFeatureEntryImpl @Inject constructor( top = 14.dp ), onClick = { + metricApi.reportSimpleEvent(SimpleEvent.OPEN_FAPHUB) navController.navigate(fapHubMainScreenApi.ROUTE.name) } )