feat: add analytics tracking to key components
- Track tab creation and closure events in TabManager - Add session tracking (created, resumed, completed) in ClaudeCodeSession - Track model selection changes in ClaudeCodeSession - Monitor agent execution events (success/failure) in AgentExecution - Include execution duration metrics for agents - Use useTrackEvent hook for consistent event tracking
This commit is contained in:
@@ -36,6 +36,7 @@ import { ErrorBoundary } from "./ErrorBoundary";
|
||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
import { AGENT_ICONS } from "./CCAgents";
|
||||
import { HooksEditor } from "./HooksEditor";
|
||||
import { useTrackEvent, useComponentMetrics } from "@/hooks";
|
||||
|
||||
interface AgentExecutionProps {
|
||||
/**
|
||||
@@ -89,6 +90,10 @@ export const AgentExecution: React.FC<AgentExecutionProps> = ({
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [copyPopoverOpen, setCopyPopoverOpen] = useState(false);
|
||||
|
||||
// Analytics tracking
|
||||
const trackEvent = useTrackEvent();
|
||||
useComponentMetrics('AgentExecution');
|
||||
|
||||
// Hooks configuration state
|
||||
const [isHooksDialogOpen, setIsHooksDialogOpen] = useState(false);
|
||||
const [activeHooksTab, setActiveHooksTab] = useState("project");
|
||||
@@ -302,6 +307,9 @@ export const AgentExecution: React.FC<AgentExecutionProps> = ({
|
||||
console.log("Agent execution started with run ID:", executionRunId);
|
||||
setRunId(executionRunId);
|
||||
|
||||
// Track agent execution start
|
||||
trackEvent.agentExecuted(agent.name || 'custom', true, agent.name, undefined);
|
||||
|
||||
// Set up event listeners with run ID isolation
|
||||
const outputUnlisten = await listen<string>(`agent-output:${executionRunId}`, (event) => {
|
||||
try {
|
||||
@@ -323,9 +331,13 @@ export const AgentExecution: React.FC<AgentExecutionProps> = ({
|
||||
|
||||
const completeUnlisten = await listen<boolean>(`agent-complete:${executionRunId}`, (event) => {
|
||||
setIsRunning(false);
|
||||
const duration = executionStartTime ? Date.now() - executionStartTime : undefined;
|
||||
setExecutionStartTime(null);
|
||||
if (!event.payload) {
|
||||
setError("Agent execution failed");
|
||||
trackEvent.agentExecuted(agent.name || 'custom', false, agent.name, duration);
|
||||
} else {
|
||||
trackEvent.agentExecuted(agent.name || 'custom', true, agent.name, duration);
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user