DebugTransport

class DebugTransport(delegate: Transport, log: (String) -> Unit = ::println) : Transport, MetadataAwareTransport

Wraps delegate, logging every event before delivering it — for eyeballing outgoing events on a real device/build during manual QA, separate from the app's production transport. Not connected to a warehouse or any assertion tooling (see the planned autograph-test module for unit-test assertions instead).

The default log (println) dumps every event's full properties/traits — do not wrap a production transport with this in a release build, since that can leak PII into device/console logs. Gate its use behind a debug-build check, or supply a log that redacts what it prints.

val tracker = Autograph {
transport(DebugTransport(SegmentTransport(analytics)))
}

When delegate stamps in its own pipeline (Transport.stampsInPipeline), the envelope isn't known yet at the point this wrapper sees the event (the delegate stamps it later, inside its own pipeline) — the logged line shows envelope=null in that case, matching what delegate itself receives.

It is a MetadataAwareTransport, so wrapping a pipeline transport does not hide that capability from the tracker: an event's EventMetadata is logged and forwarded when delegate is one too. When delegate is a pipeline transport that is not, the tracker looks through this wrapper and treats the pair exactly as it treats delegate alone: the event is delivered without its metadata, and AutographConfig.logger is told once.

Constructors

Link copied to clipboard
constructor(delegate: Transport, log: (String) -> Unit = ::println)

Properties

Link copied to clipboard
open override val stampsInPipeline: Boolean

True when this transport calls EnvelopeSource.stamp inside its own pipeline. In that case the core passes envelope = null to the event methods and the transport is responsible for stamping every event exactly once.

Functions

Link copied to clipboard
open override fun connect(envelopes: EnvelopeSource)

Called once during setup, before any events are sent.

Link copied to clipboard
open override fun flush()
Link copied to clipboard
open override fun identify(userId: String, traits: Map<String, JsonElement>, envelope: Envelope?)
Link copied to clipboard

A transport that runs transform on every event before handing it to this one: to redact a property, add one, or drop the event (return null) for sampling (#302).

Link copied to clipboard
open override fun reset()
Link copied to clipboard
open override fun screen(name: String, properties: Map<String, JsonElement>, envelope: Envelope?)

open override fun screen(name: String, properties: Map<String, JsonElement>, envelope: Envelope?, metadata: EventMetadata)

Delivers a screen view exactly as Transport.screen would, and adds metadata to the envelope the transport stamps for it. properties no longer contain RESERVED_METADATA_KEY.

Link copied to clipboard
open override fun track(name: String, properties: Map<String, JsonElement>, envelope: Envelope?)

open override fun track(name: String, properties: Map<String, JsonElement>, envelope: Envelope?, metadata: EventMetadata)

Delivers an event exactly as Transport.track would, and adds metadata to the envelope the transport stamps for this event. properties no longer contain RESERVED_METADATA_KEY.