VisitorIdManager

The anonymous visitor ID of this device, and the Visitor Switching state behind it.

This object is itself subscribable: subscribing emits the current visitor ID first, then again on every change, whether caused by regenerate, eraseLocalHistory, or an identity-driven switch when Visitor Switching is configured. Emissions are delivered on the Tealium thread.

Visitor Switching is driven entirely by the data layer. An identity is present when the visitor identity key (see VisitorIdSettingsBuilder.setVisitorIdentityKey) holds a value in the data layer, and absent when that key has been removed or has expired. The SDK has no notion of login or logout: a login is the app writing the identity to that key, a logout is the app removing it.

Operations below that depend on an identity being present read the data layer at the time of the call.

Visitor ID handling can be disabled through settings. While visitor ID handling is disabled, subscribers receive a failure carrying ModuleNotEnabledException instead of a value, both at subscription time and if it becomes disabled later; successes resume if it is re-enabled. These failures do not complete the subscription. If the Tealium instance failed to initialize, or is later shut down, subscribers receive a single failure carrying that exception (Tealium.TealiumShutdownException on shutdown) and the subscription completes.

Every method returns a failure result while visitor ID handling is disabled, and after the Tealium instance failed to initialize or was shut down.

Functions

Link copied to clipboard
abstract fun current(): SingleResult<String>

The visitor ID at the time of the call.

Link copied to clipboard

Erases every identity association Visitor Switching has stored on this device, then generates a new anonymous visitor ID and returns it.

Link copied to clipboard
abstract fun regenerate(): SingleResult<String>

Generates a new anonymous visitor ID and returns it.

Link copied to clipboard

Subscribes the given onNext to receive updates, where no Observer.onComplete is required.

abstract fun subscribe(observer: Observer<TealiumResult<String>>): Disposable

Subscribes the given observer to receive updates, including an Observer.onComplete notification when the upstream source terminates.

open fun subscribe(onNext: Consumer<TealiumResult<String>>, onComplete: Runnable): Disposable

Subscribes the given onNext to receive updates, and the given onComplete to receive the Observer.onComplete signal