Hey! I just recorded a Loom about a problem I’m fa...
# support
q
Hey! I just recorded a Loom about a problem I’m facing with the RudderStack SDK in my Next.js app. Could you please watch it and let me know if you have any insights? Here’s the link: https://www.loom.com/share/d0b8a16a9e43452cb8fa1e5c3710ddbb
m
Hey There! 👋 Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
h
they must have done that for consistency - only rudder identify has a top level traits payload - rudder tracks/page carry the traits within context
m
Hi Cameron, as Redsquare pointed out that was done for consistency. However, you can use this simple user transformation to add the traits to the event object. I have asked the team to update the docs for the same.
s
Copy code
export function transformEvent(event, metadata) {
    const traits = event.context?.traits;
    const type = event.type;
    if (traits && type === 'identify') {
        event.traits = traits;
    }
    return event;
}
Kindly do test out the transformation in your dev environment before using it in production. Thanks
h
think you need !== 'identify' @shy-kite-21035
m
I am adding the traits to the top level object if the event type is identify.
h
that is the issue though - it appears top level but only on identify
else it is on context
m
It is in context for the JS SDK.
And in the Node SDK it is both in context and in top level 🙂
h
ah ok
q
Thanks guys, so it seems like a transformation is a must have?
h
for now yeah
🙌 1
m
Unfortunately yes.