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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ test('Sends a transaction for a request to app router', async ({ page }) => {
headers: expect.objectContaining({
'user-agent': expect.any(String),
}),
url: expect.stringContaining('/server-component/parameter/1337/42'),
});

// The transaction should not contain any spans with the same name as the transaction
Expand Down
26 changes: 0 additions & 26 deletions packages/nextjs/src/common/wrapGenerationFunctionWithSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
captureException,
getActiveSpan,
getCapturedScopesOnSpan,
getClient,
getRootSpan,
handleCallbackErrors,
propagationContextFromHeaders,
Expand All @@ -13,7 +12,6 @@ import {
setCapturedScopesOnSpan,
SPAN_STATUS_ERROR,
SPAN_STATUS_OK,
spanToJSON,
startSpanManual,
winterCGHeadersToDict,
withIsolationScope,
Expand All @@ -23,8 +21,6 @@ import type { GenerationFunctionContext } from '../common/types';
import { isNotFoundNavigationError, isRedirectNavigationError } from './nextNavigationErrorUtils';
import { TRANSACTION_ATTR_SENTRY_TRACE_BACKFILL } from './span-attributes-with-logic-attached';
import { commonObjectToIsolationScope, commonObjectToPropagationContext } from './utils/tracingUtils';
import { getSanitizedRequestUrl } from './utils/urls';
import { maybeExtractSynchronousParamsAndSearchParams } from './utils/wrapperUtils';
/**
* Wraps a generation function (e.g. generateMetadata) with Sentry error and performance instrumentation.
*/
Expand All @@ -46,43 +42,23 @@ export function wrapGenerationFunctionWithSentry<F extends (...args: any[]) => a
}

const isolationScope = commonObjectToIsolationScope(headers);
let pathname = undefined as string | undefined;

const activeSpan = getActiveSpan();
if (activeSpan) {
const rootSpan = getRootSpan(activeSpan);
const { scope } = getCapturedScopesOnSpan(rootSpan);
setCapturedScopesOnSpan(rootSpan, scope ?? new Scope(), isolationScope);

const spanData = spanToJSON(rootSpan);

if (spanData.data && 'http.target' in spanData.data) {
pathname = spanData.data['http.target'] as string;
}
}

const headersDict = headers ? winterCGHeadersToDict(headers) : undefined;

let data: Record<string, unknown> | undefined = undefined;
if (getClient()?.getOptions().sendDefaultPii) {
const props: unknown = args[0];
const { params, searchParams } = maybeExtractSynchronousParamsAndSearchParams(props);
data = { params, searchParams };
}

return withIsolationScope(isolationScope, () => {
return withScope(scope => {
scope.setTransactionName(`${componentType}.${generationFunctionIdentifier} (${componentRoute})`);

isolationScope.setSDKProcessingMetadata({
normalizedRequest: {
headers: headersDict,
url: getSanitizedRequestUrl(
componentRoute,
data?.params as Record<string, string> | undefined,
headersDict,
pathname,
),
} satisfies RequestEventData,
});

Expand All @@ -106,8 +82,6 @@ export function wrapGenerationFunctionWithSentry<F extends (...args: any[]) => a

scope.setPropagationContext(propagationContext);

scope.setExtra('route_data', data);

return startSpanManual(
{
op: 'function.nextjs',
Expand Down
20 changes: 0 additions & 20 deletions packages/nextjs/src/common/wrapServerComponentWithSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
captureException,
getActiveSpan,
getCapturedScopesOnSpan,
getClient,
getRootSpan,
handleCallbackErrors,
propagationContextFromHeaders,
Expand All @@ -13,7 +12,6 @@ import {
setCapturedScopesOnSpan,
SPAN_STATUS_ERROR,
SPAN_STATUS_OK,
spanToJSON,
startSpanManual,
vercelWaitUntil,
winterCGHeadersToDict,
Expand All @@ -25,8 +23,6 @@ import type { ServerComponentContext } from '../common/types';
import { flushSafelyWithTimeout } from '../common/utils/responseEnd';
import { TRANSACTION_ATTR_SENTRY_TRACE_BACKFILL } from './span-attributes-with-logic-attached';
import { commonObjectToIsolationScope, commonObjectToPropagationContext } from './utils/tracingUtils';
import { getSanitizedRequestUrl } from './utils/urls';
import { maybeExtractSynchronousParamsAndSearchParams } from './utils/wrapperUtils';

/**
* Wraps an `app` directory server component with Sentry error instrumentation.
Expand All @@ -45,34 +41,18 @@ export function wrapServerComponentWithSentry<F extends (...args: any[]) => any>
const requestTraceId = getActiveSpan()?.spanContext().traceId;
const isolationScope = commonObjectToIsolationScope(context.headers);

let pathname = undefined as string | undefined;
const activeSpan = getActiveSpan();
if (activeSpan) {
const rootSpan = getRootSpan(activeSpan);
const { scope } = getCapturedScopesOnSpan(rootSpan);
setCapturedScopesOnSpan(rootSpan, scope ?? new Scope(), isolationScope);

const spanData = spanToJSON(rootSpan);

if (spanData.data && 'http.target' in spanData.data) {
pathname = spanData.data['http.target']?.toString();
}
}

const headersDict = context.headers ? winterCGHeadersToDict(context.headers) : undefined;

let params: Record<string, string> | undefined = undefined;

if (getClient()?.getOptions().sendDefaultPii) {
const props: unknown = args[0];
const { params: paramsFromProps } = maybeExtractSynchronousParamsAndSearchParams(props);
params = paramsFromProps;
}

isolationScope.setSDKProcessingMetadata({
normalizedRequest: {
headers: headersDict,
url: getSanitizedRequestUrl(componentRoute, params, headersDict, pathname),
} satisfies RequestEventData,
});

Expand Down