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

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