Files
ipal-kit/docs/cookie-scanner.md
T
Radosław SmolińskiandClaude Opus 5.5 37592764b5 Docs: fix doc/code drift found against 1.16.3 (docs only)
Verified the IAWL summary's "Doc/code" notes against the code and swept
CLI flags, option names/defaults and env vars. Fixed in the docs:
admin groups (consent-records, cookie-review → Privacy; Form messages
global → Forms), tab labels (More, Spam protection, E-mail sending,
Search engines; Sending method), construction field labels, {field} =
label, globalOverrides instead of "a plugin after ipalKit", enabled:false
keeps globals, pages role labels en+pl, switchLocalePath prefix,
accessibility cookie (necessary), seeding summary() shape, prepublishOnly
chain, doctor --strict --offline in the starter, package files list,
ipal-skills --external in PROGRAMISTA, DATABASE_URI (not _URL),
uploadsCollection exists, SiteProviders nonce, buildLinksField labels,
MCP list_pages limit wording, IPAL_DOCTOR_TOKEN in the env table; shipped
seo-check message "Search engines". Reference skills copy refreshed.

Open questions (not changed): forms over-long text, PAYLOAD_SECRET
length, Site settings update access, doctor seen in CI, bare
`ipal-kit create --external`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 23:47:35 +01:00

35 KiB
Raw Blame History

cookie scanner

Fills the cookie list (Cookies → Cookie list) from the admin panel. A scan lists the cookies of every integration the project switches on, plus any extra names, in a review list. The editor then sees one summary — Approve cookies, grouped by consent category, new / changed / unknown marked — and one button, Approve and add, puts every ticked cookie everywhere it is listed: the cookie list, which feeds the <CookieBanner settings="detailed"> window and <CookieTable> on the policy page (consent.md). Projects that prefer it keep per-entry review (approval: false).

What a scan never does: delete an entry, change text an editor edited, change an entry's status, add a second row for a cookie that is already listed, or add anything to the cookie banner before the editor approves.

Opt-in (cookieScanner, default off). Nothing is fetched at runtime and no browser is needed.

A second, also opt-in step — Check site (cookieScanner.crawl, see Browser crawl) — opens the site in a real browser twice (no consent / after "Accept all") through a shared scanner service, reports every non-necessary cookie or tracker present before consent as a violation, and adds what it finds to the same review list. The browser runs in the service, never in the site.

Turn it on

// payload.config.ts
ipalKit({
  // …
  cookieScanner: true,
})

Then, in the project:

  1. Import map — the scan box, the Review and approve / Site check tabs and the approval view are admin components (@intecion/ipal-kit/admin#CookieScanButton, #CookieReviewTab, #CookieSiteCheckTab, #CookieApprovalView). Run pnpm generate:importmap (again after upgrading to the combined layout — the two tab components are new).
  2. Postgres / SQLite migration — the option adds the cookie-review collection (with localized purpose and retention). Run pnpm payload migrate:create cookie-scanner, commit the migration; Coolify runs payload migrate on deploy (deployment.md). MongoDB: nothing to do. Upgrading a project that already had cookieScanner (1.14.x or earlier): the approval step adds two fields to cookie-review — change (select) and needsDescription (checkbox). Run pnpm payload migrate:create cookie-approval and commit it. Existing entries keep their status; accepted ones are not re-approved, drafts show up on the approval page without a marker.
  3. Verify — log in as an editor, open Privacy → Cookies → Review and approve. The box lists "Integrations in use" (e.g. Cookie banner, Admin panel login, Google Analytics 4). Click Scan cookies: the cookies found appear below, grouped by category. Click Approve and add; the page reloads — open the Cookie list tab: the cookies are there, with purpose and duration in every language.

Admin layout

One Cookies entry in Privacy holds everything (adminLayout: 'combined', the default):

Tab What it is
Banner, Settings window, Categories the banner texts (consent.md)
Cookie list the cookies shown in the banner's detailed window and the cookie policy table
Review and approve the scan box and the approval list inline; Edit cookies one by one opens the review entries
Site check only with crawl: start a check, its status, the violations of the latest check, a link to the warning e-mail settings

The review list (cookie-review) and the site check result (cookie-crawl) leave the navigation (admin.group: false) but keep their pages, data and API — links from the dashboard, the e-mail and Edit still open them, and /admin/cookie-approval still works. The two tabs are ui fields: no data, no schema change, no migration — only pnpm generate:importmap. Approving in the tab writes the cookie list of the same screen, so the page reloads afterwards; while the screen has unsaved changes the button waits ("Save your changes first.").

adminLayout: 'separate' keeps the older layout: Cookie review and Cookie check as their own navigation entries, no extra tabs. A project's collectionOverrides / crawl.globalOverride (e.g. its own admin.group) win in both layouts.

Every language is filled: text written in one language (in the cookie list or a review entry) goes to the languages where that field is still empty, never over a language's own text (consent.md → Every language filled).

How editors use it

Step What happens
Scan cookies Every cookie of the integrations in use goes into the review list, marked New. Rows typed into the cookie list by hand are looked up once (In the cookie list is ticked). Nothing is added to the cookie banner yet.
More cookie names (optional text box) Names seen in the browser (DevTools → Application → Cookies), one per line. Each is looked up in the project's declarations, every built-in integration, then the Open Cookie Database. A name nothing knows is marked Needs description.
Review and approve The Review and approve tab of Cookies (the same list is also at /admin/cookie-approval, linked from the dashboard and the e-mail): one table per consent category (Necessary, Functional, Analytics, Marketing, then Not yet described), each cookie with provider, purpose and duration in the content language that matches the admin language, markers New, Changed, Needs description, an Edit link and a tick box.
Untick or edit Untick a cookie to leave it waiting; Edit opens its review entry (provider, category, purpose, duration per language). A later scan keeps every value you changed and still updates values you left as suggested.
Approve and add Every ticked cookie becomes Accepted and is added to Cookies → Cookie list in every language, with the plugin's English and Polish texts (a language without its own text gets the default language's text). A row that already lists the cookie — the same name, or a pattern that covers it, e.g. _ga_* and _ga_XYZ123 — is never duplicated: only its empty provider / purpose / duration are filled, its text and category stay. The cookie list feeds the cookie policy table and the banner's detailed window, so the cookie appears there too.
Unknown cookies Approved into a category that needs consent (approval.unknownCategory, default marketing) and flagged Needs description on the review entry; writing a purpose clears the flag.
A scan finds a change An accepted cookie whose suggested text changed is marked Changed and waits for approval again; approving it fills only empty text in the cookie list.
A cookie disappears An integration switched off, a declaration removed, or a cookie the site check no longer sees: the entry is marked No longer found and listed under that heading on the approval page. Nothing is deleted — the cookie list keeps its row until an editor removes it there. Found again → the mark goes away.
Per-entry review Still works: set Status to Accepted on one entry (or in bulk edit) to add just that cookie. Rejected entries stay out and later scans do not bring them back. Rejecting never removes a row from the cookie list.

Deleting review entries is admin-only and never done by the plugin. While cookies wait, the dashboard shows "Waiting for approval: N" with a link to the approval view (approval.dashboard: false turns it off).

Labels are in English and Polish and follow the editor's admin language; cookieScanner.labels adds languages or changes text. The built-in integrations without a product name (Cookie banner, Admin panel login, Language choice, Built-in statistics) take their names from the shared admin texts (adminTexts, keys cookieIntegration*, and cookieSourceProject for your own declarations), so the scan box lists them in the editor's language; the Source stored on a review entry is in the language of whoever ran the scan (English for a site check). Rename one through cookieScanner.integrations (label: { en: '…', pl: '…' }).

What the plugin declares

Each integration the plugin injects declares its cookies in one place (DEFAULT_COOKIE_INTEGRATIONS): name or pattern (* at the end = prefix), provider, category, purpose and retention (English and Polish), and whether it may be set before consent. Only the integrations switched on in this project are part of a scan:

