diff --git a/CHANGELOG.md b/CHANGELOG.md index 160f66352..3a3cf70ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- feat: Add `--saas` CLI arg to skip self-hosted or SaaS selection step (#678) + ## 3.31.0 - fix(sveltekit): Create bundler plugin env file instead of sentryclirc (#675) diff --git a/bin.ts b/bin.ts index 20c2d9072..d72973d41 100644 --- a/bin.ts +++ b/bin.ts @@ -60,6 +60,11 @@ const argv = yargs(hideBin(process.argv)) alias: 'url', describe: 'The url to your Sentry installation\nenv: SENTRY_WIZARD_URL', }) + .option('saas', { + default: false, + describe: 'If set, skip the self-hosted or SaaS URL selection process', + type: 'boolean', + }) .option('s', { alias: 'signup', default: false, diff --git a/src/run.ts b/src/run.ts index c6d13a868..dcf8eacc1 100644 --- a/src/run.ts +++ b/src/run.ts @@ -41,6 +41,7 @@ type Args = { platform?: Platform[]; org?: string; project?: string; + saas?: boolean; }; export async function run(argv: Args) { @@ -79,18 +80,19 @@ export async function run(argv: Args) { } const wizardOptions: WizardOptions = { - telemetryEnabled: !argv.disableTelemetry, - promoCode: argv.promoCode, - url: argv.url, - orgSlug: argv.org, - projectSlug: argv.project, + telemetryEnabled: !finalArgs.disableTelemetry, + promoCode: finalArgs.promoCode, + url: finalArgs.url, + orgSlug: finalArgs.org, + projectSlug: finalArgs.project, + saas: finalArgs.saas, }; switch (integration) { case 'reactNative': await runReactNativeWizard({ ...wizardOptions, - uninstall: argv.uninstall, + uninstall: finalArgs.uninstall, }); break; diff --git a/src/telemetry.ts b/src/telemetry.ts index 2b0e401af..c946d28f0 100644 --- a/src/telemetry.ts +++ b/src/telemetry.ts @@ -34,6 +34,7 @@ export async function withTelemetry( // Set tag for passed CLI args sentryHub.setTag('args.project', !!options.wizardOptions.projectSlug); sentryHub.setTag('args.org', !!options.wizardOptions.orgSlug); + sentryHub.setTag('args.saas', !!options.wizardOptions.saas); try { return await startSpan( diff --git a/src/utils/clack-utils.ts b/src/utils/clack-utils.ts index cf56a9579..fd1e099e5 100644 --- a/src/utils/clack-utils.ts +++ b/src/utils/clack-utils.ts @@ -847,7 +847,7 @@ export async function getOrAskForProjectData( } const { url: sentryUrl, selfHosted } = await traceStep( 'ask-self-hosted', - () => askForSelfHosted(options.url), + () => askForSelfHosted(options.url, options.saas), ); const { projects, apiKeys } = await traceStep('login', () => @@ -908,10 +908,19 @@ ${chalk.cyan( * * @param urlFromArgs the url passed via the --url arg */ -async function askForSelfHosted(urlFromArgs?: string): Promise<{ +async function askForSelfHosted( + urlFromArgs?: string, + saas?: boolean, +): Promise<{ url: string; selfHosted: boolean; }> { + if (saas) { + Sentry.setTag('url', SAAS_URL); + Sentry.setTag('self-hosted', false); + return { url: SAAS_URL, selfHosted: false }; + } + if (!urlFromArgs) { const choice: 'saas' | 'self-hosted' | symbol = await abortIfCancelled( clack.select({ diff --git a/src/utils/types.ts b/src/utils/types.ts index f1feeed5b..664bb9a9a 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -47,6 +47,12 @@ export type WizardOptions = { */ projectSlug?: string; + /** + * If this option is set, the wizard will skip the self-hosted or SaaS + * selection step and directly assume that the wizard is used for Sentry SaaS. + */ + saas?: boolean; + /** * If this is set, the wizard will skip the login and project selection step. * (This can not yet be set externally but for example when redirecting from