Swift Class: TealiumConfig

Swift Class: TealiumConfig

by Community Manager on ‎02-01-2017 02:22 PM - edited on ‎12-22-2017 06:44 AM by (432 Views)

Purpose

Object provides a central place for configuring tracking options for the Tealium API. Individual modules provide their own extensions for the TealiumConfig class if they are enabled.

Supported Platforms

  • iOS
  • tvOS
  • watchOS
  • macOS

External Dependencies

Foundation

Recommended Usage

Usage of this class is mandatory.

It is automatically included in Carthage and CocoaPods framework builds.

Public API

TealiumConfig

Constructor for a TealiumConfig object. This object is required to initialize the library for your specific account.

TealiumConfig(account:String, profile:String, environment:String, optionalData:Dictionary, dataSource:String)

Parameters Type Description
account String Tealium account name
profile String Tealium profile name (usually "main")
environment String Tealium environment: "dev", "qa", or "prod"
optionalData [String: Any]? Parameter is optional, and may be omitted if you don't need it. See explanation on optionalData below
datasource String Datasource key (available from UDH). Optional.
// SAMPLE
// standard basic config object
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")

// with optionaldata and datasource
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod", optionalData: nil, datasource: "2f5s1")

// with datasource but no optionalData
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod", datasource: "2f5s1")

optionalData

Allows certain default behavior to be overridden at init time. Generally, it is better to use the override methods, rather than explicitly specifying an optionalData object.

OptionalData key Data Type Function
TealiumTagManagementConfigKey.maxQueueSize Int Integer representing the maximum queue size for cached (offline) events
TealiumTagManagementConfigKey.overrideURL String Override URL for Tag Management webview
TealiumCollectKey.overrideCollectUrl String Override URL for Tealium Collect HTTPS requests
TealiumDeviceDataModuleKey.isMemoryReportingEnabled Bool Turns low-level device memory reporting on (true) or off (false - default)
TealiumAttributionKey.isSearchAdsEnabled Bool Enables support for the Apple Search Ads API in the attribution module (default off - false)

setModulesList

The list of modules to be enabled or disabled. (see Modules List)

setModulesList(TealiumModulesList)

Parameters Type Description
modulesList TealiumModulesList* List of modules to enable or disable
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// blacklists the autotracking module
let modulesList = TealiumModulesList(isWhitelist: false, moduleNames: ["autotracking"]
config.setModulesList(modulesList)

*TealiumModulesList struct

Parameters Type Description
isWhiteList Bool Determines if modules list is a blacklist (false) or a whitelist (true)
modulesList [String] Array of module names to enable or disable

getModulesList

Returns the current module list object. (see Modules List)

getModulesList() -> TealiumModulesList

// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// blacklists the autotracking module
let modulesList = config.getModulesList()

setLogLevel

Sets a new log level

setLogLevel(logLevel: TealiumLogLevel)

Parameters Type Description
logLevel TealiumLogLevel New Log Level (see Swift Module: Logger)
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// .none .errors .warnings .verbose
let newLogLevel = TealiumLogLevel.errors
config.setLogLevel(logLevel: newLogLevel)

getLogLevel

Returns the current log level (see Swift Module: Logger)

getLogLevel() -> TealiumLogLevel

let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let logLevel = config.getLogLevel()

setTagManagementOverrideURL

Overrides the default URL used by the non-rendered UIWebView used by the Tag Management module. This should generally be avoided unless you are self-hosting your Tealium JavaScript files.

setTagManagementOverrideURL(string: String)

Parameters Type Description
string String String representing a URL to be loaded by the Tealium UIWebView
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let url = "https://tags.mycdn.com/utag/myaccount/myprofile/myenv/mobile.html"
config.setTagManagementOverrideURL(string: url)

setTagManagementQueueSize

Sets the maximum tag management queue size

setTagManagementQueueSize(to: Int)

Parameters Type Description
to Int Maximum queue size
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.setTagManagementQueueSize(to: 1)

setCollectOverrideURL

Overrides the Tealium Collect URL to send data to a different endpoint.

setCollectOverrideURL(string:String)

Parameters Type Description
string String String representing a URL for the Collect module to send data to. Can be used to force data collection to stay within a particular region (e.g. EU Central/Germany)
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// force override tealium collect base URL to EU Central
let url = "https://collect-eu-central-1.tealiumiq.com/vdata/i.gif?"
config.setCollectOverrideURL(string: url)

setMemoryReportingEnabled

Enables or disables memory reporting in the DeviceData module (default: disabled).

setMemoryReportingEnabled(Bool)

Parameters Type Description
enabled Bool Enables or disables memory reporting in the Device Data module.
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.setMemoryReportingEnabled(true)

isMemoryReportingEnabled

Returns a Bool indicating whether memory reporting is currently enabled or disabled.

isMemoryReportingEnabled() -> Bool

// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let enabled = config.isMemoryReportingEnabled()

setSearchAdsEnabled

Enables or disables memory reporting in the DeviceData module (default: disabled).

setSearchAdsEnabled(Bool)

Parameters Type Description
enabled Bool Enables or disables Apple Search Ads API in the Attribution module
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.setSearchAdsEnabled(true)

isSearchAdsEnabled

Returns a Bool indicating whether the Apple Search Ads API is currently enabled or disabled in the Attribution module.

isSearchAdsEnabled() -> Bool

// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let enabled = config.isSearchAdsEnabled()

disableRemoteHTTPCommand

Disables the built-in remote HTTP command (see Swift Module: RemoteCommands).

disableRemoteHTTPCommand()

// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.disableRemoteHTTPCommand()

enableRemoteHTTPCommand

Enables the built-in remote HTTP command (see Swift Module: RemoteCommands).

enableRemoteHTTPCommand()

// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.enableRemoteHTTPCommand()

dispatchQueue

Returns the current dispatch queue used for all Tealium processes.

dispatchQueue() -> DispatchQueue

let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let dispatchQueue = config.dispatchQueue()

setDispatchQueue

Sets a new dispatch queue for Tealium to use. Not recommended. Default is DispatchQueue.main.

setDispatchQueue(DispatchQueue)

Parameters Type Description
DispatchQueue DispatchQueue A dispatch queue to be used by Tealium
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let dispatchQ = DispatchQueue(label: "com.tealium.myqueue")
config.setDispatchQueue(dispatchQ)

defaultDispatchQueue

Returns the default dispatch queue (DispatchQueue.main).

defaultDispatchQueue() -> DispatchQueue

let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let dispatchQueue = config.dispatchQueue()

addDelegate

Adds a new delegate conforming to the TealiumDelegate protocol.

addDelegate(Delegate)

Parameters Type Description
delegate TealiumDelegate A class conforming to the TealiumDelegate protocol
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// assuming current module has implemented the TealiumDelegate protocol
config.addDelegate(self)

delegates

Returns an array of the currently-enabled delegates.

delegates() -> [TealiumDelegate]

// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let delegates = config.delegates()

Future Improvements

No planned changes.

Change Log

Build 1.4.0

  • Documentation updates
  • Additional config methods/properties added for new module functionality