diff --git a/.changeset/neat-masks-rhyme.md b/.changeset/neat-masks-rhyme.md new file mode 100644 index 0000000000..6ee9bb28bd --- /dev/null +++ b/.changeset/neat-masks-rhyme.md @@ -0,0 +1,5 @@ +--- +"create-tina-app": patch +--- + +Fix - selected package manager would not be captured as telemetry when passed in as a parameter diff --git a/packages/create-tina-app/src/index.ts b/packages/create-tina-app/src/index.ts index 269fb6dcc5..20c0a5b583 100644 --- a/packages/create-tina-app/src/index.ts +++ b/packages/create-tina-app/src/index.ts @@ -112,7 +112,7 @@ export async function run() { if (!opts.noTelemetry) { console.log(`\n${TextStylesBold.bold('Telemetry Notice')}`); console.log( - `To help the TinaCMS team improve the developer experience, create-tina-app collects anonymous usage statistics. This data helps us understand which environments and features are most important to support. Usage analytics may include: Operating system and version, package manager name and version (local only), Node.js version (local only), and the selected TinaCMS starter template.\nNo personal or project-specific code is ever collected. You can opt out at any time by passing the --noTelemetry flag.\n` + 'To help the TinaCMS team improve the developer experience, create-tina-app collects anonymous usage statistics. This data helps us understand which environments and features are most important to support. Usage analytics may include: Operating system and version, package manager name and version (local only), Node.js version (local only), and the selected TinaCMS starter template.\nNo personal or project-specific code is ever collected. You can opt out at any time by passing the --noTelemetry flag.\n' ); posthogClient = await initializePostHog( @@ -134,6 +134,14 @@ export async function run() { telemetryData[`${pkgManager}-installed`] = installedPkgManagers.includes(pkgManager); } + + // capture params as telemetry data + if (opts.template) { + telemetryData['template'] = opts.template; + } + if (opts.pkgManager) { + telemetryData['package-manager'] = opts.pkgManager; + } } const spinner = ora(); @@ -169,10 +177,7 @@ export async function run() { errorCategory: 'validation', step: TRACKING_STEPS.TEMPLATE_SELECT, fatal: true, - additionalProperties: { - ...telemetryData, - provided_template: opts.template, - }, + additionalProperties: { ...telemetryData }, } ); if (posthogClient) await posthogClient.shutdown(); @@ -183,9 +188,6 @@ export async function run() { let pkgManager = opts.pkgManager; if (pkgManager) { if (!PKG_MANAGERS.find((_pkgManager) => _pkgManager === pkgManager)) { - spinner.fail( - `The provided package manager '${opts.pkgManager}' is not supported. Please provide one of the following: ${PKG_MANAGERS}` - ); postHogCaptureError( posthogClient, userId, @@ -196,13 +198,13 @@ export async function run() { errorCategory: 'validation', step: TRACKING_STEPS.PKG_MANAGER_SELECT, fatal: true, - additionalProperties: { - ...telemetryData, - provided_pkg_manager: opts.pkgManager, - }, + additionalProperties: { ...telemetryData }, } ); if (posthogClient) await posthogClient.shutdown(); + spinner.fail( + `The provided package manager '${opts.pkgManager}' is not supported. Please provide one of the following: ${PKG_MANAGERS}` + ); exit(1); } } @@ -255,8 +257,8 @@ export async function run() { exit(1); } pkgManager = res.packageManager; - telemetryData['package-manager'] = pkgManager; } + telemetryData['package-manager'] = pkgManager; let projectName = opts.projectName; if (!projectName) { @@ -367,10 +369,7 @@ export async function run() { errorCategory: 'filesystem', step: TRACKING_STEPS.DIRECTORY_SETUP, fatal: true, - additionalProperties: { - ...telemetryData, - template: template.value, - }, + additionalProperties: { ...telemetryData }, } ); if (posthogClient) await posthogClient.shutdown(); @@ -389,10 +388,7 @@ export async function run() { errorCategory: 'filesystem', step: TRACKING_STEPS.DIRECTORY_SETUP, fatal: true, - additionalProperties: { - ...telemetryData, - template: template.value, - }, + additionalProperties: { ...telemetryData }, }); if (posthogClient) await posthogClient.shutdown(); exit(1); @@ -400,6 +396,7 @@ export async function run() { try { if (themeChoice) { + telemetryData['theme'] = themeChoice; // Add selected theme to content/settings/config.json await updateThemeSettings(rootDir, themeChoice); } @@ -420,11 +417,7 @@ export async function run() { errorCategory: 'template', step: TRACKING_STEPS.DOWNLOADING_TEMPLATE, fatal: true, - additionalProperties: { - ...telemetryData, - template: template.value, - theme: themeChoice, - }, + additionalProperties: { ...telemetryData }, }); if (posthogClient) await posthogClient.shutdown(); exit(1); @@ -443,11 +436,7 @@ export async function run() { errorCategory: 'installation', step: TRACKING_STEPS.INSTALLING_PACKAGES, fatal: false, - additionalProperties: { - ...telemetryData, - template: template.value, - package_manager: pkgManager, - }, + additionalProperties: { ...telemetryData }, }); } @@ -465,10 +454,7 @@ export async function run() { errorCategory: 'git', step: TRACKING_STEPS.GIT_INIT, fatal: false, - additionalProperties: { - ...telemetryData, - template: template.value, - }, + additionalProperties: { ...telemetryData }, }); }