minimal-analytics
minimal-analytics copied to clipboard
Support Web Worker and ServiceWorker scope
Add support for Web Worker and ServiceWorker contexts with the following changes
- When
navigator.sendBeaconisn't available, default toXMLHttpRequest(Worker) orfetch(ServiceWorker) - When
sessionStorageorlocalStorageisn't available (i.e. Worker/ ServiceWorker), use an in-memoryMapand warn thatclientIdis not persisted - Allow use of global
selforwindow, depending on context - Don't set
windowordocumentscoped events when not available - Because
localStorageisn't available in a Worker scope, per #43, allow param overrides, i.e. to pullclientIdfrom IndexedDB
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 96.58 | 77.25 | 100 | 96.49 |
index.ts | 96.46 | 77.25 | 100 | 96.39 | 283,305,393,403
model.ts | 100 | 100 | 100 | 100 |
----------|---------|----------|---------|---------|-------------------
Jest: "global" coverage threshold for branches (78%) not met: 77.25%
Looks like CI ran well this time, but failed due to test coverage. I'll take a look at covering additional branches within ga4