Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-masks-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-tina-app": patch
---

Fix - selected package manager would not be captured as telemetry when passed in as a parameter
56 changes: 21 additions & 35 deletions packages/create-tina-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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,
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand All @@ -389,17 +388,15 @@ 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);
}

try {
if (themeChoice) {
telemetryData['theme'] = themeChoice;
// Add selected theme to content/settings/config.json
await updateThemeSettings(rootDir, themeChoice);
}
Expand All @@ -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);
Expand All @@ -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 },
});
}

Expand All @@ -465,10 +454,7 @@ export async function run() {
errorCategory: 'git',
step: TRACKING_STEPS.GIT_INIT,
fatal: false,
additionalProperties: {
...telemetryData,
template: template.value,
},
additionalProperties: { ...telemetryData },
});
}

Expand Down
Loading