fix: address tests, add is_continue_remote

This commit is contained in:
Nate 2025-09-10 10:35:35 -07:00
parent 54cc0d8430
commit 2884028d21
3 changed files with 67 additions and 5 deletions

View file

@ -126,7 +126,7 @@ describe("TelemetryService - Session Metadata", () => {
1,
expect.objectContaining({
is_github_actions: "false",
ci_environment: "none",
is_continue_remote_agent: "false",
}),
);
});
@ -151,7 +151,7 @@ describe("TelemetryService - Session Metadata", () => {
1,
expect.objectContaining({
is_github_actions: "true",
ci_environment: "github_actions",
is_continue_remote_agent: "false",
}),
);
});
@ -178,7 +178,60 @@ describe("TelemetryService - Session Metadata", () => {
expect.objectContaining({
is_headless: "true",
is_github_actions: "true",
ci_environment: "github_actions",
is_continue_remote_agent: "false",
}),
);
});
it("should include is_continue_remote_agent=true when in remote agent mode", () => {
// Set Continue remote agent environment
process.env.CONTINUE_REMOTE = "true";
const mockAdd = vi.fn();
const mockRecord = vi.fn();
const service = telemetryService as any;
// Mock the session counter and startup time histogram
service.sessionCounter = { add: mockAdd };
service.startupTimeHistogram = { record: mockRecord };
service.config = { enabled: true };
service.meter = {};
service.recordSessionStart();
expect(mockAdd).toHaveBeenCalledWith(
1,
expect.objectContaining({
is_continue_remote_agent: "true",
is_github_actions: "false",
}),
);
});
it("should include all environment flags when all are true", () => {
// Set all environments
process.argv = ["node", "cli.js", "-p", "What is the weather?"];
process.env.GITHUB_ACTIONS = "true";
process.env.CONTINUE_REMOTE = "true";
const mockAdd = vi.fn();
const mockRecord = vi.fn();
const service = telemetryService as any;
// Mock the session counter and startup time histogram
service.sessionCounter = { add: mockAdd };
service.startupTimeHistogram = { record: mockRecord };
service.config = { enabled: true };
service.meter = {};
service.recordSessionStart();
expect(mockAdd).toHaveBeenCalledWith(
1,
expect.objectContaining({
is_headless: "true",
is_github_actions: "true",
is_continue_remote_agent: "true",
}),
);
});

View file

@ -20,7 +20,7 @@ import {
import { v4 as uuidv4 } from "uuid";
import { isHeadlessMode } from "../util/cli.js";
import { isGitHubActions } from "../util/git.js";
import { isContinueRemoteAgent, isGitHubActions } from "../util/git.js";
import { logger } from "../util/logger.js";
import { getVersion } from "../version.js";
@ -354,9 +354,11 @@ class TelemetryService {
logger.debug("Recording session start with telemetry");
// Add extra metadata for session breakdown
const isGitHubActionsEnv = isGitHubActions();
const sessionAttributes = this.getStandardAttributes({
is_headless: isHeadlessMode().toString(),
is_github_actions: isGitHubActions().toString(),
is_github_actions: isGitHubActionsEnv.toString(),
is_continue_remote_agent: isContinueRemoteAgent().toString(),
});
this.sessionCounter.add(1, sessionAttributes);

View file

@ -57,6 +57,13 @@ export function isGitHubActions(): boolean {
return process.env.GITHUB_ACTIONS === "true";
}
/**
* Check if running in Continue remote agents
*/
export function isContinueRemoteAgent(): boolean {
return process.env.CONTINUE_REMOTE === "true";
}
/**
* Get repository URL from GitHub Actions environment variables
* @returns GitHub repository URL or null if not available