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: zone detection #1570

Merged
merged 5 commits into from
Nov 28, 2024
Merged

fix: zone detection #1570

merged 5 commits into from
Nov 28, 2024

Conversation

pauldambra
Copy link
Member

@pauldambra pauldambra commented Nov 28, 2024

mutation observer setup is sometimes failing in Safari

I think that the underlying problem is we can't reliably get the mutation observer from an iframe

but we are at least always trying to get it from an iframe instead of only when angular has monkeyed around with it

let's reduce the number of people affected by checking correctly

i've tested locally that this doesn't freeze the test angular app that would freeze if this didn't work

and i've tested locally that i can record safari (as much as i can, it wasn't always failing)

Copy link

vercel bot commented Nov 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Nov 28, 2024 7:18pm

@pauldambra pauldambra added the bump patch Bump patch version when this PR gets merged label Nov 28, 2024
@pauldambra pauldambra requested a review from a team November 28, 2024 18:41
Copy link

github-actions bot commented Nov 28, 2024

Size Change: -1.07 kB (-0.03%)

Total Size: 3.18 MB

Filename Size Change
dist/all-external-dependencies.js 206 kB -164 B (-0.08%)
dist/array.full.js 361 kB -164 B (-0.05%)
dist/array.full.no-external.js 360 kB -164 B (-0.05%)
dist/dead-clicks-autocapture.js 14.3 kB -74 B (-0.52%)
dist/module.full.js 361 kB -164 B (-0.05%)
dist/module.full.no-external.js 360 kB -164 B (-0.05%)
dist/recorder-v2.js 115 kB -90 B (-0.08%)
dist/recorder.js 115 kB -90 B (-0.08%)
ℹ️ View Unchanged
Filename Size
dist/array.full.es5.js 258 kB
dist/array.js 175 kB
dist/array.no-external.js 174 kB
dist/customizations.full.js 12.5 kB
dist/exception-autocapture.js 9.37 kB
dist/external-scripts-loader.js 2.29 kB
dist/main.js 176 kB
dist/module.js 175 kB
dist/module.no-external.js 174 kB
dist/surveys-preview.js 57.6 kB
dist/surveys.js 63.2 kB
dist/tracing-headers.js 1.75 kB
dist/web-vitals.js 10.3 kB

compressed-size-action

Comment on lines 11 to 15
+ try {
+ if (!isFunction(x)) {
+ return false;
+ }
+ const prototypeKeys = Object.getOwnPropertyNames(x.prototype || {});
+ return prototypeKeys.some((key) => key.indexOf('__zone'));
+ return !!globalThis.Zone
+ } catch {
+ // we've seen some intermittent problems in Safari since introducing this check
+ return false
+ }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turns out it is way simpler to just check if the global zone is present
if it's not, then angular didn't taint this

just like with the previous solution, folk can configure this to not be called zone, but then they can run posthog outside of the zone 🤷

@pauldambra pauldambra requested a review from daibhin November 28, 2024 19:22
@pauldambra pauldambra merged commit 0fc5867 into main Nov 28, 2024
14 checks passed
@pauldambra pauldambra deleted the fix/zone-detection branch November 28, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch Bump patch version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants