Skip to content

Commit

Permalink
fix(opentelemetry-sdk-trace-web): don't crash in runtimes where locat…
Browse files Browse the repository at this point in the history
…ion isn't defined (#3715)

* fix(opentelemetry-sdk-trace-web): don't crash in runtimes where location isn't defined

* chore: updated changelog

* chore(opentelemetry-sdk-trace-web): fix linter issues

* fix(opentelemetry-sdk-trace-web): Remove broken test and replace with comment

---------

Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
  • Loading branch information
Grunet and dyladan authored Apr 12, 2023
1 parent 9328558 commit 9945c4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
### :bug: (Bug Fix)

* fix(instrumentation-http): fixed description for http.server.duration metric [#3710](https://github.com/open-telemetry/opentelemetry-js/pull/3710)
* fix(opentelemetry-sdk-trace-web): don't crash in runtimes where location isn't defined [#3715](https://github.com/open-telemetry/opentelemetry-js/pull/3715)

### :books: (Refine Doc)

Expand Down
6 changes: 5 additions & 1 deletion packages/opentelemetry-sdk-trace-web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ export function parseUrl(url: string): URLLike {
if (typeof URL === 'function') {
return new URL(
url,
typeof document !== 'undefined' ? document.baseURI : location.href
typeof document !== 'undefined'
? document.baseURI
: typeof location !== 'undefined' // Some JS runtimes (e.g. Deno) don't define this
? location.href
: undefined
);
}
const element = getUrlNormalizingAnchor();
Expand Down

0 comments on commit 9945c4b

Please sign in to comment.