Skip to content

Commit 0e90603

Browse files
authored
Only send beacons if the feature is not disabled (github#20282)
Fixes https://github.com/github/docs-internal/issues/20263
1 parent d639f74 commit 0e90603

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

javascripts/events.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ export function sendEvent({ type, version = '1.0.0', ...props }: SendEventProps)
103103

104104
...props,
105105
}
106-
const blob = new Blob([JSON.stringify(body)], { type: 'application/json' })
107-
navigator.sendBeacon('/events', blob)
106+
107+
// Only send the beacon if the feature is not disabled in the user's browser
108+
if (navigator?.sendBeacon) {
109+
const blob = new Blob([JSON.stringify(body)], { type: 'application/json' })
110+
navigator.sendBeacon('/events', blob)
111+
}
112+
108113
return body
109114
}
110115

0 commit comments

Comments
 (0)