Repository navigation
feat: add Jam SDK for bug report recording #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { jam } from "@jam.dev/sdk"; | ||
|
|
||
| let currentUserId: string | undefined; | ||
|
|
||
| jam.metadata(() => ({ userId: currentUserId })); | ||
|
|
||
| export function setJamUserId(userId: string | undefined): void { | ||
| currentUserId = userId; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: Programcode/DebateLab
Length of output: 13738
🏁 Script executed:
Repository: Programcode/DebateLab
Length of output: 4565
Serialize awaited initialization with auth-state changes.
init()can write an older user ID afterexchangeCodeForSession()orgetSession()resolves. If an auth-state change processes sign-out or an account switch while either operation is pending, the later initialization result can overwrite the current Jam user ID. Thecatchpath can also leave a stored Jam user ID when it sets the session tonull. Track an auth-event generation, or use one ordered state-transition path, before applying initialization results and failure cleanup. Add a regression test for a pending session operation followed by sign-out.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the narrow part: the catch path now also clears the Jam user id (and the ref backing it) when init fails, so a failed init after a real sign-in can't leave stale/signed-out user ids on subsequent Jam bug reports (3adaec2).
Declining the broader ask (generation-counter serialization across init/exchangeCodeForSession/getSession/onAuthStateChange, plus a regression test): that race already exists for
session/currentUserIdRefin this file pre-dating this PR — this diff only mirrored the existing assignment pattern for the new Jam metadata call, it didn't introduce the race. Reordering the whole auth-init flow is a heavier architectural change than this "add Jam SDK" PR should carry; happy to take it as a separate follow-up if it's worth prioritizing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Programcode, confirmed. Theinit()failure path now clears bothcurrentUserIdRef.currentand Jam metadata.The remaining initialization ordering race predates this PR. The new Jam metadata synchronization can reflect that race, but a serialization change and regression test are larger than this integration change.
Would you like me to open a follow-up GitHub issue for ordered auth initialization and auth-state transitions?
✏️ Learnings added
You are interacting with an AI system.