diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index 8f2875e1..083d1c50 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -20,7 +20,7 @@ import { } from "./sentry/telemetry"; import { Span, Transaction } from "@sentry/types"; import { createLogger, Logger } from "./sentry/logger"; -import { InternalOptions, normalizeUserOptions, validateOptions } from "./options-mapping"; +import { NormalizedOptions, normalizeUserOptions, validateOptions } from "./options-mapping"; import { getSentryCli } from "./sentry/cli"; import { makeMain } from "@sentry/node"; import os from "os"; @@ -70,18 +70,18 @@ const esbuildDebugIdInjectionFilePath = require.resolve( * * This release creation pipeline relies on Sentry CLI to execute the different steps. */ -const unplugin = createUnplugin((options, unpluginMetaContext) => { - const internalOptions = normalizeUserOptions(options); +const unplugin = createUnplugin((userOptions, unpluginMetaContext) => { + const options = normalizeUserOptions(userOptions); - const allowedToSendTelemetryPromise = shouldSendTelemetry(internalOptions); + const allowedToSendTelemetryPromise = shouldSendTelemetry(options); const { sentryHub, sentryClient } = makeSentryClient( "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737", allowedToSendTelemetryPromise, - internalOptions.project + options.project ); - addPluginOptionInformationToHub(internalOptions, sentryHub, unpluginMetaContext.framework); + addPluginOptionInformationToHub(options, sentryHub, unpluginMetaContext.framework); //TODO: This call is problematic because as soon as we set our hub as the current hub // we might interfere with other plugins that use Sentry. However, for now, we'll @@ -92,23 +92,23 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => const logger = createLogger({ prefix: `[sentry-${unpluginMetaContext.framework}-plugin]`, - silent: internalOptions.silent, - debug: internalOptions.debug, + silent: options.silent, + debug: options.debug, }); - if (!validateOptions(internalOptions, logger)) { + if (!validateOptions(options, logger)) { handleError( new Error("Options were not set correctly. See output above for more details."), logger, - internalOptions.errorHandler + options.errorHandler ); } - const cli = getSentryCli(internalOptions, logger); + const cli = getSentryCli(options, logger); const releaseNamePromise = new Promise((resolve) => { - if (options.release) { - resolve(options.release); + if (userOptions.release) { + resolve(userOptions.release); } else { resolve(cli.releases.proposeVersion()); } @@ -156,7 +156,7 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => "Unable to determine a release name. Make sure to set the `release` option or use an environment that supports auto-detection https://docs.sentry.io/cli/releases/#creating-releases`" ), logger, - internalOptions.errorHandler + options.errorHandler ); } @@ -211,13 +211,13 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => // a windows style path to `releaseInjectionTargets` const normalizedId = path.normalize(id); - if (internalOptions.releaseInjectionTargets) { + if (options.releaseInjectionTargets) { // If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option. - if (typeof internalOptions.releaseInjectionTargets === "function") { - return internalOptions.releaseInjectionTargets(normalizedId); + if (typeof options.releaseInjectionTargets === "function") { + return options.releaseInjectionTargets(normalizedId); } - return internalOptions.releaseInjectionTargets.some((entry) => { + return options.releaseInjectionTargets.some((entry) => { if (entry instanceof RegExp) { return entry.test(normalizedId); } else { @@ -247,7 +247,7 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => async transform(code, id) { logger.debug('Called "transform":', { id }); - if (!internalOptions.injectRelease) { + if (!options.injectRelease) { return; } @@ -259,10 +259,10 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => ms.append( generateGlobalInjectorCode({ release: await releaseNamePromise, - injectReleasesMap: internalOptions.injectReleasesMap, - injectBuildInformation: internalOptions._experiments.injectBuildInformation || false, - org: internalOptions.org, - project: internalOptions.project, + injectReleasesMap: options.injectReleasesMap, + injectBuildInformation: options._experiments.injectBuildInformation || false, + org: options.org, + project: options.project, }) ); } else { @@ -314,12 +314,12 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => try { if (!unpluginMetaContext.watchMode) { - if (internalOptions._experiments.debugIdUpload) { + if (options.sourcemaps?.assets) { const debugIdChunkFilePaths = ( - await glob(internalOptions._experiments.debugIdUpload.include, { + await glob(options.sourcemaps.assets, { absolute: true, nodir: true, - ignore: internalOptions._experiments.debugIdUpload.ignore, + ignore: options.sourcemaps.ignore, }) ).filter((p) => p.endsWith(".js") || p.endsWith(".mjs") || p.endsWith(".cjs")); @@ -363,15 +363,15 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => ); tmpUploadFolder = await sourceFileUploadFolderPromise; - await uploadDebugIdSourcemaps(internalOptions, ctx, tmpUploadFolder, releaseName); + await uploadDebugIdSourcemaps(options, ctx, tmpUploadFolder, releaseName); } - await createNewRelease(internalOptions, ctx, releaseName); - await cleanArtifacts(internalOptions, ctx, releaseName); - await uploadSourceMaps(internalOptions, ctx, releaseName); - await setCommits(internalOptions, ctx, releaseName); - await finalizeRelease(internalOptions, ctx, releaseName); - await addDeploy(internalOptions, ctx, releaseName); + await createNewRelease(options, ctx, releaseName); + await cleanArtifacts(options, ctx, releaseName); + await uploadSourceMaps(options, ctx, releaseName); + await setCommits(options, ctx, releaseName); + await finalizeRelease(options, ctx, releaseName); + await addDeploy(options, ctx, releaseName); } transaction?.setStatus("ok"); } catch (e: unknown) { @@ -380,7 +380,7 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => level: "error", message: "Error during writeBundle", }); - handleError(e, logger, internalOptions.errorHandler); + handleError(e, logger, options.errorHandler); } finally { if (tmpUploadFolder) { fs.rm(tmpUploadFolder, { recursive: true, force: true }, () => { @@ -402,7 +402,7 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => rollup: { renderChunk(code, chunk) { if ( - options._experiments?.debugIdUpload && + options.sourcemaps?.assets && [".js", ".mjs", ".cjs"].some((ending) => chunk.fileName.endsWith(ending)) // chunks could be any file (html, md, ...) ) { return injectDebugIdSnippetIntoChunk(code); @@ -414,7 +414,7 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => vite: { renderChunk(code, chunk) { if ( - options._experiments?.debugIdUpload && + options.sourcemaps?.assets && [".js", ".mjs", ".cjs"].some((ending) => chunk.fileName.endsWith(ending)) // chunks could be any file (html, md, ...) ) { return injectDebugIdSnippetIntoChunk(code); @@ -424,7 +424,7 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => }, }, webpack(compiler) { - if (options._experiments?.debugIdUpload) { + if (options.sourcemaps?.assets) { // Cache inspired by https://github.com/webpack/webpack/pull/15454 const cache = new WeakMap(); @@ -488,7 +488,7 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => }); if (unpluginMetaContext.framework === "esbuild") { - if (internalOptions._experiments.debugIdUpload) { + if (options.sourcemaps?.assets) { plugins.push({ name: "sentry-esbuild-debug-id-plugin", esbuild: { @@ -507,7 +507,7 @@ const unplugin = createUnplugin((options, unpluginMetaContext) => function handleError( unknownError: unknown, logger: Logger, - errorHandler: InternalOptions["errorHandler"] + errorHandler: NormalizedOptions["errorHandler"] ) { if (unknownError instanceof Error) { logger.error(unknownError.message); diff --git a/packages/bundler-plugin-core/src/options-mapping.ts b/packages/bundler-plugin-core/src/options-mapping.ts index 6dc37d4b..78567b3f 100644 --- a/packages/bundler-plugin-core/src/options-mapping.ts +++ b/packages/bundler-plugin-core/src/options-mapping.ts @@ -32,6 +32,7 @@ type OptionalInternalOptions = Partial< | "deploy" | "configFile" | "headers" + | "sourcemaps" > >; @@ -40,7 +41,7 @@ type NormalizedInternalOptions = { include: InternalIncludeEntry[]; }; -export type InternalOptions = RequiredInternalOptions & +export type NormalizedOptions = RequiredInternalOptions & OptionalInternalOptions & NormalizedInternalOptions; @@ -62,7 +63,7 @@ export type InternalIncludeEntry = RequiredInternalIncludeEntry & export const SENTRY_SAAS_URL = "https://sentry.io"; -export function normalizeUserOptions(userOptions: UserOptions): InternalOptions { +export function normalizeUserOptions(userOptions: UserOptions) { const options = { // include is the only strictly required option // (normalizeInclude needs all userOptions to access top-level include options) @@ -94,6 +95,7 @@ export function normalizeUserOptions(userOptions: UserOptions): InternalOptions injectReleasesMap: userOptions.injectReleasesMap ?? false, injectRelease: userOptions.injectRelease ?? true, uploadSourceMaps: userOptions.uploadSourceMaps ?? true, + sourcemaps: userOptions.sourcemaps, _experiments: userOptions._experiments ?? {}, // These options and can also be set via env variables or the config file. @@ -149,6 +151,10 @@ function normalizeReleaseInjectionTargets( * @return an array of `InternalIncludeEntry` objects. */ function normalizeInclude(userOptions: UserOptions): InternalIncludeEntry[] { + if (!userOptions.include) { + return []; + } + return arrayify(userOptions.include) .map((includeItem) => typeof includeItem === "string" ? { paths: [includeItem] } : includeItem @@ -198,7 +204,7 @@ function normalizeIncludeEntry( * * @returns `true` if the options are valid, `false` otherwise */ -export function validateOptions(options: InternalOptions, logger: Logger): boolean { +export function validateOptions(options: NormalizedOptions, logger: Logger): boolean { if (options.injectReleasesMap && !options.org) { logger.error( "The `injectReleasesMap` option was set but it is only supported when the `org` option is also specified.", diff --git a/packages/bundler-plugin-core/src/sentry/cli.ts b/packages/bundler-plugin-core/src/sentry/cli.ts index 329cb699..2e67ca51 100644 --- a/packages/bundler-plugin-core/src/sentry/cli.ts +++ b/packages/bundler-plugin-core/src/sentry/cli.ts @@ -1,5 +1,5 @@ import SentryCli, { SentryCliReleases } from "@sentry/cli"; -import { InternalOptions } from "../options-mapping"; +import { NormalizedOptions } from "../options-mapping"; import { Logger } from "./logger"; type SentryDryRunCLI = { @@ -14,7 +14,7 @@ export type SentryCLILike = SentryCli | SentryDryRunCLI; * In case, users selected the `dryRun` options, this returns a stub * that makes no-ops out of most CLI operations */ -export function getSentryCli(internalOptions: InternalOptions, logger: Logger): SentryCLILike { +export function getSentryCli(internalOptions: NormalizedOptions, logger: Logger): SentryCLILike { const { silent, org, project, authToken, url, vcsRemote, headers } = internalOptions; const cli = new SentryCli(internalOptions.configFile, { url, diff --git a/packages/bundler-plugin-core/src/sentry/releasePipeline.ts b/packages/bundler-plugin-core/src/sentry/releasePipeline.ts index 89d225a1..7df141f9 100644 --- a/packages/bundler-plugin-core/src/sentry/releasePipeline.ts +++ b/packages/bundler-plugin-core/src/sentry/releasePipeline.ts @@ -7,12 +7,12 @@ // - unnecessary functionality import { logger } from "@sentry/utils"; -import { InternalOptions } from "../options-mapping"; +import { NormalizedOptions } from "../options-mapping"; import { BuildContext } from "../types"; import { addSpanToTransaction } from "./telemetry"; export async function createNewRelease( - options: InternalOptions, + options: NormalizedOptions, ctx: BuildContext, releaseName: string ): Promise { @@ -32,7 +32,7 @@ export async function createNewRelease( } export async function cleanArtifacts( - options: InternalOptions, + options: NormalizedOptions, ctx: BuildContext, releaseName: string ): Promise { @@ -57,7 +57,7 @@ export async function cleanArtifacts( } export async function uploadSourceMaps( - options: InternalOptions, + options: NormalizedOptions, ctx: BuildContext, releaseName: string ): Promise { @@ -88,7 +88,7 @@ export async function uploadSourceMaps( } export async function uploadDebugIdSourcemaps( - options: InternalOptions, + options: NormalizedOptions, ctx: BuildContext, folderPathToUpload: string, releaseName: string @@ -121,7 +121,7 @@ export async function uploadDebugIdSourcemaps( } export async function setCommits( - options: InternalOptions, + options: NormalizedOptions, ctx: BuildContext, releaseName: string ): Promise { @@ -154,7 +154,7 @@ export async function setCommits( } export async function finalizeRelease( - options: InternalOptions, + options: NormalizedOptions, ctx: BuildContext, releaseName: string ): Promise { @@ -180,7 +180,7 @@ export async function finalizeRelease( } export async function addDeploy( - options: InternalOptions, + options: NormalizedOptions, ctx: BuildContext, releaseName: string ): Promise { diff --git a/packages/bundler-plugin-core/src/sentry/telemetry.ts b/packages/bundler-plugin-core/src/sentry/telemetry.ts index e63b30ef..9193f352 100644 --- a/packages/bundler-plugin-core/src/sentry/telemetry.ts +++ b/packages/bundler-plugin-core/src/sentry/telemetry.ts @@ -1,6 +1,6 @@ import SentryCli from "@sentry/cli"; import { defaultStackParser, Hub, makeNodeTransport, NodeClient, Span } from "@sentry/node"; -import { InternalOptions, SENTRY_SAAS_URL } from "../options-mapping"; +import { NormalizedOptions, SENTRY_SAAS_URL } from "../options-mapping"; import { BuildContext } from "../types"; const SENTRY_SAAS_HOSTNAME = "sentry.io"; @@ -81,7 +81,7 @@ export function addSpanToTransaction( } export function addPluginOptionInformationToHub( - options: InternalOptions, + options: NormalizedOptions, hub: Hub, bundler: "rollup" | "webpack" | "vite" | "esbuild" ) { @@ -96,7 +96,7 @@ export function addPluginOptionInformationToHub( errorHandler, deploy, include, - _experiments, + sourcemaps, } = options; hub.setTag("include", include.length > 1 ? "multiple-entries" : "single-entry"); @@ -125,7 +125,7 @@ export function addPluginOptionInformationToHub( if (errorHandler) { hub.setTag("error-handler", "custom"); } - if (_experiments.debugIdUpload) { + if (sourcemaps?.assets) { hub.setTag("debug-id-upload", true); } @@ -140,7 +140,7 @@ export function addPluginOptionInformationToHub( hub.setUser({ id: org }); } -export async function shouldSendTelemetry(options: InternalOptions): Promise { +export async function shouldSendTelemetry(options: NormalizedOptions): Promise { const { silent, org, project, authToken, url, vcsRemote, headers, telemetry, dryRun } = options; // `options.telemetry` defaults to true diff --git a/packages/bundler-plugin-core/src/types.ts b/packages/bundler-plugin-core/src/types.ts index 5cb11e3b..29858c17 100644 --- a/packages/bundler-plugin-core/src/types.ts +++ b/packages/bundler-plugin-core/src/types.ts @@ -92,9 +92,9 @@ export type Options = Omit & { * types can be uploaded by using the `ext` option. * Each path can be given as a string or an object with path-specific options * - * This is a required field. + * @deprecated Use the `sourcemaps` option instead. */ - include: string | IncludeEntry | Array; + include?: string | IncludeEntry | Array; /* --- other properties: */ @@ -213,8 +213,36 @@ export type Options = Omit & { */ uploadSourceMaps?: boolean; + /** + * Options for source maps uploading. + */ + sourcemaps?: { + /** + * A glob or an array of globs that specify the build artifacts that should be uploaded to Sentry. + * Leave this option undefined if you do not want to upload source maps to Sentry. + * + * The globbing patterns follow the implementation of the `glob` package. (https://www.npmjs.com/package/glob) + * + * Use the `debug` option to print information about which files end up being uploaded. + */ + assets: string | string[]; + + /** + * A glob or an array of globs that specify which build artifacts should not be uploaded to Sentry. + * + * Default: `[]` + * + * The globbing patterns follow the implementation of the `glob` package. (https://www.npmjs.com/package/glob) + * + * Use the `debug` option to print information about which files end up being uploaded. + */ + ignore?: string | string[]; + }; + /** * Options that are considered experimental and subject to change. + * + * @experimental API may change in any release */ _experiments?: { /** @@ -224,24 +252,6 @@ export type Options = Omit & { * Defaults to `false`. */ injectBuildInformation?: boolean; - - /** - * Configuration for debug ID upload. - * - * Note: Currently only functional for Vite, Webpack and Rollup. - */ - debugIdUpload?: { - /** - * Glob paths to files that should get be injected with a debug ID and uploaded. - */ - include: string | string[]; - /** - * Glob paths to files that should be ignored for debug ID injection and upload. - * - * Default: `[]` - */ - ignore?: string | string[]; - }; }; }; diff --git a/packages/bundler-plugin-core/test/option-mappings.test.ts b/packages/bundler-plugin-core/test/option-mappings.test.ts index 21d44e09..b69e5fba 100644 --- a/packages/bundler-plugin-core/test/option-mappings.test.ts +++ b/packages/bundler-plugin-core/test/option-mappings.test.ts @@ -1,5 +1,5 @@ import { Options } from "../src"; -import { InternalOptions, normalizeUserOptions, validateOptions } from "../src/options-mapping"; +import { NormalizedOptions, normalizeUserOptions, validateOptions } from "../src/options-mapping"; describe("normalizeUserOptions()", () => { test("should return correct value for default input", () => { @@ -113,9 +113,9 @@ describe("validateOptions", () => { }); it("should return `false` if `injectRelease` is `true` but org is not provided", () => { - const options = { injectReleasesMap: true } as Partial; + const options = { injectReleasesMap: true } as Partial; - expect(validateOptions(options as unknown as InternalOptions, mockedLogger)).toBe(false); + expect(validateOptions(options as unknown as NormalizedOptions, mockedLogger)).toBe(false); expect(mockedLogger.error).toHaveBeenCalledWith( expect.stringMatching(/injectReleasesMap.*org/), expect.stringMatching(/set.*org.*injectReleasesMap/) @@ -123,16 +123,16 @@ describe("validateOptions", () => { }); it("should return `true` if `injectRelease` is `true` and org is provided", () => { - const options = { injectReleasesMap: true, org: "my-org" } as Partial; + const options = { injectReleasesMap: true, org: "my-org" } as Partial; - expect(validateOptions(options as unknown as InternalOptions, mockedLogger)).toBe(true); + expect(validateOptions(options as unknown as NormalizedOptions, mockedLogger)).toBe(true); expect(mockedLogger.error).not.toHaveBeenCalled(); }); it("should return `false` if `setCommits` is set but neither auto nor manual options are set", () => { - const options = { setCommits: {} } as Partial; + const options = { setCommits: {} } as Partial; - expect(validateOptions(options as unknown as InternalOptions, mockedLogger)).toBe(false); + expect(validateOptions(options as unknown as NormalizedOptions, mockedLogger)).toBe(false); expect(mockedLogger.error).toHaveBeenCalledWith( expect.stringMatching(/setCommits.*missing.*properties/), expect.stringMatching(/set.*either.*auto.*repo.*commit/) @@ -142,7 +142,7 @@ describe("validateOptions", () => { it("should return `true` but warn if `setCommits` is set and both auto nor manual options are set", () => { const options = { setCommits: { auto: true, repo: "myRepo", commit: "myCommit" } }; - expect(validateOptions(options as unknown as InternalOptions, mockedLogger)).toBe(true); + expect(validateOptions(options as unknown as NormalizedOptions, mockedLogger)).toBe(true); expect(mockedLogger.error).not.toHaveBeenCalled(); expect(mockedLogger.warn).toHaveBeenCalledWith( expect.stringMatching(/setCommits.*auto.*repo.*commit/), @@ -152,9 +152,9 @@ describe("validateOptions", () => { }); it("should return `false` if `deploy`is set but `env` is not provided", () => { - const options = { deploy: {} } as Partial; + const options = { deploy: {} } as Partial; - expect(validateOptions(options as unknown as InternalOptions, mockedLogger)).toBe(false); + expect(validateOptions(options as unknown as NormalizedOptions, mockedLogger)).toBe(false); expect(mockedLogger.error).toHaveBeenCalledWith( expect.stringMatching(/deploy.*missing.*property/), expect.stringMatching(/set.*env/) @@ -162,9 +162,9 @@ describe("validateOptions", () => { }); it("should return `true` if `deploy`is set and `env` is provided", () => { - const options = { deploy: { env: "my-env" } } as Partial; + const options = { deploy: { env: "my-env" } } as Partial; - expect(validateOptions(options as unknown as InternalOptions, mockedLogger)).toBe(true); + expect(validateOptions(options as unknown as NormalizedOptions, mockedLogger)).toBe(true); expect(mockedLogger.error).not.toHaveBeenCalled(); }); @@ -175,9 +175,9 @@ describe("validateOptions", () => { authToken: "my-auth-token", include: [{}], finalize: true, - } as Partial; + } as Partial; - expect(validateOptions(options as unknown as InternalOptions, mockedLogger)).toBe(true); + expect(validateOptions(options as unknown as NormalizedOptions, mockedLogger)).toBe(true); expect(mockedLogger.error).not.toHaveBeenCalled(); }); }); diff --git a/packages/bundler-plugin-core/test/sentry/releasePipeline.test.ts b/packages/bundler-plugin-core/test/sentry/releasePipeline.test.ts index 2cbff27b..05f0e4fa 100644 --- a/packages/bundler-plugin-core/test/sentry/releasePipeline.test.ts +++ b/packages/bundler-plugin-core/test/sentry/releasePipeline.test.ts @@ -1,4 +1,4 @@ -import { InternalOptions, normalizeUserOptions } from "../../src/options-mapping"; +import { NormalizedOptions, normalizeUserOptions } from "../../src/options-mapping"; import { addDeploy, cleanArtifacts, @@ -59,7 +59,7 @@ describe("Release Pipeline", () => { describe("createNewRelease", () => { it("makes a call to Sentry CLI's releases creation command", async () => { - await createNewRelease({} as InternalOptions, ctx as unknown as BuildContext, "1.0.0"); + await createNewRelease({} as NormalizedOptions, ctx as unknown as BuildContext, "1.0.0"); expect(mockedCLI.releases.new).toHaveBeenCalledWith("1.0.0"); expect(mockedAddSpanToTxn).toHaveBeenCalledWith(ctx, "function.plugin.create_release"); @@ -69,7 +69,7 @@ describe("Release Pipeline", () => { describe("cleanArtifacts", () => { it("doest do anything if cleanArtifacts is not true", async () => { - await cleanArtifacts({} as InternalOptions, ctx as unknown as BuildContext, "my-release"); + await cleanArtifacts({} as NormalizedOptions, ctx as unknown as BuildContext, "my-release"); expect(mockedCLI.releases.execute).not.toHaveBeenCalled(); expect(mockedAddSpanToTxn).not.toHaveBeenCalled(); @@ -78,7 +78,7 @@ describe("Release Pipeline", () => { it("makes a call to Sentry CLI's artifact removal command if `cleanArtifacts` is set", async () => { await cleanArtifacts( - { cleanArtifacts: true } as InternalOptions, + { cleanArtifacts: true } as NormalizedOptions, ctx as unknown as BuildContext, "1.0.0" ); @@ -126,7 +126,7 @@ describe("Release Pipeline", () => { describe("setCommits", () => { it("doesn't do anything if `setCommits` option is not specified", async () => { - await setCommits({} as InternalOptions, ctx as unknown as BuildContext, "1.0.0"); + await setCommits({} as NormalizedOptions, ctx as unknown as BuildContext, "1.0.0"); expect(mockedCLI.releases.setCommits).not.toHaveBeenCalled(); expect(mockedAddSpanToTxn).not.toHaveBeenCalled(); @@ -135,7 +135,7 @@ describe("Release Pipeline", () => { it("makes a call to Sentry CLI if the correct options are specified", async () => { await setCommits( - { setCommits: { auto: true } } as InternalOptions, + { setCommits: { auto: true } } as NormalizedOptions, ctx as unknown as BuildContext, "1.0.0" ); @@ -148,7 +148,7 @@ describe("Release Pipeline", () => { describe("finalizeRelease", () => { it("doesn't do anything if `finalize` is not set", async () => { - await finalizeRelease({} as InternalOptions, ctx as unknown as BuildContext, "1.0.0"); + await finalizeRelease({} as NormalizedOptions, ctx as unknown as BuildContext, "1.0.0"); expect(mockedCLI.releases.finalize).not.toHaveBeenCalled(); expect(mockedAddSpanToTxn).not.toHaveBeenCalled(); @@ -157,7 +157,7 @@ describe("Release Pipeline", () => { it("makes a call to Sentry CLI's release finalization command if `finalize` is true", async () => { await finalizeRelease( - { finalize: true } as InternalOptions, + { finalize: true } as NormalizedOptions, ctx as unknown as BuildContext, "1.0.0" ); @@ -170,7 +170,7 @@ describe("Release Pipeline", () => { describe("addDeploy", () => { it("doesn't do anything if `deploy` option is not specified", async () => { - await addDeploy({} as InternalOptions, ctx as unknown as BuildContext, "1.0.0"); + await addDeploy({} as NormalizedOptions, ctx as unknown as BuildContext, "1.0.0"); expect(mockedCLI.releases.newDeploy).not.toHaveBeenCalled(); expect(mockedAddSpanToTxn).not.toHaveBeenCalled(); @@ -187,7 +187,7 @@ describe("Release Pipeline", () => { }; await addDeploy( - { deploy: deployOptions } as InternalOptions, + { deploy: deployOptions } as NormalizedOptions, ctx as unknown as BuildContext, "1.0.0" ); diff --git a/packages/bundler-plugin-core/test/sentry/telemetry.test.ts b/packages/bundler-plugin-core/test/sentry/telemetry.test.ts index 2178d5be..33faa5d4 100644 --- a/packages/bundler-plugin-core/test/sentry/telemetry.test.ts +++ b/packages/bundler-plugin-core/test/sentry/telemetry.test.ts @@ -1,5 +1,5 @@ import { Hub } from "@sentry/node"; -import { InternalOptions, normalizeUserOptions } from "../../src/options-mapping"; +import { NormalizedOptions, normalizeUserOptions } from "../../src/options-mapping"; import { addPluginOptionInformationToHub, shouldSendTelemetry } from "../../src/sentry/telemetry"; const mockCliExecute = jest.fn(); @@ -20,14 +20,14 @@ describe("shouldSendTelemetry", () => { mockCliExecute.mockImplementation( () => "Sentry Server: https://selfhostedSentry.io \nsomeotherstuff\netc" ); - expect(await shouldSendTelemetry({} as InternalOptions)).toBe(false); + expect(await shouldSendTelemetry({} as NormalizedOptions)).toBe(false); }); it("should return true if CLI returns sentry.io as a URL", async () => { mockCliExecute.mockImplementation( () => "Sentry Server: https://sentry.io \nsomeotherstuff\netc" ); - expect(await shouldSendTelemetry({} as InternalOptions)).toBe(true); + expect(await shouldSendTelemetry({} as NormalizedOptions)).toBe(true); }); }); diff --git a/packages/esbuild-plugin/README.md b/packages/esbuild-plugin/README.md index da422ece..a81f429c 100644 --- a/packages/esbuild-plugin/README.md +++ b/packages/esbuild-plugin/README.md @@ -54,10 +54,11 @@ The Sentry Esbuild Plugin takes an options argument with the following propertie | Option | Type | Required | Description | | ------------------------------------ | -------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| include | `string`/`array`/`object` | required | One or more paths that the plugin should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. Other file types can be uploaded by using the `ext` option. Each path can be given as a string or an object with path-specific options. See [table below](#include) for details. | | org | `string` | optional | The slug of the Sentry organization associated with the app. Can also be specified via the `SENTRY_ORG` environment variable. | | project | `string` | optional | The slug of the Sentry project associated with the app. Can also be specified via the `SENTRY_PROJECT` environment variable. | | authToken | `string` | optional | The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/settings/account/api/auth-tokens/. Required scopes: `project:releases` (and `org:read` if `setCommits` option is used). Can also be specified via the `SENTRY_AUTH_TOKEN` env variable. | +| sourcemaps.assets | string \| string[] | optional | A glob or an array of globs that specify the build artifacts that should be uploaded to Sentry. Leave this option undefined if you do not want to upload source maps to Sentry. The globbing patterns follow the implementation of the [`glob`](https://www.npmjs.com/package/glob) package. Use the `debug` option to print information about which files end up being uploaded. | +| sourcemaps.ignore | string \| string[] | optional | A glob or an array of globs that specify which build artifacts should not be uploaded to Sentry. The globbing patterns follow the implementation of the [`glob`](https://www.npmjs.com/package/glob) package. Use the `debug` option to print information about which files end up being uploaded. Default: `[]` | | url | `string` | optional | The base URL of your Sentry instance. Use this if you are using a self-hosted or Sentry instance other than sentry.io. This value can also be set via the `SENTRY_URL` environment variable. Defaults to https://sentry.io/, which is the correct value for SaaS customers. | | headers | `Record` | optional | Headers added to every outgoing network request. | | vcsRemote | `string` | optional | Version control system remote name. This value can also be specified via the `SENTRY_VSC_REMOTE` environment variable. Defaults to `'origin'`. | @@ -87,6 +88,7 @@ The Sentry Esbuild Plugin takes an options argument with the following propertie | injectReleasesMap | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_RELEASES` variable that maps from `{org}@{project}` to the `release` value. This might be helpful for webpack module federation or micro frontend setups. Defaults to `false`. | | uploadSourceMaps | `boolean` | optional | Whether the plugin should upload source maps to Sentry. Defaults to `true`. | | telemetry | `boolean` | optional | If set to true, internal plugin errors and performance data will be sent to Sentry. At Sentry we like to use Sentry ourselves to deliver faster and more stable products. We're very careful of what we're sending. We won't collect anything other than error and high-level performance data. We will never collect your code or any details of the projects in which you're using this plugin. Defaults to `true`. | +| include | `string`/`array`/`object` | required | One or more paths that the plugin should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. Other file types can be uploaded by using the `ext` option. Each path can be given as a string or an object with path-specific options. See [table below](#include) for details. (Note: This option is deprecated. Please use the `sourcemap` option instead) | | \_experiments.injectBuildInformation | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_BUILD_INFO` variable that contains information about the build that can be used to improve SDK functionality. Defaults to `false`. | #### options.include: diff --git a/packages/rollup-plugin/README.md b/packages/rollup-plugin/README.md index 2041ef12..030bacdc 100644 --- a/packages/rollup-plugin/README.md +++ b/packages/rollup-plugin/README.md @@ -54,10 +54,11 @@ The Sentry Rollup Plugin takes an options argument with the following properties | Option | Type | Required | Description | | ------------------------------------ | -------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| include | `string`/`array`/`object` | required | One or more paths that the plugin should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. Other file types can be uploaded by using the `ext` option. Each path can be given as a string or an object with path-specific options. See [table below](#include) for details. | | org | `string` | optional | The slug of the Sentry organization associated with the app. Can also be specified via the `SENTRY_ORG` environment variable. | | project | `string` | optional | The slug of the Sentry project associated with the app. Can also be specified via the `SENTRY_PROJECT` environment variable. | | authToken | `string` | optional | The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/settings/account/api/auth-tokens/. Required scopes: `project:releases` (and `org:read` if `setCommits` option is used). Can also be specified via the `SENTRY_AUTH_TOKEN` env variable. | +| sourcemaps.assets | string \| string[] | optional | A glob or an array of globs that specify the build artifacts that should be uploaded to Sentry. Leave this option undefined if you do not want to upload source maps to Sentry. The globbing patterns follow the implementation of the [`glob`](https://www.npmjs.com/package/glob) package. Use the `debug` option to print information about which files end up being uploaded. | +| sourcemaps.ignore | string \| string[] | optional | A glob or an array of globs that specify which build artifacts should not be uploaded to Sentry. The globbing patterns follow the implementation of the [`glob`](https://www.npmjs.com/package/glob) package. Use the `debug` option to print information about which files end up being uploaded. Default: `[]` | | url | `string` | optional | The base URL of your Sentry instance. Use this if you are using a self-hosted or Sentry instance other than sentry.io. This value can also be set via the `SENTRY_URL` environment variable. Defaults to https://sentry.io/, which is the correct value for SaaS customers. | | headers | `Record` | optional | Headers added to every outgoing network request. | | vcsRemote | `string` | optional | Version control system remote name. This value can also be specified via the `SENTRY_VSC_REMOTE` environment variable. Defaults to `'origin'`. | @@ -87,6 +88,7 @@ The Sentry Rollup Plugin takes an options argument with the following properties | injectReleasesMap | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_RELEASES` variable that maps from `{org}@{project}` to the `release` value. This might be helpful for webpack module federation or micro frontend setups. Defaults to `false`. | | uploadSourceMaps | `boolean` | optional | Whether the plugin should upload source maps to Sentry. Defaults to `true`. | | telemetry | `boolean` | optional | If set to true, internal plugin errors and performance data will be sent to Sentry. At Sentry we like to use Sentry ourselves to deliver faster and more stable products. We're very careful of what we're sending. We won't collect anything other than error and high-level performance data. We will never collect your code or any details of the projects in which you're using this plugin. Defaults to `true`. | +| include | `string`/`array`/`object` | required | One or more paths that the plugin should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. Other file types can be uploaded by using the `ext` option. Each path can be given as a string or an object with path-specific options. See [table below](#include) for details. (Note: This option is deprecated. Please use the `sourcemap` option instead) | | \_experiments.injectBuildInformation | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_BUILD_INFO` variable that contains information about the build that can be used to improve SDK functionality. Defaults to `false`. | #### options.include: diff --git a/packages/vite-plugin/README.md b/packages/vite-plugin/README.md index 639e8606..6cd60448 100644 --- a/packages/vite-plugin/README.md +++ b/packages/vite-plugin/README.md @@ -52,42 +52,44 @@ As an alternative to passing options explicitly, you can also use a `.sentryclir The Sentry Vite Plugin takes an options argument with the following properties: -| Option | Type | Required | Description | -| ----------------------------------- | -------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| include | `string`/`array`/`object` | required | One or more paths that the plugin should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. Other file types can be uploaded by using the `ext` option. Each path can be given as a string or an object with path-specific options. See [table below](#include) for details. | -| org | `string` | optional | The slug of the Sentry organization associated with the app. Can also be specified via the `SENTRY_ORG` environment variable. | -| project | `string` | optional | The slug of the Sentry project associated with the app. Can also be specified via the `SENTRY_PROJECT` environment variable. | -| authToken | `string` | optional | The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/settings/account/api/auth-tokens/. Required scopes: `project:releases` (and `org:read` if `setCommits` option is used). Can also be specified via the `SENTRY_AUTH_TOKEN` env variable. | -| url | `string` | optional | The base URL of your Sentry instance. Use this if you are using a self-hosted or Sentry instance other than sentry.io. This value can also be set via the `SENTRY_URL` environment variable. Defaults to https://sentry.io/, which is the correct value for SaaS customers. | -| headers | `Record` | optional | Headers added to every outgoing network request. | -| vcsRemote | `string` | optional | Version control system remote name. This value can also be specified via the `SENTRY_VSC_REMOTE` environment variable. Defaults to `'origin'`. | -| releaseInjectionTargets | `array`/`RegExp`/`(string \| RegExp)[]`/`function(filePath: string): bool` | optional | Filter for modules that the release should be injected in. This option takes a string, a regular expression, or an array containing strings, regular expressions, or both. It's also possible to provide a filter function that takes the absolute path of a processed module. It should return `true` if the release should be injected into the module and `false` otherwise. String values of this option require a full match with the absolute path of the module. By default, the release will be injected into all modules - however, bundlers will include the injected release code only once per entrypoint. If release injection should be disabled, provide an empty array here. | -| dist | `string` | optional | Unique identifier for the distribution, used to further segment your release. Usually your build number. | -| entries | `array`/`RegExp`/`(string \| RegExp)[]`/`function(filePath: string): bool` | optional | Filter for modules that the release should be injected in. This option takes a string, a regular expression, or an array containing strings, regular expressions, or both. It's also possible to provide a filter function that takes the absolute path of a processed module. It should return `true` if the release should be injected into the module and `false` otherwise. String values of this option require a full match with the absolute path of the bundle. By default, the release will be injected into all modules - however, bundlers will include the injected release code only once per entrypoint. | -| ignoreFile | `string` | optional | Path to a file containing list of files/directories to ignore. Can point to `.gitignore` or anything with the same format. | -| ignore | `string`/`array` | optional | One or more paths to ignore during upload. Overrides entries in `ignoreFile` file. Defaults to `['node_modules']` if neither `ignoreFile` nor `ignore` is set. | -| configFile | `string` | optional | Path to Sentry CLI config properties, as described in https://docs.sentry.io/product/cli/configuration/#configuration-file. By default, the config file is looked for upwards from the current path, and defaults from `~/.sentryclirc` are always loaded. | -| ext | `array` | optional | Array of file extensions of files to be collected for the file upload. By default the following file extensions are processed: js, map, jsbundle and bundle. | -| urlPrefix | `string` | optional | URL prefix to add to the beginning of all filenames. Defaults to `'~/'` but you might want to set this to the full URL. This is also useful if your files are stored in a sub folder. eg: url-prefix `'~/static/js'`. | -| urlSuffix | `string` | optional | URL suffix to add to the end of all filenames. Useful for appending query parameters. | -| validate | `boolean` | optional | When `true`, attempts source map validation before upload if rewriting is not enabled. It will spot a variety of issues with source maps and cancel the upload if any are found. Defaults to `false` as this can cause false positives. | -| stripPrefix | `array` | optional | When paired with the `rewrite` option, this will remove a prefix from filename references inside of sourcemaps. For instance you can use this to remove a path that is build machine specific. Note that this will NOT change the names of uploaded files. | -| stripCommonPrefix | `boolean` | optional | When paired with the `rewrite` option, this will add `~` to the `stripPrefix` array. | -| sourceMapReference | `boolean` | optional | Determines whether sentry-cli should attempt to link minified files with their corresponding maps. By default, it will match files and maps based on name, and add a Sourcemap header to each minified file for which it finds a map. Can be disabled if all minified files contain a `sourceMappingURL`. Defaults to `true`. | -| rewrite | `boolean` | optional | Enables rewriting of matching source maps so that indexed maps are flattened and missing sources are inlined if possible. Defaults to `true` | -| finalize | `boolean` | optional | Determines if the Sentry release record should be automatically finalized (meaning a date_released timestamp is added) after artifact upload. Defaults to `true`. | -| dryRun | `boolean` | optional | Attempts a dry run (useful for dev environments), making release creation a no-op. Defaults to `false`. | -| debug | `boolean` | optional | Print useful debug information. Defaults to `false`. | -| silent | `boolean` | optional | Suppresses all logs. Defaults to `false`. | -| cleanArtifacts | `boolean` | optional | Remove all the artifacts in the release before the upload. Defaults to `false`. | -| errorHandler | `function(err: Error): void` | optional | When an error occurs during rlease creation or sourcemaps upload, the plugin will call this function. By default, the plugin will simply throw an error, thereby stopping the bundling process. If an `errorHandler` callback is provided, compilation will continue, unless an error is thrown in the provided callback. | -| setCommits | `Object` | optional | Associates the release with its commits in Sentry. See [table below](#setCommits) for details. | -| deploy | `Object` | optional | Adds deployment information to the release in Sentry. See [table below](#deploy) for details. | -| injectRelease | `boolean` | optional | Whether the plugin should inject release information into the build. Defaults to `true`. | -| injectReleasesMap | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_RELEASES` variable that maps from `{org}@{project}` to the `release` value. This might be helpful for webpack module federation or micro frontend setups. Defaults to `false`. | -| uploadSourceMaps | `boolean` | optional | Whether the plugin should upload source maps to Sentry. Defaults to `true`. | -| telemetry | `boolean` | optional | If set to true, internal plugin errors and performance data will be sent to Sentry. At Sentry we like to use Sentry ourselves to deliver faster and more stable products. We're very careful of what we're sending. We won't collect anything other than error and high-level performance data. We will never collect your code or any details of the projects in which you're using this plugin. Defaults to `true`. | -| \_experimentsinjectBuildInformation | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_BUILD_INFO` variable that contains information about the build that can be used to improve SDK functionality. Defaults to `false`. | +| Option | Type | Required | Description | +| ------------------------------------ | -------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| org | `string` | optional | The slug of the Sentry organization associated with the app. Can also be specified via the `SENTRY_ORG` environment variable. | +| project | `string` | optional | The slug of the Sentry project associated with the app. Can also be specified via the `SENTRY_PROJECT` environment variable. | +| authToken | `string` | optional | The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/settings/account/api/auth-tokens/. Required scopes: `project:releases` (and `org:read` if `setCommits` option is used). Can also be specified via the `SENTRY_AUTH_TOKEN` env variable. | +| sourcemaps.assets | string \| string[] | optional | A glob or an array of globs that specify the build artifacts that should be uploaded to Sentry. Leave this option undefined if you do not want to upload source maps to Sentry. The globbing patterns follow the implementation of the [`glob`](https://www.npmjs.com/package/glob) package. Use the `debug` option to print information about which files end up being uploaded. | +| sourcemaps.ignore | string \| string[] | optional | A glob or an array of globs that specify which build artifacts should not be uploaded to Sentry. The globbing patterns follow the implementation of the [`glob`](https://www.npmjs.com/package/glob) package. Use the `debug` option to print information about which files end up being uploaded. Default: `[]` | +| url | `string` | optional | The base URL of your Sentry instance. Use this if you are using a self-hosted or Sentry instance other than sentry.io. This value can also be set via the `SENTRY_URL` environment variable. Defaults to https://sentry.io/, which is the correct value for SaaS customers. | +| headers | `Record` | optional | Headers added to every outgoing network request. | +| vcsRemote | `string` | optional | Version control system remote name. This value can also be specified via the `SENTRY_VSC_REMOTE` environment variable. Defaults to `'origin'`. | +| release | `string` | optional | Unique identifier for the release. This value can also be specified via the `SENTRY_RELEASE` environment variable. Defaults to the output of the `sentry-cli releases propose-version` command, which automatically detects values for Cordova, Heroku, AWS CodeBuild, CircleCI, Xcode, and Gradle, and otherwise uses the git `HEAD`'s commit SHA. (**the latter requires access to `git` CLI and for the root directory to be a valid repository**). | +| dist | `string` | optional | Unique identifier for the distribution, used to further segment your release. Usually your build number. | +| releaseInjectionTargets | `array`/`RegExp`/`(string \| RegExp)[]`/`function(filePath: string): bool` | optional | Filter for modules that the release should be injected in. This option takes a string, a regular expression, or an array containing strings, regular expressions, or both. It's also possible to provide a filter function that takes the absolute path of a processed module. It should return `true` if the release should be injected into the module and `false` otherwise. String values of this option require a full match with the absolute path of the module. By default, the release will be injected into all modules - however, bundlers will include the injected release code only once per entrypoint. If release injection should be disabled, provide an empty array here. | +| ignoreFile | `string` | optional | Path to a file containing list of files/directories to ignore. Can point to `.gitignore` or anything with the same format. | +| ignore | `string`/`array` | optional | One or more paths to ignore during upload. Overrides entries in `ignoreFile` file. Defaults to `['node_modules']` if neither `ignoreFile` nor `ignore` is set. | +| configFile | `string` | optional | Path to Sentry CLI config properties, as described in https://docs.sentry.io/product/cli/configuration/#configuration-file. By default, the config file is looked for upwards from the current path, and defaults from `~/.sentryclirc` are always loaded. | +| ext | `array` | optional | Array of file extensions of files to be collected for the file upload. By default the following file extensions are processed: js, map, jsbundle and bundle. | +| urlPrefix | `string` | optional | URL prefix to add to the beginning of all filenames. Defaults to `'~/'` but you might want to set this to the full URL. This is also useful if your files are stored in a sub folder. eg: url-prefix `'~/static/js'`. | +| urlSuffix | `string` | optional | URL suffix to add to the end of all filenames. Useful for appending query parameters. | +| validate | `boolean` | optional | When `true`, attempts source map validation before upload if rewriting is not enabled. It will spot a variety of issues with source maps and cancel the upload if any are found. Defaults to `false` as this can cause false positives. | +| stripPrefix | `array` | optional | When paired with the `rewrite` option, this will remove a prefix from filename references inside of sourcemaps. For instance you can use this to remove a path that is build machine specific. Note that this will NOT change the names of uploaded files. | +| stripCommonPrefix | `boolean` | optional | When paired with the `rewrite` option, this will add `~` to the `stripPrefix` array. | +| sourceMapReference | `boolean` | optional | Determines whether sentry-cli should attempt to link minified files with their corresponding maps. By default, it will match files and maps based on name, and add a Sourcemap header to each minified file for which it finds a map. Can be disabled if all minified files contain a `sourceMappingURL`. Defaults to `true`. | +| rewrite | `boolean` | optional | Enables rewriting of matching source maps so that indexed maps are flattened and missing sources are inlined if possible. Defaults to `true` | +| finalize | `boolean` | optional | Determines if the Sentry release record should be automatically finalized (meaning a date_released timestamp is added) after artifact upload. Defaults to `true`. | +| dryRun | `boolean` | optional | Attempts a dry run (useful for dev environments), making release creation a no-op. Defaults to `false`. | +| debug | `boolean` | optional | Print useful debug information. Defaults to `false`. | +| silent | `boolean` | optional | Suppresses all logs. Defaults to `false`. | +| cleanArtifacts | `boolean` | optional | Remove all the artifacts in the release before the upload. Defaults to `false`. | +| errorHandler | `function(err: Error): void` | optional | When an error occurs during rlease creation or sourcemaps upload, the plugin will call this function. By default, the plugin will simply throw an error, thereby stopping the bundling process. If an `errorHandler` callback is provided, compilation will continue, unless an error is thrown in the provided callback. | +| setCommits | `Object` | optional | Associates the release with its commits in Sentry. See [table below](#setCommits) for details. | +| deploy | `Object` | optional | Adds deployment information to the release in Sentry. See [table below](#deploy) for details. | +| injectRelease | `boolean` | optional | Whether the plugin should inject release information into the build. Defaults to `true`. | +| injectReleasesMap | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_RELEASES` variable that maps from `{org}@{project}` to the `release` value. This might be helpful for webpack module federation or micro frontend setups. Defaults to `false`. | +| uploadSourceMaps | `boolean` | optional | Whether the plugin should upload source maps to Sentry. Defaults to `true`. | +| telemetry | `boolean` | optional | If set to true, internal plugin errors and performance data will be sent to Sentry. At Sentry we like to use Sentry ourselves to deliver faster and more stable products. We're very careful of what we're sending. We won't collect anything other than error and high-level performance data. We will never collect your code or any details of the projects in which you're using this plugin. Defaults to `true`. | +| include | `string`/`array`/`object` | required | One or more paths that the plugin should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. Other file types can be uploaded by using the `ext` option. Each path can be given as a string or an object with path-specific options. See [table below](#include) for details. (Note: This option is deprecated. Please use the `sourcemap` option instead) | +| \_experiments.injectBuildInformation | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_BUILD_INFO` variable that contains information about the build that can be used to improve SDK functionality. Defaults to `false`. | #### options.include: diff --git a/packages/webpack-plugin/README.md b/packages/webpack-plugin/README.md index 7f894b15..36cdc584 100644 --- a/packages/webpack-plugin/README.md +++ b/packages/webpack-plugin/README.md @@ -54,10 +54,11 @@ The Sentry Webpack Plugin takes an options argument with the following propertie | Option | Type | Required | Description | | ------------------------------------ | -------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| include | `string`/`array`/`object` | required | One or more paths that the plugin should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. Other file types can be uploaded by using the `ext` option. Each path can be given as a string or an object with path-specific options. See [table below](#include) for details. | | org | `string` | optional | The slug of the Sentry organization associated with the app. Can also be specified via the `SENTRY_ORG` environment variable. | | project | `string` | optional | The slug of the Sentry project associated with the app. Can also be specified via the `SENTRY_PROJECT` environment variable. | | authToken | `string` | optional | The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/settings/account/api/auth-tokens/. Required scopes: `project:releases` (and `org:read` if `setCommits` option is used). Can also be specified via the `SENTRY_AUTH_TOKEN` env variable. | +| sourcemaps.assets | string \| string[] | optional | A glob or an array of globs that specify the build artifacts that should be uploaded to Sentry. Leave this option undefined if you do not want to upload source maps to Sentry. The globbing patterns follow the implementation of the [`glob`](https://www.npmjs.com/package/glob) package. Use the `debug` option to print information about which files end up being uploaded. | +| sourcemaps.ignore | string \| string[] | optional | A glob or an array of globs that specify which build artifacts should not be uploaded to Sentry. The globbing patterns follow the implementation of the [`glob`](https://www.npmjs.com/package/glob) package. Use the `debug` option to print information about which files end up being uploaded. Default: `[]` | | url | `string` | optional | The base URL of your Sentry instance. Use this if you are using a self-hosted or Sentry instance other than sentry.io. This value can also be set via the `SENTRY_URL` environment variable. Defaults to https://sentry.io/, which is the correct value for SaaS customers. | | headers | `Record` | optional | Headers added to every outgoing network request. | | vcsRemote | `string` | optional | Version control system remote name. This value can also be specified via the `SENTRY_VSC_REMOTE` environment variable. Defaults to `'origin'`. | @@ -87,6 +88,7 @@ The Sentry Webpack Plugin takes an options argument with the following propertie | injectReleasesMap | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_RELEASES` variable that maps from `{org}@{project}` to the `release` value. This might be helpful for webpack module federation or micro frontend setups. Defaults to `false`. | | uploadSourceMaps | `boolean` | optional | Whether the plugin should upload source maps to Sentry. Defaults to `true`. | | telemetry | `boolean` | optional | If set to true, internal plugin errors and performance data will be sent to Sentry. At Sentry we like to use Sentry ourselves to deliver faster and more stable products. We're very careful of what we're sending. We won't collect anything other than error and high-level performance data. We will never collect your code or any details of the projects in which you're using this plugin. Defaults to `true`. | +| include | `string`/`array`/`object` | required | One or more paths that the plugin should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. Other file types can be uploaded by using the `ext` option. Each path can be given as a string or an object with path-specific options. See [table below](#include) for details. (Note: This option is deprecated. Please use the `sourcemap` option instead) | | \_experiments.injectBuildInformation | `boolean` | optional | If set to true, the plugin will inject an additional `SENTRY_BUILD_INFO` variable that contains information about the build that can be used to improve SDK functionality. Defaults to `false`. | #### options.include: