Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions gatsby/onPreBootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ posthog.init("${process.env.GATSBY_POSTHOG_API_KEY}", {
if (!hasInAppFrame) {
return null
}
// Browser extensions (e.g. Dark Reader) inject an inline script. When it
// throws, its single frame is "global code" at line 1 of the document URL
// and is marked in_app, so it reads as a first-party error and each new
// page URL mints a new fingerprint. Our own code loads from separate script
// files, never inline in the page, so this shape is always extension noise.
var documentUrl = window.location.href.split('#')[0].replace(/\/$/, '')
var isInjectedInlineScript = exceptions.some(function (ex) {
var frames = (ex && ex.stacktrace && ex.stacktrace.frames) || []
if (frames.length !== 1) {
return false
}
var frame = frames[0]
var filename = (frame && frame.filename ? frame.filename : '').split('#')[0].replace(/\/$/, '')
Comment thread
posthog[bot] marked this conversation as resolved.
Outdated
return frame && frame.function === 'global code' && frame.lineno === 1 && filename === documentUrl
})
if (isInjectedInlineScript) {
return null
}
return event
},
person_profiles: 'identified_only',
Expand Down
Loading