Skip to content

Commit

Permalink
fix(resources): ensure BrowserDetector does not think Node.js v21 is …
Browse files Browse the repository at this point in the history
  • Loading branch information
trentm authored and Zirak committed Sep 14, 2024
1 parent 5d5e739 commit 468b8a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 468b8a1

Please sign in to comment.