Analytics are fairly simple as the main logging happens in the background. HMS has some extra functionality where the page exit can be set as well, this might be needed to get improved analytics accuracy.
Getting the analytics instance:
val analytics: Analytics = AnalyticsFactory.getAnalytics(this)
Sending custom events:
val bundle: Bundle = Bundle()
bundle.putString("custom_key", "custom_value")
analytics.logEvent("Demo_Analytics_Btn", bundle)
Setting current screen:
analytics.setCurrentScreen(this, "Demo_Analytics_Screen", null)
Setting a user property:
analytics.setUserProperty("loves_tea", "definitely")