I tried to follow the official tutorial at https://developers.google.com/web/ilt/pwa/integrating-analytics#offline_analytics for my Angular App.
But, the document looks like old. Because when I installed sw-offline-google-analytics by npm. There was not offline-google-analytics-import.js in node_modules.
So I copied the sw-offline-google-analytics.prod.v0.0.25.js in node_modules to my src directory. And I did what I can everything as much as I understood like below. There was any compile errors. But when I tested like https://developers.google.com/web/ilt/pwa/integrating-analytics#swjs_4, it doesn’t work.
[In app.module.ts]
imports: [
ServiceWorkerModule.register(‘combined-sw.js’, { enabled: environment.production })
]
[In combined-sw.js]
importScripts(‘ngsw-worker.js’);
importScripts(‘firebase-messaging-sw.js’);
importScripts(‘sw-offline-google-analytics.prod.v0.0.25.js’);
goog.offlineGoogleAnalytics.initialize();
[In angular.json]
“assets”: [
“src/sw-offline-google-analytics.prod.v0.0.25.js”
]
Could you help me to solve this issue? I cannot find any hints in googling.
Thanks in advance