analytics-ios icon indicating copy to clipboard operation
analytics-ios copied to clipboard

Problem when calling identify immediately after reset

Open zenled opened this issue 3 years ago • 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.

zenled avatar May 26 '22 10:05 zenled

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

Thanks!!

Laura-Lo avatar Jun 30 '22 07:06 Laura-Lo

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

zenled avatar Jun 30 '22 07:06 zenled

Thanks @zenled!

Laura-Lo avatar Jun 30 '22 07:06 Laura-Lo