Ability to add custom identity storage provider in @amplitude/[email protected] #448
Description
Summary
The cookieStorageProvider
property was removed in v2.0.0 of the Browser SDK, so this blocks us from being able to specify a custom storage provider for GDPR compliance purposes. It would be amazing if the SDK provided this type of functionality out of the box (e.g. switchIdentityStorage
) or added a custom
option to identityStorage
so folks can provide custom storage providers again.
Motivations
For GDPR compliance, we would like to track users using memory storage and then switch to cookies only after users have provided their consent to use tracking cookies. We were able to do this in @amplitude/[email protected]
by creating a custom Storage
instance (https://github.com/MystenLabs/sui/blob/main/apps/core/src/utils/persistableStorage.ts) and using that for the cookieStorageProvider
property. We're aware of the default recommended solution of deferring the initialization of Amplitude until users have provided consent, but that isn't quite the same and we miss out on potentially useful insights.