Issue
When using Insert Functions in Segment destinations, users may encounter errors such as:
Cannot read properties of undefined (reading 'email')
This typically occurs when the function expects a property (like email) in a specific location within the event payload, but the property is not found there.
Product
Segment
Environment
Segment Console
Cause
This error arises because the Insert Function is attempting to access a property (e.g., email) from a specific path, such as event.context.traits.email. However, in many Segment payloads, the property may actually be sent under a different path, such as event.properties.email. If the function does not find the property where it expects, it throws an error.
Resolution
Check your event payload:
Confirm where the property is being sent. In many Segment activations, it may be underpropertiesor another path.-
Review the Insert Function:
- If the function is not required for your workflow, consider disabling it in the destination settings.
- If the function is required, ensure that it references the correct location for the property in the event payload.
Test the activation again after making any changes.
Additional Information
If you are unsure whether the Insert Function is necessary for your use case, consult your engineering team or Segment documentation. If you continue to experience issues, reach out for further assistance with details about your payload and function configuration.