Tealium
public class Tealium
The main class for the Tealium SDK.
This class provides the primary interface for interacting with the Tealium SDK. It handles initialization, tracking events, managing visitor IDs, and accessing various modules like data layer, deep linking, and tracing.
-
The key that identifies the underlying instance. Equal to the
TealiumConfig.keyused to create it.Declaration
Swift
public let key: String -
Creates a new Tealium instance with the provided configuration.
Important
Hold onto the returned
Tealiuminstance for as long as you need it. Calling this method again with the sameaccount/profilecombination is supported, but each duplicate call allocates a small amount of internal state (a subject/subscription pair) that lives untilshutdown(). Prefer storing and reusing the original return value instead.Declaration
Swift
public static func create(config: TealiumConfig, completion: ((InitializationResult<Tealium>) -> Void)? = nil) -> TealiumParameters
configThe configuration for the Tealium instance.
completionA closure that is called when initialization completes, providing either the Tealium instance or an error.
Return Value
A new Tealium instance.
-
Executes the provided completion handler when
Tealiumis ready for use, from theTealiuminternal thread.Usage of this method is incentivised in case you want to call multiple
Tealiummethods in a row. Every one of those methods, if called from a different thread, will cause the execution to move into our own internal queue, causing overhead. Calling those methods from the completion of this method, instead, will skip all of those context switches and perform the operations synchronously onto our thread.Declaration
Swift
public func onReady(_ completion: @escaping (Tealium) -> Void)Parameters
completionA closure that is called with the
Tealiuminstance when it’s ready. In case of an initialization error or after shutdown, the completion won’t be called at all. -
Tracks an event with the specified name, type, and data.
Declaration
Swift
@discardableResult public func track(_ name: String, type: DispatchType = .event, data: DataObject? = nil) -> SingleResult<TrackResult, TealiumError>Parameters
nameThe name of the event to track.
typeThe type of dispatch to use (default is .event).
dataAdditional data to include with the event (optional).
Return Value
A
Singleonto which you can subscribe to receive the completion with the eventual error or theTrackResultfor this track request. -
Flushes any queued events from the system when it is considered safe to do so by any
Barriers that may be blocking, i.e. when theirisFlushablereturnstrue.Attention
This method will not override those
Barrierimplementations whoseisFlushablereturnsfalse. But when non-flushable barriers open, a flush will still occur.Declaration
Swift
@discardableResult public func flushEventQueue() -> SingleResult<Void, TealiumError> -
Resets the current visitor ID to a new anonymous one.
Note. the new anonymous ID will be associated to any identity currently set.
Declaration
Swift
@discardableResult public func resetVisitorId() -> SingleResult<String, TealiumError>Return Value
A
Singleonto which you can subscribe to receive the completion with the eventual error or the new visitor ID. -
Removes all stored visitor identifiers as hashed identities, and generates a new anonymous visitor ID.
Declaration
Swift
@discardableResult public func clearStoredVisitorIds() -> SingleResult<String, TealiumError>Return Value
A
Singleonto which you can subscribe to receive the completion with the eventual error or the new visitor ID. -
Manager for trace-related functionality.
Declaration
Swift
public private(set) lazy var trace: Trace { get set } -
Manager for deep link functionality.
Declaration
Swift
public private(set) lazy var deepLink: DeepLinkHandler { get set } -
Interface for accessing and manipulating the data layer.
Declaration
Swift
public private(set) lazy var dataLayer: DataLayer { get set } -
Creates a
ModuleProxyfor the given module to allow for an easy creation of Module Wrappers.This method should only be used when creating a
Modulewrapper. Use the already prebuilt wrappers for modules included in the SDK.Declaration
Swift
public func createModuleProxy<T, E>(for module: T.Type = T.self) -> ModuleProxy<T, E> where T : Module, E : ErrorParameters
moduleThe
Moduletype that the Proxy needs to wrap.Return Value
The
ModuleProxyfor the given module. -
Creates a
Disposablewhich can be used to store multipleDisposableinstances for bulk disposal. All methods are executed using the internalTealiumqueue to ensure operation is thread-safe when containingTealiumreturned subscriptions.Additional
Disposableinstances can be added viaDisposable.add.Declaration
Swift
public func createDisposable() -> any CompositeDisposableReturn Value
A
Disposableto dispose some operations, whilst ensuring that all operations happen on its queue. -
Shuts down this
Tealiuminstance.After calling this method, no further input will be processed and any subsequent method call on this instance will fail with
TealiumError.instanceShutdown. The instance is also removed from theTealiumInstanceManager, soTealiumInstanceManager.get(_:completion:)will no longer return it.Declaration
Swift
public func shutdown() -
lifecycle()From TealiumPrismLifecycle -
momentsAPI()From TealiumPrismMomentsAPIProvides access to the Moments API module functionality.
Declaration
Swift
func momentsAPI() -> MomentsAPIReturn Value
The Moments API module instance
View on GitHub