Skip to content

Commit 6b5c859

Browse files
perf(cli): Skip adjacent-event lookups on project event details (#1712)
`@sentry/api` 0.423.0, which #1713 bumped on main, defaults `collapse=adjacentEvents` on `getOrganizationIssueEvent` and `getProjectEvent` (getsentry/sentry-api-schema#112 and #113). With it, Sentry skips the next/previous-event lookups. Nothing in the CLI reads `nextEventID` or `previousEventID`. Requests that change: - CLI `getEvent()` → `projects/{org}/{project}/events/{event_id}/`. This is the explicit event-ID path in `sentry event view`, and it now sends the param through the SDK default. #1705 skipped it because the project endpoint didn't support `collapse` yet. getsentry/sentry#129123 added that support. Until it deploys, Sentry ignores the unknown value. - CLI `getLatestEvent()` keeps sending the param, but through the SDK default now. The explicit `collapse` query #1705 added there is gone, along with its URL assertion, since that would only test the SDK default. A tier test confirms that project event URLs with the param stay `volatile`. ### Behavior notes - Once getsentry/sentry#129123 deploys, `sentry event view <org>/<project> <event-id> --json` will return `nextEventID`/`previousEventID` as null. Issue latest-event lookups already behave this way after #1705. - Response-cache keys for project event URLs change, so existing entries miss once and then fill again. <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3Aea5efd697aa911af7986f685a5952441 --> -- [View Junior Session in Sentry](https://sentry.sentry.io/explore/conversations/agent%3Aea5efd697aa911af7986f685a5952441/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <burak.kaya@sentry.io>
1 parent 4a902fc commit 6b5c859

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

‎packages/cli/src/lib/api/events.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import {
88
type EventAttachmentDetailsResponse,
9-
type GetOrganizationIssueEventData,
109
getOrganizationIssueEvent,
1110
getProjectEvent,
1211
listOrganizationIssueEvents,
@@ -44,13 +43,6 @@ export async function getLatestEvent(
4443
issueId: string,
4544
): Promise<SentryEvent> {
4645
const config = await getOrgSdkConfig(orgSlug);
47-
// `collapse=adjacentEvents` lets Sentry skip the next/previous-event Snuba
48-
// lookups; the CLI never reads `nextEventID` or `previousEventID`. The
49-
// generated query type omits `collapse`, so the intersection keeps the
50-
// server-supported parameter without weakening the generated client type.
51-
const query: NonNullable<GetOrganizationIssueEventData["query"]> & {
52-
collapse: string[];
53-
} = { collapse: ["adjacentEvents"] };
5446

5547
const result = await getOrganizationIssueEvent({
5648
...config,
@@ -59,7 +51,6 @@ export async function getLatestEvent(
5951
issue_id: issueId,
6052
event_id: "latest",
6153
},
62-
query,
6354
});
6455

6556
return unwrapResult<SentryEvent>(result, "Failed to get latest event");

‎packages/cli/test/lib/api-client.coverage.test.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,9 +1006,6 @@ describe("events.ts", () => {
10061006
const req = new Request(input!, init);
10071007
expect(req.url).toContain("/organizations/test-org/issues/");
10081008
expect(req.url).toContain("/events/latest/");
1009-
expect(new URL(req.url).searchParams.getAll("collapse")).toEqual([
1010-
"adjacentEvents",
1011-
]);
10121009
return new Response(JSON.stringify(event), {
10131010
status: 200,
10141011
headers: { "Content-Type": "application/json" },

‎packages/toolkit-core/src/response-cache/tiers.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ describe("classifyUrl", () => {
3434
).toBe("volatile");
3535
});
3636

37+
it("keeps project events volatile when adjacent events are collapsed", () => {
38+
expect(
39+
classifyUrl(
40+
`${API}/projects/acme/backend/events/deadbeef/?collapse=adjacentEvents`,
41+
),
42+
).toBe("volatile");
43+
});
44+
3745
it("reuses full traces for at most 60 seconds, since spans can still arrive", () => {
3846
const url = `${API}/organizations/acme/trace/${TRACE_ID}/?limit=100`;
3947
expect(classifyUrl(url)).toBe("volatile");

‎packages/toolkit-core/src/response-cache/tiers.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ const URL_TIER_PATTERNS: readonly [TtlTier, readonly RegExp[]][] = [
4949
/\/trace-logs\//,
5050
// Full traces gain spans as they arrive
5151
/\/trace\/[0-9a-f]{32}\//,
52-
// Project event details embed `nextEventID`/`previousEventID` and user
53-
// reports, and reprocessing can change them for the same ID
52+
// Project event details embed user reports (and `nextEventID`/
53+
// `previousEventID` unless collapsed), and reprocessing can change them
54+
// for the same ID
5455
/\/projects\/[^/]+\/[^/]+\/events\/[^/?]+\/?(?:\?|$)/,
5556
],
5657
],

0 commit comments

Comments
 (0)