Issue
Customers using Segment may notice that their Destination Insert Function does not apply payload modifications to all events, often accompanied by the Message sent client side delivery status in the Delivery Overview.
Product
Segment Functions
Environment
Segment Console
Cause
Destination Insert Functions operate strictly on Segment backend servers and apply exclusively to Cloud Mode data flows. Middlewares can be utilised for device mode connections to update/transform events.
Resolution
To ensure every event consistently includes the required properties, you can evaluate the following recommendation:
Ensure the source<>destination is correctly set up in cloud mode, should you see the message 'Message sent client side' you need to evaluate your implementation to ensure the destination is not bundled.
Optional Code Review Tip for Insert Functions When evaluating payload properties in your JavaScript function, ensure you check for both null and undefined. If a property is completely absent from an incoming payload, JavaScript evaluates its value as undefined.
- Using strict inequality (e.g.,
if (event.properties.propertyName !== null)) evaluates to true forundefined, which may inadvertently set mapped variables toundefined. - Instead, use
if (event.properties && event.properties.propertyName != null)to evaluate the property cleanly across all payload variations.