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.

  • Creates a new Tealium instance with the provided configuration.

    Declaration

    Swift

    public static func create(config: TealiumConfig, completion: ((InitializationResult<Tealium>) -> Void)? = nil) -> Tealium

    Parameters

    config

    The configuration for the Tealium instance.

    completion

    A 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 Tealium is ready for use, from the Tealium internal thread.

    Usage of this method is incentivised in case you want to call multiple Tealium methods 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

    completion

    A closure that is called with the Tealium instance when it’s ready. In case of an initialization error 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

    name

    The name of the event to track.

    type

    The type of dispatch to use (default is .event).

    data

    Additional data to include with the event (optional).

    Return Value

    A Single onto which you can subscribe to receive the completion with the eventual error or the TrackResult for 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 their isFlushable returns true.

    Attention

    This method will not override those Barrier implementations whose isFlushable returns false. But when non-flushable barriers open, a flush will still occur.

    Declaration

    Swift

    @discardableResult
    public func flushEventQueue() -> SingleResult<Void, TealiumError>

    Return Value

    A Single onto which you can subscribe to receive the completion with the eventual error. The returned Single, in case of success, completes when the flush request is accepted, not when all the events have been flushed.

  • 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 Single onto 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 Single onto 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 ModuleProxy for the given module to allow for an easy creation of Module Wrappers.

    This method should only be used when creating a Module wrapper. 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 : Error

    Parameters

    module

    The Module type that the Proxy needs to wrap.

    Return Value

    The ModuleProxy for the given module.

  • lifecycle() From TealiumPrismLifecycle

    Creates and returns a Lifecycle object, that can be used to send custom lifecycle events.

    If you intend to use this multiple time, keep a reference to the returned object to avoid creating a new one every time you call Tealium.lifecycle().

    Declaration

    Swift

    func lifecycle() -> Lifecycle
  • momentsAPI() From TealiumPrismMomentsAPI

    Provides access to the Moments API module functionality.

    Declaration

    Swift

    func momentsAPI() -> MomentsAPI

    Return Value

    The Moments API module instance