@sentry/bundler-plugins 11.0.0-alpha.2 → 11.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/core/build-plugin-manager.js +1 -0
- package/build/cjs/core/build-plugin-manager.js.map +1 -1
- package/build/cjs/core/sentry/telemetry.js +3 -2
- package/build/cjs/core/sentry/telemetry.js.map +1 -1
- package/build/cjs/core/version.js +1 -1
- package/build/cjs/core/version.js.map +1 -1
- package/build/esm/core/build-plugin-manager.js +1 -0
- package/build/esm/core/build-plugin-manager.js.map +1 -1
- package/build/esm/core/sentry/telemetry.js +2 -1
- package/build/esm/core/sentry/telemetry.js.map +1 -1
- package/build/esm/core/version.js +1 -1
- package/build/esm/core/version.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/core/build-plugin-manager.d.ts.map +1 -1
- package/build/types/core/sentry/telemetry.d.ts.map +1 -1
- package/build/types/core/version.d.ts +1 -1
- package/build/types/core/version.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -364,6 +364,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
364
364
|
}
|
|
365
365
|
await core.startSpan(
|
|
366
366
|
// This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
|
|
367
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
367
368
|
{ name: "debug-id-sourcemap-upload", scope: sentryScope, forceTransaction: true },
|
|
368
369
|
async () => {
|
|
369
370
|
const shouldPrepare = opts?.prepareArtifacts ?? true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-plugin-manager.js","sources":["../../../src/core/build-plugin-manager.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport { closeSession, DEFAULT_ENVIRONMENT, makeSession, setMeasurement, startSpan } from '@sentry/core';\nimport * as dotenv from 'dotenv';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { SentryCliAdapter } from './cli';\nimport type { NormalizedOptions } from './options-mapping';\nimport { normalizeUserOptions, validateOptions } from './options-mapping';\nimport type { Logger } from './logger';\nimport { createLogger } from './logger';\nimport { allowedToSendTelemetry, createSentryInstance, safeFlushTelemetry } from './sentry/telemetry';\nimport type { Options, SentrySDKBuildFlags } from './types';\nimport { arrayify, getProjects, getTurborepoEnvPassthroughWarning, stripQueryAndHashFromPath } from './utils';\nimport { defaultRewriteSourcesHook, prepareBundleForDebugIdUpload } from './debug-id-upload';\nimport { globFiles } from './glob';\nimport { LIB_VERSION } from './version';\n\n// Module-level guard to prevent duplicate deploy records when multiple bundler plugin\n// instances run in the same process (e.g. Next.js creates separate webpack compilers\n// for client, server, and edge). Keyed by release name.\nconst _deployedReleases = new Set<string>();\n\n/** @internal Exported for testing only. */\nexport function _resetDeployedReleasesForTesting(): void {\n _deployedReleases.clear();\n}\n\nexport type SentryBuildPluginManager = {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger: Logger;\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: NormalizedOptions;\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags;\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata: Record<string, unknown>;\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n emitBundlerPluginExecutionSignal(): Promise<void>;\n };\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n createRelease(): Promise<void>;\n\n /**\n * Injects debug IDs into the build artifacts.\n *\n * This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n * Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n * Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n injectDebugIds(buildArtifactPaths: string[]): Promise<void>;\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method. This function takes a list of build artifact paths that will be uploaded\n */\n uploadSourcemaps(buildArtifactPaths: string[], opts?: { prepareArtifacts?: boolean }): Promise<void>;\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n deleteArtifacts(): Promise<void>;\n\n createDependencyOnBuildArtifacts: () => () => void;\n};\n\n/**\n * Creates a build plugin manager that exposes primitives for everything that a Sentry JavaScript SDK or build tooling may do during a build.\n *\n * The build plugin manager's behavior strongly depends on the options that are passed in.\n */\nexport function createSentryBuildPluginManager(\n userOptions: Options,\n bundlerPluginMetaContext: {\n /**\n * E.g. `webpack` or `nextjs` or `turbopack`\n */\n buildTool: string;\n /**\n * E.g. `5` for webpack v5 or `4` for Rollup v4\n */\n buildToolMajorVersion?: string;\n /**\n * E.g. `[sentry-webpack-plugin]` or `[@sentry/nextjs]`\n */\n loggerPrefix: string;\n },\n): SentryBuildPluginManager {\n const logger = createLogger({\n prefix: bundlerPluginMetaContext.loggerPrefix,\n silent: userOptions.silent ?? false,\n debug: userOptions.debug ?? false,\n });\n\n try {\n const dotenvFile = fs.readFileSync(path.join(process.cwd(), '.env.sentry-build-plugin'), 'utf-8');\n // NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.\n const dotenvResult = dotenv.parse(dotenvFile);\n\n // Vite has a bug/behaviour where spreading into process.env will cause it to crash\n // https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251\n Object.assign(process.env, dotenvResult);\n\n logger.info('Using environment variables configured in \".env.sentry-build-plugin\".');\n } catch (e: unknown) {\n // Ignore \"file not found\" errors but throw all others\n if (typeof e === 'object' && e && 'code' in e && e.code !== 'ENOENT') {\n throw e;\n }\n }\n\n const options = normalizeUserOptions(userOptions);\n\n if (options.disable) {\n // Early-return a noop build plugin manager instance so that we\n // don't continue validating options, setting up Sentry, etc.\n // Otherwise we might create side-effects or log messages that\n // users don't expect from a disabled plugin.\n return {\n normalizedOptions: options,\n logger,\n bundleSizeOptimizationReplacementValues: {},\n telemetry: {\n emitBundlerPluginExecutionSignal: async () => {\n /* noop */\n },\n },\n bundleMetadata: {},\n createRelease: async () => {\n /* noop */\n },\n uploadSourcemaps: async () => {\n /* noop */\n },\n deleteArtifacts: async () => {\n /* noop */\n },\n createDependencyOnBuildArtifacts: () => () => {\n /* noop */\n },\n injectDebugIds: async () => {\n /* noop */\n },\n };\n }\n\n const shouldSendTelemetry = allowedToSendTelemetry(options);\n const { sentryScope, sentryClient } = createSentryInstance(\n options,\n shouldSendTelemetry,\n bundlerPluginMetaContext.buildTool,\n bundlerPluginMetaContext.buildToolMajorVersion,\n );\n\n const { release, environment = DEFAULT_ENVIRONMENT } = sentryClient.getOptions();\n\n const sentrySession = makeSession({ release, environment });\n sentryScope.setSession(sentrySession);\n // Send the start of the session\n sentryClient.captureSession(sentrySession);\n\n let sessionHasEnded = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out\n\n function endSession(): void {\n if (sessionHasEnded) {\n return;\n }\n\n closeSession(sentrySession);\n sentryClient.captureSession(sentrySession);\n sessionHasEnded = true;\n }\n\n // We also need to manually end sessions on errors because beforeExit is not called on crashes\n process.on('beforeExit', () => {\n endSession();\n });\n\n // Set the User-Agent that Sentry CLI will use when interacting with Sentry\n process.env['SENTRY_PIPELINE'] = `${bundlerPluginMetaContext.buildTool}-plugin/${LIB_VERSION}`;\n\n // Propagate debug flag to Sentry CLI via environment variable\n // Only set if not already defined to respect user's explicit configuration\n if (options.debug && !process.env['SENTRY_LOG_LEVEL']) {\n process.env['SENTRY_LOG_LEVEL'] = 'debug';\n }\n\n // Not a bulletproof check but should be good enough to at least sometimes determine\n // if the plugin is called in dev/watch mode or for a prod build. The important part\n // here is to avoid a false positive. False negatives are okay.\n const isDevMode = process.env['NODE_ENV'] === 'development';\n\n /**\n * Handles errors caught and emitted in various areas of the plugin.\n *\n * Also sets the sentry session status according to the error handling.\n *\n * If users specify their custom `errorHandler` we'll leave the decision to throw\n * or continue up to them. By default, @param throwByDefault controls if the plugin\n * should throw an error (which causes a build fail in most bundlers) or continue.\n */\n function handleRecoverableError(unknownError: unknown, throwByDefault: boolean): void {\n sentrySession.status = 'abnormal';\n try {\n if (options.errorHandler) {\n try {\n if (unknownError instanceof Error) {\n options.errorHandler(unknownError);\n } else {\n options.errorHandler(new Error('An unknown error occurred'));\n }\n } catch (e) {\n sentrySession.status = 'crashed';\n throw e;\n }\n } else {\n // setting the session to \"crashed\" b/c from a plugin perspective this run failed.\n // However, we're intentionally not rethrowing the error to avoid breaking the user build.\n sentrySession.status = 'crashed';\n if (throwByDefault) {\n throw unknownError;\n }\n logger.error(\"An error occurred. Couldn't finish all operations:\", unknownError);\n }\n } finally {\n endSession();\n }\n }\n\n if (!validateOptions(options, logger)) {\n // Throwing by default to avoid a misconfigured plugin going unnoticed.\n handleRecoverableError(new Error('Options were not set correctly. See output above for more details.'), true);\n }\n\n // We have multiple plugins depending on generated source map files. (debug ID upload, legacy upload)\n // Additionally, we also want to have the functionality to delete files after uploading sourcemaps.\n // All of these plugins and the delete functionality need to run in the same hook (`writeBundle`).\n // Since the plugins among themselves are not aware of when they run and finish, we need a system to\n // track their dependencies on the generated files, so that we can initiate the file deletion only after\n // nothing depends on the files anymore.\n const dependenciesOnBuildArtifacts = new Set<symbol>();\n const buildArtifactsDependencySubscribers: (() => void)[] = [];\n\n function notifyBuildArtifactDependencySubscribers(): void {\n buildArtifactsDependencySubscribers.forEach(subscriber => {\n subscriber();\n });\n }\n\n function createDependencyOnBuildArtifacts(): () => void {\n const dependencyIdentifier = Symbol();\n dependenciesOnBuildArtifacts.add(dependencyIdentifier);\n\n return function freeDependencyOnBuildArtifacts() {\n dependenciesOnBuildArtifacts.delete(dependencyIdentifier);\n notifyBuildArtifactDependencySubscribers();\n };\n }\n\n /**\n * Returns a Promise that resolves when all the currently active dependencies are freed again.\n *\n * It is very important that this function is called as late as possible before wanting to await the Promise to give\n * the dependency producers as much time as possible to register themselves.\n */\n function waitUntilBuildArtifactDependenciesAreFreed(): Promise<void> {\n return new Promise<void>(resolve => {\n buildArtifactsDependencySubscribers.push(() => {\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n }\n\n const bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags = {};\n if (options.bundleSizeOptimizations) {\n const { bundleSizeOptimizations } = options;\n\n if (bundleSizeOptimizations.excludeDebugStatements) {\n bundleSizeOptimizationReplacementValues['__SENTRY_DEBUG__'] = false;\n }\n if (bundleSizeOptimizations.excludeTracing) {\n bundleSizeOptimizationReplacementValues['__SENTRY_TRACING__'] = false;\n }\n if (bundleSizeOptimizations.excludeChannelInjection) {\n bundleSizeOptimizationReplacementValues['__SENTRY_CHANNEL_INJECTION__'] = false;\n }\n if (bundleSizeOptimizations.excludeReplayCanvas) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_CANVAS__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayIframe) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_IFRAME__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayShadowDom) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_SHADOW_DOM__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayWorker) {\n bundleSizeOptimizationReplacementValues['__SENTRY_EXCLUDE_REPLAY_WORKER__'] = true;\n }\n }\n\n let bundleMetadata: Record<string, unknown> = {};\n if (options.moduleMetadata || options.applicationKey) {\n if (options.applicationKey) {\n // We use different keys so that if user-code receives multiple bundling passes, we will store the application keys of all the passes.\n // It is a bit unfortunate that we have to inject the metadata snippet at the top, because after multiple\n // injections, the first injection will always \"win\" because it comes last in the code. We would generally be\n // fine with making the last bundling pass win. But because it cannot win, we have to use a workaround of storing\n // the app keys in different object keys.\n // We can simply use the `_sentryBundlerPluginAppKey:` to filter for app keys in the SDK.\n bundleMetadata[`_sentryBundlerPluginAppKey:${options.applicationKey}`] = true;\n }\n\n if (typeof options.moduleMetadata === 'function') {\n const args = {\n org: options.org,\n project: getProjects(options.project)?.[0],\n projects: getProjects(options.project),\n release: options.release.name,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata(args) };\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata };\n }\n }\n\n return {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger,\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: options,\n\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues,\n\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata,\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n async emitBundlerPluginExecutionSignal() {\n if (await shouldSendTelemetry) {\n logger.info(\n 'Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.',\n );\n startSpan({ name: 'Sentry Bundler Plugin execution', scope: sentryScope }, () => {\n //\n });\n await safeFlushTelemetry(sentryClient);\n }\n },\n },\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n async createRelease() {\n if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not create release. Please set the `release.name` option to identify your release.',\n );\n return;\n } else if (isDevMode) {\n logger.debug('Running in development mode. Will not create release.');\n return;\n } else if (!options.authToken) {\n logger.warn(\n `No auth token provided. Will not create release. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return;\n } else if (!options.org && !options.authToken.startsWith('sntrys_')) {\n logger.warn(\n `No organization slug provided. Will not create release. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return;\n } else if (!options.project || (Array.isArray(options.project) && options.project.length === 0)) {\n logger.warn(\n `No project provided. Will not create release. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return;\n }\n\n // It is possible that this writeBundle hook is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();\n\n // Guaranteed to be set by the guard clause above.\n const releaseName = options.release.name;\n\n try {\n const cliInstance = new SentryCliAdapter(options);\n\n if (options.release.create) {\n const releaseOutput = await cliInstance.createRelease(releaseName);\n logger.debug('Release created:', releaseOutput);\n }\n\n if (options.release.uploadLegacySourcemaps) {\n const uploadTargets = arrayify(options.release.uploadLegacySourcemaps)\n .map(includeItem => (typeof includeItem === 'string' ? { paths: [includeItem] } : includeItem))\n .flatMap(includeEntry =>\n includeEntry.paths.map(directory => ({\n directory,\n dist: options.release.dist,\n ext: includeEntry.ext\n ? includeEntry.ext.map(extension => `.${extension.replace(/^\\./, '')}`)\n : ['.js', '.map', '.jsbundle', '.bundle'],\n // The old CLI only skipped `node_modules` when neither ignore source was configured.\n ignore: includeEntry.ignore\n ? arrayify(includeEntry.ignore)\n : includeEntry.ignoreFile\n ? undefined\n : ['node_modules'],\n ignoreFile: includeEntry.ignoreFile,\n urlPrefix: includeEntry.urlPrefix,\n })),\n );\n\n await cliInstance.uploadSourcemaps(releaseName, uploadTargets);\n }\n\n if (options.release.setCommits !== false) {\n try {\n await cliInstance.setCommits(\n releaseName,\n // set commits always exists due to the normalize function\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n options.release.setCommits!,\n );\n } catch (e) {\n // shouldNotThrowOnFailure being present means that the plugin defaulted to `{ auto: true }` for the setCommitsOptions, meaning that wee should not throw when CLI throws because there is no repo\n if (\n options.release.setCommits &&\n 'shouldNotThrowOnFailure' in options.release.setCommits &&\n options.release.setCommits.shouldNotThrowOnFailure\n ) {\n logger.debug(\n 'An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):',\n e,\n );\n } else {\n throw e;\n }\n }\n }\n\n if (options.release.finalize) {\n await cliInstance.finalizeRelease(releaseName);\n }\n\n if (options.release.deploy && !_deployedReleases.has(releaseName)) {\n await cliInstance.newDeploy(releaseName, options.release.deploy);\n _deployedReleases.add(releaseName);\n }\n } catch (e) {\n sentryScope.captureException('Error in \"releaseManagementPlugin\" writeBundle hook');\n await safeFlushTelemetry(sentryClient);\n handleRecoverableError(e, false);\n } finally {\n freeWriteBundleInvocationDependencyOnSourcemapFiles();\n }\n },\n\n /*\n Injects debug IDs into the build artifacts.\n\n This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n async injectDebugIds(buildArtifactPaths: string[]) {\n await startSpan({ name: 'inject-debug-ids', scope: sentryScope, forceTransaction: true }, async () => {\n try {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.injectDebugIds(buildArtifactPaths, options.sourcemaps?.ignore);\n } catch (e) {\n sentryScope.captureException('Error in \"debugIdInjectionPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n await safeFlushTelemetry(sentryClient);\n }\n });\n },\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method.\n *\n * By default, this prepares bundles in a temporary folder before uploading. You can opt into an\n * in-place, direct upload path by setting `prepareArtifacts` to `false`. If `prepareArtifacts` is set to\n * `false`, no preparation (e.g. adding `//# debugId=...` and writing adjusted source maps) is performed and no temp folder is used.\n *\n * @param buildArtifactPaths - The paths of the build artifacts to upload\n * @param opts - Optional flags to control temp folder usage and preparation\n */\n async uploadSourcemaps(buildArtifactPaths: string[], opts?: { prepareArtifacts?: boolean }) {\n if (!canUploadSourceMaps(options, logger, isDevMode)) {\n return;\n }\n\n // Early exit if assets is explicitly set to an empty array\n const assets = options.sourcemaps?.assets;\n if (Array.isArray(assets) && assets.length === 0) {\n logger.debug('Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.');\n return;\n }\n\n await startSpan(\n // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.\n { name: 'debug-id-sourcemap-upload', scope: sentryScope, forceTransaction: true },\n async () => {\n // If we're not using a temp folder, we must not prepare artifacts in-place (to avoid mutating user files)\n const shouldPrepare = opts?.prepareArtifacts ?? true;\n\n let folderToCleanUp: string | undefined;\n\n // It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n\n try {\n if (!shouldPrepare) {\n // Direct CLI upload from existing artifact paths (no globbing, no preparation)\n let pathsToUpload: string[];\n\n if (assets) {\n pathsToUpload = Array.isArray(assets) ? assets : [assets];\n logger.debug(\n `Direct upload mode: passing user-provided assets directly to CLI: ${pathsToUpload.join(', ')}`,\n );\n } else {\n // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done\n pathsToUpload = buildArtifactPaths;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(\n options.release.name ?? 'undefined',\n pathsToUpload.map(directory => ({\n directory,\n dist: options.release.dist,\n ignore: options.sourcemaps?.ignore,\n })),\n );\n });\n\n logger.info('Successfully uploaded source maps to Sentry');\n } else {\n // Prepare artifacts in temp folder before uploading\n let globAssets: string | string[];\n if (assets) {\n globAssets = assets;\n } else {\n logger.debug(\n 'No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.',\n );\n globAssets = buildArtifactPaths;\n }\n\n const globResult = await startSpan({ name: 'glob', scope: sentryScope }, async () =>\n globFiles(globAssets, { ignore: options.sourcemaps?.ignore }),\n );\n\n const debugIdChunkFilePaths = globResult.filter(debugIdChunkFilePath => {\n return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\\.(js|mjs|cjs)$/);\n });\n\n // The order of the files output by glob() is not deterministic\n // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent\n debugIdChunkFilePaths.sort();\n\n if (debugIdChunkFilePaths.length === 0) {\n logger.warn(\n \"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.\",\n );\n } else {\n const tmpUploadFolder = await startSpan({ name: 'mkdtemp', scope: sentryScope }, async () => {\n return (\n process.env?.['SENTRY_TEST_OVERRIDE_TEMP_DIR'] ||\n (await fs.promises.mkdtemp(path.join(os.tmpdir(), 'sentry-bundler-plugin-upload-')))\n );\n });\n folderToCleanUp = tmpUploadFolder;\n\n // Prepare into temp folder, then upload\n await startSpan({ name: 'prepare-bundles', scope: sentryScope }, async prepBundlesSpan => {\n // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so\n // instead we do it with a maximum of 16 concurrent workers\n const preparationTasks = debugIdChunkFilePaths.map((chunkFilePath, chunkIndex) => async () => {\n await prepareBundleForDebugIdUpload(\n chunkFilePath,\n tmpUploadFolder,\n chunkIndex,\n logger,\n options.sourcemaps?.rewriteSources ?? defaultRewriteSourcesHook,\n options.sourcemaps?.resolveSourceMap,\n );\n });\n const workers: Promise<void>[] = [];\n const worker = async (): Promise<void> => {\n while (preparationTasks.length > 0) {\n const task = preparationTasks.shift();\n if (task) {\n await task();\n }\n }\n };\n for (let workerIndex = 0; workerIndex < 16; workerIndex++) {\n workers.push(worker());\n }\n\n await Promise.all(workers);\n\n const files = await fs.promises.readdir(tmpUploadFolder);\n const stats = files.map(file => fs.promises.stat(path.join(tmpUploadFolder, file)));\n const uploadSize = (await Promise.all(stats)).reduce(\n (accumulator, { size }) => accumulator + size,\n 0,\n );\n\n setMeasurement('files', files.length, 'none', prepBundlesSpan);\n setMeasurement('upload_size', uploadSize, 'byte', prepBundlesSpan);\n\n // Preparation produced no artifacts, meaning none of the\n // matched bundles had an associated source map. This almost\n // always means source map generation is turned off in the\n // bundler, so warn instead of silently reporting success.\n if (files.length === 0) {\n logger.warn(\n `No source maps found for any of the ${debugIdChunkFilePaths.length} matched build ` +\n 'artifacts, so no source maps were uploaded to Sentry. This usually means source map ' +\n 'generation is not enabled in your bundler. Enable it so Sentry can un-minify your stack traces.',\n );\n return;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(options.release.name ?? 'undefined', [\n {\n directory: tmpUploadFolder,\n dist: options.release.dist,\n },\n ]);\n });\n\n // this must be in the method so that the \"no sourcemaps\"\n // early return doesn't also log success.\n logger.info('Successfully uploaded source maps to Sentry');\n });\n }\n }\n } catch (e) {\n sentryScope.captureException('Error in \"debugIdUploadPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n if (folderToCleanUp && !process.env?.['SENTRY_TEST_OVERRIDE_TEMP_DIR']) {\n logger.debug('Cleaning up temporary files...');\n try {\n await startSpan({ name: 'cleanup', scope: sentryScope }, async () => {\n if (folderToCleanUp) {\n await fs.promises.rm(folderToCleanUp, { recursive: true, force: true });\n logger.debug(`Temporary folder deleted: ${folderToCleanUp}`);\n }\n });\n } catch (e) {\n // A failed cleanup must not skip the teardown steps below (freeing upload\n // dependencies, flushing telemetry), so swallow and log instead of rethrowing.\n logger.debug('Failed to clean up temporary folder:', e);\n }\n }\n logger.debug('Freeing upload dependencies...');\n freeUploadDependencyOnBuildArtifacts();\n logger.debug('Flushing telemetry data...');\n await safeFlushTelemetry(sentryClient);\n logger.debug('Telemetry flushed. Plugin upload process complete.');\n }\n },\n );\n },\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n async deleteArtifacts() {\n try {\n const filesToDelete = await options.sourcemaps?.filesToDeleteAfterUpload;\n if (filesToDelete !== undefined) {\n const filePathsToDelete = await globFiles(filesToDelete);\n\n logger.debug('Waiting for dependencies on generated files to be freed before deleting...');\n\n await waitUntilBuildArtifactDependenciesAreFreed();\n\n filePathsToDelete.forEach(filePathToDelete => {\n logger.debug(`Deleting asset after upload: ${filePathToDelete}`);\n });\n\n await Promise.all(\n filePathsToDelete.map(filePathToDelete =>\n fs.promises.rm(filePathToDelete, { force: true }).catch(e => {\n // This is allowed to fail - we just don't do anything\n logger.debug(`An error occurred while attempting to delete asset: ${filePathToDelete}`, e);\n }),\n ),\n );\n }\n } catch (e) {\n sentryScope.captureException('Error in \"sentry-file-deletion-plugin\" buildEnd hook');\n await safeFlushTelemetry(sentryClient);\n // We throw by default if we get here b/c not being able to delete\n // source maps could leak them to production\n handleRecoverableError(e, true);\n }\n },\n createDependencyOnBuildArtifacts,\n };\n}\n\nfunction canUploadSourceMaps(options: NormalizedOptions, logger: Logger, isDevMode: boolean): boolean {\n if (options.sourcemaps?.disable) {\n logger.debug('Source map upload was disabled. Will not upload sourcemaps using debug ID process.');\n return false;\n }\n if (isDevMode) {\n logger.debug('Running in development mode. Will not upload sourcemaps.');\n return false;\n }\n if (!options.authToken) {\n logger.warn(\n `No auth token provided. Will not upload source maps. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return false;\n }\n if (!options.org && !options.authToken.startsWith('sntrys_')) {\n logger.warn(\n `No org provided. Will not upload source maps. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return false;\n }\n if (!getProjects(options.project)?.[0]) {\n logger.warn(\n `No project provided. Will not upload source maps. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return false;\n }\n\n return true;\n}\n"],"names":["logger","createLogger","fs","path","dotenv","normalizeUserOptions","allowedToSendTelemetry","createSentryInstance","DEFAULT_ENVIRONMENT","makeSession","closeSession","LIB_VERSION","validateOptions","getProjects","startSpan","safeFlushTelemetry","getTurborepoEnvPassthroughWarning","SentryCliAdapter","arrayify","globFiles","stripQueryAndHashFromPath","os","prepareBundleForDebugIdUpload","defaultRewriteSourcesHook","setMeasurement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,iBAAA,uBAAwB,GAAA,EAAY;AA4EnC,SAAS,8BAAA,CACd,aACA,wBAAA,EAc0B;AAC1B,EAAA,MAAMA,WAASC,mBAAA,CAAa;AAAA,IAC1B,QAAQ,wBAAA,CAAyB,YAAA;AAAA,IACjC,MAAA,EAAQ,YAAY,MAAA,IAAU,KAAA;AAAA,IAC9B,KAAA,EAAO,YAAY,KAAA,IAAS;AAAA,GAC7B,CAAA;AAED,EAAA,IAAI;AACF,IAAA,MAAM,UAAA,GAAaC,aAAA,CAAG,YAAA,CAAaC,eAAA,CAAK,IAAA,CAAK,QAAQ,GAAA,EAAI,EAAG,0BAA0B,CAAA,EAAG,OAAO,CAAA;AAEhG,IAAA,MAAM,YAAA,GAAeC,iBAAA,CAAO,KAAA,CAAM,UAAU,CAAA;AAI5C,IAAA,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,GAAA,EAAK,YAAY,CAAA;AAEvC,IAAAJ,QAAA,CAAO,KAAK,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AA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,QAAQ,SAAA,EAAW;AACtB,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,gMAAA,EAAmMC,uCAAA,CAAkC,mBAAmB,CAAC,CAAA;AAAA,KAC3P;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,QAAQ,GAAA,IAAO,CAAC,QAAQ,SAAA,CAAU,UAAA,CAAW,SAAS,CAAA,EAAG;AAC5D,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,6GAAA,EAAgHA,uCAAA,CAAkC,YAAY,CAAC,CAAA;AAAA,KACjK;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,CAACH,iBAAA,CAAY,OAAA,CAAQ,OAAO,CAAA,GAAI,CAAC,CAAA,EAAG;AACtC,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,gHAAA,EAAmHG,uCAAA,CAAkC,gBAAgB,CAAC,CAAA;AAAA,KACxK;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"build-plugin-manager.js","sources":["../../../src/core/build-plugin-manager.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport { closeSession, DEFAULT_ENVIRONMENT, makeSession, setMeasurement, startSpan } from '@sentry/core';\nimport * as dotenv from 'dotenv';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { SentryCliAdapter } from './cli';\nimport type { NormalizedOptions } from './options-mapping';\nimport { normalizeUserOptions, validateOptions } from './options-mapping';\nimport type { Logger } from './logger';\nimport { createLogger } from './logger';\nimport { allowedToSendTelemetry, createSentryInstance, safeFlushTelemetry } from './sentry/telemetry';\nimport type { Options, SentrySDKBuildFlags } from './types';\nimport { arrayify, getProjects, getTurborepoEnvPassthroughWarning, stripQueryAndHashFromPath } from './utils';\nimport { defaultRewriteSourcesHook, prepareBundleForDebugIdUpload } from './debug-id-upload';\nimport { globFiles } from './glob';\nimport { LIB_VERSION } from './version';\n\n// Module-level guard to prevent duplicate deploy records when multiple bundler plugin\n// instances run in the same process (e.g. Next.js creates separate webpack compilers\n// for client, server, and edge). Keyed by release name.\nconst _deployedReleases = new Set<string>();\n\n/** @internal Exported for testing only. */\nexport function _resetDeployedReleasesForTesting(): void {\n _deployedReleases.clear();\n}\n\nexport type SentryBuildPluginManager = {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger: Logger;\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: NormalizedOptions;\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags;\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata: Record<string, unknown>;\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n emitBundlerPluginExecutionSignal(): Promise<void>;\n };\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n createRelease(): Promise<void>;\n\n /**\n * Injects debug IDs into the build artifacts.\n *\n * This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n * Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n * Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n injectDebugIds(buildArtifactPaths: string[]): Promise<void>;\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method. This function takes a list of build artifact paths that will be uploaded\n */\n uploadSourcemaps(buildArtifactPaths: string[], opts?: { prepareArtifacts?: boolean }): Promise<void>;\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n deleteArtifacts(): Promise<void>;\n\n createDependencyOnBuildArtifacts: () => () => void;\n};\n\n/**\n * Creates a build plugin manager that exposes primitives for everything that a Sentry JavaScript SDK or build tooling may do during a build.\n *\n * The build plugin manager's behavior strongly depends on the options that are passed in.\n */\nexport function createSentryBuildPluginManager(\n userOptions: Options,\n bundlerPluginMetaContext: {\n /**\n * E.g. `webpack` or `nextjs` or `turbopack`\n */\n buildTool: string;\n /**\n * E.g. `5` for webpack v5 or `4` for Rollup v4\n */\n buildToolMajorVersion?: string;\n /**\n * E.g. `[sentry-webpack-plugin]` or `[@sentry/nextjs]`\n */\n loggerPrefix: string;\n },\n): SentryBuildPluginManager {\n const logger = createLogger({\n prefix: bundlerPluginMetaContext.loggerPrefix,\n silent: userOptions.silent ?? false,\n debug: userOptions.debug ?? false,\n });\n\n try {\n const dotenvFile = fs.readFileSync(path.join(process.cwd(), '.env.sentry-build-plugin'), 'utf-8');\n // NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.\n const dotenvResult = dotenv.parse(dotenvFile);\n\n // Vite has a bug/behaviour where spreading into process.env will cause it to crash\n // https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251\n Object.assign(process.env, dotenvResult);\n\n logger.info('Using environment variables configured in \".env.sentry-build-plugin\".');\n } catch (e: unknown) {\n // Ignore \"file not found\" errors but throw all others\n if (typeof e === 'object' && e && 'code' in e && e.code !== 'ENOENT') {\n throw e;\n }\n }\n\n const options = normalizeUserOptions(userOptions);\n\n if (options.disable) {\n // Early-return a noop build plugin manager instance so that we\n // don't continue validating options, setting up Sentry, etc.\n // Otherwise we might create side-effects or log messages that\n // users don't expect from a disabled plugin.\n return {\n normalizedOptions: options,\n logger,\n bundleSizeOptimizationReplacementValues: {},\n telemetry: {\n emitBundlerPluginExecutionSignal: async () => {\n /* noop */\n },\n },\n bundleMetadata: {},\n createRelease: async () => {\n /* noop */\n },\n uploadSourcemaps: async () => {\n /* noop */\n },\n deleteArtifacts: async () => {\n /* noop */\n },\n createDependencyOnBuildArtifacts: () => () => {\n /* noop */\n },\n injectDebugIds: async () => {\n /* noop */\n },\n };\n }\n\n const shouldSendTelemetry = allowedToSendTelemetry(options);\n const { sentryScope, sentryClient } = createSentryInstance(\n options,\n shouldSendTelemetry,\n bundlerPluginMetaContext.buildTool,\n bundlerPluginMetaContext.buildToolMajorVersion,\n );\n\n const { release, environment = DEFAULT_ENVIRONMENT } = sentryClient.getOptions();\n\n const sentrySession = makeSession({ release, environment });\n sentryScope.setSession(sentrySession);\n // Send the start of the session\n sentryClient.captureSession(sentrySession);\n\n let sessionHasEnded = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out\n\n function endSession(): void {\n if (sessionHasEnded) {\n return;\n }\n\n closeSession(sentrySession);\n sentryClient.captureSession(sentrySession);\n sessionHasEnded = true;\n }\n\n // We also need to manually end sessions on errors because beforeExit is not called on crashes\n process.on('beforeExit', () => {\n endSession();\n });\n\n // Set the User-Agent that Sentry CLI will use when interacting with Sentry\n process.env['SENTRY_PIPELINE'] = `${bundlerPluginMetaContext.buildTool}-plugin/${LIB_VERSION}`;\n\n // Propagate debug flag to Sentry CLI via environment variable\n // Only set if not already defined to respect user's explicit configuration\n if (options.debug && !process.env['SENTRY_LOG_LEVEL']) {\n process.env['SENTRY_LOG_LEVEL'] = 'debug';\n }\n\n // Not a bulletproof check but should be good enough to at least sometimes determine\n // if the plugin is called in dev/watch mode or for a prod build. The important part\n // here is to avoid a false positive. False negatives are okay.\n const isDevMode = process.env['NODE_ENV'] === 'development';\n\n /**\n * Handles errors caught and emitted in various areas of the plugin.\n *\n * Also sets the sentry session status according to the error handling.\n *\n * If users specify their custom `errorHandler` we'll leave the decision to throw\n * or continue up to them. By default, @param throwByDefault controls if the plugin\n * should throw an error (which causes a build fail in most bundlers) or continue.\n */\n function handleRecoverableError(unknownError: unknown, throwByDefault: boolean): void {\n sentrySession.status = 'abnormal';\n try {\n if (options.errorHandler) {\n try {\n if (unknownError instanceof Error) {\n options.errorHandler(unknownError);\n } else {\n options.errorHandler(new Error('An unknown error occurred'));\n }\n } catch (e) {\n sentrySession.status = 'crashed';\n throw e;\n }\n } else {\n // setting the session to \"crashed\" b/c from a plugin perspective this run failed.\n // However, we're intentionally not rethrowing the error to avoid breaking the user build.\n sentrySession.status = 'crashed';\n if (throwByDefault) {\n throw unknownError;\n }\n logger.error(\"An error occurred. Couldn't finish all operations:\", unknownError);\n }\n } finally {\n endSession();\n }\n }\n\n if (!validateOptions(options, logger)) {\n // Throwing by default to avoid a misconfigured plugin going unnoticed.\n handleRecoverableError(new Error('Options were not set correctly. See output above for more details.'), true);\n }\n\n // We have multiple plugins depending on generated source map files. (debug ID upload, legacy upload)\n // Additionally, we also want to have the functionality to delete files after uploading sourcemaps.\n // All of these plugins and the delete functionality need to run in the same hook (`writeBundle`).\n // Since the plugins among themselves are not aware of when they run and finish, we need a system to\n // track their dependencies on the generated files, so that we can initiate the file deletion only after\n // nothing depends on the files anymore.\n const dependenciesOnBuildArtifacts = new Set<symbol>();\n const buildArtifactsDependencySubscribers: (() => void)[] = [];\n\n function notifyBuildArtifactDependencySubscribers(): void {\n buildArtifactsDependencySubscribers.forEach(subscriber => {\n subscriber();\n });\n }\n\n function createDependencyOnBuildArtifacts(): () => void {\n const dependencyIdentifier = Symbol();\n dependenciesOnBuildArtifacts.add(dependencyIdentifier);\n\n return function freeDependencyOnBuildArtifacts() {\n dependenciesOnBuildArtifacts.delete(dependencyIdentifier);\n notifyBuildArtifactDependencySubscribers();\n };\n }\n\n /**\n * Returns a Promise that resolves when all the currently active dependencies are freed again.\n *\n * It is very important that this function is called as late as possible before wanting to await the Promise to give\n * the dependency producers as much time as possible to register themselves.\n */\n function waitUntilBuildArtifactDependenciesAreFreed(): Promise<void> {\n return new Promise<void>(resolve => {\n buildArtifactsDependencySubscribers.push(() => {\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n }\n\n const bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags = {};\n if (options.bundleSizeOptimizations) {\n const { bundleSizeOptimizations } = options;\n\n if (bundleSizeOptimizations.excludeDebugStatements) {\n bundleSizeOptimizationReplacementValues['__SENTRY_DEBUG__'] = false;\n }\n if (bundleSizeOptimizations.excludeTracing) {\n bundleSizeOptimizationReplacementValues['__SENTRY_TRACING__'] = false;\n }\n if (bundleSizeOptimizations.excludeChannelInjection) {\n bundleSizeOptimizationReplacementValues['__SENTRY_CHANNEL_INJECTION__'] = false;\n }\n if (bundleSizeOptimizations.excludeReplayCanvas) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_CANVAS__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayIframe) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_IFRAME__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayShadowDom) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_SHADOW_DOM__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayWorker) {\n bundleSizeOptimizationReplacementValues['__SENTRY_EXCLUDE_REPLAY_WORKER__'] = true;\n }\n }\n\n let bundleMetadata: Record<string, unknown> = {};\n if (options.moduleMetadata || options.applicationKey) {\n if (options.applicationKey) {\n // We use different keys so that if user-code receives multiple bundling passes, we will store the application keys of all the passes.\n // It is a bit unfortunate that we have to inject the metadata snippet at the top, because after multiple\n // injections, the first injection will always \"win\" because it comes last in the code. We would generally be\n // fine with making the last bundling pass win. But because it cannot win, we have to use a workaround of storing\n // the app keys in different object keys.\n // We can simply use the `_sentryBundlerPluginAppKey:` to filter for app keys in the SDK.\n bundleMetadata[`_sentryBundlerPluginAppKey:${options.applicationKey}`] = true;\n }\n\n if (typeof options.moduleMetadata === 'function') {\n const args = {\n org: options.org,\n project: getProjects(options.project)?.[0],\n projects: getProjects(options.project),\n release: options.release.name,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata(args) };\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata };\n }\n }\n\n return {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger,\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: options,\n\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues,\n\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata,\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n async emitBundlerPluginExecutionSignal() {\n if (await shouldSendTelemetry) {\n logger.info(\n 'Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.',\n );\n startSpan({ name: 'Sentry Bundler Plugin execution', scope: sentryScope }, () => {\n //\n });\n await safeFlushTelemetry(sentryClient);\n }\n },\n },\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n async createRelease() {\n if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not create release. Please set the `release.name` option to identify your release.',\n );\n return;\n } else if (isDevMode) {\n logger.debug('Running in development mode. Will not create release.');\n return;\n } else if (!options.authToken) {\n logger.warn(\n `No auth token provided. Will not create release. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return;\n } else if (!options.org && !options.authToken.startsWith('sntrys_')) {\n logger.warn(\n `No organization slug provided. Will not create release. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return;\n } else if (!options.project || (Array.isArray(options.project) && options.project.length === 0)) {\n logger.warn(\n `No project provided. Will not create release. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return;\n }\n\n // It is possible that this writeBundle hook is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();\n\n // Guaranteed to be set by the guard clause above.\n const releaseName = options.release.name;\n\n try {\n const cliInstance = new SentryCliAdapter(options);\n\n if (options.release.create) {\n const releaseOutput = await cliInstance.createRelease(releaseName);\n logger.debug('Release created:', releaseOutput);\n }\n\n if (options.release.uploadLegacySourcemaps) {\n const uploadTargets = arrayify(options.release.uploadLegacySourcemaps)\n .map(includeItem => (typeof includeItem === 'string' ? { paths: [includeItem] } : includeItem))\n .flatMap(includeEntry =>\n includeEntry.paths.map(directory => ({\n directory,\n dist: options.release.dist,\n ext: includeEntry.ext\n ? includeEntry.ext.map(extension => `.${extension.replace(/^\\./, '')}`)\n : ['.js', '.map', '.jsbundle', '.bundle'],\n // The old CLI only skipped `node_modules` when neither ignore source was configured.\n ignore: includeEntry.ignore\n ? arrayify(includeEntry.ignore)\n : includeEntry.ignoreFile\n ? undefined\n : ['node_modules'],\n ignoreFile: includeEntry.ignoreFile,\n urlPrefix: includeEntry.urlPrefix,\n })),\n );\n\n await cliInstance.uploadSourcemaps(releaseName, uploadTargets);\n }\n\n if (options.release.setCommits !== false) {\n try {\n await cliInstance.setCommits(\n releaseName,\n // set commits always exists due to the normalize function\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n options.release.setCommits!,\n );\n } catch (e) {\n // shouldNotThrowOnFailure being present means that the plugin defaulted to `{ auto: true }` for the setCommitsOptions, meaning that wee should not throw when CLI throws because there is no repo\n if (\n options.release.setCommits &&\n 'shouldNotThrowOnFailure' in options.release.setCommits &&\n options.release.setCommits.shouldNotThrowOnFailure\n ) {\n logger.debug(\n 'An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):',\n e,\n );\n } else {\n throw e;\n }\n }\n }\n\n if (options.release.finalize) {\n await cliInstance.finalizeRelease(releaseName);\n }\n\n if (options.release.deploy && !_deployedReleases.has(releaseName)) {\n await cliInstance.newDeploy(releaseName, options.release.deploy);\n _deployedReleases.add(releaseName);\n }\n } catch (e) {\n sentryScope.captureException('Error in \"releaseManagementPlugin\" writeBundle hook');\n await safeFlushTelemetry(sentryClient);\n handleRecoverableError(e, false);\n } finally {\n freeWriteBundleInvocationDependencyOnSourcemapFiles();\n }\n },\n\n /*\n Injects debug IDs into the build artifacts.\n\n This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n async injectDebugIds(buildArtifactPaths: string[]) {\n // oxlint-disable-next-line typescript/no-deprecated\n await startSpan({ name: 'inject-debug-ids', scope: sentryScope, forceTransaction: true }, async () => {\n try {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.injectDebugIds(buildArtifactPaths, options.sourcemaps?.ignore);\n } catch (e) {\n sentryScope.captureException('Error in \"debugIdInjectionPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n await safeFlushTelemetry(sentryClient);\n }\n });\n },\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method.\n *\n * By default, this prepares bundles in a temporary folder before uploading. You can opt into an\n * in-place, direct upload path by setting `prepareArtifacts` to `false`. If `prepareArtifacts` is set to\n * `false`, no preparation (e.g. adding `//# debugId=...` and writing adjusted source maps) is performed and no temp folder is used.\n *\n * @param buildArtifactPaths - The paths of the build artifacts to upload\n * @param opts - Optional flags to control temp folder usage and preparation\n */\n async uploadSourcemaps(buildArtifactPaths: string[], opts?: { prepareArtifacts?: boolean }) {\n if (!canUploadSourceMaps(options, logger, isDevMode)) {\n return;\n }\n\n // Early exit if assets is explicitly set to an empty array\n const assets = options.sourcemaps?.assets;\n if (Array.isArray(assets) && assets.length === 0) {\n logger.debug('Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.');\n return;\n }\n\n await startSpan(\n // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.\n // oxlint-disable-next-line typescript/no-deprecated\n { name: 'debug-id-sourcemap-upload', scope: sentryScope, forceTransaction: true },\n async () => {\n // If we're not using a temp folder, we must not prepare artifacts in-place (to avoid mutating user files)\n const shouldPrepare = opts?.prepareArtifacts ?? true;\n\n let folderToCleanUp: string | undefined;\n\n // It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n\n try {\n if (!shouldPrepare) {\n // Direct CLI upload from existing artifact paths (no globbing, no preparation)\n let pathsToUpload: string[];\n\n if (assets) {\n pathsToUpload = Array.isArray(assets) ? assets : [assets];\n logger.debug(\n `Direct upload mode: passing user-provided assets directly to CLI: ${pathsToUpload.join(', ')}`,\n );\n } else {\n // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done\n pathsToUpload = buildArtifactPaths;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(\n options.release.name ?? 'undefined',\n pathsToUpload.map(directory => ({\n directory,\n dist: options.release.dist,\n ignore: options.sourcemaps?.ignore,\n })),\n );\n });\n\n logger.info('Successfully uploaded source maps to Sentry');\n } else {\n // Prepare artifacts in temp folder before uploading\n let globAssets: string | string[];\n if (assets) {\n globAssets = assets;\n } else {\n logger.debug(\n 'No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.',\n );\n globAssets = buildArtifactPaths;\n }\n\n const globResult = await startSpan({ name: 'glob', scope: sentryScope }, async () =>\n globFiles(globAssets, { ignore: options.sourcemaps?.ignore }),\n );\n\n const debugIdChunkFilePaths = globResult.filter(debugIdChunkFilePath => {\n return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\\.(js|mjs|cjs)$/);\n });\n\n // The order of the files output by glob() is not deterministic\n // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent\n debugIdChunkFilePaths.sort();\n\n if (debugIdChunkFilePaths.length === 0) {\n logger.warn(\n \"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.\",\n );\n } else {\n const tmpUploadFolder = await startSpan({ name: 'mkdtemp', scope: sentryScope }, async () => {\n return (\n process.env?.['SENTRY_TEST_OVERRIDE_TEMP_DIR'] ||\n (await fs.promises.mkdtemp(path.join(os.tmpdir(), 'sentry-bundler-plugin-upload-')))\n );\n });\n folderToCleanUp = tmpUploadFolder;\n\n // Prepare into temp folder, then upload\n await startSpan({ name: 'prepare-bundles', scope: sentryScope }, async prepBundlesSpan => {\n // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so\n // instead we do it with a maximum of 16 concurrent workers\n const preparationTasks = debugIdChunkFilePaths.map((chunkFilePath, chunkIndex) => async () => {\n await prepareBundleForDebugIdUpload(\n chunkFilePath,\n tmpUploadFolder,\n chunkIndex,\n logger,\n options.sourcemaps?.rewriteSources ?? defaultRewriteSourcesHook,\n options.sourcemaps?.resolveSourceMap,\n );\n });\n const workers: Promise<void>[] = [];\n const worker = async (): Promise<void> => {\n while (preparationTasks.length > 0) {\n const task = preparationTasks.shift();\n if (task) {\n await task();\n }\n }\n };\n for (let workerIndex = 0; workerIndex < 16; workerIndex++) {\n workers.push(worker());\n }\n\n await Promise.all(workers);\n\n const files = await fs.promises.readdir(tmpUploadFolder);\n const stats = files.map(file => fs.promises.stat(path.join(tmpUploadFolder, file)));\n const uploadSize = (await Promise.all(stats)).reduce(\n (accumulator, { size }) => accumulator + size,\n 0,\n );\n\n setMeasurement('files', files.length, 'none', prepBundlesSpan);\n setMeasurement('upload_size', uploadSize, 'byte', prepBundlesSpan);\n\n // Preparation produced no artifacts, meaning none of the\n // matched bundles had an associated source map. This almost\n // always means source map generation is turned off in the\n // bundler, so warn instead of silently reporting success.\n if (files.length === 0) {\n logger.warn(\n `No source maps found for any of the ${debugIdChunkFilePaths.length} matched build ` +\n 'artifacts, so no source maps were uploaded to Sentry. This usually means source map ' +\n 'generation is not enabled in your bundler. Enable it so Sentry can un-minify your stack traces.',\n );\n return;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(options.release.name ?? 'undefined', [\n {\n directory: tmpUploadFolder,\n dist: options.release.dist,\n },\n ]);\n });\n\n // this must be in the method so that the \"no sourcemaps\"\n // early return doesn't also log success.\n logger.info('Successfully uploaded source maps to Sentry');\n });\n }\n }\n } catch (e) {\n sentryScope.captureException('Error in \"debugIdUploadPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n if (folderToCleanUp && !process.env?.['SENTRY_TEST_OVERRIDE_TEMP_DIR']) {\n logger.debug('Cleaning up temporary files...');\n try {\n await startSpan({ name: 'cleanup', scope: sentryScope }, async () => {\n if (folderToCleanUp) {\n await fs.promises.rm(folderToCleanUp, { recursive: true, force: true });\n logger.debug(`Temporary folder deleted: ${folderToCleanUp}`);\n }\n });\n } catch (e) {\n // A failed cleanup must not skip the teardown steps below (freeing upload\n // dependencies, flushing telemetry), so swallow and log instead of rethrowing.\n logger.debug('Failed to clean up temporary folder:', e);\n }\n }\n logger.debug('Freeing upload dependencies...');\n freeUploadDependencyOnBuildArtifacts();\n logger.debug('Flushing telemetry data...');\n await safeFlushTelemetry(sentryClient);\n logger.debug('Telemetry flushed. Plugin upload process complete.');\n }\n },\n );\n },\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n async deleteArtifacts() {\n try {\n const filesToDelete = await options.sourcemaps?.filesToDeleteAfterUpload;\n if (filesToDelete !== undefined) {\n const filePathsToDelete = await globFiles(filesToDelete);\n\n logger.debug('Waiting for dependencies on generated files to be freed before deleting...');\n\n await waitUntilBuildArtifactDependenciesAreFreed();\n\n filePathsToDelete.forEach(filePathToDelete => {\n logger.debug(`Deleting asset after upload: ${filePathToDelete}`);\n });\n\n await Promise.all(\n filePathsToDelete.map(filePathToDelete =>\n fs.promises.rm(filePathToDelete, { force: true }).catch(e => {\n // This is allowed to fail - we just don't do anything\n logger.debug(`An error occurred while attempting to delete asset: ${filePathToDelete}`, e);\n }),\n ),\n );\n }\n } catch (e) {\n sentryScope.captureException('Error in \"sentry-file-deletion-plugin\" buildEnd hook');\n await safeFlushTelemetry(sentryClient);\n // We throw by default if we get here b/c not being able to delete\n // source maps could leak them to production\n handleRecoverableError(e, true);\n }\n },\n createDependencyOnBuildArtifacts,\n };\n}\n\nfunction canUploadSourceMaps(options: NormalizedOptions, logger: Logger, isDevMode: boolean): boolean {\n if (options.sourcemaps?.disable) {\n logger.debug('Source map upload was disabled. Will not upload sourcemaps using debug ID process.');\n return false;\n }\n if (isDevMode) {\n logger.debug('Running in development mode. Will not upload sourcemaps.');\n return false;\n }\n if (!options.authToken) {\n logger.warn(\n `No auth token provided. Will not upload source maps. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return false;\n }\n if (!options.org && !options.authToken.startsWith('sntrys_')) {\n logger.warn(\n `No org provided. Will not upload source maps. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return false;\n }\n if (!getProjects(options.project)?.[0]) {\n logger.warn(\n `No project provided. Will not upload source maps. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return false;\n }\n\n return true;\n}\n"],"names":["logger","createLogger","fs","path","dotenv","normalizeUserOptions","allowedToSendTelemetry","createSentryInstance","DEFAULT_ENVIRONMENT","makeSession","closeSession","LIB_VERSION","validateOptions","getProjects","startSpan","safeFlushTelemetry","getTurborepoEnvPassthroughWarning","SentryCliAdapter","arrayify","globFiles","stripQueryAndHashFromPath","os","prepareBundleForDebugIdUpload","defaultRewriteSourcesHook","setMeasurement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,iBAAA,uBAAwB,GAAA,EAAY;AA4EnC,SAAS,8BAAA,CACd,aACA,wBAAA,EAc0B;AAC1B,EAAA,MAAMA,WAASC,mBAAA,CAAa;AAAA,IAC1B,QAAQ,wBAAA,CAAyB,YAAA;AAAA,IACjC,MAAA,EAAQ,YAAY,MAAA,IAAU,KAAA;AAAA,IAC9B,KAAA,EAAO,YAAY,KAAA,IAAS;AAAA,GAC7B,CAAA;AAED,EAAA,IAAI;AACF,IAAA,MAAM,UAAA,GAAaC,aAAA,CAAG,YAAA,CAAaC,eAAA,CAAK,IAAA,CAAK,QAAQ,GAAA,EAAI,EAAG,0BAA0B,CAAA,EAAG,OAAO,CAAA;AAEhG,IAAA,MAAM,YAAA,GAAeC,iBAAA,CAAO,KAAA,CAAM,UAAU,CAAA;AAI5C,IAAA,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,GAAA,EAAK,YAAY,CAAA;AAEvC,IAAAJ,QAAA,CAAO,KAAK,uEAAuE,CAAA;AAAA,EACrF,SAAS,CAAA,EAAY;AAEnB,IAAA,IAAI,OAAO,MAAM,QAAA,IAAY,CAAA,IAAK,UAAU,CAAA,IAAK,CAAA,CAAE,SAAS,QAAA,EAAU;AACpE,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF;AAEA,EAAA,MAAM,OAA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EACT;AACA,EAAA,IAAI,CAAC,QAAQ,GAAA,IAAO,CAAC,QAAQ,SAAA,CAAU,UAAA,CAAW,SAAS,CAAA,EAAG;AAC5D,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,6GAAA,EAAgHA,uCAAA,CAAkC,YAAY,CAAC,CAAA;AAAA,KACjK;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,CAACH,iBAAA,CAAY,OAAA,CAAQ,OAAO,CAAA,GAAI,CAAC,CAAA,EAAG;AACtC,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,gHAAA,EAAmHG,uCAAA,CAAkC,gBAAgB,CAAC,CAAA;AAAA,KACxK;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT;;;;"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
|
+
const server = require('@sentry/core/server');
|
|
4
5
|
const optionsMapping = require('../options-mapping.js');
|
|
5
6
|
const transports = require('./transports.js');
|
|
6
7
|
const cli = require('../cli.js');
|
|
7
8
|
const version = require('../version.js');
|
|
8
9
|
|
|
9
10
|
const SENTRY_SAAS_HOSTNAME = "sentry.io";
|
|
10
|
-
const stackParser = core.createStackParser(
|
|
11
|
+
const stackParser = core.createStackParser(server.nodeStackLineParser());
|
|
11
12
|
function createSentryInstance(options, shouldSendTelemetry, buildTool, buildToolMajorVersion) {
|
|
12
13
|
const clientOptions = {
|
|
13
14
|
platform: "node",
|
|
@@ -38,7 +39,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool, buildTool
|
|
|
38
39
|
transport: transports.makeOptionallyEnabledNodeTransport(shouldSendTelemetry)
|
|
39
40
|
};
|
|
40
41
|
core.applySdkMetadata(clientOptions, "node");
|
|
41
|
-
const client = new
|
|
42
|
+
const client = new server.ServerRuntimeClient(clientOptions);
|
|
42
43
|
const scope = new core.Scope();
|
|
43
44
|
scope.setClient(client);
|
|
44
45
|
setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersion);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sources":["../../../../src/core/sentry/telemetry.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport type { ServerRuntimeClientOptions } from '@sentry/core';\nimport { applySdkMetadata
|
|
1
|
+
{"version":3,"file":"telemetry.js","sources":["../../../../src/core/sentry/telemetry.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport type { ServerRuntimeClientOptions } from '@sentry/core/server';\nimport { applySdkMetadata } from '@sentry/core';\nimport { ServerRuntimeClient } from '@sentry/core/server';\nimport type { NormalizedOptions } from '../options-mapping';\nimport { SENTRY_SAAS_URL } from '../options-mapping';\nimport { Scope } from '@sentry/core';\nimport { createStackParser } from '@sentry/core';\nimport { nodeStackLineParser } from '@sentry/core/server';\nimport { makeOptionallyEnabledNodeTransport } from './transports';\nimport { SentryCliAdapter } from '../cli';\nimport { LIB_VERSION } from '../version';\n\nconst SENTRY_SAAS_HOSTNAME = 'sentry.io';\n\nconst stackParser = createStackParser(nodeStackLineParser());\n\nexport function createSentryInstance(\n options: NormalizedOptions,\n shouldSendTelemetry: Promise<boolean>,\n buildTool: string,\n buildToolMajorVersion: string | undefined,\n): { sentryScope: Scope; sentryClient: Client } {\n const clientOptions: ServerRuntimeClientOptions = {\n platform: 'node',\n runtime: { name: 'node', version: global.process.version },\n\n dsn: 'https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737',\n\n tracesSampleRate: 1,\n traceLifecycle: 'static',\n sampleRate: 1,\n\n release: LIB_VERSION,\n integrations: [],\n tracePropagationTargets: ['sentry.io/api'],\n\n stackParser,\n\n beforeSend: event => {\n event.exception?.values?.forEach(exception => {\n delete exception.stacktrace;\n });\n\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // Deprecated, but still applied because this client runs on the static trace lifecycle.\n // oxlint-disable-next-line typescript/no-deprecated\n beforeSendTransaction: event => {\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told\n // us that the upload URL is the Sentry SaaS URL)\n transport: makeOptionallyEnabledNodeTransport(shouldSendTelemetry),\n };\n\n applySdkMetadata(clientOptions, 'node');\n\n const client = new ServerRuntimeClient(clientOptions);\n const scope = new Scope();\n scope.setClient(client);\n\n setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersion);\n\n return { sentryScope: scope, sentryClient: client };\n}\n\nexport function setTelemetryDataOnScope(\n options: NormalizedOptions,\n scope: Scope,\n buildTool: string,\n buildToolMajorVersion?: string,\n): void {\n const { org, project, release, errorHandler, sourcemaps, reactComponentAnnotation } = options;\n\n scope.setTag('upload-legacy-sourcemaps', !!release.uploadLegacySourcemaps);\n if (release.uploadLegacySourcemaps) {\n scope.setTag(\n 'uploadLegacySourcemapsEntries',\n Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1,\n );\n }\n\n scope.setTag('module-metadata', !!options.moduleMetadata);\n scope.setTag('inject-build-information', !!options._experiments.injectBuildInformation);\n\n // Optional release pipeline steps\n if (release.setCommits) {\n scope.setTag('set-commits', release.setCommits.auto === true ? 'auto' : 'manual');\n } else {\n scope.setTag('set-commits', 'undefined');\n }\n scope.setTag('finalize-release', release.finalize);\n scope.setTag('deploy-options', !!release.deploy);\n\n // Miscellaneous options\n scope.setTag('custom-error-handler', !!errorHandler);\n scope.setTag('sourcemaps-assets', !!sourcemaps?.assets);\n scope.setTag('delete-after-upload', !!sourcemaps?.filesToDeleteAfterUpload);\n scope.setTag('sourcemaps-disabled', !!sourcemaps?.disable);\n\n scope.setTag('react-annotate', !!reactComponentAnnotation?.enabled);\n\n scope.setTag('node', process.version);\n scope.setTag('platform', process.platform);\n\n scope.setTag('meta-framework', options._metaOptions.telemetry.metaFramework ?? 'none');\n\n scope.setTag('application-key-set', options.applicationKey !== undefined);\n\n scope.setTag('ci', !!process.env['CI']);\n\n scope.setTags({\n organization: org,\n project: Array.isArray(project) ? project.join(', ') : (project ?? 'undefined'),\n bundler: buildTool,\n });\n\n if (buildToolMajorVersion) {\n scope.setTag('bundler-major-version', buildToolMajorVersion);\n }\n\n scope.setUser({ id: org });\n}\n\nexport async function allowedToSendTelemetry(options: NormalizedOptions): Promise<boolean> {\n const { telemetry, url } = options;\n\n // `options.telemetry` defaults to true\n if (telemetry === false) {\n return false;\n }\n\n if (url === SENTRY_SAAS_URL) {\n return true;\n }\n\n // Ask the CLI which Sentry server URL it resolves to. This can differ from the default (or the\n // configured `url`) because the CLI also honors a possibly existing `.sentryclirc` file.\n const cliInfoUrl = await new SentryCliAdapter(options).getServerUrl();\n\n if (cliInfoUrl === undefined) {\n return false;\n }\n\n return new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME;\n}\n\n/**\n * Flushing the SDK client can fail. We never want to crash the plugin because of telemetry.\n */\nexport async function safeFlushTelemetry(sentryClient: Client): Promise<void> {\n try {\n await sentryClient.flush(2000);\n } catch {\n // Noop when flushing fails.\n // We don't even need to log anything because there's likely nothing the user can do and they likely will not care.\n }\n}\n"],"names":["createStackParser","nodeStackLineParser","LIB_VERSION","makeOptionallyEnabledNodeTransport","applySdkMetadata","ServerRuntimeClient","Scope","SENTRY_SAAS_URL","SentryCliAdapter"],"mappings":";;;;;;;;;AAaA,MAAM,oBAAA,GAAuB,WAAA;AAE7B,MAAM,WAAA,GAAcA,sBAAA,CAAkBC,0BAAA,EAAqB,CAAA;AAEpD,SAAS,oBAAA,CACd,OAAA,EACA,mBAAA,EACA,SAAA,EACA,qBAAA,EAC8C;AAC9C,EAAA,MAAM,aAAA,GAA4C;AAAA,IAChD,QAAA,EAAU,MAAA;AAAA,IACV,SAAS,EAAE,IAAA,EAAM,QAAQ,OAAA,EAAS,MAAA,CAAO,QAAQ,OAAA,EAAQ;AAAA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O,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAI,GAAA,CAAI,UAAU,CAAA,CAAE,QAAA,KAAa,oBAAA;AAC1C;AAKA,eAAsB,mBAAmB,YAAA,EAAqC;AAC5E,EAAA,IAAI;AACF,IAAA,MAAM,YAAA,CAAa,MAAM,GAAI,CAAA;AAAA,EAC/B,CAAA,CAAA,MAAQ;AAAA,EAGR;AACF;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.0.0-
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.0.0-beta.1\";\n"],"names":[],"mappings":";;AAAO,MAAM,WAAA,GAAc;;;;"}
|
|
@@ -345,6 +345,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
|
|
|
345
345
|
}
|
|
346
346
|
await startSpan(
|
|
347
347
|
// This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
|
|
348
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
348
349
|
{ name: "debug-id-sourcemap-upload", scope: sentryScope, forceTransaction: true },
|
|
349
350
|
async () => {
|
|
350
351
|
const shouldPrepare = opts?.prepareArtifacts ?? true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-plugin-manager.js","sources":["../../../src/core/build-plugin-manager.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport { closeSession, DEFAULT_ENVIRONMENT, makeSession, setMeasurement, startSpan } from '@sentry/core';\nimport * as dotenv from 'dotenv';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { SentryCliAdapter } from './cli';\nimport type { NormalizedOptions } from './options-mapping';\nimport { normalizeUserOptions, validateOptions } from './options-mapping';\nimport type { Logger } from './logger';\nimport { createLogger } from './logger';\nimport { allowedToSendTelemetry, createSentryInstance, safeFlushTelemetry } from './sentry/telemetry';\nimport type { Options, SentrySDKBuildFlags } from './types';\nimport { arrayify, getProjects, getTurborepoEnvPassthroughWarning, stripQueryAndHashFromPath } from './utils';\nimport { defaultRewriteSourcesHook, prepareBundleForDebugIdUpload } from './debug-id-upload';\nimport { globFiles } from './glob';\nimport { LIB_VERSION } from './version';\n\n// Module-level guard to prevent duplicate deploy records when multiple bundler plugin\n// instances run in the same process (e.g. Next.js creates separate webpack compilers\n// for client, server, and edge). Keyed by release name.\nconst _deployedReleases = new Set<string>();\n\n/** @internal Exported for testing only. */\nexport function _resetDeployedReleasesForTesting(): void {\n _deployedReleases.clear();\n}\n\nexport type SentryBuildPluginManager = {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger: Logger;\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: NormalizedOptions;\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags;\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata: Record<string, unknown>;\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n emitBundlerPluginExecutionSignal(): Promise<void>;\n };\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n createRelease(): Promise<void>;\n\n /**\n * Injects debug IDs into the build artifacts.\n *\n * This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n * Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n * Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n injectDebugIds(buildArtifactPaths: string[]): Promise<void>;\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method. This function takes a list of build artifact paths that will be uploaded\n */\n uploadSourcemaps(buildArtifactPaths: string[], opts?: { prepareArtifacts?: boolean }): Promise<void>;\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n deleteArtifacts(): Promise<void>;\n\n createDependencyOnBuildArtifacts: () => () => void;\n};\n\n/**\n * Creates a build plugin manager that exposes primitives for everything that a Sentry JavaScript SDK or build tooling may do during a build.\n *\n * The build plugin manager's behavior strongly depends on the options that are passed in.\n */\nexport function createSentryBuildPluginManager(\n userOptions: Options,\n bundlerPluginMetaContext: {\n /**\n * E.g. `webpack` or `nextjs` or `turbopack`\n */\n buildTool: string;\n /**\n * E.g. `5` for webpack v5 or `4` for Rollup v4\n */\n buildToolMajorVersion?: string;\n /**\n * E.g. `[sentry-webpack-plugin]` or `[@sentry/nextjs]`\n */\n loggerPrefix: string;\n },\n): SentryBuildPluginManager {\n const logger = createLogger({\n prefix: bundlerPluginMetaContext.loggerPrefix,\n silent: userOptions.silent ?? false,\n debug: userOptions.debug ?? false,\n });\n\n try {\n const dotenvFile = fs.readFileSync(path.join(process.cwd(), '.env.sentry-build-plugin'), 'utf-8');\n // NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.\n const dotenvResult = dotenv.parse(dotenvFile);\n\n // Vite has a bug/behaviour where spreading into process.env will cause it to crash\n // https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251\n Object.assign(process.env, dotenvResult);\n\n logger.info('Using environment variables configured in \".env.sentry-build-plugin\".');\n } catch (e: unknown) {\n // Ignore \"file not found\" errors but throw all others\n if (typeof e === 'object' && e && 'code' in e && e.code !== 'ENOENT') {\n throw e;\n }\n }\n\n const options = normalizeUserOptions(userOptions);\n\n if (options.disable) {\n // Early-return a noop build plugin manager instance so that we\n // don't continue validating options, setting up Sentry, etc.\n // Otherwise we might create side-effects or log messages that\n // users don't expect from a disabled plugin.\n return {\n normalizedOptions: options,\n logger,\n bundleSizeOptimizationReplacementValues: {},\n telemetry: {\n emitBundlerPluginExecutionSignal: async () => {\n /* noop */\n },\n },\n bundleMetadata: {},\n createRelease: async () => {\n /* noop */\n },\n uploadSourcemaps: async () => {\n /* noop */\n },\n deleteArtifacts: async () => {\n /* noop */\n },\n createDependencyOnBuildArtifacts: () => () => {\n /* noop */\n },\n injectDebugIds: async () => {\n /* noop */\n },\n };\n }\n\n const shouldSendTelemetry = allowedToSendTelemetry(options);\n const { sentryScope, sentryClient } = createSentryInstance(\n options,\n shouldSendTelemetry,\n bundlerPluginMetaContext.buildTool,\n bundlerPluginMetaContext.buildToolMajorVersion,\n );\n\n const { release, environment = DEFAULT_ENVIRONMENT } = sentryClient.getOptions();\n\n const sentrySession = makeSession({ release, environment });\n sentryScope.setSession(sentrySession);\n // Send the start of the session\n sentryClient.captureSession(sentrySession);\n\n let sessionHasEnded = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out\n\n function endSession(): void {\n if (sessionHasEnded) {\n return;\n }\n\n closeSession(sentrySession);\n sentryClient.captureSession(sentrySession);\n sessionHasEnded = true;\n }\n\n // We also need to manually end sessions on errors because beforeExit is not called on crashes\n process.on('beforeExit', () => {\n endSession();\n });\n\n // Set the User-Agent that Sentry CLI will use when interacting with Sentry\n process.env['SENTRY_PIPELINE'] = `${bundlerPluginMetaContext.buildTool}-plugin/${LIB_VERSION}`;\n\n // Propagate debug flag to Sentry CLI via environment variable\n // Only set if not already defined to respect user's explicit configuration\n if (options.debug && !process.env['SENTRY_LOG_LEVEL']) {\n process.env['SENTRY_LOG_LEVEL'] = 'debug';\n }\n\n // Not a bulletproof check but should be good enough to at least sometimes determine\n // if the plugin is called in dev/watch mode or for a prod build. The important part\n // here is to avoid a false positive. False negatives are okay.\n const isDevMode = process.env['NODE_ENV'] === 'development';\n\n /**\n * Handles errors caught and emitted in various areas of the plugin.\n *\n * Also sets the sentry session status according to the error handling.\n *\n * If users specify their custom `errorHandler` we'll leave the decision to throw\n * or continue up to them. By default, @param throwByDefault controls if the plugin\n * should throw an error (which causes a build fail in most bundlers) or continue.\n */\n function handleRecoverableError(unknownError: unknown, throwByDefault: boolean): void {\n sentrySession.status = 'abnormal';\n try {\n if (options.errorHandler) {\n try {\n if (unknownError instanceof Error) {\n options.errorHandler(unknownError);\n } else {\n options.errorHandler(new Error('An unknown error occurred'));\n }\n } catch (e) {\n sentrySession.status = 'crashed';\n throw e;\n }\n } else {\n // setting the session to \"crashed\" b/c from a plugin perspective this run failed.\n // However, we're intentionally not rethrowing the error to avoid breaking the user build.\n sentrySession.status = 'crashed';\n if (throwByDefault) {\n throw unknownError;\n }\n logger.error(\"An error occurred. Couldn't finish all operations:\", unknownError);\n }\n } finally {\n endSession();\n }\n }\n\n if (!validateOptions(options, logger)) {\n // Throwing by default to avoid a misconfigured plugin going unnoticed.\n handleRecoverableError(new Error('Options were not set correctly. See output above for more details.'), true);\n }\n\n // We have multiple plugins depending on generated source map files. (debug ID upload, legacy upload)\n // Additionally, we also want to have the functionality to delete files after uploading sourcemaps.\n // All of these plugins and the delete functionality need to run in the same hook (`writeBundle`).\n // Since the plugins among themselves are not aware of when they run and finish, we need a system to\n // track their dependencies on the generated files, so that we can initiate the file deletion only after\n // nothing depends on the files anymore.\n const dependenciesOnBuildArtifacts = new Set<symbol>();\n const buildArtifactsDependencySubscribers: (() => void)[] = [];\n\n function notifyBuildArtifactDependencySubscribers(): void {\n buildArtifactsDependencySubscribers.forEach(subscriber => {\n subscriber();\n });\n }\n\n function createDependencyOnBuildArtifacts(): () => void {\n const dependencyIdentifier = Symbol();\n dependenciesOnBuildArtifacts.add(dependencyIdentifier);\n\n return function freeDependencyOnBuildArtifacts() {\n dependenciesOnBuildArtifacts.delete(dependencyIdentifier);\n notifyBuildArtifactDependencySubscribers();\n };\n }\n\n /**\n * Returns a Promise that resolves when all the currently active dependencies are freed again.\n *\n * It is very important that this function is called as late as possible before wanting to await the Promise to give\n * the dependency producers as much time as possible to register themselves.\n */\n function waitUntilBuildArtifactDependenciesAreFreed(): Promise<void> {\n return new Promise<void>(resolve => {\n buildArtifactsDependencySubscribers.push(() => {\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n }\n\n const bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags = {};\n if (options.bundleSizeOptimizations) {\n const { bundleSizeOptimizations } = options;\n\n if (bundleSizeOptimizations.excludeDebugStatements) {\n bundleSizeOptimizationReplacementValues['__SENTRY_DEBUG__'] = false;\n }\n if (bundleSizeOptimizations.excludeTracing) {\n bundleSizeOptimizationReplacementValues['__SENTRY_TRACING__'] = false;\n }\n if (bundleSizeOptimizations.excludeChannelInjection) {\n bundleSizeOptimizationReplacementValues['__SENTRY_CHANNEL_INJECTION__'] = false;\n }\n if (bundleSizeOptimizations.excludeReplayCanvas) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_CANVAS__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayIframe) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_IFRAME__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayShadowDom) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_SHADOW_DOM__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayWorker) {\n bundleSizeOptimizationReplacementValues['__SENTRY_EXCLUDE_REPLAY_WORKER__'] = true;\n }\n }\n\n let bundleMetadata: Record<string, unknown> = {};\n if (options.moduleMetadata || options.applicationKey) {\n if (options.applicationKey) {\n // We use different keys so that if user-code receives multiple bundling passes, we will store the application keys of all the passes.\n // It is a bit unfortunate that we have to inject the metadata snippet at the top, because after multiple\n // injections, the first injection will always \"win\" because it comes last in the code. We would generally be\n // fine with making the last bundling pass win. But because it cannot win, we have to use a workaround of storing\n // the app keys in different object keys.\n // We can simply use the `_sentryBundlerPluginAppKey:` to filter for app keys in the SDK.\n bundleMetadata[`_sentryBundlerPluginAppKey:${options.applicationKey}`] = true;\n }\n\n if (typeof options.moduleMetadata === 'function') {\n const args = {\n org: options.org,\n project: getProjects(options.project)?.[0],\n projects: getProjects(options.project),\n release: options.release.name,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata(args) };\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata };\n }\n }\n\n return {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger,\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: options,\n\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues,\n\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata,\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n async emitBundlerPluginExecutionSignal() {\n if (await shouldSendTelemetry) {\n logger.info(\n 'Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.',\n );\n startSpan({ name: 'Sentry Bundler Plugin execution', scope: sentryScope }, () => {\n //\n });\n await safeFlushTelemetry(sentryClient);\n }\n },\n },\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n async createRelease() {\n if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not create release. Please set the `release.name` option to identify your release.',\n );\n return;\n } else if (isDevMode) {\n logger.debug('Running in development mode. Will not create release.');\n return;\n } else if (!options.authToken) {\n logger.warn(\n `No auth token provided. Will not create release. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return;\n } else if (!options.org && !options.authToken.startsWith('sntrys_')) {\n logger.warn(\n `No organization slug provided. Will not create release. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return;\n } else if (!options.project || (Array.isArray(options.project) && options.project.length === 0)) {\n logger.warn(\n `No project provided. Will not create release. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return;\n }\n\n // It is possible that this writeBundle hook is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();\n\n // Guaranteed to be set by the guard clause above.\n const releaseName = options.release.name;\n\n try {\n const cliInstance = new SentryCliAdapter(options);\n\n if (options.release.create) {\n const releaseOutput = await cliInstance.createRelease(releaseName);\n logger.debug('Release created:', releaseOutput);\n }\n\n if (options.release.uploadLegacySourcemaps) {\n const uploadTargets = arrayify(options.release.uploadLegacySourcemaps)\n .map(includeItem => (typeof includeItem === 'string' ? { paths: [includeItem] } : includeItem))\n .flatMap(includeEntry =>\n includeEntry.paths.map(directory => ({\n directory,\n dist: options.release.dist,\n ext: includeEntry.ext\n ? includeEntry.ext.map(extension => `.${extension.replace(/^\\./, '')}`)\n : ['.js', '.map', '.jsbundle', '.bundle'],\n // The old CLI only skipped `node_modules` when neither ignore source was configured.\n ignore: includeEntry.ignore\n ? arrayify(includeEntry.ignore)\n : includeEntry.ignoreFile\n ? undefined\n : ['node_modules'],\n ignoreFile: includeEntry.ignoreFile,\n urlPrefix: includeEntry.urlPrefix,\n })),\n );\n\n await cliInstance.uploadSourcemaps(releaseName, uploadTargets);\n }\n\n if (options.release.setCommits !== false) {\n try {\n await cliInstance.setCommits(\n releaseName,\n // set commits always exists due to the normalize function\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n options.release.setCommits!,\n );\n } catch (e) {\n // shouldNotThrowOnFailure being present means that the plugin defaulted to `{ auto: true }` for the setCommitsOptions, meaning that wee should not throw when CLI throws because there is no repo\n if (\n options.release.setCommits &&\n 'shouldNotThrowOnFailure' in options.release.setCommits &&\n options.release.setCommits.shouldNotThrowOnFailure\n ) {\n logger.debug(\n 'An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):',\n e,\n );\n } else {\n throw e;\n }\n }\n }\n\n if (options.release.finalize) {\n await cliInstance.finalizeRelease(releaseName);\n }\n\n if (options.release.deploy && !_deployedReleases.has(releaseName)) {\n await cliInstance.newDeploy(releaseName, options.release.deploy);\n _deployedReleases.add(releaseName);\n }\n } catch (e) {\n sentryScope.captureException('Error in \"releaseManagementPlugin\" writeBundle hook');\n await safeFlushTelemetry(sentryClient);\n handleRecoverableError(e, false);\n } finally {\n freeWriteBundleInvocationDependencyOnSourcemapFiles();\n }\n },\n\n /*\n Injects debug IDs into the build artifacts.\n\n This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n async injectDebugIds(buildArtifactPaths: string[]) {\n await startSpan({ name: 'inject-debug-ids', scope: sentryScope, forceTransaction: true }, async () => {\n try {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.injectDebugIds(buildArtifactPaths, options.sourcemaps?.ignore);\n } catch (e) {\n sentryScope.captureException('Error in \"debugIdInjectionPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n await safeFlushTelemetry(sentryClient);\n }\n });\n },\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method.\n *\n * By default, this prepares bundles in a temporary folder before uploading. You can opt into an\n * in-place, direct upload path by setting `prepareArtifacts` to `false`. If `prepareArtifacts` is set to\n * `false`, no preparation (e.g. adding `//# debugId=...` and writing adjusted source maps) is performed and no temp folder is used.\n *\n * @param buildArtifactPaths - The paths of the build artifacts to upload\n * @param opts - Optional flags to control temp folder usage and preparation\n */\n async uploadSourcemaps(buildArtifactPaths: string[], opts?: { prepareArtifacts?: boolean }) {\n if (!canUploadSourceMaps(options, logger, isDevMode)) {\n return;\n }\n\n // Early exit if assets is explicitly set to an empty array\n const assets = options.sourcemaps?.assets;\n if (Array.isArray(assets) && assets.length === 0) {\n logger.debug('Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.');\n return;\n }\n\n await startSpan(\n // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.\n { name: 'debug-id-sourcemap-upload', scope: sentryScope, forceTransaction: true },\n async () => {\n // If we're not using a temp folder, we must not prepare artifacts in-place (to avoid mutating user files)\n const shouldPrepare = opts?.prepareArtifacts ?? true;\n\n let folderToCleanUp: string | undefined;\n\n // It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n\n try {\n if (!shouldPrepare) {\n // Direct CLI upload from existing artifact paths (no globbing, no preparation)\n let pathsToUpload: string[];\n\n if (assets) {\n pathsToUpload = Array.isArray(assets) ? assets : [assets];\n logger.debug(\n `Direct upload mode: passing user-provided assets directly to CLI: ${pathsToUpload.join(', ')}`,\n );\n } else {\n // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done\n pathsToUpload = buildArtifactPaths;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(\n options.release.name ?? 'undefined',\n pathsToUpload.map(directory => ({\n directory,\n dist: options.release.dist,\n ignore: options.sourcemaps?.ignore,\n })),\n );\n });\n\n logger.info('Successfully uploaded source maps to Sentry');\n } else {\n // Prepare artifacts in temp folder before uploading\n let globAssets: string | string[];\n if (assets) {\n globAssets = assets;\n } else {\n logger.debug(\n 'No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.',\n );\n globAssets = buildArtifactPaths;\n }\n\n const globResult = await startSpan({ name: 'glob', scope: sentryScope }, async () =>\n globFiles(globAssets, { ignore: options.sourcemaps?.ignore }),\n );\n\n const debugIdChunkFilePaths = globResult.filter(debugIdChunkFilePath => {\n return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\\.(js|mjs|cjs)$/);\n });\n\n // The order of the files output by glob() is not deterministic\n // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent\n debugIdChunkFilePaths.sort();\n\n if (debugIdChunkFilePaths.length === 0) {\n logger.warn(\n \"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.\",\n );\n } else {\n const tmpUploadFolder = await startSpan({ name: 'mkdtemp', scope: sentryScope }, async () => {\n return (\n process.env?.['SENTRY_TEST_OVERRIDE_TEMP_DIR'] ||\n (await fs.promises.mkdtemp(path.join(os.tmpdir(), 'sentry-bundler-plugin-upload-')))\n );\n });\n folderToCleanUp = tmpUploadFolder;\n\n // Prepare into temp folder, then upload\n await startSpan({ name: 'prepare-bundles', scope: sentryScope }, async prepBundlesSpan => {\n // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so\n // instead we do it with a maximum of 16 concurrent workers\n const preparationTasks = debugIdChunkFilePaths.map((chunkFilePath, chunkIndex) => async () => {\n await prepareBundleForDebugIdUpload(\n chunkFilePath,\n tmpUploadFolder,\n chunkIndex,\n logger,\n options.sourcemaps?.rewriteSources ?? defaultRewriteSourcesHook,\n options.sourcemaps?.resolveSourceMap,\n );\n });\n const workers: Promise<void>[] = [];\n const worker = async (): Promise<void> => {\n while (preparationTasks.length > 0) {\n const task = preparationTasks.shift();\n if (task) {\n await task();\n }\n }\n };\n for (let workerIndex = 0; workerIndex < 16; workerIndex++) {\n workers.push(worker());\n }\n\n await Promise.all(workers);\n\n const files = await fs.promises.readdir(tmpUploadFolder);\n const stats = files.map(file => fs.promises.stat(path.join(tmpUploadFolder, file)));\n const uploadSize = (await Promise.all(stats)).reduce(\n (accumulator, { size }) => accumulator + size,\n 0,\n );\n\n setMeasurement('files', files.length, 'none', prepBundlesSpan);\n setMeasurement('upload_size', uploadSize, 'byte', prepBundlesSpan);\n\n // Preparation produced no artifacts, meaning none of the\n // matched bundles had an associated source map. This almost\n // always means source map generation is turned off in the\n // bundler, so warn instead of silently reporting success.\n if (files.length === 0) {\n logger.warn(\n `No source maps found for any of the ${debugIdChunkFilePaths.length} matched build ` +\n 'artifacts, so no source maps were uploaded to Sentry. This usually means source map ' +\n 'generation is not enabled in your bundler. Enable it so Sentry can un-minify your stack traces.',\n );\n return;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(options.release.name ?? 'undefined', [\n {\n directory: tmpUploadFolder,\n dist: options.release.dist,\n },\n ]);\n });\n\n // this must be in the method so that the \"no sourcemaps\"\n // early return doesn't also log success.\n logger.info('Successfully uploaded source maps to Sentry');\n });\n }\n }\n } catch (e) {\n sentryScope.captureException('Error in \"debugIdUploadPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n if (folderToCleanUp && !process.env?.['SENTRY_TEST_OVERRIDE_TEMP_DIR']) {\n logger.debug('Cleaning up temporary files...');\n try {\n await startSpan({ name: 'cleanup', scope: sentryScope }, async () => {\n if (folderToCleanUp) {\n await fs.promises.rm(folderToCleanUp, { recursive: true, force: true });\n logger.debug(`Temporary folder deleted: ${folderToCleanUp}`);\n }\n });\n } catch (e) {\n // A failed cleanup must not skip the teardown steps below (freeing upload\n // dependencies, flushing telemetry), so swallow and log instead of rethrowing.\n logger.debug('Failed to clean up temporary folder:', e);\n }\n }\n logger.debug('Freeing upload dependencies...');\n freeUploadDependencyOnBuildArtifacts();\n logger.debug('Flushing telemetry data...');\n await safeFlushTelemetry(sentryClient);\n logger.debug('Telemetry flushed. Plugin upload process complete.');\n }\n },\n );\n },\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n async deleteArtifacts() {\n try {\n const filesToDelete = await options.sourcemaps?.filesToDeleteAfterUpload;\n if (filesToDelete !== undefined) {\n const filePathsToDelete = await globFiles(filesToDelete);\n\n logger.debug('Waiting for dependencies on generated files to be freed before deleting...');\n\n await waitUntilBuildArtifactDependenciesAreFreed();\n\n filePathsToDelete.forEach(filePathToDelete => {\n logger.debug(`Deleting asset after upload: ${filePathToDelete}`);\n });\n\n await Promise.all(\n filePathsToDelete.map(filePathToDelete =>\n fs.promises.rm(filePathToDelete, { force: true }).catch(e => {\n // This is allowed to fail - we just don't do anything\n logger.debug(`An error occurred while attempting to delete asset: ${filePathToDelete}`, e);\n }),\n ),\n );\n }\n } catch (e) {\n sentryScope.captureException('Error in \"sentry-file-deletion-plugin\" buildEnd hook');\n await safeFlushTelemetry(sentryClient);\n // We throw by default if we get here b/c not being able to delete\n // source maps could leak them to production\n handleRecoverableError(e, true);\n }\n },\n createDependencyOnBuildArtifacts,\n };\n}\n\nfunction canUploadSourceMaps(options: NormalizedOptions, logger: Logger, isDevMode: boolean): boolean {\n if (options.sourcemaps?.disable) {\n logger.debug('Source map upload was disabled. Will not upload sourcemaps using debug ID process.');\n return false;\n }\n if (isDevMode) {\n logger.debug('Running in development mode. Will not upload sourcemaps.');\n return false;\n }\n if (!options.authToken) {\n logger.warn(\n `No auth token provided. Will not upload source maps. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return false;\n }\n if (!options.org && !options.authToken.startsWith('sntrys_')) {\n logger.warn(\n `No org provided. Will not upload source maps. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return false;\n }\n if (!getProjects(options.project)?.[0]) {\n logger.warn(\n `No project provided. Will not upload source maps. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return false;\n }\n\n return true;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAqBA,MAAM,iBAAA,uBAAwB,GAAA,EAAY;AA4EnC,SAAS,8BAAA,CACd,aACA,wBAAA,EAc0B;AAC1B,EAAA,MAAM,SAAS,YAAA,CAAa;AAAA,IAC1B,QAAQ,wBAAA,CAAyB,YAAA;AAAA,IACjC,MAAA,EAAQ,YAAY,MAAA,IAAU,KAAA;AAAA,IAC9B,KAAA,EAAO,YAAY,KAAA,IAAS;AAAA,GAC7B,CAAA;AAED,EAAA,IAAI;AACF,IAAA,MAAM,UAAA,GAAa,EAAA,CAAG,YAAA,CAAa,IAAA,CAAK,IAAA,CAAK,QAAQ,GAAA,EAAI,EAAG,0BAA0B,CAAA,EAAG,OAAO,CAAA;AAEhG,IAAA,MAAM,YAAA,GAAe,MAAA,CAAO,KAAA,CAAM,UAAU,CAAA;AAI5C,IAAA,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,GAAA,EAAK,YAAY,CAAA;AAEvC,IAAA,MAAA,CAAO,KAAK,uEAAuE,CAAA;AAAA,EACrF,SAAS,CAAA,EAAY;AAEnB,IAAA,IAAI,OAAO,MAAM,QAAA,IAAY,CAAA,IAAK,UAAU,CAAA,IAAK,CAAA,CAAE,SAAS,QAAA,EAAU;AACpE,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF;AAEA,EAAA,MAAM,OAAA,GAAU,qBAAqB,WAAW,CAAA;AAEhD,EAAA,IAAI,QAAQ,OAAA,EAAS;AAKnB,IAAA,OAAO;AAAA,MACL,iBAAA,EAAmB,OAAA;AAAA,MACnB,MAAA;AAAA,MACA,yCAAyC,EAAC;AAAA,MAC1C,SAAA,EAAW;AAAA,QACT,kCAAkC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IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,gHAAA,EAAmH,iCAAA,CAAkC,gBAAgB,CAAC,CAAA;AAAA,KACxK;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"build-plugin-manager.js","sources":["../../../src/core/build-plugin-manager.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport { closeSession, DEFAULT_ENVIRONMENT, makeSession, setMeasurement, startSpan } from '@sentry/core';\nimport * as dotenv from 'dotenv';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { SentryCliAdapter } from './cli';\nimport type { NormalizedOptions } from './options-mapping';\nimport { normalizeUserOptions, validateOptions } from './options-mapping';\nimport type { Logger } from './logger';\nimport { createLogger } from './logger';\nimport { allowedToSendTelemetry, createSentryInstance, safeFlushTelemetry } from './sentry/telemetry';\nimport type { Options, SentrySDKBuildFlags } from './types';\nimport { arrayify, getProjects, getTurborepoEnvPassthroughWarning, stripQueryAndHashFromPath } from './utils';\nimport { defaultRewriteSourcesHook, prepareBundleForDebugIdUpload } from './debug-id-upload';\nimport { globFiles } from './glob';\nimport { LIB_VERSION } from './version';\n\n// Module-level guard to prevent duplicate deploy records when multiple bundler plugin\n// instances run in the same process (e.g. Next.js creates separate webpack compilers\n// for client, server, and edge). Keyed by release name.\nconst _deployedReleases = new Set<string>();\n\n/** @internal Exported for testing only. */\nexport function _resetDeployedReleasesForTesting(): void {\n _deployedReleases.clear();\n}\n\nexport type SentryBuildPluginManager = {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger: Logger;\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: NormalizedOptions;\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags;\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata: Record<string, unknown>;\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n emitBundlerPluginExecutionSignal(): Promise<void>;\n };\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n createRelease(): Promise<void>;\n\n /**\n * Injects debug IDs into the build artifacts.\n *\n * This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n * Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n * Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n injectDebugIds(buildArtifactPaths: string[]): Promise<void>;\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method. This function takes a list of build artifact paths that will be uploaded\n */\n uploadSourcemaps(buildArtifactPaths: string[], opts?: { prepareArtifacts?: boolean }): Promise<void>;\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n deleteArtifacts(): Promise<void>;\n\n createDependencyOnBuildArtifacts: () => () => void;\n};\n\n/**\n * Creates a build plugin manager that exposes primitives for everything that a Sentry JavaScript SDK or build tooling may do during a build.\n *\n * The build plugin manager's behavior strongly depends on the options that are passed in.\n */\nexport function createSentryBuildPluginManager(\n userOptions: Options,\n bundlerPluginMetaContext: {\n /**\n * E.g. `webpack` or `nextjs` or `turbopack`\n */\n buildTool: string;\n /**\n * E.g. `5` for webpack v5 or `4` for Rollup v4\n */\n buildToolMajorVersion?: string;\n /**\n * E.g. `[sentry-webpack-plugin]` or `[@sentry/nextjs]`\n */\n loggerPrefix: string;\n },\n): SentryBuildPluginManager {\n const logger = createLogger({\n prefix: bundlerPluginMetaContext.loggerPrefix,\n silent: userOptions.silent ?? false,\n debug: userOptions.debug ?? false,\n });\n\n try {\n const dotenvFile = fs.readFileSync(path.join(process.cwd(), '.env.sentry-build-plugin'), 'utf-8');\n // NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.\n const dotenvResult = dotenv.parse(dotenvFile);\n\n // Vite has a bug/behaviour where spreading into process.env will cause it to crash\n // https://github.com/vitest-dev/vitest/issues/1870#issuecomment-1501140251\n Object.assign(process.env, dotenvResult);\n\n logger.info('Using environment variables configured in \".env.sentry-build-plugin\".');\n } catch (e: unknown) {\n // Ignore \"file not found\" errors but throw all others\n if (typeof e === 'object' && e && 'code' in e && e.code !== 'ENOENT') {\n throw e;\n }\n }\n\n const options = normalizeUserOptions(userOptions);\n\n if (options.disable) {\n // Early-return a noop build plugin manager instance so that we\n // don't continue validating options, setting up Sentry, etc.\n // Otherwise we might create side-effects or log messages that\n // users don't expect from a disabled plugin.\n return {\n normalizedOptions: options,\n logger,\n bundleSizeOptimizationReplacementValues: {},\n telemetry: {\n emitBundlerPluginExecutionSignal: async () => {\n /* noop */\n },\n },\n bundleMetadata: {},\n createRelease: async () => {\n /* noop */\n },\n uploadSourcemaps: async () => {\n /* noop */\n },\n deleteArtifacts: async () => {\n /* noop */\n },\n createDependencyOnBuildArtifacts: () => () => {\n /* noop */\n },\n injectDebugIds: async () => {\n /* noop */\n },\n };\n }\n\n const shouldSendTelemetry = allowedToSendTelemetry(options);\n const { sentryScope, sentryClient } = createSentryInstance(\n options,\n shouldSendTelemetry,\n bundlerPluginMetaContext.buildTool,\n bundlerPluginMetaContext.buildToolMajorVersion,\n );\n\n const { release, environment = DEFAULT_ENVIRONMENT } = sentryClient.getOptions();\n\n const sentrySession = makeSession({ release, environment });\n sentryScope.setSession(sentrySession);\n // Send the start of the session\n sentryClient.captureSession(sentrySession);\n\n let sessionHasEnded = false; // Just to prevent infinite loops with beforeExit, which is called whenever the event loop empties out\n\n function endSession(): void {\n if (sessionHasEnded) {\n return;\n }\n\n closeSession(sentrySession);\n sentryClient.captureSession(sentrySession);\n sessionHasEnded = true;\n }\n\n // We also need to manually end sessions on errors because beforeExit is not called on crashes\n process.on('beforeExit', () => {\n endSession();\n });\n\n // Set the User-Agent that Sentry CLI will use when interacting with Sentry\n process.env['SENTRY_PIPELINE'] = `${bundlerPluginMetaContext.buildTool}-plugin/${LIB_VERSION}`;\n\n // Propagate debug flag to Sentry CLI via environment variable\n // Only set if not already defined to respect user's explicit configuration\n if (options.debug && !process.env['SENTRY_LOG_LEVEL']) {\n process.env['SENTRY_LOG_LEVEL'] = 'debug';\n }\n\n // Not a bulletproof check but should be good enough to at least sometimes determine\n // if the plugin is called in dev/watch mode or for a prod build. The important part\n // here is to avoid a false positive. False negatives are okay.\n const isDevMode = process.env['NODE_ENV'] === 'development';\n\n /**\n * Handles errors caught and emitted in various areas of the plugin.\n *\n * Also sets the sentry session status according to the error handling.\n *\n * If users specify their custom `errorHandler` we'll leave the decision to throw\n * or continue up to them. By default, @param throwByDefault controls if the plugin\n * should throw an error (which causes a build fail in most bundlers) or continue.\n */\n function handleRecoverableError(unknownError: unknown, throwByDefault: boolean): void {\n sentrySession.status = 'abnormal';\n try {\n if (options.errorHandler) {\n try {\n if (unknownError instanceof Error) {\n options.errorHandler(unknownError);\n } else {\n options.errorHandler(new Error('An unknown error occurred'));\n }\n } catch (e) {\n sentrySession.status = 'crashed';\n throw e;\n }\n } else {\n // setting the session to \"crashed\" b/c from a plugin perspective this run failed.\n // However, we're intentionally not rethrowing the error to avoid breaking the user build.\n sentrySession.status = 'crashed';\n if (throwByDefault) {\n throw unknownError;\n }\n logger.error(\"An error occurred. Couldn't finish all operations:\", unknownError);\n }\n } finally {\n endSession();\n }\n }\n\n if (!validateOptions(options, logger)) {\n // Throwing by default to avoid a misconfigured plugin going unnoticed.\n handleRecoverableError(new Error('Options were not set correctly. See output above for more details.'), true);\n }\n\n // We have multiple plugins depending on generated source map files. (debug ID upload, legacy upload)\n // Additionally, we also want to have the functionality to delete files after uploading sourcemaps.\n // All of these plugins and the delete functionality need to run in the same hook (`writeBundle`).\n // Since the plugins among themselves are not aware of when they run and finish, we need a system to\n // track their dependencies on the generated files, so that we can initiate the file deletion only after\n // nothing depends on the files anymore.\n const dependenciesOnBuildArtifacts = new Set<symbol>();\n const buildArtifactsDependencySubscribers: (() => void)[] = [];\n\n function notifyBuildArtifactDependencySubscribers(): void {\n buildArtifactsDependencySubscribers.forEach(subscriber => {\n subscriber();\n });\n }\n\n function createDependencyOnBuildArtifacts(): () => void {\n const dependencyIdentifier = Symbol();\n dependenciesOnBuildArtifacts.add(dependencyIdentifier);\n\n return function freeDependencyOnBuildArtifacts() {\n dependenciesOnBuildArtifacts.delete(dependencyIdentifier);\n notifyBuildArtifactDependencySubscribers();\n };\n }\n\n /**\n * Returns a Promise that resolves when all the currently active dependencies are freed again.\n *\n * It is very important that this function is called as late as possible before wanting to await the Promise to give\n * the dependency producers as much time as possible to register themselves.\n */\n function waitUntilBuildArtifactDependenciesAreFreed(): Promise<void> {\n return new Promise<void>(resolve => {\n buildArtifactsDependencySubscribers.push(() => {\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n\n if (dependenciesOnBuildArtifacts.size === 0) {\n resolve();\n }\n });\n }\n\n const bundleSizeOptimizationReplacementValues: SentrySDKBuildFlags = {};\n if (options.bundleSizeOptimizations) {\n const { bundleSizeOptimizations } = options;\n\n if (bundleSizeOptimizations.excludeDebugStatements) {\n bundleSizeOptimizationReplacementValues['__SENTRY_DEBUG__'] = false;\n }\n if (bundleSizeOptimizations.excludeTracing) {\n bundleSizeOptimizationReplacementValues['__SENTRY_TRACING__'] = false;\n }\n if (bundleSizeOptimizations.excludeChannelInjection) {\n bundleSizeOptimizationReplacementValues['__SENTRY_CHANNEL_INJECTION__'] = false;\n }\n if (bundleSizeOptimizations.excludeReplayCanvas) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_CANVAS__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayIframe) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_IFRAME__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayShadowDom) {\n bundleSizeOptimizationReplacementValues['__RRWEB_EXCLUDE_SHADOW_DOM__'] = true;\n }\n if (bundleSizeOptimizations.excludeReplayWorker) {\n bundleSizeOptimizationReplacementValues['__SENTRY_EXCLUDE_REPLAY_WORKER__'] = true;\n }\n }\n\n let bundleMetadata: Record<string, unknown> = {};\n if (options.moduleMetadata || options.applicationKey) {\n if (options.applicationKey) {\n // We use different keys so that if user-code receives multiple bundling passes, we will store the application keys of all the passes.\n // It is a bit unfortunate that we have to inject the metadata snippet at the top, because after multiple\n // injections, the first injection will always \"win\" because it comes last in the code. We would generally be\n // fine with making the last bundling pass win. But because it cannot win, we have to use a workaround of storing\n // the app keys in different object keys.\n // We can simply use the `_sentryBundlerPluginAppKey:` to filter for app keys in the SDK.\n bundleMetadata[`_sentryBundlerPluginAppKey:${options.applicationKey}`] = true;\n }\n\n if (typeof options.moduleMetadata === 'function') {\n const args = {\n org: options.org,\n project: getProjects(options.project)?.[0],\n projects: getProjects(options.project),\n release: options.release.name,\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata(args) };\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bundleMetadata = { ...bundleMetadata, ...options.moduleMetadata };\n }\n }\n\n return {\n /**\n * A logger instance that takes the options passed to the build plugin manager into account. (for silencing and log level etc.)\n */\n logger,\n\n /**\n * Options after normalization. Includes things like the inferred release name.\n */\n normalizedOptions: options,\n\n /**\n * Magic strings and their replacement values that can be used for bundle size optimizations. This already takes\n * into account the options passed to the build plugin manager.\n */\n bundleSizeOptimizationReplacementValues,\n\n /**\n * Metadata that should be injected into bundles if possible. Takes into account options passed to the build plugin manager.\n */\n // See `generateModuleMetadataInjectorCode` for how this should be used exactly\n bundleMetadata,\n\n /**\n * Contains utility functions for emitting telemetry via the build plugin manager.\n */\n telemetry: {\n /**\n * Emits a `Sentry Bundler Plugin execution` signal.\n */\n async emitBundlerPluginExecutionSignal() {\n if (await shouldSendTelemetry) {\n logger.info(\n 'Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.',\n );\n startSpan({ name: 'Sentry Bundler Plugin execution', scope: sentryScope }, () => {\n //\n });\n await safeFlushTelemetry(sentryClient);\n }\n },\n },\n\n /**\n * Will potentially create a release based on the build plugin manager options.\n *\n * Also\n * - finalizes the release\n * - sets commits\n * - uploads legacy sourcemaps\n * - adds deploy information\n */\n async createRelease() {\n if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not create release. Please set the `release.name` option to identify your release.',\n );\n return;\n } else if (isDevMode) {\n logger.debug('Running in development mode. Will not create release.');\n return;\n } else if (!options.authToken) {\n logger.warn(\n `No auth token provided. Will not create release. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return;\n } else if (!options.org && !options.authToken.startsWith('sntrys_')) {\n logger.warn(\n `No organization slug provided. Will not create release. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return;\n } else if (!options.project || (Array.isArray(options.project) && options.project.length === 0)) {\n logger.warn(\n `No project provided. Will not create release. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return;\n }\n\n // It is possible that this writeBundle hook is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeWriteBundleInvocationDependencyOnSourcemapFiles = createDependencyOnBuildArtifacts();\n\n // Guaranteed to be set by the guard clause above.\n const releaseName = options.release.name;\n\n try {\n const cliInstance = new SentryCliAdapter(options);\n\n if (options.release.create) {\n const releaseOutput = await cliInstance.createRelease(releaseName);\n logger.debug('Release created:', releaseOutput);\n }\n\n if (options.release.uploadLegacySourcemaps) {\n const uploadTargets = arrayify(options.release.uploadLegacySourcemaps)\n .map(includeItem => (typeof includeItem === 'string' ? { paths: [includeItem] } : includeItem))\n .flatMap(includeEntry =>\n includeEntry.paths.map(directory => ({\n directory,\n dist: options.release.dist,\n ext: includeEntry.ext\n ? includeEntry.ext.map(extension => `.${extension.replace(/^\\./, '')}`)\n : ['.js', '.map', '.jsbundle', '.bundle'],\n // The old CLI only skipped `node_modules` when neither ignore source was configured.\n ignore: includeEntry.ignore\n ? arrayify(includeEntry.ignore)\n : includeEntry.ignoreFile\n ? undefined\n : ['node_modules'],\n ignoreFile: includeEntry.ignoreFile,\n urlPrefix: includeEntry.urlPrefix,\n })),\n );\n\n await cliInstance.uploadSourcemaps(releaseName, uploadTargets);\n }\n\n if (options.release.setCommits !== false) {\n try {\n await cliInstance.setCommits(\n releaseName,\n // set commits always exists due to the normalize function\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n options.release.setCommits!,\n );\n } catch (e) {\n // shouldNotThrowOnFailure being present means that the plugin defaulted to `{ auto: true }` for the setCommitsOptions, meaning that wee should not throw when CLI throws because there is no repo\n if (\n options.release.setCommits &&\n 'shouldNotThrowOnFailure' in options.release.setCommits &&\n options.release.setCommits.shouldNotThrowOnFailure\n ) {\n logger.debug(\n 'An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):',\n e,\n );\n } else {\n throw e;\n }\n }\n }\n\n if (options.release.finalize) {\n await cliInstance.finalizeRelease(releaseName);\n }\n\n if (options.release.deploy && !_deployedReleases.has(releaseName)) {\n await cliInstance.newDeploy(releaseName, options.release.deploy);\n _deployedReleases.add(releaseName);\n }\n } catch (e) {\n sentryScope.captureException('Error in \"releaseManagementPlugin\" writeBundle hook');\n await safeFlushTelemetry(sentryClient);\n handleRecoverableError(e, false);\n } finally {\n freeWriteBundleInvocationDependencyOnSourcemapFiles();\n }\n },\n\n /*\n Injects debug IDs into the build artifacts.\n\n This is a separate function from `uploadSourcemaps` because that needs to run before the sourcemaps are uploaded.\n Usually the respective bundler-plugin will take care of this before the sourcemaps are uploaded.\n Only use this if you need to manually inject debug IDs into the build artifacts.\n */\n async injectDebugIds(buildArtifactPaths: string[]) {\n // oxlint-disable-next-line typescript/no-deprecated\n await startSpan({ name: 'inject-debug-ids', scope: sentryScope, forceTransaction: true }, async () => {\n try {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.injectDebugIds(buildArtifactPaths, options.sourcemaps?.ignore);\n } catch (e) {\n sentryScope.captureException('Error in \"debugIdInjectionPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n await safeFlushTelemetry(sentryClient);\n }\n });\n },\n\n /**\n * Uploads sourcemaps using the \"Debug ID\" method.\n *\n * By default, this prepares bundles in a temporary folder before uploading. You can opt into an\n * in-place, direct upload path by setting `prepareArtifacts` to `false`. If `prepareArtifacts` is set to\n * `false`, no preparation (e.g. adding `//# debugId=...` and writing adjusted source maps) is performed and no temp folder is used.\n *\n * @param buildArtifactPaths - The paths of the build artifacts to upload\n * @param opts - Optional flags to control temp folder usage and preparation\n */\n async uploadSourcemaps(buildArtifactPaths: string[], opts?: { prepareArtifacts?: boolean }) {\n if (!canUploadSourceMaps(options, logger, isDevMode)) {\n return;\n }\n\n // Early exit if assets is explicitly set to an empty array\n const assets = options.sourcemaps?.assets;\n if (Array.isArray(assets) && assets.length === 0) {\n logger.debug('Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.');\n return;\n }\n\n await startSpan(\n // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.\n // oxlint-disable-next-line typescript/no-deprecated\n { name: 'debug-id-sourcemap-upload', scope: sentryScope, forceTransaction: true },\n async () => {\n // If we're not using a temp folder, we must not prepare artifacts in-place (to avoid mutating user files)\n const shouldPrepare = opts?.prepareArtifacts ?? true;\n\n let folderToCleanUp: string | undefined;\n\n // It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)\n // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.\n const freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n\n try {\n if (!shouldPrepare) {\n // Direct CLI upload from existing artifact paths (no globbing, no preparation)\n let pathsToUpload: string[];\n\n if (assets) {\n pathsToUpload = Array.isArray(assets) ? assets : [assets];\n logger.debug(\n `Direct upload mode: passing user-provided assets directly to CLI: ${pathsToUpload.join(', ')}`,\n );\n } else {\n // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done\n pathsToUpload = buildArtifactPaths;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(\n options.release.name ?? 'undefined',\n pathsToUpload.map(directory => ({\n directory,\n dist: options.release.dist,\n ignore: options.sourcemaps?.ignore,\n })),\n );\n });\n\n logger.info('Successfully uploaded source maps to Sentry');\n } else {\n // Prepare artifacts in temp folder before uploading\n let globAssets: string | string[];\n if (assets) {\n globAssets = assets;\n } else {\n logger.debug(\n 'No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.',\n );\n globAssets = buildArtifactPaths;\n }\n\n const globResult = await startSpan({ name: 'glob', scope: sentryScope }, async () =>\n globFiles(globAssets, { ignore: options.sourcemaps?.ignore }),\n );\n\n const debugIdChunkFilePaths = globResult.filter(debugIdChunkFilePath => {\n return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\\.(js|mjs|cjs)$/);\n });\n\n // The order of the files output by glob() is not deterministic\n // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent\n debugIdChunkFilePaths.sort();\n\n if (debugIdChunkFilePaths.length === 0) {\n logger.warn(\n \"Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.\",\n );\n } else {\n const tmpUploadFolder = await startSpan({ name: 'mkdtemp', scope: sentryScope }, async () => {\n return (\n process.env?.['SENTRY_TEST_OVERRIDE_TEMP_DIR'] ||\n (await fs.promises.mkdtemp(path.join(os.tmpdir(), 'sentry-bundler-plugin-upload-')))\n );\n });\n folderToCleanUp = tmpUploadFolder;\n\n // Prepare into temp folder, then upload\n await startSpan({ name: 'prepare-bundles', scope: sentryScope }, async prepBundlesSpan => {\n // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so\n // instead we do it with a maximum of 16 concurrent workers\n const preparationTasks = debugIdChunkFilePaths.map((chunkFilePath, chunkIndex) => async () => {\n await prepareBundleForDebugIdUpload(\n chunkFilePath,\n tmpUploadFolder,\n chunkIndex,\n logger,\n options.sourcemaps?.rewriteSources ?? defaultRewriteSourcesHook,\n options.sourcemaps?.resolveSourceMap,\n );\n });\n const workers: Promise<void>[] = [];\n const worker = async (): Promise<void> => {\n while (preparationTasks.length > 0) {\n const task = preparationTasks.shift();\n if (task) {\n await task();\n }\n }\n };\n for (let workerIndex = 0; workerIndex < 16; workerIndex++) {\n workers.push(worker());\n }\n\n await Promise.all(workers);\n\n const files = await fs.promises.readdir(tmpUploadFolder);\n const stats = files.map(file => fs.promises.stat(path.join(tmpUploadFolder, file)));\n const uploadSize = (await Promise.all(stats)).reduce(\n (accumulator, { size }) => accumulator + size,\n 0,\n );\n\n setMeasurement('files', files.length, 'none', prepBundlesSpan);\n setMeasurement('upload_size', uploadSize, 'byte', prepBundlesSpan);\n\n // Preparation produced no artifacts, meaning none of the\n // matched bundles had an associated source map. This almost\n // always means source map generation is turned off in the\n // bundler, so warn instead of silently reporting success.\n if (files.length === 0) {\n logger.warn(\n `No source maps found for any of the ${debugIdChunkFilePaths.length} matched build ` +\n 'artifacts, so no source maps were uploaded to Sentry. This usually means source map ' +\n 'generation is not enabled in your bundler. Enable it so Sentry can un-minify your stack traces.',\n );\n return;\n }\n\n await startSpan({ name: 'upload', scope: sentryScope }, async () => {\n const cliInstance = new SentryCliAdapter(options);\n await cliInstance.uploadSourcemaps(options.release.name ?? 'undefined', [\n {\n directory: tmpUploadFolder,\n dist: options.release.dist,\n },\n ]);\n });\n\n // this must be in the method so that the \"no sourcemaps\"\n // early return doesn't also log success.\n logger.info('Successfully uploaded source maps to Sentry');\n });\n }\n }\n } catch (e) {\n sentryScope.captureException('Error in \"debugIdUploadPlugin\" writeBundle hook');\n handleRecoverableError(e, false);\n } finally {\n if (folderToCleanUp && !process.env?.['SENTRY_TEST_OVERRIDE_TEMP_DIR']) {\n logger.debug('Cleaning up temporary files...');\n try {\n await startSpan({ name: 'cleanup', scope: sentryScope }, async () => {\n if (folderToCleanUp) {\n await fs.promises.rm(folderToCleanUp, { recursive: true, force: true });\n logger.debug(`Temporary folder deleted: ${folderToCleanUp}`);\n }\n });\n } catch (e) {\n // A failed cleanup must not skip the teardown steps below (freeing upload\n // dependencies, flushing telemetry), so swallow and log instead of rethrowing.\n logger.debug('Failed to clean up temporary folder:', e);\n }\n }\n logger.debug('Freeing upload dependencies...');\n freeUploadDependencyOnBuildArtifacts();\n logger.debug('Flushing telemetry data...');\n await safeFlushTelemetry(sentryClient);\n logger.debug('Telemetry flushed. Plugin upload process complete.');\n }\n },\n );\n },\n\n /**\n * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.\n */\n async deleteArtifacts() {\n try {\n const filesToDelete = await options.sourcemaps?.filesToDeleteAfterUpload;\n if (filesToDelete !== undefined) {\n const filePathsToDelete = await globFiles(filesToDelete);\n\n logger.debug('Waiting for dependencies on generated files to be freed before deleting...');\n\n await waitUntilBuildArtifactDependenciesAreFreed();\n\n filePathsToDelete.forEach(filePathToDelete => {\n logger.debug(`Deleting asset after upload: ${filePathToDelete}`);\n });\n\n await Promise.all(\n filePathsToDelete.map(filePathToDelete =>\n fs.promises.rm(filePathToDelete, { force: true }).catch(e => {\n // This is allowed to fail - we just don't do anything\n logger.debug(`An error occurred while attempting to delete asset: ${filePathToDelete}`, e);\n }),\n ),\n );\n }\n } catch (e) {\n sentryScope.captureException('Error in \"sentry-file-deletion-plugin\" buildEnd hook');\n await safeFlushTelemetry(sentryClient);\n // We throw by default if we get here b/c not being able to delete\n // source maps could leak them to production\n handleRecoverableError(e, true);\n }\n },\n createDependencyOnBuildArtifacts,\n };\n}\n\nfunction canUploadSourceMaps(options: NormalizedOptions, logger: Logger, isDevMode: boolean): boolean {\n if (options.sourcemaps?.disable) {\n logger.debug('Source map upload was disabled. Will not upload sourcemaps using debug ID process.');\n return false;\n }\n if (isDevMode) {\n logger.debug('Running in development mode. Will not upload sourcemaps.');\n return false;\n }\n if (!options.authToken) {\n logger.warn(\n `No auth token provided. Will not upload source maps. Please set the \\`authToken\\` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/${getTurborepoEnvPassthroughWarning('SENTRY_AUTH_TOKEN')}`,\n );\n return false;\n }\n if (!options.org && !options.authToken.startsWith('sntrys_')) {\n logger.warn(\n `No org provided. Will not upload source maps. Please set the \\`org\\` option to your Sentry organization slug.${getTurborepoEnvPassthroughWarning('SENTRY_ORG')}`,\n );\n return false;\n }\n if (!getProjects(options.project)?.[0]) {\n logger.warn(\n `No project provided. Will not upload source maps. Please set the \\`project\\` option to your Sentry project slug.${getTurborepoEnvPassthroughWarning('SENTRY_PROJECT')}`,\n );\n return false;\n }\n\n return true;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAqBA,MAAM,iBAAA,uBAAwB,GAAA,EAAY;AA4EnC,SAAS,8BAAA,CACd,aACA,wBAAA,EAc0B;AAC1B,EAAA,MAAM,SAAS,YAAA,CAAa;AAAA,IAC1B,QAAQ,wBAAA,CAAyB,YAAA;AAAA,IACjC,MAAA,EAAQ,YAAY,MAAA,IAAU,KAAA;AAAA,IAC9B,KAAA,EAAO,YAAY,KAAA,IAAS;AAAA,GAC7B,CAAA;AAED,EAAA,IAAI;AACF,IAAA,MAAM,UAAA,GAAa,EAAA,CAAG,YAAA,CAAa,IAAA,CAAK,IAAA,CAAK,QAAQ,GAAA,EAAI,EAAG,0BAA0B,C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T;AACA,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,MAAA,CAAO,MAAM,0DAA0D,CAAA;AACvE,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,QAAQ,SAAA,EAAW;AACtB,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,gMAAA,EAAmM,iCAAA,CAAkC,mBAAmB,CAAC,CAAA;AAAA,KAC3P;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,QAAQ,GAAA,IAAO,CAAC,QAAQ,SAAA,CAAU,UAAA,CAAW,SAAS,CAAA,EAAG;AAC5D,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,6GAAA,EAAgH,iCAAA,CAAkC,YAAY,CAAC,CAAA;AAAA,KACjK;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,WAAA,CAAY,OAAA,CAAQ,OAAO,CAAA,GAAI,CAAC,CAAA,EAAG;AACtC,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,gHAAA,EAAmH,iCAAA,CAAkC,gBAAgB,CAAC,CAAA;AAAA,KACxK;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,IAAA;AACT;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createStackParser,
|
|
1
|
+
import { createStackParser, applySdkMetadata, Scope } from '@sentry/core';
|
|
2
|
+
import { nodeStackLineParser, ServerRuntimeClient } from '@sentry/core/server';
|
|
2
3
|
import { SENTRY_SAAS_URL } from '../options-mapping.js';
|
|
3
4
|
import { makeOptionallyEnabledNodeTransport } from './transports.js';
|
|
4
5
|
import { SentryCliAdapter } from '../cli.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sources":["../../../../src/core/sentry/telemetry.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport type { ServerRuntimeClientOptions } from '@sentry/core';\nimport { applySdkMetadata
|
|
1
|
+
{"version":3,"file":"telemetry.js","sources":["../../../../src/core/sentry/telemetry.ts"],"sourcesContent":["import type { Client } from '@sentry/core';\nimport type { ServerRuntimeClientOptions } from '@sentry/core/server';\nimport { applySdkMetadata } from '@sentry/core';\nimport { ServerRuntimeClient } from '@sentry/core/server';\nimport type { NormalizedOptions } from '../options-mapping';\nimport { SENTRY_SAAS_URL } from '../options-mapping';\nimport { Scope } from '@sentry/core';\nimport { createStackParser } from '@sentry/core';\nimport { nodeStackLineParser } from '@sentry/core/server';\nimport { makeOptionallyEnabledNodeTransport } from './transports';\nimport { SentryCliAdapter } from '../cli';\nimport { LIB_VERSION } from '../version';\n\nconst SENTRY_SAAS_HOSTNAME = 'sentry.io';\n\nconst stackParser = createStackParser(nodeStackLineParser());\n\nexport function createSentryInstance(\n options: NormalizedOptions,\n shouldSendTelemetry: Promise<boolean>,\n buildTool: string,\n buildToolMajorVersion: string | undefined,\n): { sentryScope: Scope; sentryClient: Client } {\n const clientOptions: ServerRuntimeClientOptions = {\n platform: 'node',\n runtime: { name: 'node', version: global.process.version },\n\n dsn: 'https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737',\n\n tracesSampleRate: 1,\n traceLifecycle: 'static',\n sampleRate: 1,\n\n release: LIB_VERSION,\n integrations: [],\n tracePropagationTargets: ['sentry.io/api'],\n\n stackParser,\n\n beforeSend: event => {\n event.exception?.values?.forEach(exception => {\n delete exception.stacktrace;\n });\n\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // Deprecated, but still applied because this client runs on the static trace lifecycle.\n // oxlint-disable-next-line typescript/no-deprecated\n beforeSendTransaction: event => {\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n // We create a transport that stalls sending events until we know that we're allowed to (i.e. when Sentry CLI told\n // us that the upload URL is the Sentry SaaS URL)\n transport: makeOptionallyEnabledNodeTransport(shouldSendTelemetry),\n };\n\n applySdkMetadata(clientOptions, 'node');\n\n const client = new ServerRuntimeClient(clientOptions);\n const scope = new Scope();\n scope.setClient(client);\n\n setTelemetryDataOnScope(options, scope, buildTool, buildToolMajorVersion);\n\n return { sentryScope: scope, sentryClient: client };\n}\n\nexport function setTelemetryDataOnScope(\n options: NormalizedOptions,\n scope: Scope,\n buildTool: string,\n buildToolMajorVersion?: string,\n): void {\n const { org, project, release, errorHandler, sourcemaps, reactComponentAnnotation } = options;\n\n scope.setTag('upload-legacy-sourcemaps', !!release.uploadLegacySourcemaps);\n if (release.uploadLegacySourcemaps) {\n scope.setTag(\n 'uploadLegacySourcemapsEntries',\n Array.isArray(release.uploadLegacySourcemaps) ? release.uploadLegacySourcemaps.length : 1,\n );\n }\n\n scope.setTag('module-metadata', !!options.moduleMetadata);\n scope.setTag('inject-build-information', !!options._experiments.injectBuildInformation);\n\n // Optional release pipeline steps\n if (release.setCommits) {\n scope.setTag('set-commits', release.setCommits.auto === true ? 'auto' : 'manual');\n } else {\n scope.setTag('set-commits', 'undefined');\n }\n scope.setTag('finalize-release', release.finalize);\n scope.setTag('deploy-options', !!release.deploy);\n\n // Miscellaneous options\n scope.setTag('custom-error-handler', !!errorHandler);\n scope.setTag('sourcemaps-assets', !!sourcemaps?.assets);\n scope.setTag('delete-after-upload', !!sourcemaps?.filesToDeleteAfterUpload);\n scope.setTag('sourcemaps-disabled', !!sourcemaps?.disable);\n\n scope.setTag('react-annotate', !!reactComponentAnnotation?.enabled);\n\n scope.setTag('node', process.version);\n scope.setTag('platform', process.platform);\n\n scope.setTag('meta-framework', options._metaOptions.telemetry.metaFramework ?? 'none');\n\n scope.setTag('application-key-set', options.applicationKey !== undefined);\n\n scope.setTag('ci', !!process.env['CI']);\n\n scope.setTags({\n organization: org,\n project: Array.isArray(project) ? project.join(', ') : (project ?? 'undefined'),\n bundler: buildTool,\n });\n\n if (buildToolMajorVersion) {\n scope.setTag('bundler-major-version', buildToolMajorVersion);\n }\n\n scope.setUser({ id: org });\n}\n\nexport async function allowedToSendTelemetry(options: NormalizedOptions): Promise<boolean> {\n const { telemetry, url } = options;\n\n // `options.telemetry` defaults to true\n if (telemetry === false) {\n return false;\n }\n\n if (url === SENTRY_SAAS_URL) {\n return true;\n }\n\n // Ask the CLI which Sentry server URL it resolves to. This can differ from the default (or the\n // configured `url`) because the CLI also honors a possibly existing `.sentryclirc` file.\n const cliInfoUrl = await new SentryCliAdapter(options).getServerUrl();\n\n if (cliInfoUrl === undefined) {\n return false;\n }\n\n return new URL(cliInfoUrl).hostname === SENTRY_SAAS_HOSTNAME;\n}\n\n/**\n * Flushing the SDK client can fail. We never want to crash the plugin because of telemetry.\n */\nexport async function safeFlushTelemetry(sentryClient: Client): Promise<void> {\n try {\n await sentryClient.flush(2000);\n } catch {\n // Noop when flushing fails.\n // We don't even need to log anything because there's likely nothing the user can do and they likely will not care.\n }\n}\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,oBAAA,GAAuB,WAAA;AAE7B,MAAM,WAAA,GAAc,iBAAA,CAAkB,mBAAA,EAAqB,CAAA;AAEpD,SAAS,oBAAA,CACd,OAAA,EACA,mBAAA,EACA,SAAA,EACA,qBAAA,EAC8C;AAC9C,EAAA,MAAM,aAAA,GAA4C;AAAA,IAChD,QAAA,EAAU,MAAA;AAAA,IACV,SAAS,EAAE,IAAA,EAAM,QAAQ,OAAA,EAAS,MAAA,CAAO,QAAQ,OAAA,EAAQ;AAAA,IAEzD,GAAA,EAAK,sEAAA;AAAA,IAEL,gBAAA,EAAkB,CAAA;AAAA,IAClB,cAAA,EAAgB,QAAA;AAAA,IAChB,UAAA,EAAY,CAAA;AAAA,IAEZ,OAAA,EAAS,WAAA;AAAA,IACT,cAAc,EAAC;AAAA,IACf,uBAAA,EAAyB,CAAC,eAAe,CAAA;AAAA,IAEzC,WAAA;AAAA,IAEA,YAAY,CAAA,KAAA,KAAS;AACnB,MAAA,KAAA,CAAM,SAAA,EAAW,MAAA,EAAQ,OAAA,CAAQ,CAAA,SAAA,KAAa;AAC5C,QAAA,OAAO,SAAA,CA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","sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.0.0-beta.1\";\n"],"names":[],"mappings":"AAAO,MAAM,WAAA,GAAc;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"11.0.0-
|
|
1
|
+
{"type":"module","version":"11.0.0-beta.1","sideEffects":["./sentry-release-injection-file.js","./sentry-esbuild-debugid-injection-file.js"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-plugin-manager.d.ts","sourceRoot":"","sources":["../../../src/core/build-plugin-manager.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAW5D,2CAA2C;AAC3C,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC;;;OAGG;IACH,uCAAuC,EAAE,mBAAmB,CAAC;IAC7D;;OAEG;IAEH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAExC;;OAEG;IACH,SAAS,EAAE;QACT;;WAEG;QACH,gCAAgC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;KACnD,CAAC;IAEF;;;;;;;;OAQG;IACH,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/B;;;;;;OAMG;IACH,cAAc,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D;;OAEG;IACH,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE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B,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D;;OAEG;IACH,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErG;;OAEG;IACH,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjC,gCAAgC,EAAE,MAAM,MAAM,IAAI,CAAC;CACpD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,OAAO,EACpB,wBAAwB,EAAE;IACxB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB,GACA,wBAAwB,CAqpB1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../../src/core/sentry/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../../src/core/sentry/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAWrC,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,mBAAmB,EAAE,OAAO,CAAC,OAAO,CAAC,EACrC,SAAS,EAAE,MAAM,EACjB,qBAAqB,EAAE,MAAM,GAAG,SAAS,GACxC;IAAE,WAAW,EAAE,KAAK,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CA+C9C;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,MAAM,EACjB,qBAAqB,CAAC,EAAE,MAAM,GAC7B,IAAI,CAmDN;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBzF;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO5E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "11.0.0-
|
|
1
|
+
export declare const LIB_VERSION = "11.0.0-beta.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/core/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/core/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/bundler-plugins",
|
|
3
|
-
"version": "11.0.0-
|
|
3
|
+
"version": "11.0.0-beta.1",
|
|
4
4
|
"description": "Sentry Bundler Plugins",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/main/packages/bundler-plugins",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
},
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@babel/core": "^7.18.5",
|
|
114
|
-
"@sentry/core": "11.0.0-
|
|
114
|
+
"@sentry/core": "11.0.0-beta.1",
|
|
115
115
|
"dotenv": "^17.4.2",
|
|
116
116
|
"find-up": "^5.0.0",
|
|
117
117
|
"glob": "^13.0.6",
|