Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/nuxt/src/server/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import type { SentryNuxtServerOptions } from '../common/types';
export function init(options: SentryNuxtServerOptions): Client | undefined {
const sentryOptions = {
environment: !isCjs() && import.meta.dev ? DEV_ENVIRONMENT : DEFAULT_ENVIRONMENT,
...options,
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