UNPKG

@botpress/adk-cli

Version:

Command-line interface for the Botpress Agent Development Kit (ADK)

72 lines (69 loc) 1.92 kB
// @bun import { telemetry_default } from "./chunk-kwmsaz7n.js"; import { getAdkVersion } from "./chunk-26vqkz52.js"; import { AgentProject, auth, workspaceCache } from "./chunk-p0hjqn4r.js"; // src/utils/telemetry-identify.ts async function identifyUser(projectPath) { try { const profile = await auth.getCurrentProfileDetails(); if (!profile) return; const credentials = await auth.getActiveCredentials(); const properties = { email: profile.email, userId: profile.accountId, userCreatedAt: profile.createdAt }; if (credentials.workspaceId) { properties.workspaceId = credentials.workspaceId; try { const workspaceName = await workspaceCache.getWorkspaceName(credentials.workspaceId); if (workspaceName) { properties.workspaceName = workspaceName; } } catch {} } if (projectPath) { try { const project = await AgentProject.load(projectPath); if (project.agentInfo) { if (project.agentInfo.botId) { properties.botId = project.agentInfo.botId; } if (project.agentInfo.workspaceId) { properties.workspaceId = project.agentInfo.workspaceId; } } } catch {} } if (properties.userId) { telemetry_default.identify(properties.userId, properties); telemetry_default.track("environment", { os: process.platform, node_version: process.version, bun_version: process.versions.bun, adk_version: getAdkVersion() }); } } catch {} } async function updateBotContext(botId, botName) { try { const profile = await auth.getCurrentProfileDetails(); if (!profile || !profile.accountId) return; telemetry_default.identify(profile.accountId, { botId, botName }); } catch {} } export { identifyUser, updateBotContext };