fix(backend): remove stale TODO-008 comment, add telemetry to suggestions route

This commit is contained in:
saravanakumardb1 2026-04-19 00:53:05 -07:00
parent fd4269949f
commit fe2ab6010e
2 changed files with 8 additions and 11 deletions

View File

@ -2,16 +2,7 @@
* Telemetry event name constants for all agentic AI features.
*
* Centralised here so backend routes and web components can reference
* a single source of truth for event names (Phase 0.5).
*
* TODO-008: Wire trackEvent() calls into backend routes
* Priority: medium | Phase: B
* These constants are defined but not yet imported anywhere. Wire them in:
* - agent-actions/routes.ts: AGENT_INBOX_ACTION_APPROVED on approve,
* AGENT_INBOX_ACTION_REJECTED on reject, AGENT_INBOX_BATCH_APPROVED on batch
* - server.ts context-message route: AI_CONTEXT_ENRICHED when source='llm',
* AI_CONTEXT_FALLBACK_USED when source='keyword' or 'generic'
* - Use: import { bufferEvent } from './telemetry.js' then bufferEvent(EVENT_NAME, { ...metadata })
* a single source of truth for event names.
*/
// ── MCP ───────────────────────────────────────────────────────

View File

@ -9,6 +9,8 @@ import { BadRequestError } from '@bytelyst/errors';
import { extractAuth } from '../../lib/auth.js';
import { isFeatureEnabled } from '../../lib/feature-flags.js';
import { PRODUCT_ID } from '../../lib/product-config.js';
import { trackEvent } from '../../lib/telemetry.js';
import { ROUTINE_SUGGEST_SHOWN } from '../../lib/telemetry-events.js';
import { generateSuggestions } from './engine.js';
import { GetSuggestionsSchema } from './types.js';
import * as timerRepo from '../timers/repository.js';
@ -48,6 +50,10 @@ export async function suggestionRoutes(app: FastifyInstance) {
offset: 0,
});
return generateSuggestions(completedTimers, routines, parsed.data.maxSuggestions);
const result = generateSuggestions(completedTimers, routines, parsed.data.maxSuggestions);
if (result.suggestions.length > 0) {
trackEvent(ROUTINE_SUGGEST_SHOWN, auth.sub, { count: result.suggestions.length, types: result.suggestions.map(s => s.type) });
}
return result;
});
}