Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/nuxt/src/server/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import type { SentryNuxtServerOptions } from '../common/types';
* @param options Configuration options for the SDK.
*/
export function init(options: SentryNuxtServerOptions): Client | undefined {
const sentryOptions = {
...options,
defaultIntegrations: getNuxtDefaultIntegrations(options),
};
const sentryOptions = { defaultIntegrations: getNuxtDefaultIntegrations(options), ...options };

applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'node']);

Expand Down
36 changes: 36 additions & 0 deletions packages/nuxt/test/client/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,41 @@ describe('Nuxt Client SDK', () => {
it('returns client from init', () => {
expect(init({})).not.toBeUndefined();
});

it('uses default integrations when not provided in options', () => {
init({ dsn: 'https://[email protected]/1337' });

expect(browserInit).toHaveBeenCalledTimes(1);
const callArgs = browserInit.mock.calls[0]?.[0];
expect(callArgs).toBeDefined();
expect(callArgs?.defaultIntegrations).toBeDefined();
expect(Array.isArray(callArgs?.defaultIntegrations)).toBe(true);
});

it('allows options.defaultIntegrations to override default integrations', () => {
const customIntegrations = [{ name: 'CustomIntegration' }];

init({
dsn: 'https://[email protected]/1337',
defaultIntegrations: customIntegrations as any,
});

expect(browserInit).toHaveBeenCalledTimes(1);
const callArgs = browserInit.mock.calls[0]?.[0];
expect(callArgs).toBeDefined();
expect(callArgs?.defaultIntegrations).toBe(customIntegrations);
});

it('allows options.defaultIntegrations to be set to false', () => {
init({
dsn: 'https://[email protected]/1337',
defaultIntegrations: false,
});

expect(browserInit).toHaveBeenCalledTimes(1);
const callArgs = browserInit.mock.calls[0]?.[0];
expect(callArgs).toBeDefined();
expect(callArgs?.defaultIntegrations).toBe(false);
});
});
});
36 changes: 36 additions & 0 deletions packages/nuxt/test/server/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,42 @@ describe('Nuxt Server SDK', () => {
expect(init({})).not.toBeUndefined();
});

it('uses default integrations when not provided in options', () => {
init({ dsn: 'https://[email protected]/1337' });

expect(nodeInit).toHaveBeenCalledTimes(1);
const callArgs = nodeInit.mock.calls[0]?.[0];
expect(callArgs).toBeDefined();
expect(callArgs?.defaultIntegrations).toBeDefined();
expect(Array.isArray(callArgs?.defaultIntegrations)).toBe(true);
});

it('allows options.defaultIntegrations to override default integrations', () => {
const customIntegrations = [{ name: 'CustomIntegration' }];

init({
dsn: 'https://[email protected]/1337',
defaultIntegrations: customIntegrations as any,
});

expect(nodeInit).toHaveBeenCalledTimes(1);
const callArgs = nodeInit.mock.calls[0]?.[0];
expect(callArgs).toBeDefined();
expect(callArgs?.defaultIntegrations).toBe(customIntegrations);
});

it('allows options.defaultIntegrations to be set to false', () => {
init({
dsn: 'https://[email protected]/1337',
defaultIntegrations: false,
});

expect(nodeInit).toHaveBeenCalledTimes(1);
const callArgs = nodeInit.mock.calls[0]?.[0];
expect(callArgs).toBeDefined();
expect(callArgs?.defaultIntegrations).toBe(false);
});

describe('lowQualityTransactionsFilter', () => {
const options = { debug: false };
const filter = lowQualityTransactionsFilter(options);
Expand Down
Loading