segmentio / analytics-next

Segment Analytics.js 2.0
https://segment.com/docs/connections/sources/catalog/libraries/website/javascript
MIT License
383 stars 128 forks source link

Support for Web Extension Service Workers #907

Open kyranjamie opened 11 months ago

kyranjamie commented 11 months ago

We've just upgraded our Chrome extensions to MV3 and are unable to collect analytics in our background script (service worker).

Are there any workarounds for this? I see Partytown mentioned but we're not using this tool and believe there must be a simpler solution.

Currently, the library internally writes the anon id to localStorage. This presumes the environment. Ideally, the AnalyticsBrowser could accept some kind of storage API with a getItem, setItem, removeItem API? This way we could pass it the chrome.storage.local object.

Something like:

new AnalyticsBrowser({
  storage: chrome.storage.local
})
jonandgon commented 4 months ago

Is there any movement on this? The lack of support for chrome extensions is make/break for us.

kyranjamie commented 2 months ago

Chasing this. We have a huge gap in our extension's analytics currently owing to this issue.

markmhendrickson commented 2 months ago

+1 this is sorely needed