Skip to content

Commit b77fe79

Browse files
author
Sylwester Zieliński
committed
Add analytics events
1 parent b736dbc commit b77fe79

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

lib_analytics/src/main/java/no/nordicsemi/android/analytics/AppAnalytics.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ class AppAnalytics @Inject constructor(
2121
AppOpenEvent,
2222
HandleDeepLinkEvent,
2323
DFUSuccessEvent -> firebase.logEvent(event.eventName, null)
24+
DeviceSelectedEvent -> firebase.logEvent(event.eventName, null)
25+
FileSelectedEvent -> firebase.logEvent(event.eventName, null)
26+
InstallationStartedEvent -> firebase.logEvent(event.eventName, null)
2427
is DFUErrorEvent -> firebase.logEvent(event.eventName, event.createBundle())
28+
is DisableResumeSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
29+
is ExternalMCUSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
30+
is ForceScanningSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
31+
is KeepBondSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
32+
is NumberOfPacketsSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
33+
is PacketsReceiptNotificationSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
2534
}
2635
}
2736
}

lib_analytics/src/main/java/no/nordicsemi/android/analytics/Events.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ object AppOpenEvent : AppEvent {
1616
override val eventName: String = "APP_OPEN_EVENT"
1717
}
1818

19+
object FileSelectedEvent : AppEvent {
20+
override val eventName: String = "FILE_SELECTED"
21+
}
22+
23+
object DeviceSelectedEvent : AppEvent {
24+
override val eventName: String = "DEVICE_SELECTED"
25+
}
26+
27+
object InstallationStartedEvent : AppEvent {
28+
override val eventName: String = "INSTALLATION_STARTED"
29+
}
30+
1931
object HandleDeepLinkEvent : AppEvent {
2032
override val eventName: String = "HANDLE_DEEP_LINK_EVENT"
2133
}

profile_dfu/src/main/java/no/nordicsemi/dfu/profile/main/viewmodel/DFUViewModel.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
88
import kotlinx.coroutines.flow.asStateFlow
99
import kotlinx.coroutines.flow.launchIn
1010
import kotlinx.coroutines.flow.onEach
11-
import no.nordicsemi.android.analytics.AppAnalytics
12-
import no.nordicsemi.android.analytics.DFUErrorEvent
13-
import no.nordicsemi.android.analytics.DFUSuccessEvent
11+
import no.nordicsemi.android.analytics.*
1412
import no.nordicsemi.android.navigation.*
1513
import no.nordicsemi.dfu.profile.DfuSettingsScreen
1614
import no.nordicsemi.dfu.profile.DfuWelcomeScreen
@@ -125,6 +123,7 @@ internal class DFUViewModel @Inject constructor(
125123
deviceViewEntity = SelectedDeviceViewEntity(args.getDevice()),
126124
progressViewEntity = WorkingProgressViewEntity()
127125
)
126+
analytics.logEvent(DeviceSelectedEvent)
128127
}
129128
null -> navigationManager.navigateTo(ScannerDestinationId)
130129
}.exhaustive
@@ -147,6 +146,7 @@ internal class DFUViewModel @Inject constructor(
147146
private fun onInstallButtonClick() = _state.value.settings?.let {
148147
repository.launch(it)
149148
_state.value = _state.value.copy(progressViewEntity = DFUProgressViewEntity.createBootloaderStage())
149+
analytics.logEvent(InstallationStartedEvent)
150150
}
151151

152152
private fun onZipFileSelected(uri: Uri) {
@@ -158,6 +158,7 @@ internal class DFUViewModel @Inject constructor(
158158
fileViewEntity = SelectedFileViewEntity(zipFile),
159159
deviceViewEntity = NotSelectedDeviceViewEntity
160160
)
161+
analytics.logEvent(FileSelectedEvent)
161162
}
162163
if (repository.device != null) {
163164
_state.value = _state.value.copy(

0 commit comments

Comments
 (0)