Skip to content

ref(nextjs): Move pages router instrumentation into separate folder #13890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2024
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
2 changes: 1 addition & 1 deletion packages/nextjs/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { applyTunnelRouteOption } from './tunnelRoute';

export * from '@sentry/react';

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

const globalWithInjectedValues = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
__rewriteFramesAssetPrefixPath__: string;
Expand Down
16 changes: 8 additions & 8 deletions packages/nextjs/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export { wrapGetStaticPropsWithSentry } from './wrapGetStaticPropsWithSentry';
export { wrapGetInitialPropsWithSentry } from './wrapGetInitialPropsWithSentry';
export { wrapAppGetInitialPropsWithSentry } from './wrapAppGetInitialPropsWithSentry';
export { wrapDocumentGetInitialPropsWithSentry } from './wrapDocumentGetInitialPropsWithSentry';
export { wrapErrorGetInitialPropsWithSentry } from './wrapErrorGetInitialPropsWithSentry';
export { wrapGetServerSidePropsWithSentry } from './wrapGetServerSidePropsWithSentry';
export { wrapGetStaticPropsWithSentry } from './pages-router-instrumentation/wrapGetStaticPropsWithSentry';
export { wrapGetInitialPropsWithSentry } from './pages-router-instrumentation/wrapGetInitialPropsWithSentry';
export { wrapAppGetInitialPropsWithSentry } from './pages-router-instrumentation/wrapAppGetInitialPropsWithSentry';
export { wrapDocumentGetInitialPropsWithSentry } from './pages-router-instrumentation/wrapDocumentGetInitialPropsWithSentry';
export { wrapErrorGetInitialPropsWithSentry } from './pages-router-instrumentation/wrapErrorGetInitialPropsWithSentry';
export { wrapGetServerSidePropsWithSentry } from './pages-router-instrumentation/wrapGetServerSidePropsWithSentry';
export { wrapServerComponentWithSentry } from './wrapServerComponentWithSentry';
export { wrapRouteHandlerWithSentry } from './wrapRouteHandlerWithSentry';
export { wrapApiHandlerWithSentryVercelCrons } from './wrapApiHandlerWithSentryVercelCrons';
export { wrapApiHandlerWithSentryVercelCrons } from './pages-router-instrumentation/wrapApiHandlerWithSentryVercelCrons';
export { wrapMiddlewareWithSentry } from './wrapMiddlewareWithSentry';
export { wrapPageComponentWithSentry } from './wrapPageComponentWithSentry';
export { wrapPageComponentWithSentry } from './pages-router-instrumentation/wrapPageComponentWithSentry';
export { wrapGenerationFunctionWithSentry } from './wrapGenerationFunctionWithSentry';
export { withServerActionInstrumentation } from './withServerActionInstrumentation';
// eslint-disable-next-line deprecation/deprecation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { captureException, withScope } from '@sentry/core';
import type { NextPageContext } from 'next';
import { flushSafelyWithTimeout } from './utils/responseEnd';
import { vercelWaitUntil } from './utils/vercelWaitUntil';
import { flushSafelyWithTimeout } from '../utils/responseEnd';
import { vercelWaitUntil } from '../utils/vercelWaitUntil';

type ContextOrProps = {
req?: NextPageContext['req'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
import { consoleSandbox, isString, logger, objectify } from '@sentry/utils';

import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
import type { AugmentedNextApiRequest, AugmentedNextApiResponse, NextApiHandler } from './types';
import { flushSafelyWithTimeout } from './utils/responseEnd';
import { escapeNextjsTracing } from './utils/tracingUtils';
import { vercelWaitUntil } from './utils/vercelWaitUntil';
import type { AugmentedNextApiRequest, AugmentedNextApiResponse, NextApiHandler } from '../types';
import { flushSafelyWithTimeout } from '../utils/responseEnd';
import { escapeNextjsTracing } from '../utils/tracingUtils';
import { vercelWaitUntil } from '../utils/vercelWaitUntil';

/**
* Wrap the given API route handler for tracing and error capturing. Thin wrapper around `withSentry`, which only
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { captureCheckIn } from '@sentry/core';
import type { NextApiRequest } from 'next';

import type { VercelCronsConfig } from './types';
import type { VercelCronsConfig } from '../types';

type EdgeRequest = {
nextUrl: URL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type App from 'next/app';

import { isBuild } from './utils/isBuild';
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from './utils/wrapperUtils';
import { isBuild } from '../utils/isBuild';
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type Document from 'next/document';

import { isBuild } from './utils/isBuild';
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from './utils/wrapperUtils';
import { isBuild } from '../utils/isBuild';
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';

type DocumentGetInitialProps = typeof Document.getInitialProps;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { NextPageContext } from 'next';
import type { ErrorProps } from 'next/error';

import { isBuild } from './utils/isBuild';
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from './utils/wrapperUtils';
import { isBuild } from '../utils/isBuild';
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { NextPage } from 'next';

import { isBuild } from './utils/isBuild';
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from './utils/wrapperUtils';
import { isBuild } from '../utils/isBuild';
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GetServerSideProps } from 'next';

import { isBuild } from './utils/isBuild';
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from './utils/wrapperUtils';
import { isBuild } from '../utils/isBuild';
import { withErrorInstrumentation, withTracedServerSideDataFetcher } from '../utils/wrapperUtils';

/**
* Create a wrapped version of the user's exported `getServerSideProps` function
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { GetStaticProps } from 'next';

import { isBuild } from './utils/isBuild';
import { callDataFetcherTraced, withErrorInstrumentation } from './utils/wrapperUtils';
import { isBuild } from '../utils/isBuild';
import { callDataFetcherTraced, withErrorInstrumentation } from '../utils/wrapperUtils';

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { captureException, getCurrentScope, withIsolationScope } from '@sentry/core';
import { extractTraceparentData } from '@sentry/utils';
import { escapeNextjsTracing } from './utils/tracingUtils';
import { escapeNextjsTracing } from '../utils/tracingUtils';

interface FunctionComponent {
(...args: unknown[]): unknown;
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/src/edge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getDefaultIntegrations, init as vercelEdgeInit } from '@sentry/vercel-e
import { isBuild } from '../common/utils/isBuild';
import { distDirRewriteFramesIntegration } from './distDirRewriteFramesIntegration';

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

export type EdgeOptions = VercelEdgeOptions;

Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { distDirRewriteFramesIntegration } from './distDirRewriteFramesIntegrati

export * from '@sentry/node';

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

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

export * from '../common';

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