Skip to content
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

fix(core): Skip empty integrations #7204

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/core/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ export function setupIntegrations(integrations: Integration[]): IntegrationIndex
const integrationIndex: IntegrationIndex = {};

integrations.forEach(integration => {
setupIntegration(integration, integrationIndex);
// guard against empty provided integrations
if (integration) {
setupIntegration(integration, integrationIndex);
}
});

return integrationIndex;
Expand Down
16 changes: 16 additions & 0 deletions packages/core/test/lib/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,22 @@ describe('BaseClient', () => {
);
});

test('skips empty integrations', () => {
const options = getDefaultTestClientOptions({
dsn: PUBLIC_DSN,
// @ts-ignore we want to force invalid integrations here
integrations: [new TestIntegration(), null, undefined],
});
const client = new TestClient(options);
client.setupIntegrations();

client.captureEvent({ message: 'message' });

expect(TestClient.instance!.event!.sdk).toEqual({
integrations: ['TestIntegration'],
});
});

test('normalizes event with default depth of 3', () => {
expect.assertions(1);

Expand Down