Skip to content

fix: propagate user id to Hevy API spans - #592

Merged
mergify[bot] merged 3 commits into
mainfrom
fix/588-propagate-user-id
Jul 11, 2026
Merged

fix: propagate user id to Hevy API spans#592
mergify[bot] merged 3 commits into
mainfrom
fix/588-propagate-user-id

Conversation

@charliecreates

@charliecreates charliecreates Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add the current user.id to manually-created hevy.api.* spans when available.
  • Add focused tests covering user ID presence and absence.
  • Add a patch changeset.

Testing

  • npm run build
  • npx vitest run src/utils/hevyClientKubb.test.ts
  • npx vitest run --exclude tests/integration/**
  • npm run check
  • npm run check:types
  • npm run check:changeset
  • git diff --check

All passed.

Deployment

Honeycomb verification remains after deployment.

Resolves #588

✨ PR Description

Purpose: Propagate user ID to Hevy API trace spans to correlate API requests with specific users in observability data.

Main changes:

  • Import getCurrentUserId from telemetry module and conditionally add user.id attribute to trace spans
  • Add test coverage for user ID propagation with and without available user context
  • Update telemetry mock to include getCurrentUserId test double for request interceptor testing

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how

@gitstream-cm gitstream-cm Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ PR Review

The PR is small and focused: it plumbs getCurrentUserId() into the Axios request interceptor and adds tests for both the present and absent cases. The production code change is correct, but one test has a stale-mock indexing bug, and the changeset type may not match project conventions.

2 issues detected:

🐞 Bug - `mock.calls[0]` is the first call ever recorded; without clearing history between tests it does not reliably refer to the call made in the current test. 🛠️

Details: The "omits the user ID attribute" test reads telemetryTestDoubles.tracerStartSpan.mock.calls[0]?.[1] to obtain the span options. Because beforeEach only calls mockReturnValue (which preserves call history), calls[0] refers to the first invocation ever recorded across all prior tests, not the one made during this test. If any earlier test also triggered tracerStartSpan, the assertion silently checks stale data and the test can pass for the wrong reason.

File: src/utils/hevyClientKubb.test.ts (930-930)

🛠️ A suggested code correction is included in the review comments.

🧹 Maintainability - A versioned patch changeset is used for an internal-only telemetry enhancement, which the project convention reserves for `--empty` changesets.

Details: The changeset uses a versioned patch entry. Per project conventions, versioned changesets are reserved for user-facing, runtime-visible changes. Adding a user.id attribute to internal Honeycomb telemetry spans is an internal observability improvement that should use npx changeset --empty instead.

File: .changeset/tidy-traces-connect.md (1-5)

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Review using Guidelines Learn how

baseURL: "https://api.hevyapp.com",
});

const spanOptions = telemetryTestDoubles.tracerStartSpan.mock.calls[0]?.[1];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐞 Bug - Stale Mock Index: Clear the mock in beforeEach by adding telemetryTestDoubles.tracerStartSpan.mockClear(), or reference the last call instead: replace mock.calls[0]?.[1] with mock.calls.at(-1)?.[1].

Suggested change
const spanOptions = telemetryTestDoubles.tracerStartSpan.mock.calls[0]?.[1];
const spanOptions = telemetryTestDoubles.tracerStartSpan.mock.calls.at(-1)?.[1];
Is this review accurate? Use 👍 or 👎 to rate it

If you want to tell us more, use /gs feedback e.g. /gs feedback this review doesn't make sense, I disagree, and it keeps repeating over and over

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Unit Test Results

  1 files   32 suites   3s ⏱️
514 tests 514 ✅ 0 💤 0 ❌
518 runs  518 ✅ 0 💤 0 ❌

Results for commit 508ea11.

♻️ This comment has been updated with latest results.

@mergify

mergify Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.01%. Comparing base (b28e11d) to head (508ea11).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #592   +/-   ##
=======================================
  Coverage   93.00%   93.01%           
=======================================
  Files          35       35           
  Lines        1572     1574    +2     
  Branches      395      396    +1     
=======================================
+ Hits         1462     1464    +2     
  Misses         48       48           
  Partials       62       62           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mergify

mergify Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 7 minutes 3 seconds in the queue, including 1 minute 19 seconds running CI.

Required conditions to merge
  • check-success = "Build and test (Node 24.x)"
  • check-success = "Build and test (Node 26.x)"

@mergify mergify Bot added the queued label Jul 11, 2026
mergify Bot added a commit that referenced this pull request Jul 11, 2026
@mergify
mergify Bot merged commit b9b6dce into main Jul 11, 2026
26 of 27 checks passed
@mergify
mergify Bot deleted the fix/588-propagate-user-id branch July 11, 2026 05:03
@mergify mergify Bot removed the queued label Jul 11, 2026
@github-actions github-actions Bot mentioned this pull request Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: propagate user.id to hevy.api HTTP spans for Honeycomb trace completeness

1 participant