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';

0 commit comments

Comments
 (0)