Skip to content

Commit

Permalink
fix: warn about missing SENTRY_ORG and SENTRY_PROJECT vars on Turborepo
Browse files Browse the repository at this point in the history
  • Loading branch information
a-hariti committed Feb 25, 2025
1 parent c4462a3 commit 1819ad1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/bundler-plugin-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 1819ad1

Please sign in to comment.