Herald

The fan-out. Holds every registered vendor and forwards each call to all of them.

It implements all five capabilities, so one instance can be bound to whichever of them your classes depend on. Bind it to those interfaces and depend on the interfaces: a ViewModel takes an EventTrackerService, not a Herald.

Build one with the Herald function.

Types

Link copied to clipboard
class Provider(val name: String, val events: EventTrackerService? = null, val properties: PropertyTrackerService? = null, val identity: IdentifiableUserService? = null, val lifecycle: AnalyticsLifecycleService? = null, val consent: ConsentService? = null)

One registered vendor: a name and whichever of the five capabilities it has.

Functions

Link copied to clipboard
open suspend override fun flush()

Best-effort request to deliver anything buffered. Worth calling when consent is revoked or the app goes to the background. Vendors with no flush API keep the default no-op.

Link copied to clipboard
open suspend override fun identify(identity: Identity)

Attach everything sent from now on to identity.

Link copied to clipboard
open suspend override fun reset()

Forget the current user. Call on sign-out.

Link copied to clipboard
open suspend override fun set(property: Property)
Link copied to clipboard
open suspend override fun setEnabled(enabled: Boolean)

Turn collection on or off.

Link copied to clipboard
open suspend override fun start()

Initialise the vendor SDK. Call once, from the code that owns the app lifecycle.

Link copied to clipboard
open suspend override fun track(event: Event)