Skip to content

Commit 3a27533

Browse files
committed
fixup passing route to core
1 parent 3813216 commit 3a27533

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

packages/nextjs/src/config/wrappers/wrapperUtils.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,28 @@ import { DataFetchingFunction } from './types';
88
* @template T Types for `getInitialProps`, `getStaticProps`, and `getServerSideProps`
99
* @param origFunction The user's exported `getInitialProps`, `getStaticProps`, or `getServerSideProps` function
1010
* @param context The context object passed by nextjs to the function
11+
* @param route The route currently being served
1112
* @returns The result of calling the user's function
1213
*/
13-
export async function wrapperCore<T extends DataFetchingFunction>(options: {
14-
origFunction: T['fn'];
15-
context: T['context'];
16-
route: string;
17-
op: string;
18-
}): Promise<T['result']> {
19-
const { origFunction, context, route, op } = options;
20-
14+
export async function wrapperCore<T extends DataFetchingFunction>(
15+
origFunction: T['fn'],
16+
context: T['context'],
17+
route: string,
18+
): Promise<T['result']> {
2119
const transaction = getActiveTransaction();
2220

2321
if (transaction) {
22+
// Pull off any leading underscores we've added in the process of wrapping the function
23+
const wrappedFunctionName = origFunction.name.replace(/^_*/, '');
24+
2425
// TODO: Make sure that the given route matches the name of the active transaction (to prevent background data
2526
// fetching from switching the name to a completely other route)
2627
transaction.name = route;
2728
transaction.metadata.source = 'route';
2829

2930
// Capture the route, since pre-loading, revalidation, etc might mean that this span may happen during another
3031
// route's transaction
31-
const span = transaction.startChild({ op, data: { route } });
32+
const span = transaction.startChild({ op: 'nextjs.data', description: `${wrappedFunctionName} (${route})` });
3233

3334
// TODO: Can't figure out how to tell TS that the types are correlated - that a `GSPropsFunction` will only get passed
3435
// `GSPropsContext` and never, say, `GSSPContext`. That's what wrapping everything in objects and using the generic

0 commit comments

Comments
 (0)