Skip to content

Commit 394b71b

Browse files
committed
Merge branch 'develop' into abhi-console-logger-integration
2 parents 696ec58 + 6501d52 commit 394b71b

File tree

20 files changed

+662
-218
lines changed

20 files changed

+662
-218
lines changed

.craft.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,12 @@ targets:
193193
onlyIfPresent: /^sentry-gatsby-\d.*\.tgz$/
194194
'npm:@sentry/google-cloud-serverless':
195195
onlyIfPresent: /^sentry-google-cloud-serverless-\d.*\.tgz$/
196+
'npm:@sentry/nestjs':
197+
onlyIfPresent: /^sentry-nestjs-\d.*\.tgz$/
196198
'npm:@sentry/nextjs':
197199
onlyIfPresent: /^sentry-nextjs-\d.*\.tgz$/
200+
'npm:@sentry/nuxt':
201+
onlyIfPresent: /^sentry-nuxt-\d.*\.tgz$/
198202
'npm:@sentry/node':
199203
onlyIfPresent: /^sentry-node-\d.*\.tgz$/
200204
'npm:@sentry/react':
@@ -211,6 +215,8 @@ targets:
211215
onlyIfPresent: /^sentry-svelte-\d.*\.tgz$/
212216
'npm:@sentry/sveltekit':
213217
onlyIfPresent: /^sentry-sveltekit-\d.*\.tgz$/
218+
'npm:@sentry/tanstackstart-react':
219+
onlyIfPresent: /^sentry-tanstackstart-react-\d.*\.tgz$/
214220
'npm:@sentry/vercel-edge':
215221
onlyIfPresent: /^sentry-vercel-edge-\d.*\.tgz$/
216222
'npm:@sentry/vue':

.size-limit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module.exports = [
7979
path: 'packages/browser/build/npm/esm/index.js',
8080
import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'replayCanvasIntegration'),
8181
gzip: true,
82-
limit: '80.5 KB',
82+
limit: '81 KB',
8383
},
8484
{
8585
name: '@sentry/browser (incl. Tracing, Replay, Feedback)',
@@ -210,7 +210,7 @@ module.exports = [
210210
import: createImport('init'),
211211
ignore: ['next/router', 'next/constants'],
212212
gzip: true,
213-
limit: '41 KB',
213+
limit: '42 KB',
214214
},
215215
// SvelteKit SDK (ESM)
216216
{

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/previous-trace-links/default/test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ sentryTest("navigation spans link back to previous trace's root span", async ({
4949
},
5050
]);
5151

52+
expect(navigation1TraceContext?.data).toMatchObject({
53+
'sentry.previous_trace': `${pageloadTraceId}-${pageloadTraceContext?.span_id}-1`,
54+
});
55+
5256
expect(navigation2TraceContext?.links).toEqual([
5357
{
5458
trace_id: navigation1TraceId,
@@ -60,6 +64,10 @@ sentryTest("navigation spans link back to previous trace's root span", async ({
6064
},
6165
]);
6266

67+
expect(navigation2TraceContext?.data).toMatchObject({
68+
'sentry.previous_trace': `${navigation1TraceId}-${navigation1TraceContext?.span_id}-1`,
69+
});
70+
6371
expect(pageloadTraceId).not.toEqual(navigation1TraceId);
6472
expect(navigation1TraceId).not.toEqual(navigation2TraceId);
6573
expect(pageloadTraceId).not.toEqual(navigation2TraceId);

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/previous-trace-links/negatively-sampled/test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ sentryTest('includes a span link to a previously negatively sampled span', async
3434
},
3535
]);
3636

37+
expect(navigationTraceContext?.data).toMatchObject({
38+
'sentry.previous_trace': expect.stringMatching(/[a-f0-9]{32}-[a-f0-9]{16}-0/),
39+
});
40+
3741
expect(navigationTraceContext?.trace_id).not.toEqual(navigationTraceContext?.links![0].trace_id);
3842
});
3943
});

dev-packages/e2e-tests/test-applications/nextjs-turbo/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
/// <reference types="next/navigation-types/compat/navigation" />
44

55
// NOTE: This file should not be edited
6-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
6+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

dev-packages/e2e-tests/test-applications/nextjs-turbo/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ const nextConfig = {
99

1010
module.exports = withSentryConfig(nextConfig, {
1111
silent: true,
12+
release: {
13+
name: 'foobar123',
14+
},
1215
});

dev-packages/e2e-tests/test-applications/nextjs-turbo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@types/node": "^18.19.1",
1818
"@types/react": "18.0.26",
1919
"@types/react-dom": "18.0.9",
20-
"next": "15.3.0-canary.8",
20+
"next": "15.3.0-canary.26",
2121
"react": "rc",
2222
"react-dom": "rc",
2323
"typescript": "~5.0.0"

dev-packages/e2e-tests/test-applications/nextjs-turbo/tests/pages-router/client-trace-propagation.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,14 @@ test('Should propagate traces from server to client in pages router', async ({ p
2828

2929
expect(serverTransaction.contexts?.trace?.trace_id).toBeDefined();
3030
expect(pageloadTransaction.contexts?.trace?.trace_id).toBe(serverTransaction.contexts?.trace?.trace_id);
31+
32+
await test.step('release was successfully injected on the serverside', () => {
33+
// Release as defined in next.config.js
34+
expect(serverTransaction.release).toBe('foobar123');
35+
});
36+
37+
await test.step('release was successfully injected on the clientside', () => {
38+
// Release as defined in next.config.js
39+
expect(pageloadTransaction.release).toBe('foobar123');
40+
});
3141
});

packages/browser-utils/src/metrics/browserMetrics.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,11 @@ export function _addMeasureSpans(
460460
}
461461
}
462462

463-
/** Instrument navigation entries */
464-
function _addNavigationSpans(span: Span, entry: PerformanceNavigationTiming, timeOrigin: number): void {
463+
/**
464+
* Instrument navigation entries
465+
* exported only for tests
466+
*/
467+
export function _addNavigationSpans(span: Span, entry: PerformanceNavigationTiming, timeOrigin: number): void {
465468
(['unloadEvent', 'redirect', 'domContentLoadedEvent', 'loadEvent', 'connect'] as const).forEach(event => {
466469
_addPerformanceNavigationTiming(span, entry, event, timeOrigin);
467470
});
@@ -511,6 +514,7 @@ function _addPerformanceNavigationTiming(
511514
name: entry.name,
512515
attributes: {
513516
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.browser.metrics',
517+
...(event === 'redirect' && entry.redirectCount != null ? { 'http.redirect_count': entry.redirectCount } : {}),
514518
},
515519
});
516520
}

packages/browser-utils/test/browser/browserMetrics.test.ts

Lines changed: 183 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import type { Span } from '@sentry/core';
1212
import { describe, beforeEach, it, expect, beforeAll, afterAll } from 'vitest';
1313

14-
import { _addMeasureSpans, _addResourceSpans } from '../../src/metrics/browserMetrics';
14+
import { _addMeasureSpans, _addNavigationSpans, _addResourceSpans } from '../../src/metrics/browserMetrics';
1515
import { WINDOW } from '../../src/types';
1616
import { TestClient, getDefaultClientOptions } from '../utils/TestClient';
1717

@@ -416,6 +416,188 @@ describe('_addResourceSpans', () => {
416416
);
417417
});
418418

419+
describe('_addNavigationSpans', () => {
420+
const pageloadSpan = new SentrySpan({ op: 'pageload', name: '/', sampled: true });
421+
422+
beforeAll(() => {
423+
setGlobalLocation(mockWindowLocation);
424+
});
425+
426+
afterAll(() => {
427+
resetGlobalLocation();
428+
});
429+
430+
beforeEach(() => {
431+
getCurrentScope().clear();
432+
getIsolationScope().clear();
433+
434+
const client = new TestClient(
435+
getDefaultClientOptions({
436+
tracesSampleRate: 1,
437+
}),
438+
);
439+
setCurrentClient(client);
440+
client.init();
441+
});
442+
443+
it('adds navigation spans based on the navigation performance entry', () => {
444+
// entry taken from a real entry via browser dev tools
445+
const entry: PerformanceNavigationTiming = {
446+
name: 'https://santry.com/test',
447+
entryType: 'navigation',
448+
startTime: 0,
449+
duration: 546.1000000014901,
450+
initiatorType: 'navigation',
451+
nextHopProtocol: 'h2',
452+
workerStart: 0,
453+
redirectStart: 7.5,
454+
redirectEnd: 20.5,
455+
redirectCount: 2,
456+
fetchStart: 4.9000000059604645,
457+
domainLookupStart: 4.9000000059604645,
458+
domainLookupEnd: 4.9000000059604645,
459+
connectStart: 4.9000000059604645,
460+
secureConnectionStart: 4.9000000059604645,
461+
connectEnd: 4.9000000059604645,
462+
requestStart: 7.9000000059604645,
463+
responseStart: 396.80000000447035,
464+
responseEnd: 416.40000000596046,
465+
transferSize: 14726,
466+
encodedBodySize: 14426,
467+
decodedBodySize: 67232,
468+
responseStatus: 200,
469+
serverTiming: [],
470+
unloadEventStart: 0,
471+
unloadEventEnd: 0,
472+
domInteractive: 473.20000000298023,
473+
domContentLoadedEventStart: 480.1000000014901,
474+
domContentLoadedEventEnd: 480.30000000447035,
475+
domComplete: 546,
476+
loadEventStart: 546,
477+
loadEventEnd: 546.1000000014901,
478+
type: 'navigate',
479+
activationStart: 0,
480+
toJSON: () => ({}),
481+
};
482+
const spans: Span[] = [];
483+
484+
getClient()?.on('spanEnd', span => {
485+
spans.push(span);
486+
});
487+
488+
_addNavigationSpans(pageloadSpan, entry, 999);
489+
490+
const trace_id = pageloadSpan.spanContext().traceId;
491+
const parent_span_id = pageloadSpan.spanContext().spanId;
492+
493+
expect(spans).toHaveLength(9);
494+
expect(spans.map(spanToJSON)).toEqual(
495+
expect.arrayContaining([
496+
expect.objectContaining({
497+
data: {
498+
'sentry.op': 'browser.domContentLoadedEvent',
499+
'sentry.origin': 'auto.ui.browser.metrics',
500+
},
501+
description: 'https://santry.com/test',
502+
op: 'browser.domContentLoadedEvent',
503+
origin: 'auto.ui.browser.metrics',
504+
parent_span_id,
505+
trace_id,
506+
}),
507+
expect.objectContaining({
508+
data: {
509+
'sentry.op': 'browser.loadEvent',
510+
'sentry.origin': 'auto.ui.browser.metrics',
511+
},
512+
description: 'https://santry.com/test',
513+
op: 'browser.loadEvent',
514+
origin: 'auto.ui.browser.metrics',
515+
parent_span_id,
516+
trace_id,
517+
}),
518+
expect.objectContaining({
519+
data: {
520+
'sentry.op': 'browser.connect',
521+
'sentry.origin': 'auto.ui.browser.metrics',
522+
},
523+
description: 'https://santry.com/test',
524+
op: 'browser.connect',
525+
origin: 'auto.ui.browser.metrics',
526+
parent_span_id,
527+
trace_id,
528+
}),
529+
expect.objectContaining({
530+
data: {
531+
'sentry.op': 'browser.TLS/SSL',
532+
'sentry.origin': 'auto.ui.browser.metrics',
533+
},
534+
description: 'https://santry.com/test',
535+
op: 'browser.TLS/SSL',
536+
origin: 'auto.ui.browser.metrics',
537+
parent_span_id,
538+
trace_id,
539+
}),
540+
expect.objectContaining({
541+
data: {
542+
'sentry.op': 'browser.cache',
543+
'sentry.origin': 'auto.ui.browser.metrics',
544+
},
545+
description: 'https://santry.com/test',
546+
op: 'browser.cache',
547+
origin: 'auto.ui.browser.metrics',
548+
parent_span_id,
549+
trace_id,
550+
}),
551+
expect.objectContaining({
552+
data: {
553+
'sentry.op': 'browser.DNS',
554+
'sentry.origin': 'auto.ui.browser.metrics',
555+
},
556+
description: 'https://santry.com/test',
557+
op: 'browser.DNS',
558+
origin: 'auto.ui.browser.metrics',
559+
parent_span_id,
560+
trace_id,
561+
}),
562+
expect.objectContaining({
563+
data: {
564+
'sentry.op': 'browser.request',
565+
'sentry.origin': 'auto.ui.browser.metrics',
566+
},
567+
description: 'https://santry.com/test',
568+
op: 'browser.request',
569+
origin: 'auto.ui.browser.metrics',
570+
parent_span_id,
571+
trace_id,
572+
}),
573+
expect.objectContaining({
574+
data: {
575+
'sentry.op': 'browser.response',
576+
'sentry.origin': 'auto.ui.browser.metrics',
577+
},
578+
description: 'https://santry.com/test',
579+
op: 'browser.response',
580+
origin: 'auto.ui.browser.metrics',
581+
parent_span_id,
582+
trace_id,
583+
}),
584+
expect.objectContaining({
585+
data: {
586+
'http.redirect_count': 2,
587+
'sentry.op': 'browser.redirect',
588+
'sentry.origin': 'auto.ui.browser.metrics',
589+
},
590+
description: 'https://santry.com/test',
591+
op: 'browser.redirect',
592+
origin: 'auto.ui.browser.metrics',
593+
parent_span_id,
594+
trace_id,
595+
}),
596+
]),
597+
);
598+
});
599+
});
600+
419601
const setGlobalLocation = (location: Location) => {
420602
// @ts-expect-error need to delete this in order to set to new value
421603
delete WINDOW.location;

0 commit comments

Comments
 (0)