Skip to content
Open
Changes from 3 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
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