Skip to content

Commit d9e95c6

Browse files
authored
Merge pull request #11613 from getsentry/prepare-release/8.0.0-beta.1
meta(changelog): Update changelog for v8.0.0-beta.1
2 parents 424914c + efa3b4f commit d9e95c6

File tree

4 files changed

+67
-19
lines changed

4 files changed

+67
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7-
## 8.0.0-beta.0
7+
## 8.0.0-beta.1
88

99
This is the first beta release of Sentry JavaScript SDK v8. With this release, there are no more planned breaking
1010
changes for the v8 cycle.
@@ -144,6 +144,10 @@ disabled.
144144
- ref(feedback): Configure font size (#11437)
145145
- ref(feedback): Refactor Feedback types into @sentry/types and reduce the exported surface area (#11355)
146146

147+
## 8.0.0-beta.0
148+
149+
This release failed to publish correctly. Use 8.0.0-beta.1 instead.
150+
147151
## 8.0.0-alpha.9
148152

149153
This is the eighth alpha release of Sentry JavaScript SDK v8, which includes a variety of breaking changes.

dev-packages/browser-integration-tests/suites/integrations/lazyLoad/validIntegration/test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import { expect } from '@playwright/test';
2+
import { SDK_VERSION } from '@sentry/browser';
23

34
import { sentryTest } from '../../../../utils/fixtures';
45

56
sentryTest('it allows to lazy load an integration', async ({ getLocalTestUrl, page }) => {
67
const url = await getLocalTestUrl({ testDir: __dirname });
78

9+
await page.route(`https://browser.sentry-cdn.com/${SDK_VERSION}/httpclient.min.js`, route => {
10+
return route.fulfill({
11+
status: 200,
12+
contentType: 'application/javascript;',
13+
body: "window.Sentry.httpClientIntegration = () => ({ name: 'HttpClient' })",
14+
});
15+
});
16+
817
await page.goto(url);
918

1019
const hasIntegration = await page.evaluate('!!window.Sentry.getClient()?.getIntegrationByName("HttpClient")');

dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/navigation/test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,28 @@ sentryTest('should create a new trace on each navigation', async ({ getLocalTest
2424
expect(navigation2TraceId).toMatch(/^[0-9a-f]{32}$/);
2525
expect(navigation1TraceId).not.toEqual(navigation2TraceId);
2626
});
27+
28+
sentryTest('error after navigation has navigation traceId', async ({ getLocalTestPath, page }) => {
29+
if (shouldSkipTracingTest()) {
30+
sentryTest.skip();
31+
}
32+
33+
const url = await getLocalTestPath({ testDir: __dirname });
34+
35+
// ensure navigation transaction is finished
36+
await getFirstSentryEnvelopeRequest<Event>(page, url);
37+
38+
const navigationEvent1 = await getFirstSentryEnvelopeRequest<Event>(page, `${url}#foo`);
39+
expect(navigationEvent1.contexts?.trace?.op).toBe('navigation');
40+
41+
const navigationTraceId = navigationEvent1.contexts?.trace?.trace_id;
42+
expect(navigationTraceId).toMatch(/^[0-9a-f]{32}$/);
43+
44+
const [, errorEvent] = await Promise.all([
45+
page.locator('#errorBtn').click(),
46+
getFirstSentryEnvelopeRequest<Event>(page),
47+
]);
48+
49+
const errorTraceId = errorEvent.contexts?.trace?.trace_id;
50+
expect(errorTraceId).toBe(navigationTraceId);
51+
});

packages/nextjs/src/common/wrapRouteHandlerWithSentry.ts

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getRootSpan,
99
handleCallbackErrors,
1010
setHttpStatus,
11+
spanToJSON,
1112
startSpan,
1213
} from '@sentry/core';
1314
import type { Span } from '@sentry/types';
@@ -24,32 +25,41 @@ function startOrUpdateSpan(spanName: string, cb: (rootSpan: Span) => Promise<Res
2425
const activeSpan = getActiveSpan();
2526
const rootSpan = activeSpan && getRootSpan(activeSpan);
2627

27-
if (rootSpan) {
28-
rootSpan.updateName(spanName);
29-
rootSpan.setAttributes({
30-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
31-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server',
32-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs',
33-
});
28+
// We have different possible scenarios here:
29+
// 1. If we have no root span, we just create a new span
30+
// 2. We have a root span that that we want to update here
31+
// 3. We have a root span that was already updated (e.g. if this is a nested call)
3432

35-
return cb(rootSpan);
36-
} else {
33+
const attributes = {
34+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
35+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server',
36+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs',
37+
} as const;
38+
39+
if (!rootSpan) {
3740
return startSpan(
3841
{
39-
op: 'http.server',
4042
name: spanName,
4143
forceTransaction: true,
42-
attributes: {
43-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route',
44-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server',
45-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs',
46-
},
47-
},
48-
(span: Span) => {
49-
return cb(span);
44+
attributes,
5045
},
46+
cb,
5147
);
5248
}
49+
50+
// If `op` is set, we assume this was already processed before
51+
// Probably this is a nested call, no need to update anything anymore
52+
// OR, if we don't have next.span_type, we don't know where this comes from and don't want to mess with it
53+
const existingAttributes = spanToJSON(rootSpan).data || {};
54+
if (existingAttributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !existingAttributes['next.span_type']) {
55+
return cb(rootSpan);
56+
}
57+
58+
// Finally, we want to update the root span, as the ones generated by next are often not good enough for us
59+
rootSpan.updateName(spanName);
60+
rootSpan.setAttributes(attributes);
61+
62+
return cb(rootSpan);
5363
}
5464

5565
/**

0 commit comments

Comments
 (0)