Skip to content

Conversation

justasm
Copy link
Member

@justasm justasm commented Dec 7, 2020

Those with access to Trafi's internal VPN can access & edit the event schema via the Mammoth editor.

Uses https://github.com/trafi/mammoth-kt to generate type-safe analytics events from the schema.

Any UI component can call Analytics.consume(AnalyticsEvent.$eventName()). By default, events go nowhere. Any SDK consumer can register an AnalyticsDelegate to do something with the events.

class PrintAnalyticsToConsole : AnalyticsDelegate {
  fun dispatchEvent(event: Analytics.Event) {
    println(event.business.name)
  }

  val screenName: String? get() = null
  val modalName: String? get() = null
}

Analytics.set(PrintAnalyticsToConsole())

this.delegate = delegate
}

data class Event(val business: RawEvent?, val publish: RawEvent)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

business should not be nullable

}

@ThreadLocal
object Analytics {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to have all these properties and functions static. In Swift we consume events through a static method: Analytics.consume(event). Currently the generated interface requires to instantiate the Analytics type and call methods from there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please experiment to see what Kotlin code gives you the result you expect. Ping me if you'd like to brainstorm ideas together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants