Adding generateAnonymousId config option #1989
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CHANGES
Added generateAnonymousId config option, which, when set to false:
I implemented this by returning null early in loadDeviceId function in DeviceIdStore.kt if generateAnonymousId is set to false. This seemed the easiest way to do this with the least amount of files changed.
Where UserStore.kt tries to use the deviceId as the user ID, deviceId should be null anyway if generateAnonymousId config option is false, due to my changes to loadDeviceId. However, there’s one scenario where there the current behaviour is perhaps not ideal:
So I’m not sure if there’s anything we can do to prevent this happening, or if we should just include a note in the docs to make this clear? We couldn’t just not return the persisted user if generateAnonymousId is false, since the persisted user ID may be something set by the customer and not the device ID.
TESTING