Skip to content

Commit ac2ad29

Browse files
committed
feat(core)!: Remove standalone Client interface & deprecate BaseClient
1 parent 0d43883 commit ac2ad29

39 files changed

+81
-71
lines changed

packages/browser-utils/test/utils/TestClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseClient, createTransport, initAndBind } from '@sentry/core';
1+
import { Client, createTransport, initAndBind } from '@sentry/core';
22
import { resolvedSyncPromise } from '@sentry/core';
33
import type {
44
BrowserClientReplayOptions,
@@ -10,7 +10,7 @@ import type {
1010

1111
export interface TestClientOptions extends ClientOptions, BrowserClientReplayOptions {}
1212

13-
export class TestClient extends BaseClient<TestClientOptions> {
13+
export class TestClient extends Client<TestClientOptions> {
1414
public constructor(options: TestClientOptions) {
1515
super(options);
1616
}

packages/browser/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
SeverityLevel,
1111
UserFeedback,
1212
} from '@sentry/core';
13-
import { BaseClient, applySdkMetadata, getSDKSource, logger } from '@sentry/core';
13+
import { Client, applySdkMetadata, getSDKSource, logger } from '@sentry/core';
1414
import { DEBUG_BUILD } from './debug-build';
1515
import { eventFromException, eventFromMessage } from './eventbuilder';
1616
import { WINDOW } from './helpers';
@@ -61,7 +61,7 @@ export type BrowserClientOptions = ClientOptions<BrowserTransportOptions> &
6161
* @see BrowserOptions for documentation on configuration options.
6262
* @see SentryClient for usage documentation.
6363
*/
64-
export class BrowserClient extends BaseClient<BrowserClientOptions> {
64+
export class BrowserClient extends Client<BrowserClientOptions> {
6565
/**
6666
* Creates a new Browser SDK instance.
6767
*

packages/core/src/asyncContext/stackStrategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../baseclient';
1+
import type { Client } from '../client';
22
import { getDefaultCurrentScope, getDefaultIsolationScope } from '../defaultScopes';
33
import { Scope } from '../scope';
44
import { isThenable } from '../utils-hoist/is';

packages/core/src/baseclient.ts renamed to packages/core/src/client.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,33 @@ const MISSING_RELEASE_FOR_SESSION_ERROR = 'Discarded session because of missing
6464
*
6565
* Call the constructor with the corresponding options
6666
* specific to the client subclass. To access these options later, use
67-
* {@link BaseClient.getOptions}.
67+
* {@link Client.getOptions}.
6868
*
6969
* If a Dsn is specified in the options, it will be parsed and stored. Use
70-
* {@link BaseClient.getDsn} to retrieve the Dsn at any moment. In case the Dsn is
70+
* {@link Client.getDsn} to retrieve the Dsn at any moment. In case the Dsn is
7171
* invalid, the constructor will throw a {@link SentryException}. Note that
7272
* without a valid Dsn, the SDK will not send any events to Sentry.
7373
*
7474
* Before sending an event, it is passed through
75-
* {@link BaseClient._prepareEvent} to add SDK information and scope data
75+
* {@link Client._prepareEvent} to add SDK information and scope data
7676
* (breadcrumbs and context). To add more custom information, override this
7777
* method and extend the resulting prepared event.
7878
*
7979
* To issue automatically created events (e.g. via instrumentation), use
80-
* {@link BaseClient.captureEvent}. It will prepare the event and pass it through
80+
* {@link Client.captureEvent}. It will prepare the event and pass it through
8181
* the callback lifecycle. To issue auto-breadcrumbs, use
82-
* {@link BaseClient.addBreadcrumb}.
82+
* {@link Client.addBreadcrumb}.
8383
*
8484
* @example
85-
* class NodeClient extends BaseClient<NodeOptions> {
85+
* class NodeClient extends Client<NodeOptions> {
8686
* public constructor(options: NodeOptions) {
8787
* super(options);
8888
* }
8989
*
9090
* // ...
9191
* }
9292
*/
93-
export abstract class BaseClient<O extends ClientOptions> {
93+
export abstract class Client<O extends ClientOptions = ClientOptions> {
9494
/** Options passed to the SDK. */
9595
protected readonly _options: O;
9696

@@ -960,7 +960,15 @@ export abstract class BaseClient<O extends ClientOptions> {
960960
): PromiseLike<Event>;
961961
}
962962

963-
export type Client<O extends ClientOptions = ClientOptions> = BaseClient<O>;
963+
/**
964+
* @deprecated Use `Client` instead. This alias may be removed in a future major version.
965+
*/
966+
export type BaseClient = Client;
967+
968+
/**
969+
* @deprecated Use `Client` instead. This alias may be removed in a future major version.
970+
*/
971+
export const BaseClient = Client;
964972

965973
/**
966974
* Verifies that return value of configured `beforeSend` or `beforeSendTransaction` is of expected type, and returns the value if so.

packages/core/src/currentScopes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getAsyncContextStrategy } from './asyncContext';
2-
import type { Client } from './baseclient';
32
import { getGlobalSingleton, getMainCarrier } from './carrier';
3+
import type { Client } from './client';
44
import { Scope } from './scope';
55
import type { TraceContext } from './types-hoist';
66
import { dropUndefinedKeys } from './utils-hoist/object';

packages/core/src/envelope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from './baseclient';
1+
import type { Client } from './client';
22
import { getDynamicSamplingContextFromSpan } from './tracing/dynamicSamplingContext';
33
import type { SentrySpan } from './tracing/sentrySpan';
44
import type {

packages/core/src/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from './baseclient';
1+
import type { Client } from './client';
22
import type { Scope } from './scope';
33
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from './semanticAttributes';
44
import { SPAN_STATUS_ERROR, setHttpStatus, startInactiveSpan } from './tracing';

packages/core/src/getCurrentHubShim.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Client } from './baseclient';
21
import { addBreadcrumb } from './breadcrumbs';
2+
import type { Client } from './client';
33
import { getClient, getCurrentScope, getIsolationScope, withScope } from './currentScopes';
44
import {
55
captureEvent,

packages/core/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ export { Scope } from './scope';
5151
export type { CaptureContext, ScopeContext, ScopeData } from './scope';
5252
export { notifyEventProcessors } from './eventProcessors';
5353
export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api';
54-
export { BaseClient } from './baseclient';
55-
export type { Client } from './baseclient';
54+
export {
55+
Client,
56+
// eslint-disable-next-line deprecation/deprecation
57+
BaseClient,
58+
} from './client';
5659
export { ServerRuntimeClient } from './server-runtime-client';
5760
export { initAndBind, setCurrentClient } from './sdk';
5861
export { createTransport } from './transports/base';

packages/core/src/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from './baseclient';
1+
import type { Client } from './client';
22
import { getClient } from './currentScopes';
33
import { DEBUG_BUILD } from './debug-build';
44
import type { Event, EventHint, Integration, IntegrationFn, Options } from './types-hoist';

packages/core/src/integrations/functiontostring.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../baseclient';
1+
import type { Client } from '../client';
22
import { getClient } from '../currentScopes';
33
import { defineIntegration } from '../integration';
44
import type { IntegrationFn, WrappedFunction } from '../types-hoist';

packages/core/src/scope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable max-lines */
2-
import type { Client } from './baseclient';
2+
import type { Client } from './client';
33
import { updateSession } from './session';
44
import type {
55
Attachment,

packages/core/src/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from './baseclient';
1+
import type { Client } from './client';
22
import { getCurrentScope } from './currentScopes';
33
import { DEBUG_BUILD } from './debug-build';
44
import type { ClientOptions } from './types-hoist';

packages/core/src/server-runtime-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import type {
1212
TraceContext,
1313
} from './types-hoist';
1414

15-
import { BaseClient } from './baseclient';
1615
import { createCheckInEnvelope } from './checkin';
16+
import { Client } from './client';
1717
import { getIsolationScope, getTraceContextFromScope } from './currentScopes';
1818
import { DEBUG_BUILD } from './debug-build';
1919
import type { Scope } from './scope';
@@ -40,7 +40,7 @@ export interface ServerRuntimeClientOptions extends ClientOptions<BaseTransportO
4040
*/
4141
export class ServerRuntimeClient<
4242
O extends ClientOptions & ServerRuntimeClientOptions = ServerRuntimeClientOptions,
43-
> extends BaseClient<O> {
43+
> extends Client<O> {
4444
/**
4545
* Creates a new Edge SDK instance.
4646
* @param options Configuration options for this SDK.

packages/core/src/session.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function makeSession(context?: Omit<SessionContext, 'started' | 'status'>
3838
* Note that this function mutates the passed object and returns void.
3939
* (Had to do this instead of returning a new and updated session because closing and sending a session
4040
* makes an update to the session after it was passed to the sending logic.
41-
* @see BaseClient.captureSession )
41+
* @see Client.captureSession )
4242
*
4343
* @param session the `Session` to update
4444
* @param context the `SessionContext` holding the properties that should be updated in @param session

packages/core/src/tracing/dynamicSamplingContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../baseclient';
1+
import type { Client } from '../client';
22
import { DEFAULT_ENVIRONMENT } from '../constants';
33
import { getClient } from '../currentScopes';
44
import type { Scope } from '../scope';

packages/core/src/types-hoist/hub.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../baseclient';
1+
import type { Client } from '../client';
22
import type { Scope } from '../scope';
33
import type { Breadcrumb, BreadcrumbHint } from './breadcrumb';
44
import type { Event, EventHint } from './event';

packages/core/src/types-hoist/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../baseclient';
1+
import type { Client } from '../client';
22
import type { Event, EventHint } from './event';
33

44
/** Integration Class Interface */

packages/core/src/types-hoist/profiling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../baseclient';
1+
import type { Client } from '../client';
22
import type { DebugImage } from './debugMeta';
33
import type { Integration } from './integration';
44
import type { MeasurementUnit } from './measurement';

packages/core/src/types-hoist/transport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../baseclient';
1+
import type { Client } from '../client';
22
import type { Envelope } from './envelope';
33

44
export type TransportRequest = {

packages/core/src/utils-hoist/eventbuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../baseclient';
1+
import type { Client } from '../client';
22
import type {
33
Event,
44
EventHint,

packages/core/src/utils/isSentryRequestUrl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../baseclient';
1+
import type { Client } from '../client';
22
import type { DsnComponents } from '../types-hoist';
33

44
/**

packages/core/src/utils/prepareEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../baseclient';
1+
import type { Client } from '../client';
22
import { DEFAULT_ENVIRONMENT } from '../constants';
33
import { getGlobalScope } from '../currentScopes';
44
import { notifyEventProcessors } from '../eventProcessors';

packages/core/test/lib/baseclient.test.ts renamed to packages/core/test/lib/client.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type {
2-
Client} from '../../src';
31
import {
42
Scope,
53
SentryError,
@@ -13,6 +11,7 @@ import {
1311
setCurrentClient,
1412
withMonitor,
1513
} from '../../src';
14+
import type { BaseClient, Client } from '../../src/client';
1615
import * as integrationModule from '../../src/integration';
1716
import type { Envelope, ErrorEvent, Event, TransactionEvent } from '../../src/types-hoist';
1817
import * as loggerModule from '../../src/utils-hoist/logger';
@@ -36,7 +35,7 @@ jest.spyOn(loggerModule, 'consoleSandbox').mockImplementation(cb => cb());
3635
jest.spyOn(stringModule, 'truncate').mockImplementation(str => str);
3736
jest.spyOn(timeModule, 'dateTimestampInSeconds').mockImplementation(() => 2020);
3837

39-
describe('BaseClient', () => {
38+
describe('Client', () => {
4039
beforeEach(() => {
4140
TestClient.sendEventCalled = undefined;
4241
TestClient.instance = undefined;
@@ -2099,7 +2098,8 @@ describe('BaseClient', () => {
20992098

21002099
// Make sure types work for both Client & BaseClient
21012100
const scenarios = [
2102-
['BaseClient', new TestClient(options)],
2101+
// eslint-disable-next-line deprecation/deprecation
2102+
['BaseClient', new TestClient(options) as BaseClient],
21032103
['Client', new TestClient(options) as Client],
21042104
] as const;
21052105

packages/core/test/lib/envelope.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type {
2-
Client} from '../../src';
1+
import type { Client } from '../../src';
32
import {
43
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
54
SentrySpan,

packages/core/test/lib/integrations/third-party-errors-filter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../../../src/baseclient';
1+
import type { Client } from '../../../src/client';
22
import { thirdPartyErrorFilterIntegration } from '../../../src/integrations/third-party-errors-filter';
33
import { addMetadataToStackFrames } from '../../../src/metadata';
44
import type { Event } from '../../../src/types-hoist';

packages/core/test/lib/scope.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type {
2-
Client} from '../../src';
1+
import type { Client } from '../../src';
32
import {
43
applyScopeDataToEvent,
54
getCurrentScope,

packages/core/test/lib/sdk.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client} from '../../src';
1+
import type { Client } from '../../src';
22
import { captureCheckIn, getCurrentScope, setCurrentClient } from '../../src';
33
import { installedIntegrations } from '../../src/integration';
44
import { initAndBind } from '../../src/sdk';

packages/core/test/lib/utils/isSentryRequestUrl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../../../src/baseclient';
1+
import type { Client } from '../../../src/client';
22

33
import { isSentryRequestUrl } from '../../../src';
44

packages/core/test/lib/utils/traceData.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type {
2-
Client} from '../../../src/';
1+
import type { Client } from '../../../src/';
32
import {
43
SentrySpan,
54
getCurrentScope,

packages/core/test/mocks/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
SeverityLevel,
1010
} from '../../src/types-hoist';
1111

12-
import { BaseClient } from '../../src/baseclient';
12+
import { Client } from '../../src/client';
1313
import { initAndBind } from '../../src/sdk';
1414
import { createTransport } from '../../src/transports/base';
1515
import { resolvedSyncPromise } from '../../src/utils-hoist/syncpromise';
@@ -37,7 +37,7 @@ export interface TestClientOptions extends ClientOptions {
3737
defaultIntegrations?: Integration[] | false;
3838
}
3939

40-
export class TestClient extends BaseClient<TestClientOptions> {
40+
export class TestClient extends Client<TestClientOptions> {
4141
public static instance?: TestClient;
4242
public static sendEventCalled?: (event: Event) => void;
4343

packages/core/test/mocks/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client} from '../../src';
1+
import type { Client } from '../../src';
22
import { getClient, getCurrentScope } from '../../src';
33
import type { Event, EventProcessor, Integration } from '../../src/types-hoist';
44

packages/core/test/utils-hoist/eventbuilder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '../../src/baseclient';
1+
import type { Client } from '../../src/client';
22
import { eventFromMessage, eventFromUnknownInput } from '../../src/utils-hoist/eventbuilder';
33
import { nodeStackLineParser } from '../../src/utils-hoist/node-stack-trace';
44
import { createStackParser } from '../../src/utils-hoist/stacktrace';

packages/feedback/src/core/TestClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { BrowserClientReplayOptions, ClientOptions, Event, SeverityLevel } from '@sentry/core';
2-
import { BaseClient, createTransport, initAndBind, resolvedSyncPromise } from '@sentry/core';
2+
import { Client, createTransport, initAndBind, resolvedSyncPromise } from '@sentry/core';
33

44
export interface TestClientOptions extends ClientOptions, BrowserClientReplayOptions {}
55

66
/**
77
*
88
*/
9-
export class TestClient extends BaseClient<TestClientOptions> {
9+
export class TestClient extends Client<TestClientOptions> {
1010
public constructor(options: TestClientOptions) {
1111
super(options);
1212
}

packages/opentelemetry/src/custom/client.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Tracer } from '@opentelemetry/api';
22
import { trace } from '@opentelemetry/api';
33
import type { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';
4-
import type { BaseClient, Client } from '@sentry/core';
4+
import type { Client } from '@sentry/core';
55
import { SDK_VERSION } from '@sentry/core';
66
import type { OpenTelemetryClient as OpenTelemetryClientInterface } from '../types';
77

@@ -10,7 +10,8 @@ import type { OpenTelemetryClient as OpenTelemetryClientInterface } from '../typ
1010
/* eslint-disable @typescript-eslint/no-explicit-any */
1111

1212
/**
13-
* Wrap an Client with things we need for OpenTelemetry support.
13+
* Wrap an Client class with things we need for OpenTelemetry support.
14+
* Make sure that the Client class passed in is non-abstract!
1415
*
1516
* Usage:
1617
* const OpenTelemetryClient = getWrappedClientClass(NodeClient);
@@ -19,11 +20,12 @@ import type { OpenTelemetryClient as OpenTelemetryClientInterface } from '../typ
1920
export function wrapClientClass<
2021
ClassConstructor extends new (
2122
...args: any[]
22-
) => Client & BaseClient<any>,
23+
) => Client,
2324
WrappedClassConstructor extends new (
2425
...args: any[]
25-
) => Client & BaseClient<any> & OpenTelemetryClientInterface,
26+
) => Client & OpenTelemetryClientInterface,
2627
>(ClientClass: ClassConstructor): WrappedClassConstructor {
28+
// @ts-expect-error We just assume that this is non-abstract, if you pass in an abstract class this would make it non-abstract
2729
class OpenTelemetryClient extends ClientClass implements OpenTelemetryClientInterface {
2830
public traceProvider: BasicTracerProvider | undefined;
2931
private _tracer: Tracer | undefined;

0 commit comments

Comments
 (0)