-
Notifications
You must be signed in to change notification settings - Fork 129
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
fix: zone detection #1570
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: -1.07 kB (-0.03%) Total Size: 3.18 MB
ℹ️ View Unchanged
|
+ 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 | ||
+ } |
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.
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 🤷
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)