From 7ba1bf82752d0af2c41e3845460b907940874b13 Mon Sep 17 00:00:00 2001 From: Winston Hoy Date: Tue, 12 Dec 2023 13:24:19 -0500 Subject: [PATCH] feat(nextjs): Export common shims for server and edge nextjs modules Export common shims (BrowserTracing, Feedback, Replay) to improve DX by: - logging error when server/edge SDK inits invoke client only modules - avoiding compilation warnings for uninvoked client only configuration Fixes GH-9796 --- packages/nextjs/src/edge/index.ts | 2 ++ packages/nextjs/src/index.types.ts | 1 + packages/nextjs/src/server/index.ts | 2 ++ 3 files changed, 5 insertions(+) diff --git a/packages/nextjs/src/edge/index.ts b/packages/nextjs/src/edge/index.ts index 5c4d39c3bdc7..53a3d7b1cddf 100644 --- a/packages/nextjs/src/edge/index.ts +++ b/packages/nextjs/src/edge/index.ts @@ -4,6 +4,8 @@ import type { SdkMetadata } from '@sentry/types'; import { GLOBAL_OBJ, addOrUpdateIntegration, escapeStringForRegex } from '@sentry/utils'; import type { VercelEdgeOptions } from '@sentry/vercel-edge'; import { init as vercelEdgeInit } from '@sentry/vercel-edge'; +// This is exported to warn when server/edge SDK inits invoke client only modules and to avoid compilation warnings for uninvoked client only configuration +export { BrowserTracing, Feedback, Replay } from '@sentry-internal/integration-shims'; import { isBuild } from '../common/utils/isBuild'; diff --git a/packages/nextjs/src/index.types.ts b/packages/nextjs/src/index.types.ts index 50c1a747b599..06b9692943bb 100644 --- a/packages/nextjs/src/index.types.ts +++ b/packages/nextjs/src/index.types.ts @@ -7,6 +7,7 @@ export * from './client'; export * from './server'; export * from './edge'; +export type { BrowserTracing, Feedback, Replay } from '@sentry/react'; import type { Integration, Options, StackParser } from '@sentry/types'; import type * as clientSdk from './client'; diff --git a/packages/nextjs/src/server/index.ts b/packages/nextjs/src/server/index.ts index b049be2c31b8..9d5d47a07f46 100644 --- a/packages/nextjs/src/server/index.ts +++ b/packages/nextjs/src/server/index.ts @@ -6,6 +6,8 @@ import { Integrations, configureScope, getCurrentHub, init as nodeInit } from '@ import type { EventProcessor } from '@sentry/types'; import type { IntegrationWithExclusionOption } from '@sentry/utils'; import { addOrUpdateIntegration, escapeStringForRegex, logger } from '@sentry/utils'; +// This is exported to warn when server/edge SDK inits invoke client only modules and to avoid compilation warnings for uninvoked client only configuration +export { BrowserTracing, Feedback, Replay } from '@sentry-internal/integration-shims'; import { DEBUG_BUILD } from '../common/debug-build'; import { devErrorSymbolicationEventProcessor } from '../common/devErrorSymbolicationEventProcessor';