Cookie scanner: one approval for everything a scan finds

After "Scan cookies" or a site check, the new Approve cookies view
(/admin/cookie-approval) lists what waits, grouped by consent category, with
provider, purpose and duration and New / Changed / Needs description markers.
One "Approve and add" puts every ticked cookie into Cookie banner -> Cookie
list in every locale. That list feeds the cookie policy table and the
detailed settings window.

- Never overwrites editor text or categories, never adds a second row (a
  pattern and a concrete name are the same cookie), never deletes.
- Unknown cookies are approved into a category that needs consent
  (approval.unknownCategory, default marketing) and flagged Needs
  description; writing a purpose clears the flag.
- Cookies a scan or crawl no longer finds are flagged No longer found, for
  review only.
- The dashboard and the crawl e-mail say how many cookies wait and link to
  the view; nothing is added without approval.
- Optional: cookieScanner.approval false keeps per-entry review.
- Migration: cookie-review gains change and needsDescription.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-28 22:17:46 +01:00
co-authored by Claude Opus 5.5
parent 0e7966dfbb
commit 86ff3f5ff7
25 changed files with 1186 additions and 114 deletions
+25 -2
View File
@@ -23,6 +23,10 @@ const setKey: CollectionBeforeChangeHook = ({ data, originalDoc }) => {
data.name = name
data.key = `${storage}:${name}`
}
// An editor who writes the purpose has described the cookie.
if (typeof data.purpose === 'string' && data.purpose.trim() && (data.needsDescription ?? originalDoc?.needsDescription)) {
data.needsDescription = false
}
return data
}
@@ -91,9 +95,9 @@ export function buildCookieReviewCollection(options: CookieScannerOptions = {}):
},
admin: {
components: {
beforeListTable: [{ clientProps: { crawl, labels }, path: '@intecion/ipal-kit/admin#CookieScanButton' }],
beforeListTable: [{ clientProps: { approval: options.approval !== false, crawl, labels }, path: '@intecion/ipal-kit/admin#CookieScanButton' }],
},
defaultColumns: ['name', 'vendor', 'category', 'status', 'source', 'listed', ...(crawl ? ['violation'] : [])],
defaultColumns: ['name', 'vendor', 'category', 'status', 'change', 'listed', ...(crawl ? ['violation'] : [])],
description: L('collectionDescription'),
group: { en: 'Privacy', pl: 'Prywatność' },
listSearchableFields: ['name', 'vendor'],
@@ -178,6 +182,25 @@ export function buildCookieReviewCollection(options: CookieScannerOptions = {}):
admin: { description: L('listedDescription'), position: 'sidebar', readOnly: true },
label: L('listed'),
},
{
name: 'change',
type: 'select',
admin: { description: L('changeDescription'), position: 'sidebar', readOnly: true },
index: true,
label: L('change'),
options: [
{ label: L('changeNew'), value: 'new' },
{ label: L('changeChanged'), value: 'changed' },
{ label: L('changeGone'), value: 'gone' },
],
},
{
name: 'needsDescription',
type: 'checkbox',
admin: { description: L('needsDescriptionDescription'), position: 'sidebar' },
defaultValue: false,
label: L('needsDescription'),
},
{ name: 'lastScannedAt', type: 'date', admin: { position: 'sidebar', readOnly: true }, label: L('lastScannedAt') },
...crawlFields,
// `storage:name`, one entry per cookie — what a rescan matches on.