Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics in common:core module #29

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Analytics in common:core module #29

wants to merge 5 commits into from

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