EventAdapter

interface EventAdapter

Contract for a destination that receives events. Implementations may deliver immediately (in-process SDKs) or batch over the network.

Implementation requirements

  • Safe to invoke from a single background thread. The dispatcher serializes calls per adapter instance, so adapters do not need to be reentrant.

  • Never throw to the caller. Wrap exceptions and return a DeliveryOutcome instead.

  • Idempotent: the same event may be delivered more than once if the library cannot distinguish a successful delivery (e.g. timeout after the server received the request).

Since

1.0.0

See also

in.singhangad.eventtracker.EventTrackerConfig.Builder.addAdapter

Inheritors

Properties

Link copied to clipboard
abstract val id: String

Stable, unique identifier for this destination (e.g. "firebase", "backend").

Functions

Link copied to clipboard
abstract fun accepts(event: TrackEvent): Boolean

Decide whether this adapter wants the given event.

Link copied to clipboard
abstract suspend fun deliver(event: TrackEvent): DeliveryOutcome

Deliver a single event. Realtime adapters forward to their SDK here; batch adapters typically return DeliveryOutcome.Success immediately (the event is already persisted).

Link copied to clipboard
open suspend fun flush(): DeliveryOutcome

Called when in.singhangad.eventtracker.EventTracker.flush is invoked. Batch adapters should drain their queue here. Default is a no-op.

Link copied to clipboard
open suspend fun identify(userId: String?, traits: Map<String, Any?>)

Forwarded user identification. Called when the host app calls in.singhangad.eventtracker.EventTracker.identify. Default is a no-op.

Link copied to clipboard
abstract fun initialize(context: Context, logger: EventLogger)

Called once during in.singhangad.eventtracker.EventTracker.initialize. Use this to initialise any underlying SDK, open connections, or set up resources.

Link copied to clipboard
open fun onOptOut()

Called when the host opts out and local data is being cleared. Implementations should clear any locally cached user state.