diff --git a/packages/integration-shims/src/index.ts b/packages/integration-shims/src/index.ts index 510b26ddbb76..e887ac725023 100644 --- a/packages/integration-shims/src/index.ts +++ b/packages/integration-shims/src/index.ts @@ -1,3 +1,4 @@ export { feedbackIntegrationShim } from './Feedback'; export { replayIntegrationShim } from './Replay'; export { browserTracingIntegrationShim } from './BrowserTracing'; +export { launchDarklyIntegrationShim, buildLaunchDarklyFlagUsedHandlerShim } from './launchDarkly'; diff --git a/packages/integration-shims/src/launchDarkly.ts b/packages/integration-shims/src/launchDarkly.ts new file mode 100644 index 000000000000..8254ac8e4b80 --- /dev/null +++ b/packages/integration-shims/src/launchDarkly.ts @@ -0,0 +1,38 @@ +import { consoleSandbox, defineIntegration, isBrowser } from '@sentry/core'; +import { FAKE_FUNCTION } from './common'; + +/** + * This is a shim for the LaunchDarkly integration. + * We need this in order to not throw runtime errors when accidentally importing this on the server through a meta framework like Next.js. + */ +export const launchDarklyIntegrationShim = defineIntegration((_options?: unknown) => { + if (!isBrowser()) { + consoleSandbox(() => { + // eslint-disable-next-line no-console + console.warn('The launchDarklyIntegration() can only be used in the browser.'); + }); + } + + return { + name: 'LaunchDarkly', + }; +}); + +/** + * This is a shim for the LaunchDarkly flag used handler. + */ +export function buildLaunchDarklyFlagUsedHandlerShim(): unknown { + if (!isBrowser()) { + consoleSandbox(() => { + // eslint-disable-next-line no-console + console.warn('The buildLaunchDarklyFlagUsedHandler() should only be used in the browser.'); + }); + } + + return { + name: 'sentry-flag-auditor', + type: 'flag-used', + synchronous: true, + method: FAKE_FUNCTION, + }; +} diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 9ab46ee4b98b..459f013bc3c3 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -94,6 +94,7 @@ "devDependencies": { "@types/resolve": "1.20.3", "eslint-plugin-react": "^7.31.11", + "@sentry-internal/integration-shims": "9.32.0", "next": "13.5.9" }, "peerDependencies": { diff --git a/packages/nextjs/src/index.types.ts b/packages/nextjs/src/index.types.ts index c630d545061c..479c0b462c9f 100644 --- a/packages/nextjs/src/index.types.ts +++ b/packages/nextjs/src/index.types.ts @@ -138,3 +138,6 @@ export declare function wrapApiHandlerWithSentryVercelCrons(WrappingTarget: C): C; export { captureRequestError } from './common/captureRequestError'; + +export declare const launchDarklyIntegration: typeof clientSdk.launchDarklyIntegration; +export declare const buildLaunchDarklyFlagUsedHandler: typeof clientSdk.buildLaunchDarklyFlagUsedHandler; diff --git a/packages/nextjs/src/server/index.ts b/packages/nextjs/src/server/index.ts index a6594e7fae1e..255937273859 100644 --- a/packages/nextjs/src/server/index.ts +++ b/packages/nextjs/src/server/index.ts @@ -389,3 +389,8 @@ function sdkAlreadyInitialized(): boolean { export * from '../common'; export { wrapApiHandlerWithSentry } from '../common/pages-router-instrumentation/wrapApiHandlerWithSentry'; + +export { + launchDarklyIntegrationShim as launchDarklyIntegration, + buildLaunchDarklyFlagUsedHandlerShim as buildLaunchDarklyFlagUsedHandler, +} from '@sentry-internal/integration-shims'; diff --git a/yarn.lock b/yarn.lock index bd6c7af98fde..66a02ddb2de5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29248,7 +29248,7 @@ vite@^5.0.0, vite@^5.4.11, vite@^5.4.5: optionalDependencies: fsevents "~2.3.3" -vitefu@^0.2.2, vitefu@^0.2.4, vitefu@^0.2.5: +vitefu@^0.2.2, vitefu@^0.2.4: version "0.2.5" resolved "https://registry.yarnpkg.com/vitefu/-/vitefu-0.2.5.tgz#c1b93c377fbdd3e5ddd69840ea3aa70b40d90969" integrity sha512-SgHtMLoqaeeGnd2evZ849ZbACbnwQCIwRH57t18FxcXoZop0uQu0uzlIhJBlF/eWVzuce0sHeqPcDo+evVcg8Q== pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy