Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

- 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)
Expand Down
5 changes: 5 additions & 0 deletions bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Copy link
Member Author

@Lms24 Lms24 Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed we didn't add --project and --org to this list. @obostjancic was this on purpose? If not, I'll quickly add it. This ensures that --help lists the two options in the help message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed that it's missing from the readme file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think the readme was generally a bit outdated. I updated it, along with adding --project and --org to the readme and --help output in a follow-up PR: #679

default: false,
describe: 'If set, skip the self-hosted or SaaS URL selection process',
type: 'boolean',
})
.option('s', {
alias: 'signup',
default: false,
Expand Down
14 changes: 8 additions & 6 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Args = {
platform?: Platform[];
org?: string;
project?: string;
saas?: boolean;
};

export async function run(argv: Args) {
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export async function withTelemetry<F>(
// 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(
Expand Down
13 changes: 11 additions & 2 deletions src/utils/clack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () =>
Expand Down Expand Up @@ -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({
Expand Down
6 changes: 6 additions & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading