Skip to content

Commit

Permalink
Add analytics events
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylwester Zieliński committed May 23, 2022
1 parent b736dbc commit b77fe79
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ class AppAnalytics @Inject constructor(
AppOpenEvent,
HandleDeepLinkEvent,
DFUSuccessEvent -> firebase.logEvent(event.eventName, null)
DeviceSelectedEvent -> firebase.logEvent(event.eventName, null)
FileSelectedEvent -> firebase.logEvent(event.eventName, null)
InstallationStartedEvent -> firebase.logEvent(event.eventName, null)
is DFUErrorEvent -> firebase.logEvent(event.eventName, event.createBundle())
is DisableResumeSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
is ExternalMCUSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
is ForceScanningSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
is KeepBondSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
is NumberOfPacketsSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
is PacketsReceiptNotificationSettingsEvent -> firebase.logEvent(event.eventName, event.createBundle())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ object AppOpenEvent : AppEvent {
override val eventName: String = "APP_OPEN_EVENT"
}

object FileSelectedEvent : AppEvent {
override val eventName: String = "FILE_SELECTED"
}

object DeviceSelectedEvent : AppEvent {
override val eventName: String = "DEVICE_SELECTED"
}

object InstallationStartedEvent : AppEvent {
override val eventName: String = "INSTALLATION_STARTED"
}

object HandleDeepLinkEvent : AppEvent {
override val eventName: String = "HANDLE_DEEP_LINK_EVENT"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import no.nordicsemi.android.analytics.AppAnalytics
import no.nordicsemi.android.analytics.DFUErrorEvent
import no.nordicsemi.android.analytics.DFUSuccessEvent
import no.nordicsemi.android.analytics.*
import no.nordicsemi.android.navigation.*
import no.nordicsemi.dfu.profile.DfuSettingsScreen
import no.nordicsemi.dfu.profile.DfuWelcomeScreen
Expand Down Expand Up @@ -125,6 +123,7 @@ internal class DFUViewModel @Inject constructor(
deviceViewEntity = SelectedDeviceViewEntity(args.getDevice()),
progressViewEntity = WorkingProgressViewEntity()
)
analytics.logEvent(DeviceSelectedEvent)
}
null -> navigationManager.navigateTo(ScannerDestinationId)
}.exhaustive
Expand All @@ -147,6 +146,7 @@ internal class DFUViewModel @Inject constructor(
private fun onInstallButtonClick() = _state.value.settings?.let {
repository.launch(it)
_state.value = _state.value.copy(progressViewEntity = DFUProgressViewEntity.createBootloaderStage())
analytics.logEvent(InstallationStartedEvent)
}

private fun onZipFileSelected(uri: Uri) {
Expand All @@ -158,6 +158,7 @@ internal class DFUViewModel @Inject constructor(
fileViewEntity = SelectedFileViewEntity(zipFile),
deviceViewEntity = NotSelectedDeviceViewEntity
)
analytics.logEvent(FileSelectedEvent)
}
if (repository.device != null) {
_state.value = _state.value.copy(
Expand Down

0 comments on commit b77fe79

Please sign in to comment.