Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(resources): ensure BrowserDetector does not think Node.js v21 is a browser #4604

Merged
merged 3 commits into from
Apr 4, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
### :bug: (Bug Fix)

* fix(sdk-trace-web): fix invalid timings in span events [#4486](https://github.com/open-telemetry/opentelemetry-js/pull/4486) @Abinet18
* fix(resources): ensure BrowserDetector does not think Node.js v21 is a browser [#4561](https://github.com/open-telemetry/opentelemetry-js/issues/4561) @trentm

### :books: (Refine Doc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ import { diag } from '@opentelemetry/api';
*/
class BrowserDetectorSync implements DetectorSync {
detect(config?: ResourceDetectionConfig): IResource {
const isBrowser = typeof navigator !== 'undefined';
const isBrowser =
typeof navigator !== 'undefined' &&
global.process?.versions?.node === undefined && // Node.js v21 adds `navigator`
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore don't have Bun types
global.Bun?.version === undefined; // Bun (bun.sh) defines `navigator`
if (!isBrowser) {
return Resource.empty();
}
Expand Down