Extending the Framework
Adding a New Sink
To send data to a new provider (e.g., Mixpanel), implement AnalyticsSink. Make sure to add
@Inject and @ContributesIntoSet(AppScope::class) to get it injected into the pipeline.
kotlin1@Inject2@ContributesIntoSet(AppScope::class)3class MixpanelSink(private val mixpanel: MixpanelAPI) : AnalyticsSink {4 override fun track(event: AnalyticsEvent, contextProperties: Map<ContextAnalyticsProperty, String>) {5 val props = JSONObject()6 // Add event properties7 event.eventProperties.forEach { (k, v) -> props.put(k.name, v) }8 // Add context properties9 contextProperties.forEach { (k, v) -> props.put(k.name, v) }1011 mixpanel.track(event.name, props)12 }13}
Defining New Properties
Define strongly-typed keys for your properties to maintain consistency.
kotlin1// In AnalyticsProperty.kt or a feature-specific extensions file2data object UserTier : ContextAnalyticsProperty(3 name = "user_tier",4 scope = AnalyticsPropertyScope.USER5)