Integration On when Cookies
Cookie banner always cookie-consent (necessary, 6 months)
Theme choice Site settings → Theme → Allow theme toggle on theme (or theme.storageKey) in local storage — necessary (a preference the visitor chose), until changed or site data is cleared, may be set before consent
Admin panel login always payload-token (<cookiePrefix>-token, necessary, editors only)
Language choice more than one locale in i18n NEXT_LOCALE (functional, session)
Built-in statistics stats option ipal_vid (analytics, 6 months)
Google Analytics 4 GA4 ID in Site integrations _ga, _ga_* (analytics, 2 years)
Google Tag Manager GTM ID in Site integrations _gcl_* (marketing — the Conversion Linker; other tags in the container: add their names or declare them)
Meta Pixel Pixel ID _fbp, _fbc (marketing, 3 months)
Microsoft Clarity Clarity ID _clck, _clsk, CLID, MUID
LinkedIn Insight Tag partner ID li_fat_id, bcookie, lidc, UserMatchHistory
TikTok Pixel Pixel ID _ttp, _tt_enable_cookie
Cloudflare Turnstile both Turnstile keys set cf_clearance (necessary; only when pre-clearance is on in Cloudflare)

An ID that fails its format check counts as off. Declarations cover browser storage too (storage: 'localStorage' | 'sessionStorage'): the theme choice is the plugin's only storage key. The accessibility widget (a11y-prefs cookie) has no plugin option the scan could check, so it is not declared: add it with declarations when the site uses the widget.

Every entry keeps its type (cookie, local storage, session storage) from the scan through the review and approval into Cookies → Cookie list (Type column; shared by all languages, default Cookie). The banner's detailed window shows the type for entries that are not cookies, and <CookieTable> adds a Type column when the list has one (consent.md). A row that was already in the list keeps the type it has; rows from before the type existed are Cookie — set storage rows by hand.

Unknown names are looked up in a bundled copy of the Open Cookie Database (about 2,300 entries, Apache License 2.0). The package ships the license text in licenses/open-cookie-database-LICENSE.txt; the data module names the upstream commit and the changes made (converted from CSV, two columns left out). The table is loaded only when a scan runs.

Category mapping (DEFAULT_DATABASE_CATEGORIES):

Database Consent category
Analytics analytics
Marketing marketing
Necessary, Security necessary
Functional, Personalization functional

