- Add intelligent-router.sh hook for automatic agent routing - Add AUTO-TRIGGER-SUMMARY.md documentation - Add FINAL-INTEGRATION-SUMMARY.md documentation - Complete Prometheus integration (6 commands + 4 tools) - Complete Dexto integration (12 commands + 5 tools) - Enhanced Ralph with access to all agents - Fix /clawd command (removed disable-model-invocation) - Update hooks.json to v5 with intelligent routing - 291 total skills now available - All 21 commands with automatic routing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
// Non-React capture helpers for use in event handlers.
|
|
// These functions work outside of React context (e.g., in handlers.ts).
|
|
|
|
import posthog from 'posthog-js';
|
|
import type { LLMTokensConsumedEvent } from '@dexto/analytics';
|
|
|
|
/**
|
|
* Check if analytics is enabled by looking for the injected config.
|
|
*/
|
|
function isAnalyticsEnabled(): boolean {
|
|
if (typeof window === 'undefined') return false;
|
|
return !!(window as any).__DEXTO_ANALYTICS__;
|
|
}
|
|
|
|
/**
|
|
* Get base context properties included with every event.
|
|
*/
|
|
function getBaseContext() {
|
|
if (typeof window === 'undefined') {
|
|
return { app: 'dexto-webui' };
|
|
}
|
|
const config = (window as any).__DEXTO_ANALYTICS__;
|
|
return {
|
|
app: 'dexto-webui',
|
|
app_version: config?.appVersion ?? 'unknown',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Capture LLM token usage event.
|
|
* Called from event handlers (non-React context).
|
|
*
|
|
* @param params - Token usage data (source is automatically set to 'webui')
|
|
*/
|
|
export function captureTokenUsage(params: Omit<LLMTokensConsumedEvent, 'source'>): void {
|
|
if (!isAnalyticsEnabled()) return;
|
|
|
|
try {
|
|
posthog.capture('dexto_llm_tokens_consumed', {
|
|
...getBaseContext(),
|
|
source: 'webui',
|
|
...params,
|
|
});
|
|
} catch {
|
|
// Analytics should never break the app
|
|
}
|
|
}
|