From 9772d0f135e8170a77f2da0f7740da0febeb13ef Mon Sep 17 00:00:00 2001 From: John Pham Date: Wed, 8 Jan 2025 15:19:17 -0800 Subject: [PATCH] release: v0.1.16 --- package.json | 2 +- src/lib/posthog.ts | 52 ---------------------------------------------- src/lib/upgrade.ts | 6 +++--- 3 files changed, 4 insertions(+), 56 deletions(-) diff --git a/package.json b/package.json index 8e9f77d..e5e951f 100644 --- a/package.json +++ b/package.json @@ -43,5 +43,5 @@ "peerDependencies": { "typescript": "^5.6.2" }, - "version": "0.1.15" + "version": "0.1.16" } \ No newline at end of file diff --git a/src/lib/posthog.ts b/src/lib/posthog.ts index a046cf6..4615895 100644 --- a/src/lib/posthog.ts +++ b/src/lib/posthog.ts @@ -1,5 +1,3 @@ -import { Command } from "commander"; -import os from "node:os"; import { PostHog } from "posthog-node"; export const postHogClient = new PostHog( @@ -19,53 +17,3 @@ export const postHogClient = new PostHog( export const IS_TRACKING_DISABLED = process.env.SF_CLI_TELEMETRY_OPTOUT === "1" || process.env.SF_CLI_TELEMETRY_OPTOUT === "true"; - -export function setupCliTracking(program: Command) { - const startTime = Date.now(); - // Track at program level to ensure we catch every CLI invocation - process.on("exit", async code => { - const endTime = Date.now(); - const executionDuration = endTime - startTime; - - // Get the executed command and subcommand - const args = process.argv.slice(2); - const commandName = args[0] || "help"; - const subCommandName = args[1]; - - // Parse the arguments into a key-value object - const parsedArgs: Record = {}; - for (let i = 0; i < args.length; i++) { - const arg = args[i]; - if (arg.startsWith("--")) { - const key = arg.slice(2); - // If next arg doesn't start with -, treat it as the value - if (i + 1 < args.length && !args[i + 1].startsWith("-")) { - parsedArgs[key] = args[i + 1]; - i++; // Skip the value in next iteration - } else { - parsedArgs[key] = true; // Flag without value - } - } - } - - const eventData = { - commandName, - subCommandName, - arguments: parsedArgs, - rawArgs: process.argv.slice(2), - exitStatus: code, - executionDuration, - cliVersion: program.version(), - os: os.platform(), - shell: process.env.SHELL, - }; - - postHogClient.capture({ - distinctId: "cli-user", - event: "cli_executed", - properties: eventData, - }); - - await postHogClient.shutdown(); - }); -} diff --git a/src/lib/upgrade.ts b/src/lib/upgrade.ts index 67b74d8..fc6b43d 100644 --- a/src/lib/upgrade.ts +++ b/src/lib/upgrade.ts @@ -47,7 +47,7 @@ export function registerUpgrade(program: Command) { // Check if user has already installed latest version. if (version === currentVersion) { spinner.succeed(`You are already on version ${currentVersion}.`); - // process.exit(0); + return; } const isOnLatestVersion = await getIsOnLatestVersion(currentVersion); @@ -55,7 +55,7 @@ export function registerUpgrade(program: Command) { spinner.succeed( `You are already on the latest version (${currentVersion}).` ); - // process.exit(0); + return; } // Fetch the install script @@ -96,6 +96,6 @@ export function registerUpgrade(program: Command) { } spinner.succeed("Upgrade completed successfully"); - // process.exit(0); + return; }); }