|
1 | 1 | import { Backend, logger, Options, SentryError } from '@sentry/core';
|
2 | 2 | import { SentryEvent, SentryEventHint, SentryResponse, Severity, Status, Transport } from '@sentry/types';
|
3 | 3 | import { isDOMError, isDOMException, isError, isErrorEvent, isPlainObject } from '@sentry/utils/is';
|
4 |
| -import { supportsFetch } from '@sentry/utils/supports'; |
| 4 | +import { supportsBeacon, supportsFetch } from '@sentry/utils/supports'; |
5 | 5 | import { eventFromPlainObject, eventFromStacktrace, prepareFramesForEvent } from './parsers';
|
6 | 6 | import { computeStackTrace } from './tracekit';
|
7 |
| -import { FetchTransport, XHRTransport } from './transports'; |
| 7 | +import { BeaconTransport, FetchTransport, XHRTransport } from './transports'; |
8 | 8 |
|
9 | 9 | /**
|
10 | 10 | * Configuration options for the Sentry Browser SDK.
|
@@ -149,11 +149,16 @@ export class BrowserBackend implements Backend {
|
149 | 149 | const transportOptions = this.options.transportOptions
|
150 | 150 | ? this.options.transportOptions
|
151 | 151 | : { dsn: this.options.dsn };
|
152 |
| - this.transport = this.options.transport |
153 |
| - ? new this.options.transport({ dsn: this.options.dsn }) |
154 |
| - : supportsFetch() |
155 |
| - ? new FetchTransport(transportOptions) |
156 |
| - : new XHRTransport(transportOptions); |
| 152 | + |
| 153 | + if (this.options.transport) { |
| 154 | + this.transport = new this.options.transport({ dsn: this.options.dsn }); |
| 155 | + } else if (supportsBeacon()) { |
| 156 | + this.transport = new BeaconTransport(transportOptions); |
| 157 | + } else if (supportsFetch()) { |
| 158 | + this.transport = new FetchTransport(transportOptions); |
| 159 | + } else { |
| 160 | + this.transport = new XHRTransport(transportOptions); |
| 161 | + } |
157 | 162 | }
|
158 | 163 |
|
159 | 164 | return this.transport.send(event);
|
|
0 commit comments