-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Stop passing
defaultIntegrations
as client option
- Loading branch information
Showing
56 changed files
with
439 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
|
||
import type { BrowserClient } from '@sentry/browser'; | ||
import { | ||
browserTracingIntegration, | ||
getActiveSpan, | ||
|
@@ -9,11 +8,11 @@ import { | |
getIsolationScope, | ||
} from '@sentry/browser'; | ||
import * as SentryBrowser from '@sentry/browser'; | ||
import { SDK_VERSION, getClient } from '@sentry/browser'; | ||
import { SDK_VERSION } from '@sentry/browser'; | ||
|
||
import { init } from '../../src/client/sdk'; | ||
|
||
const browserInit = vi.spyOn(SentryBrowser, 'init'); | ||
const browserInit = vi.spyOn(SentryBrowser, 'initWithDefaultIntegrations'); | ||
|
||
describe('Sentry client SDK', () => { | ||
describe('init', () => { | ||
|
@@ -45,6 +44,7 @@ describe('Sentry client SDK', () => { | |
}, | ||
}, | ||
}), | ||
expect.any(Function), | ||
); | ||
}); | ||
|
||
|
@@ -54,45 +54,39 @@ describe('Sentry client SDK', () => { | |
['tracesSampler', { tracesSampler: () => 1.0 }], | ||
['no tracing option set', {}], | ||
])('adds browserTracingIntegration if tracing is enabled via %s', (_, tracingOptions) => { | ||
init({ | ||
const client = init({ | ||
dsn: 'https://[email protected]/1337', | ||
...tracingOptions, | ||
}); | ||
|
||
const integrationsToInit = browserInit.mock.calls[0]![0]?.defaultIntegrations; | ||
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing'); | ||
|
||
expect(integrationsToInit).toContainEqual(expect.objectContaining({ name: 'BrowserTracing' })); | ||
const browserTracing = client?.getIntegrationByName('BrowserTracing'); | ||
expect(browserTracing).toBeDefined(); | ||
}); | ||
|
||
it("doesn't add browserTracingIntegration if `__SENTRY_TRACING__` is set to false", () => { | ||
(globalThis as any).__SENTRY_TRACING__ = false; | ||
|
||
init({ | ||
const client = init({ | ||
dsn: 'https://[email protected]/1337', | ||
tracesSampleRate: 1, | ||
}); | ||
|
||
const integrationsToInit = browserInit.mock.calls[0]![0]?.defaultIntegrations || []; | ||
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing'); | ||
|
||
expect(integrationsToInit).not.toContainEqual(expect.objectContaining({ name: 'BrowserTracing' })); | ||
const browserTracing = client?.getIntegrationByName('BrowserTracing'); | ||
expect(browserTracing).toBeUndefined(); | ||
|
||
delete (globalThis as any).__SENTRY_TRACING__; | ||
}); | ||
|
||
it('Overrides the automatically default browserTracingIntegration instance with a a user-provided browserTracingIntegration instance', () => { | ||
init({ | ||
const client = init({ | ||
dsn: 'https://[email protected]/1337', | ||
integrations: [ | ||
browserTracingIntegration({ finalTimeout: 10, instrumentNavigation: false, instrumentPageLoad: false }), | ||
], | ||
tracesSampleRate: 1, | ||
}); | ||
|
||
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing'); | ||
const browserTracing = client?.getIntegrationByName('BrowserTracing'); | ||
expect(browserTracing).toBeDefined(); | ||
|
||
// no active span means the settings were respected | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.