Automattic / Automattic-Tracks-iOS

Client library for tracking user events for later analysis
GNU General Public License v2.0
41 stars 12 forks source link

Add an anonymous ID to configure ExPlat for authenticated users #213

Closed jaclync closed 2 years ago

jaclync commented 2 years ago

For https://github.com/woocommerce/woocommerce-ios/issues/7435

Description

Previously, we passed nil to the anonymous ID parameter in the ExPlat configuration and we observed a high crossover rate where the same logged-in user has been assigned to more than one variation for the same A/A test. From @aaronyan's investigation pbxNRc-1S0-p2#comment-3688, the nil anonymous ID might have caused a high crossover rate because the anonymous ID is prioritized over the authenticated user ID when assigning a variation for an A/B experiment.

Once assignment requests include the anon_id, then I think we should see a lot less crossovers! The anon_id will be given priority on the assignment side, so the user will be assigned the same variation that was originally given to them while they were anonymous.

Therefore, this PR added a new parameter anonymousID to switchToAuthenticatedUser where wpComToken is expected for ExPlat configuration. This was added as a new method so that it doesn't affect any other apps.

Testing instructions

Please check the testing steps in https://github.com/woocommerce/woocommerce-ios/pull/7574.