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
14 changes: 14 additions & 0 deletions src/commands/projects/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
listProjects,
getProject,
getProjectApiKey,
reportAgentConnected,
} from '../../lib/api/platform.js';
import { getGlobalConfig, saveGlobalConfig, saveProjectConfig } from '../../lib/config.js';
import { requireAuth } from '../../lib/credentials.js';
Expand Down Expand Up @@ -62,6 +63,14 @@ export function registerProjectLinkCommand(program: Command): void {
// Install agent skills
await installSkills(json);
await reportCliUsage('cli.link_direct', true, 6);

// Report agent-connected event (best-effort)
try {
const urlMatch = opts.apiBaseUrl.match(/^https?:\/\/([^.]+)\.[^.]+\.insforge\.app/);
if (urlMatch) {
await reportAgentConnected({ app_key: urlMatch[1] }, apiUrl);
}
} catch { /* ignore */ }
return;
} catch (err) {
await reportCliUsage('cli.link_direct', false);
Expand Down Expand Up @@ -160,6 +169,11 @@ export function registerProjectLinkCommand(program: Command): void {
// Install agent skills
await installSkills(json);
await reportCliUsage('cli.link', true, 6);

// Report agent-connected event (best-effort)
try {
await reportAgentConnected({ project_id: project.id }, apiUrl);
} catch { /* ignore */ }
} catch (err) {
await reportCliUsage('cli.link', false);
handleError(err, json);
Expand Down
19 changes: 19 additions & 0 deletions src/lib/api/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ export async function getProjectApiKey(projectId: string, apiUrl?: string): Prom
return data.access_api_key;
}

export async function reportAgentConnected(
payload: { project_id?: string; app_key?: string },
apiUrl?: string,
): Promise<void> {
const baseUrl = getPlatformApiUrl(apiUrl);
const headers: Record<string, string> = {
'Content-Type': 'application/json',
};
const token = getAccessToken();
if (token) {
headers.Authorization = `Bearer ${token}`;
}
await fetch(`${baseUrl}/tracking/v1/agent-connected`, {
method: 'POST',
headers,
body: JSON.stringify(payload),
});
}
Comment thread
jwfing marked this conversation as resolved.

export async function createProject(
orgId: string,
name: string,
Expand Down
Loading