Reputation: 83
I'm trying to send Google Analytics events from Firefox extension background page. As there is no window object in the background page, I can't use the ga.js library. Is there a way to work around it in Javascript other than sending events from the content scripts?
Upvotes: 0
Views: 391
Reputation: 5830
As Wladimir suggested, there are privacy concerns with gathering metrics in an add-on like this, and built-in metrics that respect user privacy provided by addons.mozilla.org.
If you want a 'back-ground-page-like' environment, the page-worker api allows you to load a url and interact with the dom using the same apis and message-passing scheme used for content scripts. Pages loaded into page-worker do not have escalated privileges, they work just like a normal web page.
If you implement GA in a page-worker and submit your add-on for review, I believe you will need to clearly state a privacy policy indicating that you are collecting statistics, and your code may not be accepted depending on the type of data you are collecting. The easiest thing to do is just let AMO handle stats for you.
Upvotes: 1