Tealium Prism React Native
    Preparing search index...

    Class Tealium

    A Tealium Prism instance for one account and profile.

    Get an instance with Tealium.create. The constructor is private. Every instance method that talks to the native SDK returns a Promise. Tealium.create is synchronous. After Tealium.shutdown, those Promises reject with ErrorCode.INSTANCE_SHUT_DOWN, except that calling Tealium.shutdown again resolves.

    const tealium = Tealium.create("my_account", "my_profile", Environment.prod);
    await tealium.track("homepage", "view");
    Index
    dataLayer: DataLayer

    DataLayer facade, mirroring the native Prism DataLayer module.

    instanceId: string

    Stable id addressing this instance in every native call. Equal to the SDK's TealiumConfig.key, the string "{account}-{profile}", so it also matches the key this class caches instances under (see create).

    trace: Trace

    Trace controls, namespaced to mirror the native Prism Trace module.

    • Tracks an event or a view.

      The Promise rejects with a TealiumError if the instance is shut down or the native SDK reports a failure. It rejects with a plain Error if data cannot be serialized, for example if it contains a BigInt or a circular reference.

      Parameters

      • name: string

        Name of the event or view.

      • type: DispatchType = "event"

        Dispatch type. Defaults to "event".

      • Optionaldata: JsonValueObject

        Data to attach to the dispatch. TypeScript rejects values that are not JsonValue types. At runtime, track serializes data with JSON.stringify, so it silently omits object properties whose values are functions, symbols, or undefined.

      Returns Promise<TrackResult>

      A Promise that resolves with the TrackResult. The result reports whether the SDK accepted or dropped the dispatch.

      const result = await tealium.track("user_login", "event", {
      customer_id: "1234567890",
      });
      console.log(result.status);
    • Creates a Tealium instance for an account and profile, or returns the existing one.

      If an instance already exists for the same account and profile, this method logs a warning and returns it. It ignores newly passed environment, settingsFile, settingsUrl, and logLevel in that case.

      The optional arguments mirror the settings sources of the native TealiumConfig. An omitted argument leaves that source unconfigured. The settings precedence is local < remote < programmatic on both platforms. A key in settingsUrl (remote) overrides the same key in settingsFile (local). logLevel (programmatic) overrides both.

      Parameters

      • account: string

        Tealium account name.

      • profile: string

        Tealium profile name.

      • environment: string

        Environment name, such as dev, qa, or prod. See Environment.

      • OptionalsettingsFile: string

        Name of a JSON settings file bundled with the app. It provides the local settings, which have the lowest priority. On iOS this is a resource name in the main bundle, and the .json extension is optional. On Android this is a file name in the assets/ directory. The native SDK skips local settings silently if the file is missing or invalid.

      • OptionalsettingsUrl: string

        Full URL of a remote JSON settings resource. The native SDK fetches and caches these remote settings, which have middle priority, and refreshes them at the configured interval. Without a URL, the SDK fetches no remote settings.

      • OptionallogLevel: LogLevel

        Log verbosity of the native Prism SDK. See LogLevel.

      Returns Tealium

      The Tealium instance. Native initialization continues asynchronously, so a native failure does not make this method throw. Later calls on the instance reject instead.

      TealiumError with code ErrorCode.NATIVE_MODULE_NOT_REGISTERED if the native module is missing. The error is thrown synchronously.

      const tealium = Tealium.create(
      "my_account",
      "my_profile",
      Environment.prod,
      "my_settings.json",
      "https://tags.tiqcdn.com/dle/my_account/my_profile/mobile_settings_prod.json"
      );