Skip to content

Commit

Permalink
release: v0.1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnPhamous committed Jan 8, 2025
1 parent eebd9d9 commit 9772d0f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 56 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
"peerDependencies": {
"typescript": "^5.6.2"
},
"version": "0.1.15"
"version": "0.1.16"
}
52 changes: 0 additions & 52 deletions src/lib/posthog.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Command } from "commander";
import os from "node:os";
import { PostHog } from "posthog-node";

export const postHogClient = new PostHog(
Expand All @@ -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<string, any> = {};
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();
});
}
6 changes: 3 additions & 3 deletions src/lib/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ 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);
if (isOnLatestVersion) {
spinner.succeed(
`You are already on the latest version (${currentVersion}).`
);
// process.exit(0);
return;
}

// Fetch the install script
Expand Down Expand Up @@ -96,6 +96,6 @@ export function registerUpgrade(program: Command) {
}

spinner.succeed("Upgrade completed successfully");
// process.exit(0);
return;
});
}

0 comments on commit 9772d0f

Please sign in to comment.