From cce67f2c9afa30401f729c6eeb83ce7e8710019f Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Tue, 6 Dec 2022 10:42:32 +0800 Subject: [PATCH] Telemetry: Add project type and version info to init event --- code/lib/cli/src/initiate.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/code/lib/cli/src/initiate.ts b/code/lib/cli/src/initiate.ts index 1b9e24a2496b..890313af708e 100644 --- a/code/lib/cli/src/initiate.ts +++ b/code/lib/cli/src/initiate.ts @@ -1,7 +1,7 @@ import type { Package } from 'update-notifier'; import chalk from 'chalk'; import prompts from 'prompts'; -import { telemetry } from '@storybook/telemetry'; +import { telemetry, getStorybookCoreVersion } from '@storybook/telemetry'; import { withTelemetry } from '@storybook/core-server'; import { installableProjectTypes, ProjectType } from './project_types'; @@ -274,10 +274,6 @@ async function doInitiate(options: CommandOptions, pkg: Package): Promise const welcomeMessage = 'storybook init - the simplest way to add a Storybook to your project.'; logger.log(chalk.inverse(`\n ${welcomeMessage} \n`)); - if (!options.disableTelemetry) { - telemetry('init', {}, { stripMetadata: true }); - } - // Update notify code. const { default: updateNotifier } = await import('update-notifier'); updateNotifier({ @@ -327,6 +323,11 @@ async function doInitiate(options: CommandOptions, pkg: Package): Promise packageManager.installDependencies(); } + if (!options.disableTelemetry) { + const version = await getStorybookCoreVersion(); + telemetry('init', { projectType, version }); + } + await automigrate({ yes: options.yes || process.env.CI === 'true', useNpm, force: pkgMgr }); logger.log('\nTo run your Storybook, type:\n');