diff --git a/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt b/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt index 09767fad..e5b03c2a 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt @@ -40,13 +40,18 @@ import com.moez.QKSMS.feature.scheduled.ScheduledActivity import com.moez.QKSMS.feature.settings.SettingsActivity import com.moez.QKSMS.feature.settings.about.AboutActivity import com.moez.QKSMS.feature.themepicker.ThemePickerActivity +import com.moez.QKSMS.manager.AnalyticsManager import com.moez.QKSMS.manager.NotificationManager import javax.inject.Inject import javax.inject.Singleton @Singleton -class Navigator @Inject constructor(private val context: Context, private val notificationManager: NotificationManager) { +class Navigator @Inject constructor( + private val context: Context, + private val analyticsManager: AnalyticsManager, + private val notificationManager: NotificationManager +) { private fun startActivity(intent: Intent) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) @@ -61,7 +66,12 @@ class Navigator @Inject constructor(private val context: Context, private val no } } - fun showQksmsPlusActivity() { + /** + * @param source String to indicate where this QKSMS+ screen was launched from. This should be + * one of [main_menu, compose_schedule, settings_night, settings_theme] + */ + fun showQksmsPlusActivity(source: String) { + analyticsManager.track("Viewed QKSMS+", Pair("source", source)) val intent = Intent(context, PlusActivity::class.java) startActivity(intent) } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt index 224fe1b2..60c5d1cf 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/compose/ComposeViewModel.kt @@ -618,7 +618,7 @@ class ComposeViewModel @Inject constructor( // View QKSMS+ view.viewQksmsPlusIntent .autoDisposable(view.scope()) - .subscribe { navigator.showQksmsPlusActivity() } + .subscribe { navigator.showQksmsPlusActivity("compose_schedule") } // Navigate back view.optionsItemIntent diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt index 60b7b11a..62e90807 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/main/MainViewModel.kt @@ -183,7 +183,7 @@ class MainViewModel @Inject constructor( .doOnNext { if (it == DrawerItem.SCHEDULED) navigator.showScheduled() } .doOnNext { if (it == DrawerItem.BLOCKING) navigator.showBlockedConversations() } .doOnNext { if (it == DrawerItem.SETTINGS) navigator.showSettings() } - .doOnNext { if (it == DrawerItem.PLUS) navigator.showQksmsPlusActivity() } + .doOnNext { if (it == DrawerItem.PLUS) navigator.showQksmsPlusActivity("main_menu") } .doOnNext { if (it == DrawerItem.HELP) navigator.showSupport() } .distinctUntilChanged() .doOnNext { diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusViewModel.kt index 289e099c..4fcc6db6 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/plus/PlusViewModel.kt @@ -35,8 +35,6 @@ class PlusViewModel @Inject constructor( ) : QkViewModel(PlusState()) { init { - analyticsManager.track("Viewed QKSMS+") - disposables += billingManager.upgradeStatus .subscribe { upgraded -> newState { copy(upgraded = upgraded) } } diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsViewModel.kt index 5cf5253c..d7d3d502 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsViewModel.kt @@ -173,7 +173,7 @@ class SettingsViewModel @Inject constructor( view.viewQksmsPlusIntent .autoDisposable(view.scope()) - .subscribe { navigator.showQksmsPlusActivity() } + .subscribe { navigator.showQksmsPlusActivity("settings_night") } view.startTimeSelectedIntent .autoDisposable(view.scope()) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerViewModel.kt b/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerViewModel.kt index 89328b2b..75e8cd53 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerViewModel.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/themepicker/ThemePickerViewModel.kt @@ -82,7 +82,7 @@ class ThemePickerViewModel @Inject constructor( // Show QKSMS+ activity view.viewQksmsPlusIntent .autoDisposable(view.scope()) - .subscribe { navigator.showQksmsPlusActivity() } + .subscribe { navigator.showQksmsPlusActivity("settings_theme") } // Reset the theme view.hsvThemeClearedIntent