fix(passport): write PassportStamp when authed users visit a town#61
Merged
Conversation
The read side + display + PDF + toast all shipped in #57, but the write-site hook was flagged as a follow-up and never landed. Result: signed-in visitors saw 0 stamps forever no matter how many towns they walked into. - New `upsertPassportStamp(userId, townId, townOwnerId)` helper. Idempotent on `(userId, townId)`: first visit creates the row, subsequent visits bump `lastVisitedAt` and increment `visitCount`. No-op if the visitor is the town's owner (mirrors the schema rule — own-town visits show as `TOWNS OWNED: N` on the identity page and don't need to stamp too). - Called fire-and-forget from the visit path in `[town]/page.tsx`, right next to `creditFirstVisitAura` and `recordTownActivity`. Only fires for signed-in viewers; guests are still aggregated at read time from their `town-visit-<slug>` cookies in `loadGuestPassportData`. Closes the write-site gap on #55. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bug
Signed-in visitors were seeing 0 stamps on their passport no matter how many towns they walked into. Reproduced from an incident screenshot — a real user (Manik) with a valid passport id and one owned town landed on `/passport` and the right page was blank.
Root cause: the passport read side, the display, the PDF export, the OG image, and the entry toast all shipped in #57. The write-site hook — the actual `PassportStamp` upsert on visit — was called out explicitly in the follow-up section of that PR and never landed.
Fix
Related
Test plan
🤖 Generated with Claude Code