Skip to content

Commit dee5dc6

Browse files
jethronigneel64
authored andcommitted
Always access navigator via window
snowplow#1285
1 parent 3be6c87 commit dee5dc6

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@snowplow/browser-tracker-core",
5+
"comment": "Consistently access navigator via window.navigator",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@snowplow/browser-tracker-core"
10+
}

libraries/browser-tracker-core/src/helpers/browser_props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function getBrowserProperties() {
1010
devicePixelRatio: window.devicePixelRatio,
1111
cookiesEnabled: window.navigator.cookieEnabled,
1212
online: window.navigator.onLine,
13-
browserLanguage: navigator.language || (navigator as any).userLanguage,
13+
browserLanguage: window.navigator.language || (window.navigator as any).userLanguage,
1414
documentLanguage: document.documentElement.lang,
1515
webdriver: window.navigator.webdriver,
1616
deviceMemory: (window.navigator as any).deviceMemory,

libraries/browser-tracker-core/src/tracker/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export function Tracker(
228228
// First-party cookie secure attribute
229229
configCookieSecure = trackerConfiguration.cookieSecure ?? true,
230230
// Do Not Track browser feature
231-
dnt = navigator.doNotTrack || navigator.msDoNotTrack || window.doNotTrack,
231+
dnt = window.navigator.doNotTrack || window.navigator.msDoNotTrack || window.doNotTrack,
232232
// Do Not Track
233233
configDoNotTrack =
234234
typeof trackerConfiguration.respectDoNotTrack !== 'undefined'

libraries/browser-tracker-core/src/tracker/out_queue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function OutQueueManager(
8181
isBeaconAvailable = Boolean(
8282
isBeaconRequested &&
8383
window.navigator &&
84-
window.navigator.sendBeacon &&
84+
typeof window.navigator.sendBeacon === 'function' &&
8585
!hasWebKitBeaconBug(window.navigator.userAgent)
8686
),
8787
useBeacon = isBeaconAvailable && isBeaconRequested,
@@ -412,7 +412,7 @@ export function OutQueueManager(
412412
type: 'application/json',
413413
});
414414
try {
415-
beaconStatus = navigator.sendBeacon(url, blob);
415+
beaconStatus = window.navigator.sendBeacon(url, blob);
416416
} catch (error) {
417417
beaconStatus = false;
418418
}

0 commit comments

Comments
 (0)