chore: implement a new prompt to enable A/B test and track the event (#24125)

* chore: implement a new prompt to enable A/B test and track the event

* chore: update the name of the event

* chore: lint
This commit is contained in:
Maxime Castres 2025-08-22 12:34:48 +02:00 committed by GitHub
parent 1dfd60174c
commit 6a38f974ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 1 deletions

View File

@ -41,6 +41,7 @@ async function createApp(scope: Scope) {
packageManager,
gitInit,
runApp,
isABTestEnabled,
} = scope;
const shouldRunSeed = useExample && installDependencies;
@ -254,6 +255,10 @@ async function createApp(scope: Scope) {
logger.fatal('Failed to start your Strapi application');
}
}
if (isABTestEnabled) {
await trackUsage({ event: 'didEnableABTest', scope });
}
}
async function runInstall({ rootPath, packageManager }: Scope) {

View File

@ -161,6 +161,7 @@ async function run(args: string[]): Promise<void> {
'styled-components': '^6.0.0',
},
shouldCreateGrowthSsoTrial,
isABTestEnabled: false,
};
if (options.template !== undefined) {
@ -207,6 +208,8 @@ async function run(args: string[]): Promise<void> {
scope.gitInit = await prompts.gitInit();
}
scope.isABTestEnabled = await prompts.enableABTests();
addDatabaseDependencies(scope);
try {

View File

@ -75,4 +75,19 @@ async function installDependencies(packageManager: string) {
return installDependencies;
}
export { directory, typescript, example, gitInit, installDependencies };
async function enableABTests() {
const { enableABTests } = await inquirer.prompt<{
enableABTests: boolean;
}>([
{
type: 'confirm',
name: 'enableABTests',
message: `Participate in anonymous A/B testing (to improve Strapi)?`,
default: false,
},
]);
return enableABTests;
}
export { directory, typescript, example, gitInit, installDependencies, enableABTests };

View File

@ -64,6 +64,7 @@ export interface Scope {
useExample?: boolean;
gitInit?: boolean;
shouldCreateGrowthSsoTrial: boolean;
isABTestEnabled: boolean;
}
export type ClientName = 'mysql' | 'postgres' | 'sqlite';