Skip to content

Instantly share code, notes, and snippets.

@amsterdatech
Last active January 3, 2021 20:09
Show Gist options
  • Save amsterdatech/caf653067dca10660e0b4c095872df79 to your computer and use it in GitHub Desktop.
Save amsterdatech/caf653067dca10660e0b4c095872df79 to your computer and use it in GitHub Desktop.
Koin Analytics Module
const val TRACKER_SAMPLE = "sample_tracker"
val analyticsModule = module {
single<Tracker>(named(TRACKER_SAMPLE)) { SampleTracker(androidApplication()) }
single<Analytics> { AnalyticsImpl(androidApplication(), mutableListOf(get(named(TRACKER_SAMPLE)))) }
}
// Code on your base fragment or base activity
val analytics: Analytics by inject()
//And now you are able to just
analytics.track { name = EVENT.PAGE_VIEW
put(EVENT.PAGE_NAME, DISPLAY.YOUR_SCREEN)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment