Create, test, and connect a function to transform events before they sync to a destination.
Write JavaScript to modify event properties, validate fields, or enrich event data on a Hightouch Events sync. This guide walks through creating, testing, and connecting a function.
To create a new function, go to Event Collection → Functions and
select Create function.When you create a function, you’ll start with a default function definition,
which you can edit to add custom transformation logic.Keep these requirements in mind:
All code must have a transformEvents function definition, which receives a
batch of events, and returns a batch of transformed events
Test the function works as expected by using the test panel in the function
code editor view.Modify the input in the test panel, and select Test. Results will be
displayed in the output panel, along with any console logs. If the function
errors during execution, the error and stack trace will be displayed.
To save a function, hit Save changes at the bottom of the code editor.
Upon save, if the function is connected to any event syncs, the new function
code will immediately be used.To connect a function to a sync, use the Connected syncs tab, where you can
connect or disconnect a function from a sync. When a function is connected
to a sync, events in the target event sync will immediately begin to be transformed by
the function.Note: a function can be connected to multiple syncs, but a sync can only have
one function connected to it at a time.
Functions are executed after contract validation (if a contract is defined
for the respective event source). This means events blocked by contracts
are not able to be transformed using functions.
Use Promise.all to run async code in parallel, reducing the chance of
hitting a timeout
If a function errors, the entire batch is failed and will be retried
based on the sync retry configuration