fix(public): fix self-view tracking logic in profile and card view handlers#294
Open
hariom888 wants to merge 5 commits into
Open
fix(public): fix self-view tracking logic in profile and card view handlers#294hariom888 wants to merge 5 commits into
hariom888 wants to merge 5 commits into
Conversation
|
Hi, |
ShantKhatri
requested changes
May 28, 2026
c3ea871 to
2afa258
Compare
Contributor
Author
|
@ShantKhatri Done, reverted all unintended formatting changes. Only the isSelfView logic remains. |
ShantKhatri
approved these changes
Jun 6, 2026
ShantKhatri
left a comment
Collaborator
There was a problem hiding this comment.
LGTM! @Harxhit, you can have the final review.
Collaborator
|
Please resolve the merge conflicts and pin me our pr-review channel. |
Signed-off-by: hariom888 <hariom880088@gmail.com>
|
@hariom888 is attempting to deploy a commit to the Prashantkumar Khatri's projects Team on Vercel. A member of the Team first needs to authorize it. |
CI — All Checks PassedBackend — PASS
Mobile — SKIP
Web — SKIP
Last updated: |
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.
Problem
In apps/backend/src/routes/public.ts, when an authenticated owner views their own profile, viewerId was left as null (not set to their id). The guard
if (viewerId !== user.id)then evaluatesnull !== user.idwhich is always true, so the self-view wasrecorded in cardView anyway. This silently inflated totalViews and uniqueViewers on the analytics dashboard.
Fix
Introduced an explicit
isSelfViewboolean flag in both the /:username and /:username/card/:cardId handlers. When the decoded JWT id matches user.id, isSelfView is set to true and viewerId stays null. The guard is changed fromviewerId !== user.idto!isSelfView, which correctly blocks the insert for authenticated owners while still tracking unauthenticated views with viewerId: null.Affected handlers
Testing
Closes #203