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

Store and confirm what experiments a user is enrolled in #208

Closed charliescheer closed 2 years ago

charliescheer commented 2 years ago

On Day One iOS right now we are looking to be able to have experiments that are only for new users. We had been verifying this by using a locally stored and calculated array of the experiments that a user is enrolled in or qualified for. This has a few issues with it, namely the potential for getting out of sync with what experiments ExPlat thinks a user is enrolled in, and has caused a bug where new user only experiments are being shown to existing users.

This PR is part of the process to fix that bug. With these changes, when we refresh the experiments I am storing the experiments names that are returned from the server and making that accessible outside of the package to confirm if a user is enrolled for a specific experiment. We need to store this separately because the server returns the name of the experiment for all enrolled experiments as a key and what the user is assigned to as a value. If the user is in the control group it returns null, and the existing ab-testing-assignments dictionary ignores the pairs with null as a value.

I chose to store the values in a separate array rather than change ab-testing-assignments to store the keys even if nothing was returned to avoid creating any potential issues with other apps that are using the experiments values.

With these changes we will be able to more accurately confirm what experiments a user participating in