"Functional" is not mapped to necessary on purpose: the database files some trackers there (Hotjar's user id), and a lookup nobody checked yet must not skip consent. The editor lowers the category when a cookie really is necessary, or the project changes the map: cookieScanner: { databaseCategories: { Functional: 'necessary' } }.

Refresh the copy (maintainers of ipal-kit, not projects):

pnpm cookie-db:refresh

scripts/refresh-cookie-database.mjs downloads the CSV and the license at the latest commit (or --ref <sha>), refuses to write if the license is no longer Apache-2.0, and rewrites src/modules/consent/scanner/data/openCookieDatabase.ts and the license file. Review the diff, run the tests, commit.

Options

cookieScanner: true or an object (CookieScannerOptions, every key optional):

Key Default What it does
declarations [] The project's own cookies (custom embeds, chat, YouTube): CookieDeclaration[], always part of a scan
integrations built-ins (defaults) => integrations — filter, change or add CookieIntegrations (each: key, label — one string or { en, pl, … } per admin language, declarations, isEnabled(ctx))
database true false = no Open Cookie Database lookup
databaseCategories table above Partial map from database category to consent category
access editor and up ({ req }) => boolean — who may scan, start a crawl and read its status
collectionOverrides — Change cookie-review: an object merges access / admin / hooks key by key (your keys win), a function takes over (keep the slug)
labels en, pl { de: { scanButton: 'Cookies scannen', … } } — merged over the plugin's labels (CookieScanLabels)
syncAccepted true false = accepting or approving only marks the entry; nothing is written to Cookie banner
approval on one summary and one Approve and add for everything found — false = per-entry review only (no view, no endpoint, no dashboard reminder); { unknownCategory, dashboard } — see below
approval.unknownCategory 'marketing' category given to cookies nothing knows when they are approved; pick one that needs consent (functional, analytics, marketing)
approval.dashboard true false = no "Waiting for approval" reminder on the dashboard
crawl off browser crawl through the scanner service — Browser crawl
adminLayout 'combined' one Cookies entry with Review and approve and Site check tabs; 'separate' = own navigation entries — Admin layout

A project declaration:

import type { CookieDeclaration } from '@intecion/ipal-kit'

const youtube: CookieDeclaration = {
  name: 'VISITOR_INFO1_LIVE',
  vendor: 'Google (YouTube)',
  category: 'marketing',
  domain: 'youtube.com',
  purpose: { en: 'YouTube: player preferences and bandwidth estimate.', pl: 'YouTube: preferencje odtwarzacza.' },
  retention: { en: '6 months', pl: '6 mies.' },
  setBeforeConsent: false,
}

ipalKit({ cookieScanner: { declarations: [youtube] } })

A project integration that is on only when a field is filled:

import type { CookieIntegration } from '@intecion/ipal-kit'

const chat: CookieIntegration = {
  key: 'chat',
  label: 'Live chat',
  isEnabled: (ctx) => Boolean(ctx.integrations.chatWidgetId),
  declarations: [/* CookieDeclaration … */],
}

ipalKit({ cookieScanner: { integrations: (defaults) => [...defaults, chat] } })

ctx (CookieScanContext) has payload, integrations (the Site integrations global, depth 0) and plugin ({ localeCount, stats }).

Endpoint

GET /api/ipal/cookie-scan { ok, integrations: [{ key, label }] } — what a scan covers; label in the admin language of the request
POST /api/ipal/cookie-scan body { names?: string[] | string } (newline or comma separated, up to 200, names with spaces, ;, , or = dropped) → { ok, summary: { created, updated, unchanged, unknown, newUnknown, gone }, integrations }
GET /api/ipal/cookie-approval?locale=pl { ok, pending, gone } — CookieApprovalItems (id, name, category, vendor, purpose, retention, change, unknown) in that content locale (default locale otherwise)
POST /api/ipal/cookie-approval body { ids?: (string | number)[] } — approves those pending entries (all pending without ids) → { ok, result: { added, filled, unchanged, needsDescription, skipped } }
Access editor and up (userMeetsRole; without access every logged-in account), or cookieScanner.access; otherwise 403

Paths: COOKIE_SCAN_PATH (/ipal/cookie-scan), COOKIE_APPROVAL_PATH (/ipal/cookie-approval), under the API route; the admin view is at COOKIE_APPROVAL_VIEW_PATH (/cookie-approval) under the admin route.

COOKIE_REVIEW_SLUG, group Privacy (with the default adminLayout: 'combined' it is out of the navigation and shown as the Review and approve tab of Cookies). Fields: name, storage (cookie / localStorage / sessionStorage), category, vendor, domain, purpose (localized), retention (localized), setBeforeConsent, status (draft / accepted / rejected), needsDescription (set when an unknown cookie is approved without a purpose; cleared when a purpose is written), and read-only change (new / changed / gone — what the latest scan noticed; approving clears it), source (integration / project / database / unknown / manual), sourceDetail, listed, lastScannedAt; hidden key (storage:name, unique — what a rescan matches) and suggested (the last scan's values — a value still equal to it was not edited). Access: create / read / update editor and up, delete admin.

Building blocks

All from @intecion/ipal-kit (server-safe), for your own admin view, a CLI or a scheduled job:

Export What it does
runCookieScan({ payload, plugin, options?, names?, req? }) the whole scan as the endpoint runs it → { enabled, summary }
collectCookieFindings({ ctx, integrations?, declarations?, names?, database?, databaseCategories? }) findings without writing anything; names are strings or CookieObservations ({ name, storage?, domain? }); matches maps each to its review key
applyCookieFindings({ payload, findings, entries?, req?, collection? }) writes findings as drafts with the merge rules above → CookieScanSummary (created, updated, unchanged, unknown, newUnknown); entries collects CookieReviewEntryRefs
cookieScanContext(payload, plugin, req?) the CookieScanContext a scan uses
parseCookieNames(input) the panel's text box → clean names
mergeCookieReview(current, previous, next), suggestionFor(finding, locales) the "never overwrite an edit" rule, pure
addToCookieList({ payload, entry, req? }) what accepting does: add the row or fill its empty text → 'added' | 'filled' | 'unchanged'; a row with the same name or a covering pattern counts as the same cookie (sameCookie(a, b))
loadCookieApproval({ payload, locale, req? }) the approval list → CookieApprovalList (pending, gone)
approveCookies({ payload, ids?, unknownCategory?, addToList?, req? }) what Approve and add does → CookieApprovalResult
countPendingCookies(payload), PENDING_WHERE how many wait / the query for them (drafts, and accepted cookies marked changed)
buildCookieApprovalEndpoints(options) the GET/POST approval endpoints, to wire by hand
flagGoneEntries({ payload, keep, where, req? }), nextChange(existing, changed) the "no longer found" flag and the marker rule (CookieChange)
DEFAULT_UNKNOWN_CATEGORY 'marketing'
CookieApprovalView, CookieApprovalForm (/admin) the approval view (server) and its form (client), injected as views.ipalCookieApproval
loadCookieDatabase(), indexCookieDatabase(rows), lookupCookie(index, name, categories?) the Open Cookie Database lookup
DEFAULT_COOKIE_INTEGRATIONS, DEFAULT_DATABASE_CATEGORIES, cookieNameMatches(pattern, name) declarations and matching
buildCookieReviewCollection(options), buildCookieScanEndpoints(options, plugin) the collection and endpoints, to wire by hand
COOKIE_SCAN_LABELS, mergeCookieScanLabels(overrides) admin labels
CookieScanButton (/admin) the box above the list (with Check site when crawl is on)
CookieReviewTab, CookieSiteCheckTab (/admin) the two tabs of the combined layout (client components; props approval, labels, unknownCategory / labels)
addCookieScannerTabs(global, { approval, crawl, labels, unknownCategory? }) adds those tabs to a global with a tabs field — for a project that builds its own cookie global
CookieScanButton props scan / onChange hide the scan part (the Site check tab) / called after a scan or a finished check
CookieApprovalForm props onApproved / blockedReason after approving (the tab reloads the page) / why the button waits
CookieCrawlAlert (/admin) the dashboard warning: cookies waiting for approval, and with crawl violations or a failed check (props approval, crawl)
buildCookieCrawlGlobal(labels), buildCookieCrawlEndpoints({ labels, options, plugin }) the crawl's global and endpoints, to wire by hand
resolveCrawlConfig(crawlOptions, payload) options + env + serverURL → ResolvedCrawlConfig (what is missing)
parseCrawlResult(body) validates the service's JSON (CrawlResult, CrawlObservation, CrawlRequest)
ingestCrawlResult({ payload, result, options, config, labels, plugin }), finishCrawl(…) applies a result: drafts, flags (→ CrawlIngestSummary), then the global and the e-mail
findCrawlViolations({ observations, requests, categoryOf, consentMode?, trackerHosts? }) the violation rule, pure (CrawlViolation)
DEFAULT_TRACKER_HOSTS, GOOGLE_TAG_HOSTS request hosts that count before consent
sendCrawlWarning({ payload, labels, siteUrl, summary, to, pending? }) the e-mail, through payload.sendEmail; with pending it says approval is waiting and links to the approval view
bearerMatches(header, token) constant-time bearer check

Types: CookieDeclaration, CookieIntegration, CookieScanContext, CookieFinding, CookieFindingSource, CookieStorage, LocalizedText, CookieScannerOptions, CookieScanSummary, CookieReviewValues, CookieDatabaseIndex, CookieScanLabels, OpenCookieCategory, CookieObservation, CookieReviewEntryRef; approval: CookieApprovalOptions, CookieApprovalItem, CookieApprovalList, CookieApprovalResult, CookieChange; crawl: CookieCrawlOptions, ResolvedCrawlConfig, CrawlResult, CrawlObservation, CrawlRequest, CrawlViolation, CrawlIngestSummary.

Browser crawl

What a page really sets — a GTM tag, an iframe, a script pasted into a block — shows only in a browser. cookieScanner.crawl adds Check site to the Cookie review box. One shared scanner service (services/cookie-crawler in the ipal-kit repository, run by the team on Coolify) does the browsing for every site:

editor ── Check site ──▶ site  POST /api/ipal/cookie-crawl
                         site ── POST {IPAL_COOKIE_SCAN_URL}/crawl (Bearer token) ──▶ scanner service
                                                              crawls the sitemap pages twice:
                                                              1. fresh profile, no decision
                                                              2. fresh profile, clicks "Accept all"
site  POST /api/ipal/cookie-crawl/results (Bearer token) ◀── cookies, storage keys, third-party hosts
      → drafts in Cookie review, violations, Cookie check global (`cookie-crawl`), dashboard warning, e-mail

Turn it on in a site

ipalKit({
  cookieScanner: { crawl: true },
})
  1. Env (Coolify → the site → Environment Variables):

    Variable Value
    IPAL_COOKIE_SCAN_URL the service's URL, e.g. https://cookie-crawler.intecion.net
    IPAL_COOKIE_SCAN_TOKEN a random token of at least 16 characters (openssl rand -hex 32), the same one as in the service's IPAL_CRAWLER_SITES entry for this site
    NEXT_PUBLIC_SERVER_URL already set — the public origin the service crawls and calls back (or Payload serverURL, or crawl.siteUrl)

    Validate them at startup: assertEnv(ipalEnvRules({ cookieCrawl: true })) (required in production).

  2. Import map: pnpm generate:importmap (the dashboard warning CookieCrawlAlert).

  3. Migration (Postgres / SQLite): crawl adds the cookie-crawl global and three fields to cookie-review (violation, violationDetail, seenBeforeConsent): pnpm payload migrate:create cookie-crawl, commit; Coolify runs payload migrate on deploy.

  4. Service: add the site to the service's IPAL_CRAWLER_SITES (below) and redeploy the service.

  5. Verify: Cookie review shows "Check site" enabled (when disabled, the box names the missing env var). Click it: the status says "Crawling…", then after one to a few minutes "Last crawl …: N pages, N violations, N new unknown" and the list reloads. Privacy → Cookie check shows the latest result. A test: put a <script>document.cookie='_fbp=x'</script> in a block on a staging page → the next crawl reports _fbp as a violation and the dashboard shows the warning.

What a crawl records and reports

Pages the site URL + up to maxPages (default 20, max 100) same-origin URLs from /sitemap.xml (one level of sitemap index)
Recorded per run cookies (name, domain), localStorage and sessionStorage keys, hosts of third-party requests, with the first pages they appeared on
New findings every cookie / key goes through the same lookup and merge rules as Scan cookies — new names wait on the approval page (marked New), edited text is kept, status is never changed, nothing is added to the cookie banner before approval
Disappeared an accepted cookie the crawl no longer sees (and nothing still declares) is marked No longer found — for review only, never deleted
Violation (cookie or key) seen before consent and its review entry's category is not necessary — an entry without a category counts too, until an editor classifies it
Violation (request) a request before consent to a tracker host (DEFAULT_TRACKER_HOSTS: Meta, LinkedIn, TikTok, Clarity, Bing, Hotjar, YouTube). Google's tag hosts (GOOGLE_TAG_HOSTS) count only with consentMode: 'basic' — in advanced (the plugin's default) the Google tag may load before consent with every signal denied
Review entries seenBeforeConsent, violation and violationDetail ("before consent on /, /about") — from the latest crawl only: every crawl clears the previous flags
Cookie check global (cookie-crawl) latest result only (no history): status, started / finished, by whom, pages, counts, violations, third-party hosts, error
"Accept all" not found the second run had no consent — the global's error says so (crawl.acceptSelector for a custom banner)
Dashboard a warning above the dashboard after a crawl with violations or a failed crawl (crawl.dashboard: false turns it off), and "Waiting for approval: N" with Review and approve while cookies wait (approval.dashboard)
E-mail opt-in per site: Privacy → Cookie check → E-mail warnings to (admin; comma-separated). Sent after a crawl with violations, new unknown cookies, or new cookies waiting for approval — then it says "Cookies waiting for approval: N. Nothing is added to the cookie banner until you approve them." and links to the approval view. Through the project's Payload email adapter (email: mailAdapter(), email.md). Empty = no e-mail

A crawl still "running" after 30 minutes counts as failed (the service never reported back), and a new one may start. One crawl per site at a time (409 otherwise).

Scheduled crawls

A Coolify Scheduled Task on the site's application (or any cron) starts a crawl with the token — no editor session needed:

curl -fsS -X POST -H "Authorization: Bearer $IPAL_COOKIE_SCAN_TOKEN" "$NEXT_PUBLIC_SERVER_URL/api/ipal/cookie-crawl"

Weekly is plenty (0 6 * * 1). New violations, unknown cookies and cookies waiting for approval then show on the dashboard and, when recipients are set, by e-mail. Nothing a scheduled crawl finds is added to the cookie banner until an editor approves it.

crawl options

crawl: true or CookieCrawlOptions:

Key Default What it does
serviceUrl env IPAL_COOKIE_SCAN_URL scanner service base URL
token env IPAL_COOKIE_SCAN_TOKEN shared secret (≥ 16 characters); shorter = not configured
siteUrl Payload serverURL, else NEXT_PUBLIC_SERVER_URL public origin to crawl; the callback goes to <siteUrl>/api/ipal/cookie-crawl/results
maxPages 20 (max 100) sitemap pages besides the site URL
acceptSelector [data-ipal="accept"] the banner's "Accept all" button (the plugin's CookieBanner has it in every mode)
consentMode 'advanced' 'basic' = Google tag requests before consent are violations too — match the project's SiteProviders analytics={{ consentMode }}
trackerHosts DEFAULT_TRACKER_HOSTS (defaults) => [...defaults, 'widget.chat.example']
dashboard true false = no dashboard warning
globalOverride — change the cookie-crawl global like globalOverrides (object merges access / admin / hooks, a function takes over)

