Skip to content

Commit

Permalink
Merge branch 'develop' into sig/nuxt-simplified-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
s1gr1d authored Sep 13, 2024
2 parents cfdf1dd + 1664dc7 commit 48eb052
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ sentryTest('should set extras from multiple consecutive calls', async ({ getLoca
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);

expect(eventData.message).toBe('consecutive_calls');
expect(eventData.extra).toMatchObject({ extra: [], Infinity: 2, null: null, obj: { foo: ['bar', 'baz', 1] } });
expect(eventData.extra).toMatchObject({
extra: [],
Infinity: 2,
null: '[Infinity]',
obj: { foo: ['bar', 'baz', 1] },
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Sentry.init({
dsn: useRuntimeConfig().public.sentry.dsn,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1.0,
trackComponents: true,
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { expect, test } from '@nuxt/test-utils/playwright';
import { waitForTransaction } from '@sentry-internal/test-utils';
import type { Span } from '@sentry/nuxt';

test('sends a pageload root span with a parameterized URL', async ({ page }) => {
const transactionPromise = waitForTransaction('nuxt-3', async transactionEvent => {
return transactionEvent.transaction === '/test-param/:param()';
});

await page.goto(`/test-param/1234`);

const rootSpan = await transactionPromise;

expect(rootSpan).toMatchObject({
contexts: {
trace: {
data: {
'sentry.source': 'route',
'sentry.origin': 'auto.pageload.vue',
'sentry.op': 'pageload',
'params.param': '1234',
},
op: 'pageload',
origin: 'auto.pageload.vue',
},
},
transaction: '/test-param/:param()',
transaction_info: {
source: 'route',
},
});
});

test('sends component tracking spans when `trackComponents` is enabled', async ({ page }) => {
const transactionPromise = waitForTransaction('nuxt-3', async transactionEvent => {
return transactionEvent.transaction === '/client-error';
});

await page.goto(`/client-error`);

const rootSpan = await transactionPromise;
const errorButtonSpan = rootSpan.spans.find((span: Span) => span.description === 'Vue <ErrorButton>');

const expected = {
data: { 'sentry.origin': 'auto.ui.vue', 'sentry.op': 'ui.vue.mount' },
description: 'Vue <ErrorButton>',
op: 'ui.vue.mount',
parent_span_id: expect.any(String),
span_id: expect.any(String),
start_timestamp: expect.any(Number),
timestamp: expect.any(Number),
trace_id: expect.any(String),
origin: 'auto.ui.vue',
};

expect(errorButtonSpan).toMatchObject(expected);
});
3 changes: 2 additions & 1 deletion packages/nuxt/src/index.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Integration, Options, StackParser } from '@sentry/types';
import type { SentryNuxtClientOptions } from './common/types';
import type * as clientSdk from './index.client';
import type * as serverSdk from './index.server';

Expand All @@ -8,7 +9,7 @@ export * from './index.client';
export * from './index.server';

// re-export colliding types
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): void;
export declare function init(options: Options | SentryNuxtClientOptions | serverSdk.NodeOptions): void;
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
export declare const getDefaultIntegrations: (options: Options) => Integration[];
Expand Down
7 changes: 4 additions & 3 deletions packages/utils/src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ function visit(
// Get the simple cases out of the way first
if (
value == null || // this matches null and undefined -> eqeq not eqeqeq
(['number', 'boolean', 'string'].includes(typeof value) && !Number.isNaN(value))
['boolean', 'string'].includes(typeof value) ||
(typeof value === 'number' && Number.isFinite(value))
) {
return value as Primitive;
}
Expand Down Expand Up @@ -220,8 +221,8 @@ function stringifyValue(
return '[SyntheticEvent]';
}

if (typeof value === 'number' && value !== value) {
return '[NaN]';
if (typeof value === 'number' && !Number.isFinite(value)) {
return `[${value}]`;
}

if (typeof value === 'function') {
Expand Down
2 changes: 2 additions & 0 deletions packages/utils/test/normalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ describe('normalize()', () => {
describe('changes unserializeable/global values/classes to their respective string representations', () => {
test('primitive values', () => {
expect(normalize(NaN)).toEqual('[NaN]');
expect(normalize(Infinity)).toEqual('[Infinity]');
expect(normalize(-Infinity)).toEqual('[-Infinity]');
expect(normalize(Symbol('dogs'))).toEqual('[Symbol(dogs)]');
expect(normalize(BigInt(1121201212312012))).toEqual('[BigInt: 1121201212312012]');
});
Expand Down

0 comments on commit 48eb052

Please sign in to comment.