When you add a transformation and connect it to a destination supporting cloud mode, RudderStack:

  1. Tracks and collects events at the source.
  2. Applies the transformation logic to the your events.
  3. Forwards the transformed event to your connected destination.
Github Badge Transformations workflow

Debugging transformations

Once you add a transformation, you can capture any event-related information in the form of logs while running a test on your transformation. You can do this by including the log function in your transformation code.

An example of using the log function is shown below:

export function transformEvent(event, metadata) {
const meta = metadata(event);
event.sourceId = meta.sourceId;
log("Event Name is", event.event, ";", "Message ID is", event.messageId);
log("Source ID is", meta.sourceId);
return event;
}

On adding the above transformation and clicking Run Test, you can see the resulting log in the Logs section of the dashboard, as shown:

Transformation log
You can pass a string, number, or an object as an argument to the log function.

Applying transformation on a batch of events

You can also perform any aggregation or roll-up operation on a batch of events using the transformBatch function instead of transformEvent, as shown:

export function transformBatch(events, metadata) {
return events;
}
If you want to ensure event ordering while using transformBatch, make sure you pass the messageId from the input event to the output event. Without the messageId, RudderStack will not guarantee the event ordering. It is highly recommended to use transformEvent as much as possible, as it ensures event ordering.

Limitations

The transformation fails if the following memory and time limits are exceeded:

ParameterLimit
Memory limit128 MB
Execution time limit4 seconds

Contact us

For more information on the topics covered on this page, email us or start a conversation in our Slack community.

On this page