Closed DeanGracey closed 4 months ago
Hey @DeanGracey, To add custom context, you need to set the values in the following format:
const options = {
tier: {
category: 'premium',
type: 'gold',
},
};
Please follow our documentation on setting custom context for more details: https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-react-native-sdk/#setting-custom-context.
hi @1abhishekpandey, That doesn't seem to work for a value (not object) at the top level.
i.e if I do the call like this:
const options = {
environment: ENV,
}
return rudderClient.track(
event,
{
email,
userId,
...properties,
},
options,
)
I get this:
"context": {
"app": {
"build": "1",
"name": "WeR1Dev",
"namespace": "ai.wer1.dev.music.player",
"version": "1.28.10"
},
"device": {
"attTrackingStatus": 0,
"id": "efabe9ac-2ef3-4e6b-b954-90e899cd7e62",
"manufacturer": "Apple",
"model": "arm64",
"name": "iPhone SE (3rd generation)",
"type": "iOS"
},
"library": {
"name": "rudder-ios-library",
"version": "1.27.0"
},
"locale": "en-ZA",
"network": {
"cellular": false,
"wifi": true
},
"os": {
"name": "iOS",
"version": "17.2"
},
"screen": {
"density": 2,
"height": 667,
"width": 375
},
"timezone": "Africa/Johannesburg",
"traits": {
"anonymousId": "6652f7fa-67b2-45d7-93b8-5d5663a9d608"
}
},
Right, that's in our backlog, and we will support that in the future. For now, please send it like this:
const options = {
environment: {
ENV: true,
}
};
You can also utilise our transformation feature to achieve your use case: https://www.rudderstack.com/docs/transformations/overview/.
I see, thank you
Hello,
I'm trying to add data to the top level of the context object.
I can track an event like this:
I get my env var within the properties object from 1. I can get it in additional under context from 2. I cannot get 3 or 4 as top level in the context object.
resulting JSON:
Is it possible to add to the top level context object?