EnvelopeSource

interface EnvelopeSource

Provides instrumentation envelopes. Implemented by the library core; transports that run their own event pipeline (e.g. Segment) call stamp from inside that pipeline so that sequence numbers match the actual enqueue order — including events the transport generates itself, such as lifecycle events.

Functions

Link copied to clipboard
abstract fun reset()

Rotates the session (e.g. on logout): starts a fresh session id and per-session sequence. Device-lifetime counters are preserved. Thread-safe.

Link copied to clipboard
abstract fun stamp(): Envelope

Returns a new envelope, recording the current time as its event_timestamp. Thread-safe; each call advances the sequence counters. Transports that stamp inside their own pipeline call this, since the app's original call time isn't available to them.

open fun stamp(eventTimestampMillis: Long): Envelope

Returns a new envelope recording eventTimestampMillis as its event_timestamp — captured at the track/screen/identify call site so the timestamp reflects when the app fired the event, not when the serial dispatcher later drained and stamped it (which can lag under backpressure). Thread-safe; each call advances the sequence counters. The default ignores the timestamp and delegates to stamp; the library core overrides it to honor the value.