[codex] add cookie consent modal#123
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR implements a complete cookie consent system that lets users control analytics data collection. It introduces a consent API endpoint, client-side state management via React hooks, a user-facing modal, and gates Vercel Analytics and PostHog behind the user's preference while updating privacy documentation. ChangesCookie Consent Infrastructure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
apps/web/lib/cookie-consent.ts (2)
25-25: 💤 Low valueConsider trimming the decoded value for robustness.
While browsers typically don't include leading/trailing whitespace in cookie values, adding
.trim()afterdecodeURIComponent(value)would make the parser more defensive against edge cases.♻️ Optional defensive improvement
- const decoded = decodeURIComponent(value); + const decoded = decodeURIComponent(value).trim();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/lib/cookie-consent.ts` at line 25, The decoded cookie value should be trimmed to guard against stray whitespace: update the assignment to apply .trim() after decodeURIComponent(value) (i.e., change the usage of the decoded variable created from decodeURIComponent(value) to decodeURIComponent(value).trim()) wherever the cookie parsing sets the decoded variable so the parser becomes more defensive.
37-46: 💤 Low valueConsider using a cookie parsing library for robustness.
The manual string parsing works correctly for standard cookie strings, but a library like
cookiewould handle more edge cases and be more maintainable. This is a minor nice-to-have improvement.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/lib/cookie-consent.ts` around lines 37 - 46, Replace the manual cookie-string splitting in getCookieConsentFromCookieString with a robust cookie parser: import a cookie parsing library (e.g., the cookie package) and use its parse function to extract the COOKIE_CONSENT_COOKIE value, then pass that value to parseCookieConsent and return the result (or null if undefined). Keep references to COOKIE_CONSENT_COOKIE and parseCookieConsent unchanged so callers and downstream parsing remain consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/web/lib/cookie-consent.ts`:
- Line 25: The decoded cookie value should be trimmed to guard against stray
whitespace: update the assignment to apply .trim() after
decodeURIComponent(value) (i.e., change the usage of the decoded variable
created from decodeURIComponent(value) to decodeURIComponent(value).trim())
wherever the cookie parsing sets the decoded variable so the parser becomes more
defensive.
- Around line 37-46: Replace the manual cookie-string splitting in
getCookieConsentFromCookieString with a robust cookie parser: import a cookie
parsing library (e.g., the cookie package) and use its parse function to extract
the COOKIE_CONSENT_COOKIE value, then pass that value to parseCookieConsent and
return the result (or null if undefined). Keep references to
COOKIE_CONSENT_COOKIE and parseCookieConsent unchanged so callers and downstream
parsing remain consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d9f7a4c0-7cbb-442e-8e92-186414630af0
📒 Files selected for processing (16)
apps/web/__tests__/api/cookie-consent.test.tsapps/web/__tests__/unit/cookie-consent.test.tsapps/web/app/(landing)/join/[username]/opengraph-image.tsxapps/web/app/(landing)/join/[username]/ref-cookie.tsxapps/web/app/(landing)/layout.tsxapps/web/app/(landing)/privacy/page.tsxapps/web/app/api/cookie-consent/route.tsapps/web/app/layout.tsxapps/web/app/opengraph-image.tsxapps/web/components/landing/CookieConsentModal.tsxapps/web/components/providers/ConsentAwareAnalytics.tsxapps/web/components/providers/PostHogProvider.tsxapps/web/components/providers/useAnalyticsConsent.tsapps/web/lib/cookie-consent.tsapps/web/lib/open-stats.tsapps/web/next.config.ts
💤 Files with no reviewable changes (2)
- apps/web/app/opengraph-image.tsx
- apps/web/app/(landing)/join/[username]/opengraph-image.tsx
Summary
Why
The landing page needed a lightweight cookie consent flow that distinguishes essential platform cookies from analytics cookies. The implementation keeps Supabase Auth integrated with Next.js while preventing analytics libraries from initializing until users explicitly opt in.
Validation
bun --cwd apps/web test __tests__/unit/cookie-consent.test.ts __tests__/api/cookie-consent.test.tsbun --cwd apps/web lintbun --cwd apps/web typecheckbun --cwd apps/web test:e2e e2e/landing.spec.tshttp://localhost:3000: no Next issue badge and zero new console warnings/errors after fresh navigation.Summary by CodeRabbit
New Features
Documentation