Skip to content

Commit

Permalink
ref(backend): Delete Backend classes (#4919)
Browse files Browse the repository at this point in the history
Delete the Backend classes. Specifically the following classes and files are removed:

* `Backend (interface)`
* `BaseBackend`*
* `BrowserBackend`
* `NodeBackend`
* `TestBackend`*

*`Options` interfaces in these files were moved to the respective Client files

Additionally,

* delete (the previously ported) `NoopTransport` test in packages/browser/test/unit/backend.test.ts.
* adjust a few remaining Backend references in tests to use Client classes
* adjust `BaseBackend` documentation to no longer include Backend information
  • Loading branch information
Lms24 authored and lobsterkatie committed Apr 13, 2022
1 parent d9ee071 commit 1a52dd0
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 483 deletions.
83 changes: 0 additions & 83 deletions packages/browser/src/backend.ts

This file was deleted.

29 changes: 23 additions & 6 deletions packages/browser/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
import { BaseClient, getEnvelopeEndpointWithUrlEncodedAuth, initAPIDetails, Scope, SDK_VERSION } from '@sentry/core';
import { Event, EventHint, Severity, Transport, TransportOptions } from '@sentry/types';
import { Event, EventHint, Options, Severity, Transport, TransportOptions } from '@sentry/types';
import { getGlobalObject, logger, supportsFetch } from '@sentry/utils';

import { BrowserBackend, BrowserOptions } from './backend';
import { eventFromException, eventFromMessage } from './eventbuilder';
import { IS_DEBUG_BUILD } from './flags';
import { injectReportDialog, ReportDialogOptions } from './helpers';
import { Breadcrumbs } from './integrations';
import { FetchTransport, makeNewFetchTransport, makeNewXHRTransport, XHRTransport } from './transports';

/**
* Configuration options for the Sentry Browser SDK.
* @see BrowserClient for more information.
*/
export interface BrowserOptions extends Options {
/**
* A pattern for error URLs which should exclusively be sent to Sentry.
* This is the opposite of {@link Options.denyUrls}.
* By default, all errors will be sent.
*/
allowUrls?: Array<string | RegExp>;

/**
* A pattern for error URLs which should not be sent to Sentry.
* To allow certain errors instead, use {@link Options.allowUrls}.
* By default, all errors will be sent.
*/
denyUrls?: Array<string | RegExp>;
}

/**
* The Sentry Browser SDK Client.
*
* @see BrowserOptions for documentation on configuration options.
* @see SentryClient for usage documentation.
* TODO(v7): remove BrowserBackend
*/
export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
export class BrowserClient extends BaseClient<BrowserOptions> {
/**
* Creates a new Browser SDK instance.
*
Expand All @@ -35,8 +53,7 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
version: SDK_VERSION,
};

// TODO(v7): remove BrowserBackend param
super(BrowserBackend, options);
super(options);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions packages/browser/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ export {
withScope,
} from '@sentry/core';

// TODO(v7): refactor to use client here!
export { BrowserOptions } from './backend';
export { BrowserClient } from './client';
export { BrowserClient, BrowserOptions } from './client';
export { injectReportDialog, ReportDialogOptions } from './helpers';
export { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDialog, flush, close, wrap } from './sdk';
export { SDK_NAME } from './version';
3 changes: 1 addition & 2 deletions packages/browser/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { getCurrentHub, initAndBind, Integrations as CoreIntegrations } from '@s
import { Hub } from '@sentry/types';
import { addInstrumentationHandler, getGlobalObject, logger, resolvedSyncPromise } from '@sentry/utils';

import { BrowserOptions } from './backend';
import { BrowserClient } from './client';
import { BrowserClient, BrowserOptions } from './client';
import { IS_DEBUG_BUILD } from './flags';
import { ReportDialogOptions, wrap as internalWrap } from './helpers';
import { Breadcrumbs, Dedupe, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';
Expand Down
14 changes: 0 additions & 14 deletions packages/browser/test/unit/backend.test.ts

This file was deleted.

17 changes: 7 additions & 10 deletions packages/browser/test/unit/integrations/linkederrors.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ExtendedError } from '@sentry/types';

import { BrowserBackend } from '../../../src/backend';
import { BrowserClient } from '../../../src/client';
import * as LinkedErrorsModule from '../../../src/integrations/linkederrors';

describe('LinkedErrors', () => {
Expand Down Expand Up @@ -34,9 +34,8 @@ describe('LinkedErrors', () => {
one.cause = two;

const originalException = one;
// TODO(v7): refactor to use client here!
const backend = new BrowserBackend({});
return backend.eventFromException(originalException).then(event => {
const client = new BrowserClient({});
return client.eventFromException(originalException).then(event => {
const result = LinkedErrorsModule._handler('cause', 5, event, {
originalException,
});
Expand Down Expand Up @@ -65,9 +64,8 @@ describe('LinkedErrors', () => {
one.reason = two;

const originalException = one;
const backend = new BrowserBackend({});
// TODO(v7): refactor to use client here!
return backend.eventFromException(originalException).then(event => {
const client = new BrowserClient({});
return client.eventFromException(originalException).then(event => {
const result = LinkedErrorsModule._handler('reason', 5, event, {
originalException,
});
Expand All @@ -92,10 +90,9 @@ describe('LinkedErrors', () => {
one.cause = two;
two.cause = three;

const backend = new BrowserBackend({});
const client = new BrowserClient({});
const originalException = one;
// TODO(v7): refactor to use client here!
return backend.eventFromException(originalException).then(event => {
return client.eventFromException(originalException).then(event => {
const result = LinkedErrorsModule._handler('cause', 2, event, {
originalException,
});
Expand Down
161 changes: 0 additions & 161 deletions packages/core/src/basebackend.ts

This file was deleted.

Loading

0 comments on commit 1a52dd0

Please sign in to comment.