feat(den): analytics event model + /v1/telemetry/analytics endpoint (Layer 1+2)#2148
Open
benjaminshafii wants to merge 1 commit into
Open
feat(den): analytics event model + /v1/telemetry/analytics endpoint (Layer 1+2)#2148benjaminshafii wants to merge 1 commit into
benjaminshafii wants to merge 1 commit into
Conversation
Layer 1+2 of OpenWork Analytics: - extend telemetry_event with source, session_id, duration_ms, success - expand allowed event types (session/task lifecycle) and drop unknown types and disallowed sources at ingest - new GET /v1/telemetry/analytics: members, active members (7d/30d), distinct sessions, task completed/failed counts, avg task duration, and a 12-week trend of active members / sessions / tasks
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
First of three PRs implementing OpenWork Analytics Layers 1 (who is using AI) and 2 (how often).
Server-side foundation:
ee/packages/den-db/src/schema/telemetry.ts+ migration0021): addssource,session_id,duration_ms,successcolumns totelemetry_event, and expands the allowed event types to the PRD set:user.active,session.active,session.started/ended,task.started/completed/failed.POST /v1/telemetry/ingest): unknown event types are silently dropped, disallowedsourcevalues are nulled,durationMsis clamped. Still fire-and-forget (always 204, errors swallowed). No content fields exist anywhere in the pipeline — only event names, timestamps, opaque session ids, durations, and success flags.GET /v1/telemetry/analytics: org-scoped Layer 1+2 aggregates — members, pending invites, active members (7d/30d), distinct sessions (7d/30d), tasks completed/failed (7d/30d), avg task duration (30d), and a 12-week trend of active members / sessions / tasks per week.The existing
/v1/telemetry/adoptionendpoint is unchanged for compatibility.Stack
Tests
Commands run:
pnpm --filter @openwork-ee/den-db db:generate— migration0021_flaky_hex.sqlgenerated cleanlynpx tsc --noEmitinee/apps/den-api— passesdev:den:mysql+ drizzle push +dev:den:api+seed:demo-org):POST /v1/telemetry/ingestwith 6 events → 204totally.unknown) not stored (5 rows in DB), disallowed source (evil-source) stored as NULLGET /v1/telemetry/analyticsreturned correct aggregates:members: 17,activeMembers7d: 1,sessions7d: 2(distinct session ids),tasksCompleted7d: 2,tasksFailed7d: 1,avgTaskDurationMs30d: 30000= (42000+18000)/2 ✓Raw verification output:
No video for this server-only PR; the stacked dashboard PR includes UI screenshots of this data rendered.
Notes / decisions
GET /v1/telemetry/analyticsfollows the same auth posture as the existing/adoptionendpoint (signed-in member of the org; aggregates only, no per-member breakdown), with the admin gate enforced in the dashboard UI route group.COUNT(DISTINCT session_id), which naturally ignores legacy rows without a session id.