Extending the Framework

Adding a New Sink

To send data to a new provider (e.g., Mixpanel), implement AnalyticsSink and add @ContributesIntoSet(AppScope::class) to register it with the pipeline. This Android example assumes MixpanelAPI is already provided by your DI graph:

kotlin
1@ContributesIntoSet(AppScope::class)
2class MixpanelSink(private val mixpanel: MixpanelAPI) : AnalyticsSink {
3 override fun send(
4 eventName: String,
5 createdAt: Instant,
6 properties: Map<String, String>,
7 ) {
8 mixpanel.track(eventName, JSONObject(properties))
9 }
10}

The pipeline already combines context and event properties. This example forwards the event name and properties; map createdAt to your provider's timestamp field if you need to preserve occurrence time.

Defining New Properties

Define strongly-typed keys for your properties to maintain consistency.

kotlin
1// In AnalyticsProperty.kt or a feature-specific extensions file
2data object UserTier : ContextAnalyticsProperty(
3 name = "user_tier",
4 scope = AnalyticsPropertyScope.USER
5)