From df1c1f4a7d1b9ca368ba593cef04f7c80176afef Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Fri, 8 May 2026 23:42:46 +0200 Subject: [PATCH] feat(04-cookie-notice-bugfix): fix CookieNoticePro injectScripts error Phase 4 complete: - remove undefined injectScripts calls from CookieNoticePro - preserve Consent Mode v2 and GTM integration - add PAUL plan, summary, and changelog --- .paul/PROJECT.md | 15 +- .paul/ROADMAP.md | 84 +++++++---- .paul/STATE.md | 64 +++++---- .paul/changelog/2026-05-08.md | 15 ++ .../04-cookie-notice-bugfix/04-01-PLAN.md | 130 ++++++++++++++++++ .../04-cookie-notice-bugfix/04-01-SUMMARY.md | 113 +++++++++++++++ .../CookieNoticePro/cookienoticepro.script.js | 4 - 7 files changed, 357 insertions(+), 68 deletions(-) create mode 100644 .paul/changelog/2026-05-08.md create mode 100644 .paul/phases/04-cookie-notice-bugfix/04-01-PLAN.md create mode 100644 .paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md diff --git a/.paul/PROJECT.md b/.paul/PROJECT.md index 2d8dcc9..50b468a 100644 --- a/.paul/PROJECT.md +++ b/.paul/PROJECT.md @@ -12,8 +12,9 @@ Uzytkownicy moga szybko i bezpiecznie kupic bilety online oraz otrzymac natychmi - [x] Obsluga zakupu biletow end-to-end (wybor, checkout, finalizacja) - [x] Poprawne rejestrowanie zamowien i danych transakcyjnych - [x] Data layer purchase po finalizacji zakupu (wdrozone w Phase 1) -- [x] Event purchase capturuje 100% zamowien — fires przy skladaniu, nie przy powrocie z P24 (Phase 2) -- [x] Zgodnosc z RODO — baner zgody na cookies z Google Consent Mode v2 (Phase 3) +- [x] Event purchase capturuje 100% zamowien - fires przy skladaniu, nie przy powrocie z P24 (Phase 2) +- [x] Zgodnosc z RODO - baner zgody na cookies z Google Consent Mode v2 (Phase 3) +- [x] Baner cookies dziala bez bledu `injectScripts is not defined` (Phase 4) ### Should Have - [x] Spojny tracking analityczny dla zdarzen ecommerce @@ -25,7 +26,7 @@ Uzytkownicy moga szybko i bezpiecznie kupic bilety online oraz otrzymac natychmi ## Constraints - PHP + Medoo + prepared statements bez sklejania SQL - Bez logiki biznesowej w widokach -- Bez zmian poza zakresem ecommerce tracking dla aktualnej pracy +- Bez zmian poza zakresem ecommerce tracking/cookie consent dla aktualnej pracy ## Key Decisions @@ -36,13 +37,15 @@ Uzytkownicy moga szybko i bezpiecznie kupic bilety online oraz otrzymac natychmi | Payload ecommerce budowany w backendzie | Phase 1 | Bezpieczenstwo, brak XSS | | cookieNoticePro.init() zamiast $.fn.cookieNoticePro() | Phase 3 | Zgodnie z dokumentacja biblioteki | | Consent Mode v2 default-denied przed GTM snippetem | Phase 3 | Wymog Google od marca 2024 | +| Usuniecie niezdefiniowanego injectScripts() | Phase 4 | Naprawia blad konsoli przy cookies bez zmiany GTM/Consent Mode | ## Success Criteria -- Event purchase trafia do data layer po zlozeniu zamowienia (osiagniete — Phase 2) +- Event purchase trafia do data layer po zlozeniu zamowienia (osiagniete - Phase 2) - Payload zawiera wszystkie dostepne dane transakcyjne i produktowe - Integracja nie wplywa negatywnie na istniejacy checkout -- Baner cookies zgodny z RODO + Google Consent Mode v2 (osiagniete — Phase 3) +- Baner cookies zgodny z RODO + Google Consent Mode v2 (osiagniete - Phase 3) +- Baner cookies nie generuje bledu `injectScripts is not defined` (osiagniete - Phase 4) --- *Created: 2026-04-19 20:20* -*Last updated: 2026-04-26 after Phase 3 (v0.2 complete)* +*Last updated: 2026-05-08 after Phase 4 (v0.3 hotfix complete)* diff --git a/.paul/ROADMAP.md b/.paul/ROADMAP.md index 0ca8535..da053c1 100644 --- a/.paul/ROADMAP.md +++ b/.paul/ROADMAP.md @@ -1,15 +1,19 @@ # Roadmap: bilety.brzezovka.pl ## Overview -W najblizszej iteracji skupiamy sie na uzupelnieniu warstwy analitycznej po zakupie biletow, tak aby tracking ecommerce byl kompletny i wiarygodny, oraz na zgodnosci z RODO poprzez wdrozenie banera zgody na cookies. +Projekt obejmuje sprzedaz biletow online, tracking ecommerce oraz zgodnosc cookies/RODO. Ostatnia iteracja to hotfix banera cookies po wykryciu bledu JavaScript w CookieNoticePro. ## Current Milestone -**v0.2 Analytics & Privacy** (v0.2.0) -Status: Complete (2026-04-26) -Phases: 3 of 3 complete +**v0.3 Cookie Notice Hotfix** (v0.3.0) +Status: Complete (2026-05-08) +Phases: 1 of 1 complete ## Previous Milestones +### v0.2 Analytics & Privacy +Status: Complete (2026-04-26) +Phases: 3 of 3 complete + ### v0.1 Initial Release Status: Complete (2026-04-19) Phases: 1 of 1 complete @@ -21,10 +25,11 @@ Phases: 1 of 1 complete | 1 | Purchase Data Layer | 1 | Complete | 2026-04-19 | | 2 | Purchase Event Pre-Payment | 1 | Complete | 2026-04-26 | | 3 | Cookie Consent Banner | 1 | Complete | 2026-04-26 | +| 4 | Cookie Notice Bugfix | 1 | Complete | 2026-05-08 | ## Phase Details -### Phase 1: Purchase Data Layer (v0.1 — Complete) +### Phase 1: Purchase Data Layer (v0.1 - Complete) **Goal:** Dodac event purchase do data layer po finalizacji zakupu biletow z kompletnym payloadem. **Depends on:** Nothing (first phase) @@ -34,49 +39,68 @@ Phases: 1 of 1 complete --- -### Phase 2: Purchase Event Pre-Payment +### Phase 2: Purchase Event Pre-Payment (Complete) -**Goal:** Przenieść event purchase do momentu przekierowania na bramkę płatniczą (po złożeniu zamówienia, przed płatnością Przelewy24). +**Goal:** Przeniesc event purchase do momentu przekierowania na bramke platnicza po zlozeniu zamowienia, przed platnoscia Przelewy24. **Depends on:** Phase 1 (purchase payload builder already implemented) -**Research:** Not needed (flow is clear from existing code) +**Research:** Not needed **Context:** -- GTM (GTM-TW9WCD9J) jest już wdrożony w layout-logged.php -- Aktualnie event purchase fires na order-confirm (po płatności) -- Cel: przenieść event na przelewy24 (po złożeniu zamówienia w DB, przed redirect do P24) -- Uwaga: strona przelewy24.php auto-submits formularz — GTM/GA4 używa beacon transport (navigator.sendBeacon), więc event powinien dotrzeć przed nawigacją +- GTM (GTM-TW9WCD9J) jest wdrozony w `templates/site/layout-logged.php`. +- Event purchase zostal przeniesiony na strone `przelewy24`. +- Strona `przelewy24.php` auto-submits formularz, wiec tracking korzysta z beacon transport. **Scope:** -- Wywołanie buildPurchaseDataLayer() w metodzie przelewy24() kontrolera -- Dodanie dataLayer push do templates/tickets/przelewy24.php -- Usunięcie purchase push z templates/tickets/order-confirm.php +- Wywolanie `buildPurchaseDataLayer()` w metodzie `przelewy24()` kontrolera. +- Dodanie dataLayer push do `templates/tickets/przelewy24.php`. +- Usuniecie purchase push z `templates/tickets/order-confirm.php`. **Plans:** -- [ ] 02-01: Przeniesienie eventu purchase na stronę przelewy24 +- [x] 02-01: Przeniesienie eventu purchase na strone przelewy24 (UNIFY complete) --- -### Phase 3: Cookie Consent Banner +### Phase 3: Cookie Consent Banner (Complete) -**Goal:** Wdrożyć baner zgody na cookies (CookieNoticePro) z Google Consent Mode v2 i naprawić błąd analityki w bibliotece. -**Depends on:** Phase 2 (niezależna, ale logicznie po Phase 2 dla spójności analitycznej) -**Research:** Not needed (biblioteka dostępna w pomysloweprezenty.pl/libraries/CookieNoticePro/) +**Goal:** Wdrozyc baner zgody na cookies (CookieNoticePro) z Google Consent Mode v2 i naprawic blad analityki w bibliotece. +**Depends on:** Phase 2 +**Research:** Not needed **Context:** -- Biblioteka: c:\visual studio code\projekty\pomysloweprezenty.pl\libraries\CookieNoticePro\ -- Bug do naprawienia: w cookienoticepro.script.js ~linia 351, gdy analytics NIE jest zaakceptowane, kod wywołuje gtag('consent','update',{'analytics_storage':'granted'}) zamiast 'denied' -- Inicjalizacja Consent Mode v2 musi być PRZED snippetem GTM w -- Tylko layout-logged.php jest używany (layout-unlogged.php nie jest renderowany) +- Biblioteka: `libraries/CookieNoticePro/`. +- Consent Mode v2 musi byc przed snippetem GTM w ``. +- Tylko `templates/site/layout-logged.php` jest uzywany przez glowne widoki. **Scope:** -- Kopiowanie plików CookieNoticePro do libraries/CookieNoticePro/ -- Naprawa błędu analytics_storage w cookienoticepro.script.js -- Dodanie consent mode v2 default init przed GTM w layout-logged.php -- Integracja CSS/JS banera + inicjalizacja w layout-logged.php +- Pliki CookieNoticePro w `libraries/CookieNoticePro/`. +- Naprawa `analytics_storage: denied` przy braku zgody analytics. +- Consent Mode v2 default przed GTM w `layout-logged.php`. +- Integracja CSS/JS banera + inicjalizacja `cookieNoticePro.init()`. **Plans:** -- [ ] 03-01: Integracja CookieNoticePro + Consent Mode v2 +- [x] 03-01: Integracja CookieNoticePro + Consent Mode v2 (UNIFY complete) + +--- + +### Phase 4: Cookie Notice Bugfix (Complete) + +**Goal:** Naprawic blad JavaScript `Uncaught ReferenceError: injectScripts is not defined` w CookieNoticePro. +**Depends on:** Phase 3 (CookieNoticePro already integrated) +**Research:** Not needed (root cause is visible in local source) + +**Context:** +- `libraries/CookieNoticePro/cookienoticepro.script.js` wywolywal `injectScripts()` w dwoch miejscach. +- Funkcja `injectScripts` nie istnieje w tej kopii biblioteki. +- Blad wystepowal po kliknieciu akceptacji cookies oraz mogl wystapic przy inicjalizacji z zapisanymi zgodami. + +**Scope:** +- Usuniecie wywolan `injectScripts()`. +- Zachowanie `cookieNoticePro.init()` w `templates/site/layout-logged.php`. +- Zachowanie Google Consent Mode v2 i GTM bez zmian. + +**Plans:** +- [x] 04-01: Naprawa undefined `injectScripts` w CookieNoticePro (UNIFY complete) --- *Roadmap created: 2026-04-19* -*Last updated: 2026-04-26 — Added v0.2 milestone (Phase 2 + Phase 3)* +*Last updated: 2026-05-08 - v0.3 Cookie Notice Hotfix complete* diff --git a/.paul/STATE.md b/.paul/STATE.md index 142fccc..a89d4be 100644 --- a/.paul/STATE.md +++ b/.paul/STATE.md @@ -2,53 +2,61 @@ ## Project Reference -See: .paul/PROJECT.md (updated 2026-04-26) +See: .paul/PROJECT.md (updated 2026-05-08) **Core value:** Uzytkownicy moga szybko i bezpiecznie kupic bilety online oraz otrzymac natychmiastowe potwierdzenie zakupu. -**Current focus:** v0.2 Analytics & Privacy — COMPLETE +**Current focus:** v0.3 Cookie Notice Hotfix - COMPLETE ## Current Position -Milestone: v0.2 Analytics & Privacy — COMPLETE -Phase: 3 of 3 (Cookie Consent Banner) — Complete -Plan: 03-01 complete -Status: Milestone complete — ready for next milestone -Last activity: 2026-04-26 — Phase 3 complete, v0.2 shipped +Milestone: v0.3 Cookie Notice Hotfix - COMPLETE +Phase: 1 of 1 (Cookie Notice Bugfix) - Complete +Plan: 04-01 complete +Status: Milestone complete - ready for next milestone +Last activity: 2026-05-08 - Phase 4 complete, v0.3 hotfix shipped Progress: - Milestone: [##########] 100% -- Phase 3: [##########] 100% +- Phase 4: [##########] 100% ## Loop Position Current loop state: ``` -PLAN ──▶ APPLY ──▶ UNIFY - ✓ ✓ ✓ [Loop complete — milestone complete] +PLAN ---> APPLY ---> UNIFY + ok ok ok [Loop complete - milestone complete] ``` ## Accumulated Context ### Codebase Mapped Date: 2026-04-26 -Documents: `.paul/codebase/` (8 files — stack, architecture, structure, conventions, testing, integrations, concerns, db_schema) +Documents: `.paul/codebase/` (8 files - stack, architecture, structure, conventions, testing, integrations, concerns, db_schema) ### GTM Status -- GTM-TW9WCD9J już wdrożony w templates/site/layout-logged.php -- layout-unlogged.php NIE jest renderowany — view/class.Site.php zawsze używa layout-logged.php +- GTM-TW9WCD9J already integrated in templates/site/layout-logged.php. +- layout-unlogged.php is not rendered; view/class.Site.php always uses layout-logged.php. ### Decisions -- 2026-04-19: Event purchase emitowany na order-confirm, nie na przelewy24 (eliminuje falszywe konwersje). -- 2026-04-19: Payload ecommerce budowany w backendzie i serializowany bezpiecznie do widoku. -- 2026-04-26: ZMIANA — event purchase przeniesiony na przelewy24 (post-order, pre-payment). Capturuje 100% zamowien. -- 2026-04-26: cookieNoticePro.init() zamiast $.fn.cookieNoticePro() — zgodnie z dokumentacja biblioteki. -- 2026-04-26: Consent Mode v2 default-denied inicjalizowany przed GTM snippetem (wymog Google od marca 2024). +- 2026-04-19: Event purchase emitted on order-confirm, not on przelewy24. +- 2026-04-19: Ecommerce payload built in backend and safely serialized into the view. +- 2026-04-26: Event purchase moved to przelewy24 (post-order, pre-payment) to capture all orders. +- 2026-04-26: `cookieNoticePro.init()` used instead of `$.fn.cookieNoticePro()`. +- 2026-04-26: Consent Mode v2 default-denied initialized before the GTM snippet. +- 2026-05-08: Undefined `injectScripts()` calls removed from CookieNoticePro instead of adding a no-op stub. -### Cookie Consent (Phase 3 — COMPLETE) -- Biblioteka: libraries/CookieNoticePro/ (skopiowana z pomysloweprezenty.pl) -- Bug naprawiony: linia ~351 — blok else teraz wysyla analytics_storage: 'denied' -- Dodatkowe poprawki: CSS initial hide dla acceptBtnSettingsLabel, Bootstrap 5 compat reset -- Consent Mode v2 init PRZED snippetem GTM w layout-logged.php +### Cookie Consent (Phase 3 - COMPLETE) +- Library: `libraries/CookieNoticePro/`. +- Analytics denied bug fixed around line 351. +- Additional fixes: CSS initial hide for `acceptBtnSettingsLabel`, Bootstrap 5 compatibility reset. +- Consent Mode v2 init is before the GTM snippet in `templates/site/layout-logged.php`. + +### Cookie Notice Hotfix (Phase 4 - COMPLETE) +- Reported browser error: `Uncaught ReferenceError: injectScripts is not defined`. +- Root cause: `libraries/CookieNoticePro/cookienoticepro.script.js` called `injectScripts()` but this function was absent in the local library copy. +- Applied fix: removed both `injectScripts()` calls from `libraries/CookieNoticePro/cookienoticepro.script.js`. +- Verification passed: no `injectScripts` references remain, `node --check` passes, and layout still contains Consent Mode v2, GTM, and `cookieNoticePro.init()`. +- Summary: `.paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md`. ### Deferred Issues None. @@ -57,16 +65,16 @@ None. None. ### Git State -Last commit: 28d3815 +Last commit: current phase commit (`feat(04-cookie-notice-bugfix): fix CookieNoticePro injectScripts error`) Branch: main Feature branches merged: none ## Session Continuity -Last session: 2026-04-26 -Stopped at: v0.2 milestone complete -Next action: /paul:milestone — zdefiniuj v0.3 lub /paul:complete-milestone -Resume file: .paul/ROADMAP.md +Last session: 2026-05-08 +Stopped at: v0.3 hotfix milestone complete +Next action: Start next milestone when needed +Resume file: .paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md --- *STATE.md - Updated after every significant action* diff --git a/.paul/changelog/2026-05-08.md b/.paul/changelog/2026-05-08.md new file mode 100644 index 0000000..6be8668 --- /dev/null +++ b/.paul/changelog/2026-05-08.md @@ -0,0 +1,15 @@ +# 2026-05-08 + +## Co zrobiono + +- [Phase 4, Plan 01] Naprawiono blad `Uncaught ReferenceError: injectScripts is not defined` w CookieNoticePro. +- Usunieto dwa wywolania niezdefiniowanego `injectScripts()` z obslugi akceptacji cookies i inicjalizacji przy zapisanej zgodzie. +- Zweryfikowano skladnie pliku JS oraz obecnosc `cookieNoticePro.init()`, Consent Mode v2 i GTM w layoucie. + +## Zmienione pliki + +- `libraries/CookieNoticePro/cookienoticepro.script.js` +- `.paul/phases/04-cookie-notice-bugfix/04-01-PLAN.md` +- `.paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md` +- `.paul/STATE.md` +- `.paul/ROADMAP.md` diff --git a/.paul/phases/04-cookie-notice-bugfix/04-01-PLAN.md b/.paul/phases/04-cookie-notice-bugfix/04-01-PLAN.md new file mode 100644 index 0000000..b0e66c7 --- /dev/null +++ b/.paul/phases/04-cookie-notice-bugfix/04-01-PLAN.md @@ -0,0 +1,130 @@ +--- +phase: 04-cookie-notice-bugfix +plan: 01 +type: execute +wave: 1 +depends_on: [] +files_modified: + - libraries/CookieNoticePro/cookienoticepro.script.js +autonomous: true +delegation: off +--- + + +## Goal +Naprawic blad JavaScript `Uncaught ReferenceError: injectScripts is not defined` w CookieNoticePro. + +## Purpose +Baner cookies musi dzialac bez bledow konsoli, bo kontroluje zgody RODO i Google Consent Mode v2 przed uruchamianiem analityki. + +## Output +Zmodyfikowany `libraries/CookieNoticePro/cookienoticepro.script.js` bez wywolan nieistniejacej funkcji `injectScripts()`. + + + + +- No clarifications needed - blad jest jednoznaczny: `injectScripts()` jest wywolywane w `cookienoticepro.script.js`, ale nie jest zdefiniowane w tej kopii biblioteki. + + +## Project Context +@.paul/PROJECT.md +@.paul/ROADMAP.md +@.paul/STATE.md + +## Prior Work +@.paul/phases/03-cookie-consent/03-01-SUMMARY.md + +## Source Files +@libraries/CookieNoticePro/cookienoticepro.script.js +@templates/site/layout-logged.php + + + + +## AC-1: Brak ReferenceError przy akceptacji cookies +```gherkin +Given strona laduje CookieNoticePro i baner jest widoczny +When uzytkownik klika "Akceptuj" +Then konsola przegladarki nie pokazuje `ReferenceError: injectScripts is not defined` +``` + +## AC-2: Brak ReferenceError przy zapisanych zgodach +```gherkin +Given przegladarka ma zapisane cookies `cnp_consent` i `cnp_prefs` +When strona inicjalizuje `cookieNoticePro.init()` +Then konsola przegladarki nie pokazuje `ReferenceError: injectScripts is not defined` +``` + +## AC-3: Consent Mode pozostaje aktywny +```gherkin +Given uzytkownik akceptuje lub aktualizuje preferencje cookies +When CookieNoticePro zapisuje preferencje +Then `googleConsentModeHandler()` nadal aktualizuje `analytics_storage` oraz zgody reklamowe zgodnie z preferencjami +``` + + + + + + + Task 1: Usun wywolania nieistniejacego injectScripts + libraries/CookieNoticePro/cookienoticepro.script.js + + Usun lub zastap bezpiecznie dwa wywolania `injectScripts()`: + - w handlerze klikniecia `#cookieAccept` + - w galezi dla juz zapisanej zgody + + Zachowaj wywolania `config.onConsentAccept.call(this)` i `googleConsentModeHandler()`. + Nie dodawaj pustej globalnej funkcji jako obejscia, bo maskowaloby to blad integracji biblioteki bez rzeczywistej potrzeby w projekcie. + + rg -n "injectScripts" libraries/CookieNoticePro/cookienoticepro.script.js zwraca brak wynikow + AC-1 i AC-2 satisfied: CookieNoticePro nie odwoluje sie do niezdefiniowanej funkcji. + + + + Task 2: Zweryfikuj skladnie i sciezke inicjalizacji + libraries/CookieNoticePro/cookienoticepro.script.js, templates/site/layout-logged.php + + Sprawdz, ze po zmianie plik JavaScript nadal jest parsowalny, a `templates/site/layout-logged.php` dalej laduje biblioteke i wywoluje `cookieNoticePro.init()`. + Nie zmieniaj snippetow GTM ani domyslnych ustawien Consent Mode v2 w layoutcie. + + node --check libraries/CookieNoticePro/cookienoticepro.script.js; rg -n "cookieNoticePro.init|Google Consent Mode v2|GTM-TW9WCD9J" templates/site/layout-logged.php + AC-3 satisfied: mechanizm zgody pozostaje podlaczony, a plik JS przechodzi walidacje skladni. + + + + + + +## DO NOT CHANGE +- `templates/site/layout-logged.php` poza ewentualna weryfikacja; nie zmieniac GTM ani Consent Mode v2. +- `libraries/CookieNoticePro/cookienoticepro.style.css`. +- Checkout, order flow, data layer purchase i integracja Przelewy24. +- Baza danych i konfiguracja serwera. + +## SCOPE LIMITS +- Plan dotyczy tylko bledu `injectScripts is not defined`. +- Nie aktualizowac calej biblioteki CookieNoticePro. +- Nie dodawac nowych zaleznosci frontendowych. + + + + +Before declaring plan complete: +- [ ] `rg -n "injectScripts" libraries/CookieNoticePro/cookienoticepro.script.js` returns no results. +- [ ] `node --check libraries/CookieNoticePro/cookienoticepro.script.js` passes. +- [ ] `rg -n "cookieNoticePro.init|Google Consent Mode v2|GTM-TW9WCD9J" templates/site/layout-logged.php` confirms existing integration remains present. +- [ ] Browser console has no `ReferenceError: injectScripts is not defined` after accepting cookies and after reload with saved consent. +- [ ] All acceptance criteria met. + + + +- CookieNoticePro does not call undefined functions. +- Consent Mode v2 updates still run after preference changes. +- No unrelated files or flows are modified. +- Summary created after apply. + + + +After completion, create `.paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md`. + diff --git a/.paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md b/.paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md new file mode 100644 index 0000000..749c521 --- /dev/null +++ b/.paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md @@ -0,0 +1,113 @@ +--- +phase: 04-cookie-notice-bugfix +plan: 01 +subsystem: ui +tags: [cookies, gdpr, consent-mode-v2, cookienoticepro, javascript] + +requires: + - phase: 03-cookie-consent + provides: CookieNoticePro integrated with Google Consent Mode v2 +provides: + - CookieNoticePro no longer calls undefined `injectScripts()` + - Browser console hotfix for cookie acceptance and saved-consent initialization +affects: [cookies, analytics, consent-mode-v2] + +tech-stack: + added: [] + patterns: [keep CookieNoticePro integration minimal, preserve Consent Mode v2 flow] + +key-files: + created: [] + modified: + - libraries/CookieNoticePro/cookienoticepro.script.js + +key-decisions: + - "Removed undefined `injectScripts()` calls instead of adding an empty compatibility stub." + - "Preserved `googleConsentModeHandler()` and existing layout integration unchanged." + +patterns-established: + - "CookieNoticePro fixes stay scoped to the vendor copy unless project integration requires layout changes." + +duration: 15min +started: 2026-05-08T00:00:00Z +completed: 2026-05-08T00:00:00Z +--- + +# Phase 4 Plan 01: Cookie Notice Bugfix Summary + +**CookieNoticePro no longer throws `ReferenceError: injectScripts is not defined` during cookie acceptance or initialization with saved consent.** + +## Performance + +| Metric | Value | +|--------|-------| +| Duration | ~15 min | +| Started | 2026-05-08 | +| Completed | 2026-05-08 | +| Tasks | 2 completed | +| Files modified | 1 source file + PAUL docs | + +## Acceptance Criteria Results + +| Criterion | Status | Notes | +|-----------|--------|-------| +| AC-1: Brak ReferenceError przy akceptacji cookies | Pass | `injectScripts()` call removed from `#cookieAccept` handler. | +| AC-2: Brak ReferenceError przy zapisanych zgodach | Pass | `injectScripts()` call removed from saved-consent initialization path. | +| AC-3: Consent Mode pozostaje aktywny | Pass | `googleConsentModeHandler()` remains in both relevant consent paths; layout still contains Consent Mode v2, GTM, and `cookieNoticePro.init()`. | + +## Accomplishments + +- Removed both calls to undefined `injectScripts()` from `libraries/CookieNoticePro/cookienoticepro.script.js`. +- Preserved the existing callback and Google Consent Mode update flow. +- Confirmed the layout integration still loads CookieNoticePro and GTM/Consent Mode v2. + +## Verification Results + +| Check | Result | +|-------|--------| +| `rg -n "injectScripts" libraries/CookieNoticePro/cookienoticepro.script.js` | Pass - no matches | +| `node --check libraries/CookieNoticePro/cookienoticepro.script.js` | Pass | +| `rg -n "cookieNoticePro.init|Google Consent Mode v2|GTM-TW9WCD9J" templates/site/layout-logged.php` | Pass - all integration points present | + +## Files Created/Modified + +| File | Change | Purpose | +|------|--------|---------| +| `libraries/CookieNoticePro/cookienoticepro.script.js` | Modified | Removed undefined `injectScripts()` calls. | +| `.paul/phases/04-cookie-notice-bugfix/04-01-PLAN.md` | Created | Execution plan for the hotfix. | +| `.paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md` | Created | Completion record for the hotfix. | +| `.paul/STATE.md` | Modified | Updated PAUL loop state for plan/apply/unify. | +| `.paul/ROADMAP.md` | Modified | Added and closed the v0.3 hotfix phase. | + +## Decisions Made + +| Decision | Rationale | Impact | +|----------|-----------|--------| +| Remove undefined calls instead of adding a no-op `injectScripts()` | The project does not use CookieNoticePro's script injection hook, and a no-op would hide unused behavior. | Smaller, clearer fix with no global compatibility shim. | +| Leave layout and GTM snippets unchanged | The reported bug was inside the CookieNoticePro script, not the integration layer. | Lower blast radius; existing Consent Mode v2 behavior preserved. | + +## Deviations from Plan + +None - plan executed as written. + +## Issues Encountered + +| Issue | Resolution | +|-------|------------| +| Existing PAUL files contained mixed/garbled character encoding from prior content. | New hotfix PAUL entries were written in ASCII to avoid additional encoding churn. | + +## Next Phase Readiness + +**Ready:** +- v0.3 hotfix is complete. +- CookieNoticePro can be manually checked in the browser without the known `injectScripts` ReferenceError. + +**Concerns:** +- Browser console verification on production/staging should still be performed after deployment because local CLI checks cannot execute full browser interaction. + +**Blockers:** +- None. + +--- +*Phase: 04-cookie-notice-bugfix, Plan: 01* +*Completed: 2026-05-08* diff --git a/libraries/CookieNoticePro/cookienoticepro.script.js b/libraries/CookieNoticePro/cookienoticepro.script.js index e742686..3cd01a9 100644 --- a/libraries/CookieNoticePro/cookienoticepro.script.js +++ b/libraries/CookieNoticePro/cookienoticepro.script.js @@ -160,7 +160,6 @@ Make your own cookie information popup in minutes. path: "/" }); config.onConsentAccept.call(this); - config.showSettingsBtn? injectScripts() : null; if(config.enableGoogleConsentMode) { googleConsentModeHandler(); } @@ -202,9 +201,6 @@ Make your own cookie information popup in minutes. } // If already consent is accepted, inject preferences else { - if(config.showSettingsBtn) { - injectScripts(); - } if(config.enableMinimize){ minimizeCookieBanner(); }