Repository navigation
feat(cli): add event analytics command for dropped events - #1812
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Refs DAIN-1940
Refs DAIN-1940 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
91a4f3d to
870b28e
Compare
There was a problem hiding this comment.
First-pass review on behalf of @BYK, checked against his feedback on #1579 and #1559 and the recent CLI standardisation work (reviewed at 870b28e).
Most of the earlier feedback is addressed. The name is now event analytics. Examples moved to docs.examples. Datasets go through the shared buildDatasetParser. The JSON output is flat rows with an item schema, so --fields outcome,reason,events works. The project ID is resolved strictly through fetchProjectId. Nice work on the redo.
Requesting changes for these:
@sentry/apialready has this endpoint.lib/api/dropped-events.tssays it is "Not yet in@sentry/api", butlistOrganizationEventsDropped,ListOrganizationEventsDroppedResponseandvListOrganizationEventsDroppedResponseare all in the catalog's@sentry/api.packages/cli/AGENTS.mdsays to use the SDK types instead of redundant Valibot schemas, and BYK made the same point on #1559 ("we should use them from there not repeat types across repos"). The local response schema intypes/dropped-events.tsduplicates the SDK's.- The output schema is in its own module. AGENTS.md says
src/output-schemas/has one module per top-level command, soDroppedEventRowSchemabelongs inoutput-schemas/event.ts. Its API fields (outcome,reason,category,tags) should come from the generated valibot entries, asproject.tsdoes withvOrganizationProjectResponseDict.item.entries. --periodis back to a local 24h default. The earlier commit that switched it toLIST_PERIOD_FLAG/PERIOD_ALIASESwas lost in the force-push. BYK asked on #1559 for the default to match the rest of the CLI, andattribute,span,trace,replayandagent-conversation listall use the shared 7d flag.
I'm pushing a commit for all three right after this review:
getDroppedEventscallslistOrganizationEventsDroppedthroughgetOrgSdkConfig+unwrapResult, likelib/api/issue-tags.ts.types/dropped-events.tsandoutput-schemas/dropped-events.tsare gone. The row schema lives inoutput-schemas/event.ts, built fromvListOrganizationEventsDroppedResponse, andoutcomeLabelmoved into the formatter.- Sentry only added
tagsin getsentry/sentry#127850. The summarizer still defaults them to[]for older self-hosted servers, and a formatter test covers that. --perioduses the shared flag again. The skill reference is regenerated.
Still on you (@manessaraj): "analytics" only shows drops. On #1579 BYK asked to note adding accepted and other volumes, so that this becomes a real analytics command. The response already includes acceptedEvents, and share is computed against them, but they never appear in the output, and the PR doesn't link a follow-up. Either show the accepted total (for example as a row or a header line), or open a ticket and link it here.
The event, dropped-events API, and formatter tests pass with the fix commit, along with CLI typecheck and repo lint. I didn't run the full suite.
- getDroppedEvents uses listOrganizationEventsDropped with getOrgSdkConfig and unwrapResult instead of a hand-written request and response schema. - The row schema moves to output-schemas/event.ts and takes its API fields from vListOrganizationEventsDroppedResponse. types/dropped-events.ts and output-schemas/dropped-events.ts are removed. - Tags still default to [] for servers older than getsentry/sentry#127850. - --period uses LIST_PERIOD_FLAG and PERIOD_ALIASES (7d default, -t). Co-Authored-By: BYK <[email protected]>
event analytics only listed drops, though the endpoint returns the accepted volume and share was already computed against it. BYK asked on #1579 for accepted volume so this is a real analytics command. - Accepted volume comes first as its own outcome row (Sentry reports outcome and reason `accepted`, no tags). Drop rows follow, sorted as before. - The human output shows accepted as a header line with no reason table. - The "No dropped events" hint now fires when only accepted rows exist. - The row schema, summarizer and formatter are renamed from DroppedEvent* to EventOutcome*, since rows are no longer only drops. Co-Authored-By: BYK <[email protected]>
|
On behalf of @BYK: I pushed f536c4c, which takes care of the last open item from the review ("analytics" only showing drops).
@manessaraj, if you'd rather show accepted a different way (for example as a header line only, with no JSON row), say so and I'll change it. Verified: CLI |
The formatter renders accepted and dropped volume now, so the dropped-events file name was stale next to the EventOutcome* exports. lib/api/dropped-events.ts keeps its name: it wraps the events-dropped endpoint (listOrganizationEventsDropped). Co-Authored-By: BYK <[email protected]>
did on behalf of me, now we're good
Adds
sentry event analytics, which reports events Sentry received but dropped before storage (rate-limited, filtered, invalid, abuse, client-discarded, cardinality-limited), one row per outcome and reason with each slice's share of total volume. It is the CLI counterpart to thefind_dropped_eventsMCP tool, so an agent or a person working headless can see data-fidelity gaps without the web UI.This reopens the work previously attempted in #1579, redone from scratch. The earlier attempt duplicated the dropped-events schema and dataset handling inside the CLI, which drifted from the MCP implementation and drew repeated review. The redo instead reuses the now-shared pieces that landed since then — the
buildDatasetParserdataset map inlib/datasets.ts(sometricsnormalizes totracemetricsat parse time) and thefind_dropped_eventsMCP feedback on response shape and tags — and builds on the standard command, target, and completion primitives rather than hand-rolled ones. The schema treatstagsas optional, matching the endpoint and the MCP tool.Verified end-to-end against production (project 1): the command resolves the project, fetches dropped events, and renders both the grouped human table and the JSON array, across the errors and spans datasets.
Refs DAIN-1940