Access: start a crawl and read its status — editor and up (cookieScanner.access), or the bearer token; the results endpoint — the bearer token only, and only for the running job id; the cookie-crawl global — read editor and up, update (the e-mail field) admin.

Endpoints

GET /api/ipal/cookie-crawl { configured, missing, status, startedAt, finishedAt, summary, error }
POST /api/ipal/cookie-crawl starts a crawl → 202; 403, 409 (one is running), 503 (not configured), 502 (service unreachable — the global says why)
POST /api/ipal/cookie-crawl/results the service's callback: Authorization: Bearer <token>, body = the wire format (CrawlResult) → 200; 401, 400, 409 (not the running job)

Paths: COOKIE_CRAWL_PATH, COOKIE_CRAWL_RESULTS_PATH; env names: COOKIE_SCAN_URL_ENV, COOKIE_SCAN_TOKEN_ENV; global slug COOKIE_CRAWL_SLUG.

Scanner service on Coolify

One service for every site the team runs. Code: services/cookie-crawler/ in the ipal-kit repository (Node + Playwright, no other dependency; not part of the npm package).

  1. Coolify → Project → New Resource → Application from the ipal-kit Git repository.

    • Build pack: Dockerfile; base directory services/cookie-crawler; Dockerfile Dockerfile.
    • Port: 3000. Health check path: /health (the image also has a Docker HEALTHCHECK).
    • Domain: e.g. https://cookie-crawler.intecion.net (Coolify issues the certificate).
    • Resources: 1–2 GB RAM, 1 CPU per concurrent crawl (Chromium). Keep CRAWLER_CONCURRENCY=1 unless the server has room.
  2. Environment variables:

    Variable Default
    IPAL_CRAWLER_SITES — (required) acme.pl=TOKEN1,shop.example.com=TOKEN2 — the sites it may crawl, each with its own token (≥ 16 characters; www. is ignored). A token only opens its own site
    PORT 3000
    CRAWLER_CONCURRENCY 1 crawls at the same time
    CRAWLER_QUEUE_MAX 20 waiting crawls; more → 429
    CRAWLER_JOB_TIMEOUT_MS 600000 a longer crawl is reported as failed
    CRAWLER_WAIT_MS 3000 wait on every page for late tags (defer analytics)
    CRAWLER_ALLOW_HTTP unset 1 only for local tests; sites must be https
  3. Deploy, then check: curl https://cookie-crawler.intecion.net/health → {"ok":true,…}.

  4. Adding a site: generate a token, add host=token to IPAL_CRAWLER_SITES, redeploy the service; set the same token as the site's IPAL_COOKIE_SCAN_TOKEN.

  5. Updating Playwright: the npm version in services/cookie-crawler/package.json and the image tag in its Dockerfile (mcr.microsoft.com/playwright:v1.64.0-noble) must match; change both, redeploy.

