Closed flo-butterfly closed 12 months ago
Setting context
is not currently an option when calling track
. The recommended way of doing this is by using plugins or stripping them on Cloud:
Here's a short guide on how to write a plugin
The example shows just a logger but you can transform the event however you want, for example stripping the device.id
:
export class RemoveDeviceID extends Plugin {
type = PluginType.before;
execute(event: SegmentEvent) {
return {
...event,
context: {
...event.context,
device: {
...event.context.device,
id: "0000"
}
}
}
}
}
The IP is special though as it is stamped by Segment Cloud when it arrives, not collected by the library.
I recommend contacting technical support at Segment to evaluate options to strip this depending on your case (that might also work for the deviceId if you're not using any native plugins).
Hi,
We want to anonymize the ip to 0.0.0.0 as well as device.id to 0000 To do so on track, we call:
Segment.track(event, { properties, context: { ip: '0.0.0.0', device: { id: '0000' } }, });
but it seems to set those values in the property context of Properties, instead of the context itself (where you can see context ip is set 2x):
analytics-react-native
version: 2.8.0Steps to reproduce
Segment.track("an event", { properties, context: { ip: '0.0.0.0', device: { id: '0000' } }, });
Expected behavior The context ip an device id should be set respectively to 0.0.0.0 and 0000
Actual behavior the context ip and context device id are not overwritten and those values are being added in the "Properties" instead