From 733e5b000456325629adb033647b635c6bdfc068 Mon Sep 17 00:00:00 2001 From: Hieu Vu Date: Mon, 1 Jan 2024 11:02:31 +0700 Subject: [PATCH] Introduce feature based tracking --- .../navigator/analytics/AnalyticsModule.kt | 17 +++++++++++++++++ .../analytics/folders/FoldersAnalytics.kt | 6 ++++++ .../analytics/folders/FoldersAnalyticsImpl.kt | 17 +++++++++++++++++ .../arkbuilders/navigator/di/AppComponent.kt | 2 ++ .../screen/folders/FoldersFragment.kt | 6 ++++-- 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/dev/arkbuilders/navigator/analytics/AnalyticsModule.kt create mode 100644 app/src/main/java/dev/arkbuilders/navigator/analytics/folders/FoldersAnalytics.kt create mode 100644 app/src/main/java/dev/arkbuilders/navigator/analytics/folders/FoldersAnalyticsImpl.kt diff --git a/app/src/main/java/dev/arkbuilders/navigator/analytics/AnalyticsModule.kt b/app/src/main/java/dev/arkbuilders/navigator/analytics/AnalyticsModule.kt new file mode 100644 index 00000000..7a5e0cbe --- /dev/null +++ b/app/src/main/java/dev/arkbuilders/navigator/analytics/AnalyticsModule.kt @@ -0,0 +1,17 @@ +package dev.arkbuilders.navigator.analytics + +import dagger.Module +import dagger.Provides +import dev.arkbuilders.navigator.analytics.folders.FoldersAnalytics +import dev.arkbuilders.navigator.analytics.folders.FoldersAnalyticsImpl +import org.matomo.sdk.Tracker +import javax.inject.Singleton + +@Module +class AnalyticsModule { + + @Singleton + @Provides + fun provideFolderAnalytics(matomoTracker: Tracker): FoldersAnalytics = + FoldersAnalyticsImpl(matomoTracker) +} diff --git a/app/src/main/java/dev/arkbuilders/navigator/analytics/folders/FoldersAnalytics.kt b/app/src/main/java/dev/arkbuilders/navigator/analytics/folders/FoldersAnalytics.kt new file mode 100644 index 00000000..4aaf0259 --- /dev/null +++ b/app/src/main/java/dev/arkbuilders/navigator/analytics/folders/FoldersAnalytics.kt @@ -0,0 +1,6 @@ +package dev.arkbuilders.navigator.analytics.folders + +interface FoldersAnalytics { + fun trackScreen() + fun trackAction() +} diff --git a/app/src/main/java/dev/arkbuilders/navigator/analytics/folders/FoldersAnalyticsImpl.kt b/app/src/main/java/dev/arkbuilders/navigator/analytics/folders/FoldersAnalyticsImpl.kt new file mode 100644 index 00000000..6e7575d1 --- /dev/null +++ b/app/src/main/java/dev/arkbuilders/navigator/analytics/folders/FoldersAnalyticsImpl.kt @@ -0,0 +1,17 @@ +package dev.arkbuilders.navigator.analytics.folders + +import org.matomo.sdk.Tracker +import javax.inject.Inject + +class FoldersAnalyticsImpl @Inject constructor( + private val matomoTracker: Tracker +): FoldersAnalytics { + + override fun trackScreen() { + TODO("Not yet implemented") + } + + override fun trackAction() { + TODO("Not yet implemented") + } +} diff --git a/app/src/main/java/dev/arkbuilders/navigator/di/AppComponent.kt b/app/src/main/java/dev/arkbuilders/navigator/di/AppComponent.kt index 21f20dda..5ac3daff 100644 --- a/app/src/main/java/dev/arkbuilders/navigator/di/AppComponent.kt +++ b/app/src/main/java/dev/arkbuilders/navigator/di/AppComponent.kt @@ -26,6 +26,7 @@ import dev.arkbuilders.navigator.presentation.screen.resources.adapter.FileItemV import dev.arkbuilders.navigator.presentation.screen.resources.adapter.ResourcesGridPresenter import dev.arkbuilders.navigator.presentation.screen.settings.SettingsFragment import dev.arkbuilders.arkfilepicker.folders.FoldersRepo +import dev.arkbuilders.navigator.analytics.AnalyticsModule import dev.arkbuilders.navigator.di.modules.DispatcherModule import javax.inject.Singleton @@ -36,6 +37,7 @@ import javax.inject.Singleton CiceroneModule::class, RepoModule::class, DispatcherModule::class, + AnalyticsModule::class, ] ) diff --git a/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/folders/FoldersFragment.kt b/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/folders/FoldersFragment.kt index 11c93d81..f8f30d59 100644 --- a/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/folders/FoldersFragment.kt +++ b/app/src/main/java/dev/arkbuilders/navigator/presentation/screen/folders/FoldersFragment.kt @@ -81,8 +81,10 @@ class FoldersFragment : Fragment(R.layout.fragment_folders) { init() viewModel.observe(this, state = ::render, sideEffect = ::handleSideEffect) - TrackHelper.track().screen(requireActivity()) - .title("Folders management").with(analytics) + TrackHelper.track().screen("Folders").title("Folders management").with(analytics) + TrackHelper.track().event("folder screen", "view sceen") + .name("label").value(1000f).with(analytics) + } fun init() {