Traits added to the events calls made to the API
In some of our code, we track events without providing any additional information, like this:
SEGAnalytics.shared().track("myEvent") /* as described by the documentation */
But when we take a look at what is sent to the API, we noticed that some user traits were sent along the event data and the device-specific data (I'll show here a sample raw event tracking request):
{
"anonymousId": "someID",
"context": {
[... device-specific infos ...],
"traits": [... userTraits...],
},
"event": "myEvent",
"timestamp": "sometime",
"type": "track",
"userId": "foo",
[...]
}
I'm talking about the traits field in the context. Reading the code, it seems that this field is populated from a cache, but this behavior is not documented anywhere, and it cause us some trouble, because we stopped sending those traits from this source and it corrupts our data by sending what can assume is the last known values of the traits.
Would you have a recommendation about what to do in this case? Thanks a lot.
Yep - this behaviour is intentional (the android library does this as well) - there are a number of reasons for this but the primary one is that you might turn in new tools later who might still want to Although it is something we have considered removing.
I am not sure I understand the problem you are facing with this - could you write in to our support team with more details (https://segment.com/contact) and they might be able to offer some recommendations for your specific case.
Thanks for the quick answer!
Our main issue is that this side effect is not documented, therefore not expected by developpers, and in our case it's sending wrong values as a result.
Could you please update your documentation to reflect this behavior, and specify by the way how we're supposed to stop it?
Makes sense - there isn't a way to turn this off unfortunately. Do you mind writing into our support team? They can update the docs and might also be able to offer workarounds with your specific situation.
I'll shoot them an email, yes. If you don't mind, I'll also keep this issue open for now, in case there's a useful workaround that could be shared with the SDK's users.
Update: the support team has the information, they're gonna take action (doc update + perhaps code change to be able to deactivate the behavior). Closing this for now.