Skip to content

fix(sdk): preserve device and session ids after failed requests - #670

Open
pcbeingused333 wants to merge 1 commit into
Openpanel-dev:mainfrom
pcbeingused333:fix/sdk-preserve-identifiers-c2797
Open

pcbeingused333 wants to merge 1 commit into
Openpanel-dev:mainfrom
pcbeingused333:fix/sdk-preserve-identifiers-c2797

Conversation

@pcbeingused333

@pcbeingused333 pcbeingused333 commented Nov 12, 2026 •

Copy link
Copy Markdown

A failed tracking request currently clears previously resolved device and session IDs because send() assigns IDs even when Api.fetch() returns null. Subsequent replay chunks are then queued because the SDK no longer has a session.

Return without updating identifiers when the request has no result. Successful responses still update the IDs and retain the existing first-session queue flush behavior.

Testing

The SDK regression test first resolves IDs, simulates a failed request returning null, checks that both IDs survive, and verifies a subsequent replay reaches the API. Before the fix: 3 passed, 1 failed. After the fix: 4 passed, 0 failed (bun test ./packages/sdks/sdk/src/index.test.ts).

AI assistance: this change and regression test were generated with Codex.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed tracking so requests that return no result preserve previously resolved device and session identifiers.
    • Subsequent replay sends now trigger another fetch when needed, helping tracking continue with the correct identity.

Keep resolved identifiers when tracking returns no result so subsequent replay chunks can still be sent.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The SDK now preserves stored device and session IDs when a request returns no result. A test verifies that a null response leaves the IDs unchanged and that a subsequent replay triggers another fetch.

Changes: SDK identity preservation

Layer / File(s) Summary
Send identity update and validation
packages/sdks/sdk/src/index.ts, packages/sdks/sdk/src/index.test.ts
send skips identity updates for AI events and requests without results. The test verifies that a null response preserves known IDs and that a replay triggers another fetch.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

Suggested reviewers: lindesvard

Merge Risk: Minimal · up to 88d4a

A failed tracking request no longer clears previously resolved device and session IDs, and successful responses still update them. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the core change: after a failed request, the SDK keeps the previously resolved device and session IDs instead of clearing them. The raw summary says send() now returns early for reques…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the core change: after a failed request, the SDK keeps the previously resolved device and session IDs instead of clearing them. The raw summary says send() now returns early for requests with no result and no longer clears the stored IDs, and the objectives describe the same behavior. The title is specific, uses a conventional commit prefix, and is 63 characters long.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 34945434-d7c1-46a7-8e80-d6a6a98105ca
Commits

Reviewing files that changed from the base of the PR and between a5a6eb7 and 88d4ac4.

Files selected for processing: 2

  • packages/sdks/sdk/src/index.test.ts
  • packages/sdks/sdk/src/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

This branch has not been deployed

No deployments
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.

2 participants