Skip to content
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

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

mgax
Copy link
Contributor

@mgax mgax commented Dec 12, 2023

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:

[Error] TypeError: undefined is not an Object. (evaluating ''msTrackingProtectionEnabled' in window.external')
	(anonymous function) (tracker.js:3:114)
	Global Code (tracker.js:137)

```
[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
@mgax mgax marked this pull request as ready for review December 12, 2023 11:30
Copy link
Contributor

@tomusher tomusher left a 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.

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (31909a4) 87.84% compared to head (844947c) 87.84%.
Report is 11 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Comment on lines 3 to 4
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()) {
Copy link
Member

@Stormheg Stormheg Dec 13, 2023

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.

@mgax mgax requested a review from Stormheg December 13, 2023 16:42
@Stormheg Stormheg merged commit ced8a81 into wagtail-nest:main Dec 14, 2023
11 checks passed
@mgax mgax deleted the fix-safari-window-external branch December 14, 2023 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants