Skip to content

refactor(event): deduplicate span tree building into shared helper#581

Merged
BYK merged 1 commit intomainfrom
fix/event-view-dedup-span-tree
Mar 26, 2026
Merged

refactor(event): deduplicate span tree building into shared helper#581
BYK merged 1 commit intomainfrom
fix/event-view-dedup-span-tree

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Mar 26, 2026

Summary

Follow-up to #574 addressing Bugbot feedback about duplicated span tree building logic.

The span tree assembly (fetch spans → build trace object → assemble EventViewData) was duplicated across three locations that could diverge over time:

  1. fetchLatestEventData — issue URL path
  2. fetchSpecificEventData — SHORT-ID/EVENT-ID path
  3. func() inline — normal event view path

The inline path also had a subtle inconsistency: it used spanTreeResult.spans without ?? [] and omitted the && traceId guard that the other two paths had.

Fix

Extracted buildEventViewData(org, event, spans) as a shared helper. All three paths now use it:

  • fetchLatestEventData → calls getLatestEvent() then buildEventViewData()
  • SHORT-ID/EVENT-ID path → calls getEvent() then buildEventViewData()
  • func() inline → calls fetchEventWithContext() then buildEventViewData()

fetchSpecificEventData is removed entirely (net -22 lines).

Changes

  • src/commands/event/view.ts: Added buildEventViewData, removed fetchSpecificEventData, updated all three call sites

Extract buildEventViewData() that handles span tree fetch + trace
assembly in one place. Previously this logic was duplicated across:

1. fetchLatestEventData (issue URL path)
2. fetchSpecificEventData (SHORT-ID/EVENT-ID path)
3. func() inline (normal event view path)

The inline path also had a subtle difference: it used
spanTreeResult.spans without ?? [] and omitted the && traceId guard.
Now all paths use the same consistent logic.

Addresses #574 (comment)
@github-actions
Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Dashboard

  • Add pagination and glob filtering to dashboard list by BYK in #560
  • Rich terminal chart rendering for dashboard view by BYK in #555

Init

  • Propagate sentry-trace headers to wizard API calls by betegon in #567
  • Treat bare slug as new project name when not found by BYK in #554

Other

  • (formatters) Colorize SQL in DB span descriptions by BYK in #546
  • (telemetry) Report unknown commands to Sentry by BYK in #563
  • Bidirectional cursor pagination (-c next / -c prev) by BYK in #564
  • Add sentry sourcemap inject and sentry sourcemap upload commands by BYK in #547
  • Native debug ID injection and sourcemap upload by BYK in #543

Bug Fixes 🐛

Dashboard

  • Validate display types against all datasets by betegon in #577
  • Auto-clamp widget limit instead of erroring by BYK in #573
  • Default issue dataset table columns to ["issue"] by betegon in #570
  • Scale timeseries bar width to fill chart area by BYK in #562
  • Resolve dashboard by ID/slug in addition to title by BYK in #559

Event

  • Detect SHORT-ID/EVENT-ID format in event view by BYK in #574
  • Auto-fallback to org-wide search when event 404s in project by BYK in #575

Other

  • (api) Show meaningful message for network errors instead of '0 Unknown' by BYK in #572
  • (event-view) Auto-redirect issue short IDs in two-arg form (CLI-MP) by BYK in #558
  • (help) Show help when user passes help as positional arg by BYK in #561
  • (issue) Auto-redirect bare org slug to org-all mode in issue list by BYK in #576
  • Reject @-selectors in parseOrgProjectArg with helpful redirect by BYK in #557

Internal Changes 🔧

Coverage

  • Use informational-patch input instead of sed hack by BYK in #544
  • Make checks informational on release branches by BYK in #541

Other

  • (api) Collapse stats on issue detail endpoints to save 100-300ms by BYK in #551
  • (ci) Upgrade GitHub Actions to Node 24 runtime by BYK in #542
  • (db) DRY up database layer with shared helpers and lint enforcement by BYK in #550
  • (event) Deduplicate span tree building into shared helper by BYK in #581
  • (issue-list) Use collapse parameter to skip unused Snuba queries by BYK in #545
  • Bump Bun from 1.3.9 to 1.3.11 by BYK in #552
  • Regenerate skill files by github-actions[bot] in ec1ffe28

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

Codecov Results 📊

126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1276 uncovered lines.
❌ Project coverage is 95.45%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.46%    95.45%    -0.01%
==========================================
  Files          194       194         —
  Lines        28040     28036        -4
  Branches         0         0         —
==========================================
+ Hits         26766     26760        -6
- Misses        1274      1276        +2
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK merged commit bdd75c0 into main Mar 26, 2026
22 checks passed
@BYK BYK deleted the fix/event-view-dedup-span-tree branch March 26, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant