Skip to content

Commit 5c5ac2c

Browse files
authored
ref(browser): Remove sendBeacon API usage (#7552)
1 parent 6426b58 commit 5c5ac2c

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

packages/browser/src/client.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Scope } from '@sentry/core';
2-
import { BaseClient, getEnvelopeEndpointWithUrlEncodedAuth, SDK_VERSION } from '@sentry/core';
2+
import { BaseClient, SDK_VERSION } from '@sentry/core';
33
import type {
44
BrowserClientReplayOptions,
55
ClientOptions,
@@ -9,7 +9,7 @@ import type {
99
Severity,
1010
SeverityLevel,
1111
} from '@sentry/types';
12-
import { createClientReportEnvelope, dsnToString, getSDKSource, logger, serializeEnvelope } from '@sentry/utils';
12+
import { createClientReportEnvelope, dsnToString, getSDKSource, logger } from '@sentry/utils';
1313

1414
import { eventFromException, eventFromMessage } from './eventbuilder';
1515
import { WINDOW } from './helpers';
@@ -132,24 +132,7 @@ export class BrowserClient extends BaseClient<BrowserClientOptions> {
132132

133133
__DEBUG_BUILD__ && logger.log('Sending outcomes:', outcomes);
134134

135-
const url = getEnvelopeEndpointWithUrlEncodedAuth(this._dsn, this._options);
136135
const envelope = createClientReportEnvelope(outcomes, this._options.tunnel && dsnToString(this._dsn));
137-
138-
try {
139-
const isRealNavigator = Object.prototype.toString.call(WINDOW && WINDOW.navigator) === '[object Navigator]';
140-
const hasSendBeacon = isRealNavigator && typeof WINDOW.navigator.sendBeacon === 'function';
141-
// Make sure beacon is not used if user configures custom transport options
142-
if (hasSendBeacon && !this._options.transportOptions) {
143-
// Prevent illegal invocations - https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
144-
const sendBeacon = WINDOW.navigator.sendBeacon.bind(WINDOW.navigator);
145-
sendBeacon(url, serializeEnvelope(envelope));
146-
} else {
147-
// If beacon is not supported or if they are using the tunnel option
148-
// use our regular transport to send client reports to Sentry.
149-
void this._sendEnvelope(envelope);
150-
}
151-
} catch (e) {
152-
__DEBUG_BUILD__ && logger.error(e);
153-
}
136+
void this._sendEnvelope(envelope);
154137
}
155138
}

0 commit comments

Comments
 (0)