From c4462a386be2f5c55e9e2e1df7cebe44d5de57ec Mon Sep 17 00:00:00 2001 From: Abdellah Hariti Date: Fri, 14 Feb 2025 15:54:00 +0100 Subject: [PATCH 1/4] chore: point user to setup missing SENTRY_AUTH_TOKEN in passThroughEnv on Turborepo closes #674 --- packages/bundler-plugin-core/src/index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index 159444bc..fe7704c2 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -319,7 +319,11 @@ export function sentryUnpluginFactory({ const injectionCode = generateModuleMetadataInjectorCode(metadata); plugins.push(moduleMetadataInjectionPlugin(injectionCode)); } - + // https://turbo.build/repo/docs/reference/system-environment-variables#environment-variables-in-tasks + const isRunningInTurboRepo = Boolean(process.env["TURBO_HASH"]); + const TUROBOREPO_PASSTHROUGH_TOKEN_MSG = isRunningInTurboRepo + ? "\nYou seem to be using Truborepo, did you forget to put `SENTRY_AUTH_TOKEN` in `passThroughEnv`? https://turbo.build/repo/docs/reference/configuration#passthroughenv" + : ""; if (!options.release.name) { logger.debug( "No release name provided. Will not create release. Please set the `release.name` option to identify your release." @@ -328,7 +332,8 @@ export function sentryUnpluginFactory({ logger.debug("Running in development mode. Will not create release."); } else if (!options.authToken) { logger.warn( - "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/" + "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/" + + TUROBOREPO_PASSTHROUGH_TOKEN_MSG ); } else if (!options.org && !options.authToken.startsWith("sntrys_")) { logger.warn( @@ -378,7 +383,8 @@ export function sentryUnpluginFactory({ logger.debug("Running in development mode. Will not upload sourcemaps."); } else if (!options.authToken) { logger.warn( - "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/" + "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/" + + TUROBOREPO_PASSTHROUGH_TOKEN_MSG ); } else if (!options.org && !options.authToken.startsWith("sntrys_")) { logger.warn( From 1819ad1ae87ad40d8dd2af2cfeb4685306dd2a52 Mon Sep 17 00:00:00 2001 From: Abdellah Hariti Date: Tue, 25 Feb 2025 12:11:35 +0000 Subject: [PATCH 2/4] fix: warn about missing SENTRY_ORG and SENTRY_PROJECT vars on Turborepo --- packages/bundler-plugin-core/src/index.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index fe7704c2..53f13241 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -321,9 +321,10 @@ export function sentryUnpluginFactory({ } // https://turbo.build/repo/docs/reference/system-environment-variables#environment-variables-in-tasks const isRunningInTurboRepo = Boolean(process.env["TURBO_HASH"]); - const TUROBOREPO_PASSTHROUGH_TOKEN_MSG = isRunningInTurboRepo - ? "\nYou seem to be using Truborepo, did you forget to put `SENTRY_AUTH_TOKEN` in `passThroughEnv`? https://turbo.build/repo/docs/reference/configuration#passthroughenv" - : ""; + const getTruboRepoEnvPassthroughWarning = (envVarName: string) => + isRunningInTurboRepo + ? `\nYou seem to be using Truborepo, did you forget to put ${envVarName} in \`passThroughEnv\`? https://turbo.build/repo/docs/reference/configuration#passthroughenv` + : ""; if (!options.release.name) { logger.debug( "No release name provided. Will not create release. Please set the `release.name` option to identify your release." @@ -333,15 +334,17 @@ export function sentryUnpluginFactory({ } else if (!options.authToken) { logger.warn( "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/" + - TUROBOREPO_PASSTHROUGH_TOKEN_MSG + getTruboRepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN") ); } else if (!options.org && !options.authToken.startsWith("sntrys_")) { logger.warn( - "No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug." + "No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug." + + getTruboRepoEnvPassthroughWarning("SENTRY_ORG") ); } else if (!options.project) { logger.warn( - "No project provided. Will not create release. Please set the `project` option to your Sentry project slug." + "No project provided. Will not create release. Please set the `project` option to your Sentry project slug." + + getTruboRepoEnvPassthroughWarning("SENTRY_PROJECT") ); } else { plugins.push( @@ -384,7 +387,7 @@ export function sentryUnpluginFactory({ } else if (!options.authToken) { logger.warn( "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/" + - TUROBOREPO_PASSTHROUGH_TOKEN_MSG + getTruboRepoEnvPassthroughWarning ); } else if (!options.org && !options.authToken.startsWith("sntrys_")) { logger.warn( From 01c981668fe47f22d342b2e1b9f503f0ac6bf456 Mon Sep 17 00:00:00 2001 From: Abdellah Hariti Date: Tue, 25 Feb 2025 12:24:15 +0000 Subject: [PATCH 3/4] oops --- packages/bundler-plugin-core/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index 53f13241..98c21849 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -387,7 +387,7 @@ export function sentryUnpluginFactory({ } else if (!options.authToken) { logger.warn( "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/" + - getTruboRepoEnvPassthroughWarning + getTruboRepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN") ); } else if (!options.org && !options.authToken.startsWith("sntrys_")) { logger.warn( From c5ce9badedebd77042a69d071a10a8b38eeffca7 Mon Sep 17 00:00:00 2001 From: Abdellah Hariti Date: Tue, 25 Feb 2025 12:29:30 +0000 Subject: [PATCH 4/4] more warnings --- packages/bundler-plugin-core/src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index 98c21849..fc28d1c1 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -391,11 +391,13 @@ export function sentryUnpluginFactory({ ); } else if (!options.org && !options.authToken.startsWith("sntrys_")) { logger.warn( - "No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." + "No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." + + getTruboRepoEnvPassthroughWarning("SENTRY_ORG") ); } else if (!options.project) { logger.warn( - "No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug." + "No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug." + + getTruboRepoEnvPassthroughWarning("SENTRY_PROJECT") ); } else { // This option is only strongly typed for the webpack plugin, where it is used. It has no effect on other plugins