diff --git a/packages/cli/src/lib/errors.ts b/packages/cli/src/lib/errors.ts index dcc8bd198..f4794f6d2 100644 --- a/packages/cli/src/lib/errors.ts +++ b/packages/cli/src/lib/errors.ts @@ -33,6 +33,7 @@ import { redactCredentialText } from "./credential-redaction.js"; import { buildBillingUrl, buildOrgSettingsUrl, + buildSeerAutoReloadUrl, buildSeerSettingsUrl, buildSourceCodeIntegrationsUrl, } from "./sentry-urls.js"; @@ -932,8 +933,8 @@ export class SeerError extends CliError { // out_of_credits orgs already have Seer, so a trial is not the fix. // Sentry doesn't say whether auto-reload is off or has run through its // top-ups, so the advice covers both. - out_of_credits: `Someone with billing access can adjust Seer spend and auto-reload in Sentry:\n ${buildBillingUrl(this.orgSlug, "seer")}`, - daily_cap_exceeded: `Someone with billing access can raise the limit in Sentry, or you can try again tomorrow:\n ${buildBillingUrl(this.orgSlug, "seer")}`, + out_of_credits: `Someone with billing access can adjust Seer spend and auto-reload in Sentry:\n ${buildSeerAutoReloadUrl(this.orgSlug)}`, + daily_cap_exceeded: `Someone with billing access can raise the limit in Sentry, or you can try again tomorrow:\n ${buildSeerAutoReloadUrl(this.orgSlug, "daily_cap_exceeded")}`, // Setup gaps are fixed in Sentry settings, not with a trial. scm_integration_required: `Connect GitHub or GitLab to Sentry:\n ${buildSourceCodeIntegrationsUrl(this.orgSlug)}`, repos_not_linked: `Connect the project's repositories in Seer settings:\n ${buildSeerSettingsUrl(this.orgSlug)}`, diff --git a/packages/cli/src/lib/sentry-urls.ts b/packages/cli/src/lib/sentry-urls.ts index 3e8dbd507..458dc605b 100644 --- a/packages/cli/src/lib/sentry-urls.ts +++ b/packages/cli/src/lib/sentry-urls.ts @@ -308,6 +308,22 @@ export function buildBillingUrl(orgSlug: string, product?: string): string { return product ? `${base}?product=${product}` : base; } +/** + * Build URL to the billing page with the Seer auto-reload modal open. + * + * @param orgSlug - Organization slug + * @param denialReason - Why Seer stopped, which the modal uses for its copy + */ +export function buildSeerAutoReloadUrl( + orgSlug: string, + denialReason?: string, +): string { + const hash = denialReason + ? `#open-seer-auto-reload-modal:${denialReason}` + : "#open-seer-auto-reload-modal"; + return `${buildBillingUrl(orgSlug)}${hash}`; +} + // Logs URLs /** diff --git a/packages/cli/test/lib/errors.test.ts b/packages/cli/test/lib/errors.test.ts index 3ce5e7510..312c66553 100644 --- a/packages/cli/test/lib/errors.test.ts +++ b/packages/cli/test/lib/errors.test.ts @@ -397,20 +397,20 @@ describe("SeerError", () => { expect(formatted).toContain("my-org"); }); - test("format() includes billing URL for out_of_credits with orgSlug", () => { + test("format() links auto-reload modal for out_of_credits with orgSlug", () => { const formatted = new SeerError("out_of_credits", "my-org").format(); expect(formatted).toContain("Your organization is out of Seer credits."); expect(formatted).toContain( - "https://my-org.sentry.io/settings/billing/overview/?product=seer", + "https://my-org.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal", ); }); - test("format() includes billing URL for daily_cap_exceeded with orgSlug", () => { + test("format() links auto-reload modal with reason for daily_cap_exceeded with orgSlug", () => { const formatted = new SeerError("daily_cap_exceeded", "my-org").format(); expect(formatted).toBe( "Your organization has reached its daily Seer spend limit.\n\n" + "Someone with billing access can raise the limit in Sentry, or you can try again tomorrow:\n" + - " https://my-org.sentry.io/settings/billing/overview/?product=seer", + " https://my-org.sentry.io/settings/billing/overview/#open-seer-auto-reload-modal:daily_cap_exceeded", ); });