JavaScriptEngineAdapter
Adapter interface for a JavaScript engine capable of evaluating JavaScript code and returning a result as a DataItem.
Implementations are responsible for managing the lifecycle of the underlying engine and must release any resources when dispose is called.
Required JS Environment
Implementations must expose the following objects in the JS global scope before any script is evaluated:
payload- the current dispatch payload as a mutable object that can be modified by the scriptscope- the current dispatch scope as a string (e.g. "aftercollectors")tracker— forwards tracking calls back into the native SDK viatracker.trackSupported signatures include:track(eventName, payload)- triggers a tracking call with the specified event name and optional payloadtrack(eventName, type, payload)- triggers a tracking call with the specified event name, type, and payloaddrop()- a function that allows the script to drop the current dispatch by clearing thepayloadobjectdataLayer- an object that provides access to the SDK data layer for reading and writing persistent values. Must support at least the following methods:(get,set,remove,clear)console— provides logging support (e.g.console.warn,console.log)dataLayer— exposes the SDK data layer for reading and writing persistent valuesExpiry— provides expiry policy constants for use withdataLayer
Functions
Evaluates the given js code and emits the result as a TealiumResult wrapping a DataItem.