I’m looking for some guidance regarding patterns to use for loading/unloading Piwik in our Angular SPAs. For reference, I’ve consumed the documentation here: @piwikpro/ngx-piwik-pro - npm
Our applications retain user preferences using localstorage, including the user’s consent preference. We display a Piwik consent modal depending on the value(or lack of value) of the user’s consent preference.
You can imagine a scenario where on first launch we do not have the user’s tracking consent, so we must load our SPA without NgxPiwikProModule in Angular’s AppModule. If consent is given at a later time, the entire Application must be re-bootstrapped because NgxPiwikProModule can only be provided during bootstrapping. Similarly, if the user withdraws consent at a later time, the application must be re-bootstrapped to remove NgxPiwikProModule from Angular’s root module pool.
This is clunky. Surely this must be an issue for others using Piwik’s Angular tooling?
What is Piwik’s expected patterning for an Angular application loading and unloading these modules when the user’s consent is absent (first run) or changes later?