Skip to content

Commit

Permalink
feat(v8/core): Remove deprecated client.setupIntegrations method
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Mar 18, 2024
1 parent a99f260 commit 716f779
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 90 deletions.
17 changes: 0 additions & 17 deletions packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
/** Array of set up integrations. */
protected _integrations: IntegrationIndex;

/** Indicates whether this client's integrations have been set up. */
protected _integrationsInitialized: boolean;

/** Number of calls being processed */
protected _numProcessing: number;

Expand All @@ -122,7 +119,6 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
protected constructor(options: O) {
this._options = options;
this._integrations = {};
this._integrationsInitialized = false;
this._numProcessing = 0;
this._outcomes = {};
this._hooks = {};
Expand Down Expand Up @@ -303,16 +299,6 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
this._eventProcessors.push(eventProcessor);
}

/**
* This is an internal function to setup all integrations that should run on the client.
* @deprecated Use `client.init()` instead.
*/
public setupIntegrations(forceInitialize?: boolean): void {
if ((forceInitialize && !this._integrationsInitialized) || (this._isEnabled() && !this._integrationsInitialized)) {
this._setupIntegrations();
}
}

/** @inheritdoc */
public init(): void {
if (this._isEnabled()) {
Expand Down Expand Up @@ -533,9 +519,6 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
const { integrations } = this._options;
this._integrations = setupIntegrations(this, integrations);
afterSetupIntegrations(this, integrations);

// TODO v8: We don't need this flag anymore
this._integrationsInitialized = true;
}

/** Updates existing session based on the provided event */
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ export class Hub implements HubInterface {
const top = this.getStackTop();
top.client = client;
top.scope.setClient(client);
// eslint-disable-next-line deprecation/deprecation
if (client && client.setupIntegrations) {
// eslint-disable-next-line deprecation/deprecation
client.setupIntegrations();
if (client) {
client.init();
}
}

Expand Down
63 changes: 0 additions & 63 deletions packages/core/test/lib/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1471,18 +1471,6 @@ describe('BaseClient', () => {
global.__SENTRY__ = {};
});

test('sets up each integration on `setupIntegrations` call', () => {
expect.assertions(2);

const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, integrations: [new TestIntegration()] });
const client = new TestClient(options);
// eslint-disable-next-line deprecation/deprecation
client.setupIntegrations();

expect(Object.keys((client as any)._integrations).length).toEqual(1);
expect(client.getIntegrationByName(TestIntegration.id)).toBeTruthy();
});

test('sets up each integration on `init` call', () => {
expect.assertions(2);

Expand All @@ -1494,18 +1482,6 @@ describe('BaseClient', () => {
expect(client.getIntegrationByName(TestIntegration.id)).toBeTruthy();
});

test('skips installation for `setupIntegrations()` if DSN is not provided', () => {
expect.assertions(2);

const options = getDefaultTestClientOptions({ integrations: [new TestIntegration()] });
const client = new TestClient(options);
// eslint-disable-next-line deprecation/deprecation
client.setupIntegrations();

expect(Object.keys((client as any)._integrations).length).toEqual(0);
expect(client.getIntegrationByName(TestIntegration.id)).toBeFalsy();
});

test('skips installation for `init()` if DSN is not provided', () => {
expect.assertions(2);

Expand All @@ -1517,22 +1493,6 @@ describe('BaseClient', () => {
expect(client.getIntegrationByName(TestIntegration.id)).toBeFalsy();
});

test('skips installation for `setupIntegrations()` if `enabled` is set to `false`', () => {
expect.assertions(2);

const options = getDefaultTestClientOptions({
dsn: PUBLIC_DSN,
enabled: false,
integrations: [new TestIntegration()],
});
const client = new TestClient(options);
// eslint-disable-next-line deprecation/deprecation
client.setupIntegrations();

expect(Object.keys((client as any)._integrations).length).toEqual(0);
expect(client.getIntegrationByName(TestIntegration.id)).toBeFalsy();
});

test('skips installation for `init()` if `enabled` is set to `false`', () => {
expect.assertions(2);

Expand All @@ -1548,29 +1508,6 @@ describe('BaseClient', () => {
expect(client.getIntegrationByName(TestIntegration.id)).toBeFalsy();
});

test('skips installation if integrations are already installed', () => {
expect.assertions(4);

const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, integrations: [new TestIntegration()] });
const client = new TestClient(options);
// note: not the `Client` method `setupIntegrations`, but the free-standing function which that method calls
const setupIntegrationsHelper = jest.spyOn(integrationModule, 'setupIntegrations');

// it should install the first time, because integrations aren't yet installed...
// eslint-disable-next-line deprecation/deprecation
client.setupIntegrations();

expect(Object.keys((client as any)._integrations).length).toEqual(1);
expect(client.getIntegrationByName(TestIntegration.id)).toBeTruthy();
expect(setupIntegrationsHelper).toHaveBeenCalledTimes(1);

// ...but it shouldn't try to install a second time
// eslint-disable-next-line deprecation/deprecation
client.setupIntegrations();

expect(setupIntegrationsHelper).toHaveBeenCalledTimes(1);
});

test('does not add integrations twice when calling `init` multiple times', () => {
const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, integrations: [new TestIntegration()] });
const client = new TestClient(options);
Expand Down
6 changes: 0 additions & 6 deletions packages/types/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ export interface Client<O extends ClientOptions = ClientOptions> {
* */
addIntegration(integration: Integration): void;

/**
* This is an internal function to setup all integrations that should run on the client.
* @deprecated Use `client.init()` instead.
*/
setupIntegrations(forceInitialize?: boolean): void;

/**
* Initialize this client.
* Call this after the client was set on a scope.
Expand Down

0 comments on commit 716f779

Please sign in to comment.