Consent compliance: docs, agent guide, skills, changelog, shared behaviour spec, browser check, reference e2e
- docs/consent.md: compliance defaults, Global Privacy Control, withdrawal, consent log on by default and the SQL migration; no more "UODO requirement" or "GPC not needed". docs/analytics.md: what Consent Mode advanced sends. - docs/consent-behaviour-spec.md: the behaviour IAPL and IAWL share, with the 13-item test list. - CHANGELOG 1.17.0: the SQL migration first, a before → after table for an existing site. - AGENT.md, iapl-setup / iapl-upgrade / iapl-reference / iapl-consent-check, PROGRAMISTA item 78; reference skills copy. - iapl-consent-check: Global Privacy Control, equal prominence and withdrawal runs; Google asset warnings. - Reference site uses the new defaults; e2e for GPC, a stale grant, equal prominence, withdrawal; e2e:built runs every consent test in both bundlers. YouTubeEmbed warns in development without a poster. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
99036eb70c
commit
f5c53e4523
@@ -185,7 +185,7 @@ export function Analytics(props: AnalyticsProps) {
|
||||
if (linkedInPartnerId) {loadLinkedIn(linkedInPartnerId)}
|
||||
if (tiktokPixelId) {loadTikTok(tiktokPixelId)}
|
||||
}
|
||||
if (state.analytics && clarityProjectId) {loadClarity(clarityProjectId, state)}
|
||||
if (state.analytics && clarityProjectId) {loadClarity(clarityProjectId, { analytics: state.analytics, marketing: state.marketing })}
|
||||
}, [
|
||||
ready,
|
||||
state.marketing,
|
||||
|
||||
@@ -60,13 +60,16 @@ function listedPerCategory(rows: ConsentTexts['cookies']): { cookies: ConsentCoo
|
||||
}
|
||||
|
||||
export function ConsentProvider({ children, cookieMap, cookieValue, gpc, logEndpoint, maxAgeDays, nonce, texts }: ConsentProviderProps) {
|
||||
// Keyed by content: the texts and the map are often new objects on every render.
|
||||
const listKey = JSON.stringify(texts.cookies ?? null)
|
||||
const listed = useMemo(() => listedPerCategory(texts.cookies), [listKey])
|
||||
const listed = useMemo(() => listedPerCategory(JSON.parse(listKey) as ConsentTexts['cookies']), [listKey])
|
||||
const cookieMapKey = JSON.stringify(cookieMap ?? null)
|
||||
const mergedCookies = useMemo(() => {
|
||||
const out: ConsentCookieMap = { ...listed.cookies }
|
||||
for (const [cat, names] of Object.entries(cookieMap ?? {}) as [ConsentCategory, string[]][]) {out[cat] = [...(out[cat] ?? []), ...names]}
|
||||
const extra = (JSON.parse(cookieMapKey) ?? {}) as ConsentCookieMap
|
||||
for (const [cat, names] of Object.entries(extra) as [ConsentCategory, string[]][]) {out[cat] = [...(out[cat] ?? []), ...names]}
|
||||
return out
|
||||
}, [listed, JSON.stringify(cookieMap ?? null)])
|
||||
}, [listed, cookieMapKey])
|
||||
const consent = useConsent({
|
||||
cookieMap: mergedCookies,
|
||||
cookieValue,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
export { ConsentProvider, useConsentContext } from './ConsentContext.js'
|
||||
export { ConsentScript } from './ConsentScript.js'
|
||||
export { readEffectiveConsent } from './consentStore.js'
|
||||
export { CookieBanner } from './CookieBanner.js'
|
||||
export type { CookieBannerAction, CookieBannerClassNames, CookieSettingsAction } from './CookieBanner.js'
|
||||
export { bottomOverlap, COOKIE_BUTTON_AVOID, CookieButton } from './CookieButton.js'
|
||||
@@ -8,5 +9,4 @@ export type { CookieButtonProps } from './CookieButton.js'
|
||||
// Client-only consent exports — hook, provider, and UI components.
|
||||
export { DEFAULT_COOKIE_MAP, useConsent } from './useConsent.js'
|
||||
export type { ConsentCookieMap } from './useConsent.js'
|
||||
export { readEffectiveConsent } from './consentStore.js'
|
||||
export { clarityConsent, signalVendors } from './vendorConsent.js'
|
||||
|
||||
@@ -173,7 +173,7 @@ export function useConsent(options: ConsentCookieMap | UseConsentOptions = {}) {
|
||||
// look like it worked while nothing changed.
|
||||
updateConsent(next)
|
||||
try {
|
||||
onDecision?.({ gpc, id, state: next, version })
|
||||
onDecision?.({ id, gpc, state: next, version })
|
||||
} catch {
|
||||
// a logging hook must never break the banner
|
||||
}
|
||||
@@ -199,7 +199,6 @@ export function useConsent(options: ConsentCookieMap | UseConsentOptions = {}) {
|
||||
rewritten.current = staleKey
|
||||
write(record.state, resolved.state, record.id ?? newConsentId(), true)
|
||||
// runs for a stale record only; `write` reads everything else it needs
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [staleKey])
|
||||
|
||||
const acceptAll = useCallback(() => persist(ACCEPT_ALL_CONSENT), [persist])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
type YouTubeEmbedProps = {
|
||||
/** Classes per element; nothing is styled by default (keep the aspect ratio in your CSS). */
|
||||
@@ -10,8 +10,9 @@ type YouTubeEmbedProps = {
|
||||
/** Accessible name of the play button, from the panel ("Play: <title>"). */
|
||||
playLabel: string
|
||||
/**
|
||||
* Poster URL — your own upload (no request to Google until play) or omit to
|
||||
* use YouTube's thumbnail (i.ytimg.com, no cookies).
|
||||
* Poster URL — your own upload (no request to Google until play). Omitted, YouTube's thumbnail
|
||||
* (i.ytimg.com, no cookies) loads with the page: a request to Google before any choice, which the consent check
|
||||
* reports as a warning. New sites pass a poster; a development warning says so.
|
||||
*/
|
||||
poster?: string
|
||||
/** Video title, from the panel — iframe title for screen readers. */
|
||||
@@ -29,6 +30,11 @@ type YouTubeEmbedProps = {
|
||||
export function YouTubeEmbed({ classNames = {}, note, playLabel, poster, title, videoId }: YouTubeEmbedProps) {
|
||||
const [playing, setPlaying] = useState(false)
|
||||
const id = /^[\w-]{6,20}$/.test(videoId) ? videoId : ''
|
||||
useEffect(() => {
|
||||
if (!poster && id && process.env.NODE_ENV !== 'production') {
|
||||
console.warn(`[iapl] <YouTubeEmbed videoId="${id}"> has no poster: YouTube's thumbnail loads from Google before any choice — pass an uploaded poster (docs/storage.md)`)
|
||||
}
|
||||
}, [poster, id])
|
||||
if (!id) {return null}
|
||||
if (playing) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user