Raw Analytics Responses Break API Consistency
The analytics module delivers data in raw form, skipping the standard success envelope - no success: true guard. Six endpoints spit out flat objects like { eventsIngested, eventsFailed } instead of wrapped responses. This inconsistency forces developers to hunt for every endpoint, risking silent failures. Line 119 in /health sends raw health data; line 214’s 404 error skips the expected { error: '...' } format. Without a uniform envelope, even basic error handling becomes a guessing game. A simple fix? A utility function like successReply(reply, data) wraps every response in { success: true, data }, restoring predictability. Fastify’s schema validation doesn’t fix this - just confirms the structure. For teams building on this module, this isn’t just a style issue; it’s a safety gap. Do you trust your app to handle missing success flags? Before shipping analytics, wrap every reply - your users depend on it.