Migrate a V2 function to the V3 runtime
New event and visitor functions use the V3 runtime. Existing functions that use the V2 runtime need to be migrated to the V3 runtime. This article provides information on the migration process.
Event and visitor functions that use the V3 runtime differ from V2 functions as follows:
- Input data is provided as parameters instead of named exports.
- An event function has two parameters:
event
andhelper
. - A visitor function has three parameters:
visitor
,visit
, andhelper
.
- An event function has two parameters:
- The
helper
object is used to get an authentication token ID or retrieve global variables.auth.get()
andstore.get()
have been replaced withhelper.getAuth()
andhelper.getGlobalVariable()
. track()
is used to send events to Tealium Collect.
Migrate function code
To migrate a V2 function to the V3 runtime, follow these steps:
- Create a new function of the appropriate type (event or visitor).
For more information, see Create a function. - Replace the default function code with an empty event or visitor function, as follows:
activate(async ({ event, helper }) => { });
activate(async ({ visitor, visit, helper }) => { });
- Copy the code from your V2 function that is between the opening and closing curly braces, { }, for the function. The import statements and the function declaration are not needed.
- Paste the code into the new function.
- If your V2 function used other libraries, such as CrytpoES, import them as before. For more information on importing libraries, see APIs and libraries for functions. For example:
import CryptoES from 'crypto-es';
- If your V2 function used
auth.get()
orstore.get()
addhelper
to the function parameters. For example:
activate(async ({ event, helper }) => {
- Replace any instances of
auth.get()
withhelper.getAuth()
. - Replace any instances of
store.get()
withhelper.getGlobalVariable()
. - If your V2 function used
tealium.sendCollectEvent()
, replace these calls withtrack()
calls, as follows:activate(({ event }) => { const newEvent = { data: event.data.udo }; track(newEvent, { tealium_account: event.account, tealium_profile: event.profile, tealium_datasource: 'abc123' }) })
This page was last updated: June 28, 2023