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
This commit is contained in:
2026-05-08 23:42:46 +02:00
parent f71a1711bb
commit df1c1f4a7d
7 changed files with 357 additions and 68 deletions

View File

@@ -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] Obsluga zakupu biletow end-to-end (wybor, checkout, finalizacja)
- [x] Poprawne rejestrowanie zamowien i danych transakcyjnych - [x] Poprawne rejestrowanie zamowien i danych transakcyjnych
- [x] Data layer purchase po finalizacji zakupu (wdrozone w Phase 1) - [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] 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] 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 ### Should Have
- [x] Spojny tracking analityczny dla zdarzen ecommerce - [x] Spojny tracking analityczny dla zdarzen ecommerce
@@ -25,7 +26,7 @@ Uzytkownicy moga szybko i bezpiecznie kupic bilety online oraz otrzymac natychmi
## Constraints ## Constraints
- PHP + Medoo + prepared statements bez sklejania SQL - PHP + Medoo + prepared statements bez sklejania SQL
- Bez logiki biznesowej w widokach - 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 ## 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 | | Payload ecommerce budowany w backendzie | Phase 1 | Bezpieczenstwo, brak XSS |
| cookieNoticePro.init() zamiast $.fn.cookieNoticePro() | Phase 3 | Zgodnie z dokumentacja biblioteki | | 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 | | 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 ## 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 - Payload zawiera wszystkie dostepne dane transakcyjne i produktowe
- Integracja nie wplywa negatywnie na istniejacy checkout - 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* *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)*

View File

@@ -1,15 +1,19 @@
# Roadmap: bilety.brzezovka.pl # Roadmap: bilety.brzezovka.pl
## Overview ## 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 ## Current Milestone
**v0.2 Analytics & Privacy** (v0.2.0) **v0.3 Cookie Notice Hotfix** (v0.3.0)
Status: Complete (2026-04-26) Status: Complete (2026-05-08)
Phases: 3 of 3 complete Phases: 1 of 1 complete
## Previous Milestones ## Previous Milestones
### v0.2 Analytics & Privacy
Status: Complete (2026-04-26)
Phases: 3 of 3 complete
### v0.1 Initial Release ### v0.1 Initial Release
Status: Complete (2026-04-19) Status: Complete (2026-04-19)
Phases: 1 of 1 complete Phases: 1 of 1 complete
@@ -21,10 +25,11 @@ Phases: 1 of 1 complete
| 1 | Purchase Data Layer | 1 | Complete | 2026-04-19 | | 1 | Purchase Data Layer | 1 | Complete | 2026-04-19 |
| 2 | Purchase Event Pre-Payment | 1 | Complete | 2026-04-26 | | 2 | Purchase Event Pre-Payment | 1 | Complete | 2026-04-26 |
| 3 | Cookie Consent Banner | 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 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. **Goal:** Dodac event purchase do data layer po finalizacji zakupu biletow z kompletnym payloadem.
**Depends on:** Nothing (first phase) **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) **Depends on:** Phase 1 (purchase payload builder already implemented)
**Research:** Not needed (flow is clear from existing code) **Research:** Not needed
**Context:** **Context:**
- GTM (GTM-TW9WCD9J) jest już wdrożony w layout-logged.php - GTM (GTM-TW9WCD9J) jest wdrozony w `templates/site/layout-logged.php`.
- Aktualnie event purchase fires na order-confirm (po płatności) - Event purchase zostal przeniesiony na strone `przelewy24`.
- Cel: przenieść event na przelewy24 (po złożeniu zamówienia w DB, przed redirect do P24) - Strona `przelewy24.php` auto-submits formularz, wiec tracking korzysta z beacon transport.
- Uwaga: strona przelewy24.php auto-submits formularz — GTM/GA4 używa beacon transport (navigator.sendBeacon), więc event powinien dotrzeć przed nawigacją
**Scope:** **Scope:**
- Wywołanie buildPurchaseDataLayer() w metodzie przelewy24() kontrolera - Wywolanie `buildPurchaseDataLayer()` w metodzie `przelewy24()` kontrolera.
- Dodanie dataLayer push do templates/tickets/przelewy24.php - Dodanie dataLayer push do `templates/tickets/przelewy24.php`.
- Usunięcie purchase push z templates/tickets/order-confirm.php - Usuniecie purchase push z `templates/tickets/order-confirm.php`.
**Plans:** **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. **Goal:** Wdrozyc baner zgody na cookies (CookieNoticePro) z Google Consent Mode v2 i naprawic blad analityki w bibliotece.
**Depends on:** Phase 2 (niezależna, ale logicznie po Phase 2 dla spójności analitycznej) **Depends on:** Phase 2
**Research:** Not needed (biblioteka dostępna w pomysloweprezenty.pl/libraries/CookieNoticePro/) **Research:** Not needed
**Context:** **Context:**
- Biblioteka: c:\visual studio code\projekty\pomysloweprezenty.pl\libraries\CookieNoticePro\ - Biblioteka: `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' - Consent Mode v2 musi byc przed snippetem GTM w `<head>`.
- Inicjalizacja Consent Mode v2 musi być PRZED snippetem GTM w <head> - Tylko `templates/site/layout-logged.php` jest uzywany przez glowne widoki.
- Tylko layout-logged.php jest używany (layout-unlogged.php nie jest renderowany)
**Scope:** **Scope:**
- Kopiowanie plików CookieNoticePro do libraries/CookieNoticePro/ - Pliki CookieNoticePro w `libraries/CookieNoticePro/`.
- Naprawa błędu analytics_storage w cookienoticepro.script.js - Naprawa `analytics_storage: denied` przy braku zgody analytics.
- Dodanie consent mode v2 default init przed GTM w layout-logged.php - Consent Mode v2 default przed GTM w `layout-logged.php`.
- Integracja CSS/JS banera + inicjalizacja w layout-logged.php - Integracja CSS/JS banera + inicjalizacja `cookieNoticePro.init()`.
**Plans:** **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* *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*

View File

@@ -2,53 +2,61 @@
## Project Reference ## 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. **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 ## Current Position
Milestone: v0.2 Analytics & Privacy — COMPLETE Milestone: v0.3 Cookie Notice Hotfix - COMPLETE
Phase: 3 of 3 (Cookie Consent Banner) Complete Phase: 1 of 1 (Cookie Notice Bugfix) - Complete
Plan: 03-01 complete Plan: 04-01 complete
Status: Milestone complete ready for next milestone Status: Milestone complete - ready for next milestone
Last activity: 2026-04-26 — Phase 3 complete, v0.2 shipped Last activity: 2026-05-08 - Phase 4 complete, v0.3 hotfix shipped
Progress: Progress:
- Milestone: [##########] 100% - Milestone: [##########] 100%
- Phase 3: [##########] 100% - Phase 4: [##########] 100%
## Loop Position ## Loop Position
Current loop state: Current loop state:
``` ```
PLAN ──▶ APPLY ──▶ UNIFY PLAN ---> APPLY ---> UNIFY
[Loop complete milestone complete] ok ok ok [Loop complete - milestone complete]
``` ```
## Accumulated Context ## Accumulated Context
### Codebase Mapped ### Codebase Mapped
Date: 2026-04-26 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 Status
- GTM-TW9WCD9J już wdrożony w templates/site/layout-logged.php - GTM-TW9WCD9J already integrated in templates/site/layout-logged.php.
- layout-unlogged.php NIE jest renderowany — view/class.Site.php zawsze używa layout-logged.php - layout-unlogged.php is not rendered; view/class.Site.php always uses layout-logged.php.
### Decisions ### Decisions
- 2026-04-19: Event purchase emitowany na order-confirm, nie na przelewy24 (eliminuje falszywe konwersje). - 2026-04-19: Event purchase emitted on order-confirm, not on przelewy24.
- 2026-04-19: Payload ecommerce budowany w backendzie i serializowany bezpiecznie do widoku. - 2026-04-19: Ecommerce payload built in backend and safely serialized into the view.
- 2026-04-26: ZMIANA — event purchase przeniesiony na przelewy24 (post-order, pre-payment). Capturuje 100% zamowien. - 2026-04-26: Event purchase moved to przelewy24 (post-order, pre-payment) to capture all orders.
- 2026-04-26: cookieNoticePro.init() zamiast $.fn.cookieNoticePro() — zgodnie z dokumentacja biblioteki. - 2026-04-26: `cookieNoticePro.init()` used instead of `$.fn.cookieNoticePro()`.
- 2026-04-26: Consent Mode v2 default-denied inicjalizowany przed GTM snippetem (wymog Google od marca 2024). - 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) ### Cookie Consent (Phase 3 - COMPLETE)
- Biblioteka: libraries/CookieNoticePro/ (skopiowana z pomysloweprezenty.pl) - Library: `libraries/CookieNoticePro/`.
- Bug naprawiony: linia ~351 — blok else teraz wysyla analytics_storage: 'denied' - Analytics denied bug fixed around line 351.
- Dodatkowe poprawki: CSS initial hide dla acceptBtnSettingsLabel, Bootstrap 5 compat reset - Additional fixes: CSS initial hide for `acceptBtnSettingsLabel`, Bootstrap 5 compatibility reset.
- Consent Mode v2 init PRZED snippetem GTM w layout-logged.php - 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 ### Deferred Issues
None. None.
@@ -57,16 +65,16 @@ None.
None. None.
### Git State ### Git State
Last commit: 28d3815 Last commit: current phase commit (`feat(04-cookie-notice-bugfix): fix CookieNoticePro injectScripts error`)
Branch: main Branch: main
Feature branches merged: none Feature branches merged: none
## Session Continuity ## Session Continuity
Last session: 2026-04-26 Last session: 2026-05-08
Stopped at: v0.2 milestone complete Stopped at: v0.3 hotfix milestone complete
Next action: /paul:milestone — zdefiniuj v0.3 lub /paul:complete-milestone Next action: Start next milestone when needed
Resume file: .paul/ROADMAP.md Resume file: .paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md
--- ---
*STATE.md - Updated after every significant action* *STATE.md - Updated after every significant action*

View File

@@ -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`

