Skip to content

Commit

Permalink
feat: mark sm onboarding steps as done on init
Browse files Browse the repository at this point in the history
  • Loading branch information
BohdanOne committed Dec 11, 2024
1 parent b35f9f5 commit 70a4b1d
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions packages/init/src/SliceMachineInitProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class SliceMachineInitProcess {
await this.syncDataWithPrismic();
await this.initializeProject();
await this.initializePlugins();
await this.completeOnboardingSteps();
} catch (error) {
await this.trackError(error);

Expand Down Expand Up @@ -893,14 +894,18 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
};
}

protected async completeOnboardingSteps(...steps: string[]): Promise<void> {
protected async completeOnboardingSteps(): Promise<void> {
try {
const { value: onboardingExperimentVariant } =
(await this.manager.telemetry.getExperimentVariant(
"shared-onboarding",
)) ?? {};
if (onboardingExperimentVariant === "with-shared-onboarding") {
this.manager.prismicRepository.completeOnboardingStep(...steps);
this.manager.prismicRepository.completeOnboardingStep(
"chooseLocale",
"createProject",
"setupSliceMachine",
);
}
} catch (error) {
await this.trackError(error);
Expand Down Expand Up @@ -933,11 +938,6 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
framework: this.context.framework.wroomTelemetryID,
starterId: this.context.starterId,
});

await this.completeOnboardingSteps(
"createProject",
"setupSliceMachine",
);
} catch (error) {
// When we have an error here, it's most probably because the user has a stale SESSION cookie

Expand Down Expand Up @@ -973,11 +973,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
const documentsRead = await this.readDocuments();

if (documentsRead !== undefined && documentsRead.documents.length > 0) {
// if there are documents to push, we assume it's a starter which
// has a master locale already set, and we only ensure the onboarding
// step is completed.
await this.completeOnboardingSteps("chooseLocale");

// if there are documents to push, we assume it's a starter which has a master locale already set
return;
}

Expand All @@ -989,8 +985,6 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
task.title = `Main content language set to ${chalk.cyan(
"English - United States",
)} 🇺🇸. You can change it anytime in your project settings.`;

await this.completeOnboardingSteps("chooseLocale");
},
},
]);
Expand Down

0 comments on commit 70a4b1d

Please sign in to comment.