-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Safari JS error accessing window.external
#68
Conversation
``` [Error] TypeError: undefined is not an Object. (evaluating ''msTrackingProtectionEnabled' in window.external') (anonymous function) (tracker.js:3:114) Global Code (tracker.js:137) ``` https://developer.mozilla.org/en-US/docs/Web/API/Window/external#browser_compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #68 +/- ##
=======================================
Coverage 87.84% 87.84%
=======================================
Files 15 15
Lines 732 732
Branches 137 137
=======================================
Hits 643 643
Misses 54 54
Partials 35 35 ☔ View full report in Codecov by Sentry. |
if (window.doNotTrack || navigator.doNotTrack || navigator.msDoNotTrack || (window.external || {}).msTrackingProtectionEnabled) { | ||
if (window.doNotTrack == '1' || navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1' || 'msTrackingProtectionEnabled' in window.external && window.external.msTrackingProtectionEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are good dropping the entire window.external.msTrackingProtectionEnabled
check.
This appears to be only supported in Internet Explorer 9 if this docs page I found is accurate: https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/gg593071(v=vs.85)
We don't support IE.
The
tracker.js
code attempts to honour the "Do Not Track" browser flag, but it's using a deprecated API, which has been removed from Safari. Currently it fails with this message: