Skip to content

Commit

Permalink
Telemetry: Add project type and version info to init event
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Dec 6, 2022
1 parent 098664d commit 63e76fe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions code/lib/cli/src/initiate.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -274,10 +274,6 @@ async function doInitiate(options: CommandOptions, pkg: Package): Promise<void>
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({
Expand Down Expand Up @@ -323,6 +319,11 @@ async function doInitiate(options: CommandOptions, pkg: Package): Promise<void>
...(isEsm ? { commonJs: true } : undefined),
});

if (!options.disableTelemetry) {
const version = await getStorybookCoreVersion();
telemetry('init', { projectType, version }, { stripMetadata: true });
}

if (!options.skipInstall) {
packageManager.installDependencies();
}
Expand Down

0 comments on commit 63e76fe

Please sign in to comment.