segmentio/analytics-ios

Problem when calling identify immediately after reset

zenled opened this issue · 3 comments

When calling identify immediately after calling reset, the userId and traits will not get reset.

Minimal example:

// Swift
Analytics.shared().identify("123", traits: ["firstName": "John", "age":"20"])
Analytics.shared().flush()
Analytics.shared().reset()
Analytics.shared().identify(nil, traits: ["firstName": "David"])
// Segment debugger
IDENTIFY: "traits": {"userId": "123", "firstName": "John", "age": "20"}
IDENTIFY: "traits": {"userId": "123", "firstName": "David", "age": "20" } // userId and traits did not get reset

The first IDENTIFY call works as expected.
In the second IDENTIFY call, I would expect the userId and age to not have a value.

But if I add a delay after the reset it all works as expected.

Analytics.shared().identify("123", traits: ["firstName": "John", "age":"20"])
Analytics.shared().flush()
Analytics.shared().reset()
sleep(2)
Analytics.shared().identify(nil, traits: ["firstName": "David"])
// Segment debugger
IDENTIFY: "traits": {"userId": "123", "firstName": "John", "age": "20"}
IDENTIFY: "traits": {"firstName": "David"}

Library version 4.1.6.

Hi @zenled!
Same is happening to me, did you find any solution apart from applying a delay?

Thanks!!

@Laura-Lo Unfortunately, I haven't found a solution, I just use a delay.

Thanks @zenled!