From 271a1d057234346fc127b6f259c766a8b26a603f Mon Sep 17 00:00:00 2001 From: "Matt Wicks [SSW]" Date: Fri, 2 Jan 2026 14:58:16 +1100 Subject: [PATCH] fix(create-tina-app): fix package manager telemetry (#6277) This pull request fixes an issue where the selected package manager was not being properly captured in telemetry when passed as a parameter in `create-tina-app`. **Telemetry data handling improvements:** * Ensured the selected package manager is always captured in telemetry, regardless of how it is provided (either as a parameter or through user input). (.changeset/neat-masks-rhyme.md, [packages/create-tina-app/src/index.tsL255-R256](diffhunk://#diff-ac1b8c916251d9122d94fbf42933af2d6829962fb0a80ab6d68fa462a9225e44L255-R256)) * Standardized the way telemetry data is sent by removing redundant or inconsistent inclusion of `template`, `theme`, and `package_manager` properties in the `additionalProperties` object, instead relying on the consolidated `telemetryData` object. [[1]](diffhunk://#diff-ac1b8c916251d9122d94fbf42933af2d6829962fb0a80ab6d68fa462a9225e44L367-R367) [[2]](diffhunk://#diff-ac1b8c916251d9122d94fbf42933af2d6829962fb0a80ab6d68fa462a9225e44L389-R394) [[3]](diffhunk://#diff-ac1b8c916251d9122d94fbf42933af2d6829962fb0a80ab6d68fa462a9225e44L420-R415) [[4]](diffhunk://#diff-ac1b8c916251d9122d94fbf42933af2d6829962fb0a80ab6d68fa462a9225e44L443-R434) [[5]](diffhunk://#diff-ac1b8c916251d9122d94fbf42933af2d6829962fb0a80ab6d68fa462a9225e44L465-R452) **Bug fix:** * Fixed a bug where the selected package manager was incorrectly assigned to the `provided_template` property instead of `package-manager` in telemetry events. **Minor enhancement:** * Added the selected theme to telemetry data when a theme is chosen. --- .changeset/neat-masks-rhyme.md | 5 +++ packages/create-tina-app/src/index.ts | 56 ++++++++++----------------- 2 files changed, 26 insertions(+), 35 deletions(-) create mode 100644 .changeset/neat-masks-rhyme.md 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 }, }); }