Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages/analytics-browser-test/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ describe('integration', () => {
resolve();
}, 4000);
});
});
}, 10000);

test('should send page view', () => {
let payload: any = undefined;
Expand Down
1 change: 1 addition & 0 deletions packages/analytics-browser/src/browser-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class AmplitudeBrowser extends AmplitudeCore implements BrowserClient, An
},
);
diagnosticsClient.setTag('library', `${LIBPREFIX}/${VERSION}`);
diagnosticsClient.setTag('user_agent', navigator.userAgent);
Copy link
Contributor

Choose a reason for hiding this comment

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

Accessing navigator.userAgent without a guard can crash in non‑browser contexts. Consider guarding with typeof navigator !== 'undefined' (like in Context) before setting the tag.

Suggested change
diagnosticsClient.setTag('user_agent', navigator.userAgent);
if (typeof navigator !== 'undefined') {
diagnosticsClient.setTag('user_agent', navigator.userAgent);
}

🚀 Want me to fix this? Reply ex: "fix it for me".


await super._init(browserOptions);
this.logBrowserOptions(browserOptions);
Expand Down
Loading