WorkerGlobalScope (which ServiceWorkerGlobalScope inherits from) does not include localStorage or sessionStorage, but using @minimal-analytics@gav4 in a ServiceWorker context throws a ReferenceError because of this hard dependency. It also throws a QuotaExceededError in a Safari Private tab when attempting to call setItem.
Instead, using a wrapper like storage-factory would prevent these runtime errors. Developers in a Worker context would then need to manually set the Client ID cid value, i.e. by copying the clientId value on the main thread between localStorage and indexedDB.
WorkerGlobalScope(whichServiceWorkerGlobalScopeinherits from) does not includelocalStorageorsessionStorage, but using@minimal-analytics@gav4in a ServiceWorker context throws aReferenceErrorbecause of this hard dependency. It also throws aQuotaExceededErrorin a Safari Private tab when attempting to callsetItem.Instead, using a wrapper like storage-factory would prevent these runtime errors. Developers in a Worker context would then need to manually set the Client ID
cidvalue, i.e. by copying theclientIdvalue on the main thread betweenlocalStorageandindexedDB.