Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the analytics.js shim to handle more ways of using the ga API
It turns out that a website can do something like ga(tracker => { ... }); and the inline function should be called. That wasn't handled yet, so let's add the necessary logic from Mozilla's shim script[1] (but adjusted as necessary). It also turns out that websites sometimes have their own inline definition of ga(), that assigns any call arguments to the ga.q queue. The calls in the queue are supposed to be made with the real ga() function, once that has been loaded. This also wasn't handled yet in our shim. I notice that we still do not handle further ways of using the ga API, in the future it might be worth just switching to Mozilla's script entirely. 1 - https://searchfox.org/mozilla-central/source/browser/extensions/webcompat/shims/google-analytics-and-tag-manager.js
- Loading branch information