View File

@@ -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
---
<objective>
## 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()`.
</objective>
<context>
<clarifications>
- No clarifications needed - blad jest jednoznaczny: `injectScripts()` jest wywolywane w `cookienoticepro.script.js`, ale nie jest zdefiniowane w tej kopii biblioteki.
</clarifications>
## 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
</context>
<acceptance_criteria>
## 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
```
</acceptance_criteria>
<tasks>
<task type="auto">
<name>Task 1: Usun wywolania nieistniejacego injectScripts</name>
<files>libraries/CookieNoticePro/cookienoticepro.script.js</files>
<action>
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.
</action>
<verify>rg -n "injectScripts" libraries/CookieNoticePro/cookienoticepro.script.js zwraca brak wynikow</verify>
<done>AC-1 i AC-2 satisfied: CookieNoticePro nie odwoluje sie do niezdefiniowanej funkcji.</done>
</task>
<task type="auto">
<name>Task 2: Zweryfikuj skladnie i sciezke inicjalizacji</name>
<files>libraries/CookieNoticePro/cookienoticepro.script.js, templates/site/layout-logged.php</files>
<action>
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.
</action>
<verify>node --check libraries/CookieNoticePro/cookienoticepro.script.js; rg -n "cookieNoticePro.init|Google Consent Mode v2|GTM-TW9WCD9J" templates/site/layout-logged.php</verify>
<done>AC-3 satisfied: mechanizm zgody pozostaje podlaczony, a plik JS przechodzi walidacje skladni.</done>
</task>
</tasks>
<boundaries>
## 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.
</boundaries>
<verification>
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.
</verification>
<success_criteria>
- 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.
</success_criteria>
<output>
After completion, create `.paul/phases/04-cookie-notice-bugfix/04-01-SUMMARY.md`.
</output>

View File

@@ -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*

View File

@@ -160,7 +160,6 @@ Make your own cookie information popup in minutes.
path: "/" path: "/"
}); });
config.onConsentAccept.call(this); config.onConsentAccept.call(this);
config.showSettingsBtn? injectScripts() : null;
if(config.enableGoogleConsentMode) { if(config.enableGoogleConsentMode) {
googleConsentModeHandler(); googleConsentModeHandler();
} }
@@ -202,9 +201,6 @@ Make your own cookie information popup in minutes.
} }
// If already consent is accepted, inject preferences // If already consent is accepted, inject preferences
else { else {
if(config.showSettingsBtn) {
injectScripts();
}
if(config.enableMinimize){ if(config.enableMinimize){
minimizeCookieBanner(); minimizeCookieBanner();
} }