Skip to content

fix: Remove globalThis usage #3033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/browser/src/transports/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { API } from '@sentry/core';
import { Event, Response, SentryRequestType, Status, Transport, TransportOptions } from '@sentry/types';
import {
Event,
Response as SentryResponse,
SentryRequestType,
Status,
Transport,
TransportOptions,
} from '@sentry/types';
import { logger, parseRetryAfterHeader, PromiseBuffer, SentryError } from '@sentry/utils';

/** Base Transport class implementation */
Expand All @@ -13,7 +20,7 @@ export abstract class BaseTransport implements Transport {
protected readonly _api: API;

/** A simple buffer holding all requests. */
protected readonly _buffer: PromiseBuffer<Response> = new PromiseBuffer(30);
protected readonly _buffer: PromiseBuffer<SentryResponse> = new PromiseBuffer(30);

/** Locks transport after receiving rate limits in a response */
protected readonly _rateLimits: Record<string, Date> = {};
Expand All @@ -27,7 +34,7 @@ export abstract class BaseTransport implements Transport {
/**
* @inheritDoc
*/
public sendEvent(_: Event): PromiseLike<Response> {
public sendEvent(_: Event): PromiseLike<SentryResponse> {
throw new SentryError('Transport Class has to implement `sendEvent` method');
}

Expand All @@ -49,9 +56,9 @@ export abstract class BaseTransport implements Transport {
reject,
}: {
requestType: SentryRequestType;
response: globalThis.Response | XMLHttpRequest;
response: Response | XMLHttpRequest;
headers: Record<string, string | null>;
resolve: (value?: Response | PromiseLike<Response> | null | undefined) => void;
resolve: (value?: SentryResponse | PromiseLike<SentryResponse> | null | undefined) => void;
reject: (reason?: unknown) => void;
}): void {
const status = Status.fromHttpCode(response.status);
Expand Down