Skip to content

Commit d135140

Browse files
authored
feat: cn serve boolean (#8005)
* feat: cn serve boolean * capture sessionStart for cn serve
1 parent 775f731 commit d135140

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

extensions/cli/src/commands/serve.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import chalk from "chalk";
22
import type { ChatHistoryItem } from "core/index.js";
33
import express, { Request, Response } from "express";
44

5+
import { posthogService } from "src/telemetry/posthogService.js";
6+
57
import { getAccessToken, getAssistantSlug } from "../auth/workos.js";
68
import { runEnvironmentInstallSafe } from "../environment/environmentHandler.js";
79
import { processCommandFlags } from "../flags/flagProcessor.js";
@@ -42,6 +44,8 @@ interface ServeOptions extends ExtendedCommandOptions {
4244

4345
// eslint-disable-next-line max-statements
4446
export async function serve(prompt?: string, options: ServeOptions = {}) {
47+
await posthogService.capture("sessionStart", {});
48+
4549
// Check if prompt should come from stdin instead of parameter
4650
let actualPrompt = prompt;
4751
if (!prompt) {

extensions/cli/src/telemetry/posthogService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import node_machine_id from "node-machine-id";
55
import type { PostHog as PostHogType } from "posthog-node";
66

77
import { isAuthenticatedConfig, loadAuthConfig } from "../auth/workos.js";
8-
import { isHeadlessMode } from "../util/cli.js";
8+
import { isHeadlessMode, isServe } from "../util/cli.js";
99
import { isGitHubActions } from "../util/git.js";
1010
import { logger } from "../util/logger.js";
1111
import { getVersion } from "../version.js";
@@ -95,6 +95,7 @@ export class PosthogService {
9595
ideType: "cli",
9696
isHeadless: isHeadlessMode(),
9797
isGitHubCI: isGitHubActions(),
98+
isServe: isServe(),
9899
};
99100
const payload = {
100101
distinctId: this.uniqueId,

extensions/cli/src/util/cli.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ export function isHeadlessMode(): boolean {
99
const args = process.argv.slice(2);
1010
return args.includes("-p") || args.includes("--print");
1111
}
12+
13+
export function isServe(): boolean {
14+
return process.argv?.includes("serve") ?? false;
15+
}

0 commit comments

Comments
 (0)