diff --git a/experimental/CHANGELOG.md b/experimental/CHANGELOG.md index 11e98847da..bc0fb011da 100644 --- a/experimental/CHANGELOG.md +++ b/experimental/CHANGELOG.md @@ -21,6 +21,8 @@ All notable changes to experimental packages in this project will be documented ### :bug: (Bug Fix) +* fix(otlp-exporter-base): replaced usage of window with _globalThis [#4157](https://github.com/open-telemetry/opentelemetry-js/pull/4157) @cristianmadularu + ### :books: (Refine Doc) ### :house: (Internal) diff --git a/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts b/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts index 2888e317df..dbe02b222d 100644 --- a/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts +++ b/experimental/packages/otlp-exporter-base/src/platform/browser/OTLPExporterBrowserBase.ts @@ -20,7 +20,7 @@ import * as otlpTypes from '../../types'; import { parseHeaders } from '../../util'; import { sendWithBeacon, sendWithXhr } from './util'; import { diag } from '@opentelemetry/api'; -import { getEnv, baggageUtils } from '@opentelemetry/core'; +import { getEnv, baggageUtils, _globalThis } from '@opentelemetry/core'; /** * Collector Metric Exporter abstract base class @@ -53,11 +53,11 @@ export abstract class OTLPExporterBrowserBase< } onInit(): void { - window.addEventListener('unload', this.shutdown); + _globalThis.addEventListener('unload', this.shutdown); } onShutdown(): void { - window.removeEventListener('unload', this.shutdown); + _globalThis.removeEventListener('unload', this.shutdown); } send(