Skip to content

Commit af2f5cb

Browse files
author
Luca Forstner
authored
ref(nextjs): Move pages router instrumentation into separate folder (#13890)
Simply moves all runtime agnostic instrumentation related to the pages router into its own folder.
1 parent a9a22e8 commit af2f5cb

14 files changed

+32
-32
lines changed

packages/nextjs/src/client/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { applyTunnelRouteOption } from './tunnelRoute';
1313

1414
export * from '@sentry/react';
1515

16-
export { captureUnderscoreErrorException } from '../common/_error';
16+
export { captureUnderscoreErrorException } from '../common/pages-router-instrumentation/_error';
1717

1818
const globalWithInjectedValues = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
1919
__rewriteFramesAssetPrefixPath__: string;

packages/nextjs/src/common/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
export { wrapGetStaticPropsWithSentry } from './wrapGetStaticPropsWithSentry';
2-
export { wrapGetInitialPropsWithSentry } from './wrapGetInitialPropsWithSentry';
3-
export { wrapAppGetInitialPropsWithSentry } from './wrapAppGetInitialPropsWithSentry';
4-
export { wrapDocumentGetInitialPropsWithSentry } from './wrapDocumentGetInitialPropsWithSentry';
5-
export { wrapErrorGetInitialPropsWithSentry } from './wrapErrorGetInitialPropsWithSentry';
6-
export { wrapGetServerSidePropsWithSentry } from './wrapGetServerSidePropsWithSentry';
1+
export { wrapGetStaticPropsWithSentry } from './pages-router-instrumentation/wrapGetStaticPropsWithSentry';
2+
export { wrapGetInitialPropsWithSentry } from './pages-router-instrumentation/wrapGetInitialPropsWithSentry';
3+
export { wrapAppGetInitialPropsWithSentry } from './pages-router-instrumentation/wrapAppGetInitialPropsWithSentry';
4+
export { wrapDocumentGetInitialPropsWithSentry } from './pages-router-instrumentation/wrapDocumentGetInitialPropsWithSentry';
5+
export { wrapErrorGetInitialPropsWithSentry } from './pages-router-instrumentation/wrapErrorGetInitialPropsWithSentry';
6+
export { wrapGetServerSidePropsWithSentry } from './pages-router-instrumentation/wrapGetServerSidePropsWithSentry';
77
export { wrapServerComponentWithSentry } from './wrapServerComponentWithSentry';
88
export { wrapRouteHandlerWithSentry } from './wrapRouteHandlerWithSentry';
9-
export { wrapApiHandlerWithSentryVercelCrons } from './wrapApiHandlerWithSentryVercelCrons';
9+
export { wrapApiHandlerWithSentryVercelCrons } from './pages-router-instrumentation/wrapApiHandlerWithSentryVercelCrons';
1010
export { wrapMiddlewareWithSentry } from './wrapMiddlewareWithSentry';
11-
export { wrapPageComponentWithSentry } from './wrapPageComponentWithSentry';
11+
export { wrapPageComponentWithSentry } from './pages-router-instrumentation/wrapPageComponentWithSentry';
1212
export { wrapGenerationFunctionWithSentry } from './wrapGenerationFunctionWithSentry';
1313
export { withServerActionInstrumentation } from './withServerActionInstrumentation';
1414
// eslint-disable-next-line deprecation/deprecation

packages/nextjs/src/common/_error.ts renamed to packages/nextjs/src/common/pages-router-instrumentation/_error.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { captureException, withScope } from '@sentry/core';
22
import type { NextPageContext } from 'next';
3-
import { flushSafelyWithTimeout } from './utils/responseEnd';
4-
import { vercelWaitUntil } from './utils/vercelWaitUntil';
3+
import { flushSafelyWithTimeout } from '../utils/responseEnd';
4+
import { vercelWaitUntil } from '../utils/vercelWaitUntil';
55

66
type ContextOrProps = {
77
req?: NextPageContext['req'];

packages/nextjs/src/common/wrapApiHandlerWithSentry.ts renamed to packages/nextjs/src/common/pages-router-instrumentation/wrapApiHandlerWithSentry.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import {
99
import { consoleSandbox, isString, logger, objectify } from '@sentry/utils';
1010

1111
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
12-
import type { AugmentedNextApiRequest, AugmentedNextApiResponse, NextApiHandler } from './types';
13-
import { flushSafelyWithTimeout } from './utils/responseEnd';
14-
import { escapeNextjsTracing } from './utils/tracingUtils';
15-
import { vercelWaitUntil } from './utils/vercelWaitUntil';
12+
import type { AugmentedNextApiRequest, AugmentedNextApiResponse, NextApiHandler } from '../types';
13+
import { flushSafelyWithTimeout } from '../utils/responseEnd';
14+
import { escapeNextjsTracing } from '../utils/tracingUtils';
15+
import { vercelWaitUntil } from '../utils/vercelWaitUntil';
1616

1717
/**
1818
* Wrap the given API route handler for tracing and error capturing. Thin wrapper around `withSentry`, which only

packages/nextjs/src/common/wrapApiHandlerWithSentryVercelCrons.ts renamed to packages/nextjs/src/common/pages-router-instrumentation/wrapApiHandlerWithSentryVercelCrons.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { captureCheckIn } from '@sentry/core';
22
import type { NextApiRequest } from 'next';
33

4-
import type { VercelCronsConfig } from './types';
4+
import type { VercelCronsConfig } from '../types';
55

66
type EdgeRequest = {
77
nextUrl: URL;

packages/nextjs/src/common/wrapAppGetInitialPropsWithSentry.ts renamed to packages/nextjs/src/common/pages-router-instrumentation/wrapAppGetInitialPropsWithSentry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type App from 'next/app';
22

3-
import { isBuild } from './utils/isBuild';
4-
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from './utils/wrapperUtils';
3+
import { isBuild } from '../utils/isBuild';
4+
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';
55

66
type AppGetInitialProps = (typeof App)['getInitialProps'];
77

packages/nextjs/src/common/wrapDocumentGetInitialPropsWithSentry.ts renamed to packages/nextjs/src/common/pages-router-instrumentation/wrapDocumentGetInitialPropsWithSentry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type Document from 'next/document';
22

3-
import { isBuild } from './utils/isBuild';
4-
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from './utils/wrapperUtils';
3+
import { isBuild } from '../utils/isBuild';
4+
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';
55

66
type DocumentGetInitialProps = typeof Document.getInitialProps;
77

packages/nextjs/src/common/wrapErrorGetInitialPropsWithSentry.ts renamed to packages/nextjs/src/common/pages-router-instrumentation/wrapErrorGetInitialPropsWithSentry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { NextPageContext } from 'next';
22
import type { ErrorProps } from 'next/error';
33

4-
import { isBuild } from './utils/isBuild';
5-
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from './utils/wrapperUtils';
4+
import { isBuild } from '../utils/isBuild';
5+
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';
66

77
type ErrorGetInitialProps = (context: NextPageContext) => Promise<ErrorProps>;
88

packages/nextjs/src/common/wrapGetInitialPropsWithSentry.ts renamed to packages/nextjs/src/common/pages-router-instrumentation/wrapGetInitialPropsWithSentry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { NextPage } from 'next';
22

3-
import { isBuild } from './utils/isBuild';
4-
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from './utils/wrapperUtils';
3+
import { isBuild } from '../utils/isBuild';
4+
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';
55

66
type GetInitialProps = Required<NextPage>['getInitialProps'];
77

packages/nextjs/src/common/wrapGetServerSidePropsWithSentry.ts renamed to packages/nextjs/src/common/pages-router-instrumentation/wrapGetServerSidePropsWithSentry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { GetServerSideProps } from 'next';
22

3-
import { isBuild } from './utils/isBuild';
4-
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from './utils/wrapperUtils';
3+
import { isBuild } from '../utils/isBuild';
4+
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';
55

66
/**
77
* Create a wrapped version of the user's exported `getServerSideProps` function

packages/nextjs/src/common/wrapGetStaticPropsWithSentry.ts renamed to packages/nextjs/src/common/pages-router-instrumentation/wrapGetStaticPropsWithSentry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { GetStaticProps } from 'next';
22

3-
import { isBuild } from './utils/isBuild';
4-
import { callDataFetcherTraced, withErrorInstrumentation } from './utils/wrapperUtils';
3+
import { isBuild } from '../utils/isBuild';
4+
import { callDataFetcherTraced, withErrorInstrumentation } from '../utils/wrapperUtils';
55

66
type Props = { [key: string]: unknown };
77

packages/nextjs/src/common/wrapPageComponentWithSentry.ts renamed to packages/nextjs/src/common/pages-router-instrumentation/wrapPageComponentWithSentry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { captureException, getCurrentScope, withIsolationScope } from '@sentry/core';
22
import { extractTraceparentData } from '@sentry/utils';
3-
import { escapeNextjsTracing } from './utils/tracingUtils';
3+
import { escapeNextjsTracing } from '../utils/tracingUtils';
44

55
interface FunctionComponent {
66
(...args: unknown[]): unknown;

packages/nextjs/src/edge/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getDefaultIntegrations, init as vercelEdgeInit } from '@sentry/vercel-e
66
import { isBuild } from '../common/utils/isBuild';
77
import { distDirRewriteFramesIntegration } from './distDirRewriteFramesIntegration';
88

9-
export { captureUnderscoreErrorException } from '../common/_error';
9+
export { captureUnderscoreErrorException } from '../common/pages-router-instrumentation/_error';
1010

1111
export type EdgeOptions = VercelEdgeOptions;
1212

packages/nextjs/src/server/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { distDirRewriteFramesIntegration } from './distDirRewriteFramesIntegrati
2626

2727
export * from '@sentry/node';
2828

29-
export { captureUnderscoreErrorException } from '../common/_error';
29+
export { captureUnderscoreErrorException } from '../common/pages-router-instrumentation/_error';
3030

3131
const globalWithInjectedValues = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
3232
__rewriteFramesDistDir__?: string;
@@ -325,4 +325,4 @@ function sdkAlreadyInitialized(): boolean {
325325

326326
export * from '../common';
327327

328-
export { wrapApiHandlerWithSentry } from '../common/wrapApiHandlerWithSentry';
328+
export { wrapApiHandlerWithSentry } from '../common/pages-router-instrumentation/wrapApiHandlerWithSentry';

0 commit comments

Comments
 (0)