feat(core): derive consent category metadata from cookie context - #171
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughCookie context entries now support labels, descriptions, and ChangesCookie consent metadata
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CookieContextEntry
participant deriveConsentConfig
participant resolveCookieTypeMeta
participant useConsent
participant CookiePreferences
deriveConsentConfig->>CookieContextEntry: Read metadata
deriveConsentConfig->>resolveCookieTypeMeta: Resolve localized fallbacks
deriveConsentConfig->>useConsent: Expose derived categories
useConsent->>CookiePreferences: Provide category metadata
CookiePreferences->>CookiePreferences: Render labels and descriptions
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@packages/core/src/consent/derive.ts`:
- Around line 27-37: Update the locale passed to createT in the category
fallback path within derive so it uses the same effective locale selected for
the returned consent configuration, giving options.locale precedence over
policy.locale. Ensure resolveCookieTypeMeta receives that effective locale
through the shared translator, and add a regression test covering an
options.locale override.
In `@packages/core/src/i18n/cookie-type.ts`:
- Around line 14-16: Update the dictionary lookup in the cookie type resolution
logic to verify that key is an own property of known before reading known[key].
For inherited keys such as constructor or toString, skip the entry branch and
return t.cookie.types.fallback({ key }); preserve the existing label and
description behavior for valid own entries.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 27b8b79a-288e-4793-81a7-84809f7c48b6
📒 Files selected for processing (16)
.changeset/quiet-cookies-describe.mdapps/web/content/docs/consent/index.mdapps/web/content/docs/policy/configuration.mdapps/web/content/docs/policy/policies/cookies.mdapps/web/src/components/CookiePreferences.tsxapps/web/src/policystack.tspackages/core/src/consent/derive.test.tspackages/core/src/consent/derive.tspackages/core/src/documents/cookie.tspackages/core/src/i18n/cookie-type.tspackages/core/src/policy-version.test.tspackages/core/src/types.tspackages/react/src/consent.test.tsxpackages/react/src/provider.test.tsxpackages/sdk/llms.txtpackages/sdk/src/llms.ts
An explicit `options.locale` already overrode `policy.locale` for the returned consent config, but the cookie-type dictionary behind derived category copy still read `policy.locale`, so the config could report one locale while its labels came from another. Resolve the locale once and feed both, coercing through `coerceLocale` so a free-string locale maps to the same `Locale` `resolveLocale` picks downstream without warning twice. Also note in the changeset that categories without explicit copy now render dictionary labels instead of the capitalised key.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.
Inline comments:
In @.changeset/quiet-cookies-describe.md:
- Around line 5-7: Update the release note’s fallback-copy description to state
that derived categories use options.locale when provided, otherwise
policy.locale. Keep the existing explanation of dictionary fallback and
custom-category behavior unchanged.
In `@packages/core/src/consent/locale.ts`:
- Around line 14-17: Update deriveConsentConfig to compute one effective locale
using the same fallback precedence as resolveLocale, including
navigator.language when options.locale and policy.locale are absent, then pass
that locale to both coerceLocale and resolveLocale so derived category copy and
the consent configuration use the same result.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 395d008f-3fbc-41d6-9f17-64f584841082
📒 Files selected for processing (4)
.changeset/quiet-cookies-describe.mdpackages/core/src/consent/derive.test.tspackages/core/src/consent/derive.tspackages/core/src/consent/locale.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/core/src/consent/derive.test.ts
- packages/core/src/consent/derive.ts
…Object `cookies.used` keys are user-authored, so a bare index into the dictionary's label map resolved `constructor`/`toString` up the prototype chain to a truthy non-entry and threw `entry.label is not a function` instead of returning the locale's generic fallback. Guard the lookup with `Object.hasOwn`, matching the check in consent/triggers.
Summary
Derives localized consent category labels, descriptions, and GPC behavior from cookie context so preference panels no longer maintain separate copy tables. Closes #160.
Changes
Summary by CodeRabbit
New Features
Documentation