What the service refuses: a site not in IPAL_CRAWLER_SITES, a token that is not that site's, a callback URL on another origin than the site, plain http. It crawls only the listed origins (no open proxy), runs Chromium as the image's non-root user, and keeps nothing after a crawl.

DNS and network:

  • One DNS record for the service: cookie-crawler.<team domain> → A/AAAA to the Coolify server (the team runs the zone; add it with the other records, deployment.md §6). No record is needed per site.
  • The site must reach the service URL (outbound HTTPS from the site container), and the service must reach each site's public URL (outbound HTTPS) — the crawl must go through the public domain, CDN and proxy, as a visitor's browser does. On the same Coolify server both go out and back through the public domain; do not point siteUrl at an internal container name (cookies are set for the public domain).
  • Sites behind Cloudflare (WAF, Bot Fight Mode, "Under Attack"): allow the Coolify server's IP, or the crawl sees a challenge page instead of the site. Every crawler request carries the header X-Ipal-Cookie-Crawler: 1 for a WAF rule.
  • The crawler's page views land in the site's stats and analytics like any visitor without consent (cookieless) and with consent on the second run. Filter the Coolify server's IP in GA4 if it matters.

From a laptop or CI

The same crawl, without the service: cd services/cookie-crawler && npm install && npx playwright install chromium, then node cli.mjs https://acme.pl --pages 10 prints the result as JSON (exit code 1 when anything but the consent cookie is stored before consent). It does not know the site's categories — the panel's Check site gives the verdict. ipal-consent-check → cookie-scan (cookie-scan.mjs) stays the quick check for projects without the service; paste the names it reports as unknown into More cookie names.

Turn off, override, extend

  • Separate screens: adminLayout: 'separate'.
  • Turn off one approval: approval: false — per-entry review only (set Accepted on each entry), no approval view, endpoint or reminder.
  • Turn off the crawl only: omit crawl (default) — no cookie-crawl global, no crawl endpoints, no dashboard warning, no violation fields; dashboard: false keeps the crawl without the warning.
  • Turn off: omit cookieScanner (default). Turning it off later keeps no endpoint and no collection; Cookies → Cookie list keeps every row (it is still edited by hand or by the skill's import script).
  • Override: collectionOverrides (access, admin, hooks), access (who scans), labels, databaseCategories, integrations (change or drop a built-in), syncAccepted: false, approval.unknownCategory, approval.dashboard; for the crawl serviceUrl, token, siteUrl, maxPages, acceptSelector, consentMode, trackerHosts, globalOverride.
  • Extend: declarations and integrations for the project's own cookies; the building blocks above for your own UI, CLI or scheduled scan; the crawl's wire format (CrawlResult) to feed results from another crawler.