When you add a transformation and connect it to a cloud mode-supported destination, RudderStack does the following:
- Tracks and collects events at the source.
- Applies the transformation logic to your events.
- Forwards the transformed event to your connected destination.
Applying transformation on a batch of events
You can 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;}
def transformBatch(events, metadata): return events
transformBatch
function, make sure you pass the messageId
from the input event to the output event. Without the messageId
, RudderStack does not guarantee event ordering. It is highly recommended to use
transformEvent
as much as possible, as it ensures event ordering.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;}
def transformEvent(event, metadata): 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:
log
function.Limitations
The transformation fails if the following memory and time limits are exceeded:
Parameter | Limit |
---|---|
Memory limit | 128 MB |
Execution time limit | 4 seconds |
Contact us
For more information on the topics covered on this page, email us or start a conversation in our Slack community.