Skip to content

fix(post): send the post view only once the token is valid - #7555

Merged
idoshamun merged 2 commits into
mainfrom
fix/post-view-wait-for-token
Dec 3, 2026
Merged

idoshamun merged 2 commits into
mainfrom
fix/post-view-wait-for-token

Conversation

@idoshamun

@idoshamun idoshamun commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Changes

Fixes dailydotdev/daily#2214: a post opened from a notification doesn't show up in reading history and doesn't count for the streak.

  • useTrackPostView and the mount-time view effects in Brief, Social/Twitter, Poll and Digest posts now wait for isTokenValid before they send viewPost. That's the same flag the feed already waits on: the token was refreshed, or the cached one is still valid.
  • BriefPostContent.tsx now falls under the strict typecheck, so its three snapshot containerRef props get a RefObject<HTMLElement> cast at the call site, as SnapshotSharePanel does. These were existing errors, not new ones.
  • New useTrackPostView.spec.tsx: no view while the token is invalid, and exactly one once it becomes valid. It fails without the fix.

Why: a push or email link loads the post page cold. The user comes from the cached boot data immediately, so viewPost went out before /boot had reissued the 15-minute access token. After hours away that token has expired, so the API sees an anonymous request and returns UNAUTHENTICATED. isFinalViewRejection treats that as final, so the view is dropped and never retried. The BootProvider recovery after a token refresh only re-runs failed queries, not mutations.

Evidence (Nov 19 – Dec 2). Same posts, logged-in users, opened via the reading reminder push vs opened in-app:

Surface From push: view recorded In-app open: view recorded
Android app 36% (263 opens) 99% (6,245)
Mobile web 24% (591) 99% (9,434)
Desktop 63% (785) 93% (20,516)

Nov 1–14 looked the same (Android 29%), so this isn't a recent regression.

Verification: the new spec, the shared hooks/post, components/post and hooks/streaks suites (273 tests), the full webapp suite (705 tests), pnpm --filter webapp typecheck and oxlint/oxfmt all pass. typecheck-strict-changed passes too. I haven't reproduced it on a device.

Events

No new tracking events.

Experiment

No new experiments.


🤖 Opened by Smith (AI assistant) on behalf of @idoshamun.

Opening a post straight from a push or email link loads the page cold. The
user comes from the cached boot data right away, so the view effect fired
viewPost before /boot had reissued the 15-minute access token. After a few
hours away that token has expired, the API sees an anonymous request and
answers UNAUTHENTICATED, and useViewPost treats that as a final rejection:
the view is dropped, never retried, and the read is missing from history
and the streak.

Gate every mount-time view on isTokenValid, the flag the feed already waits
on (token refreshed, or a cached token that is still valid), so the view goes
out once the session is usable.

Fixes dailydotdev/daily#2214
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
daily-webapp Ready Ready Preview Dec 3, 2026 9:27am UTC

Request Review

@idoshamun
idoshamun enabled auto-merge (squash) December 3, 2026 09:18
…refs

Touching BriefPostContent pulls it into typecheck_strict_changed, which flagged three existing RefObject<HTMLDivElement | null> props. Cast at the call site, as SnapshotSharePanel does.
@idoshamun
idoshamun merged commit 7300c01 into main Dec 3, 2026
12 checks passed
@idoshamun
idoshamun deleted the fix/post-view-wait-for-token branch December 3, 2026 09:27

This branch was successfully deployed

1 active deployment
Preview — b63d0a50 Deployed Dec 3, 2026 by vercel[bot]
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.

🐛 BUG: Notification not counting

1 participant