feat(diagnostics): Phase 3a — structured ad:error events + Logger wiring#5
Draft
LockeAG wants to merge 5 commits into
Draft
feat(diagnostics): Phase 3a — structured ad:error events + Logger wiring#5LockeAG wants to merge 5 commits into
LockeAG wants to merge 5 commits into
Conversation
Make every ad failure programmatically observable. Five additions, all
opt-in, none of which existed:
- `ad:error` CustomEvent on the host element with typed phase + slotId +
adUnit + error + recoverable payload (AdErrorEventDetail).
- Activate the dormant Logger across 9 sites in ad.component.ts +
config.provider.ts (was imported by nothing).
- Debug toggle with high → low precedence:
1. DreamsAdConfig.init({ debug }) — explicit boolean
2. ?dae-debug=1 URL param (parsed once at module load)
3. window.__dreamsDebug = true (runtime toggleable, auto mode only)
- DreamsAdConfig.openConsole() wraps googletag.openConsole() with cmd
queueing + safe fallback.
- Auto-bridge ad:error → window.dataLayer as `dreams_ad_error`, mirroring
the existing prebid_bid_won pattern. GTM consumers get errors with no
additional wiring.
Wraps previously-unprotected GPT calls in granular try/catch — phase
field localizes which lifecycle step failed:
config-resolution, targeting-resolution, slot-define, slot-display,
slot-refresh, apstag-init, prebid-init, out-of-page-define, size-mapping.
Targeting service's silent timeout (resolve with []) now surfaces as
ad:error (recoverable: true) so consumers can detect window.dfp setup
issues without diffing analytics.
Out of scope: Sentry/external trackers, retry logic, error rate-limiting,
INP/LCP attribution.
Add consumer-facing documentation for the additions landing in v0.7.0: - Features list: ad:error event, debug toggle, full lifecycle bullets - New Diagnostics & Debugging section: ad:error wiring, dataLayer bridge, debug toggle precedence (init.debug > ?dae-debug=1 > window.__dreamsDebug), DreamsAdConfig.openConsole() - Events section: ad:requested, ad:response, ad:loaded, ad:error with full phase reference table - AdConfigInit example + signature: collapseEmptyDivs, debug - Methods list: openConsole, getCollapseEmptyDivs - Exported types: AdErrorEventDetail, AdErrorPhase, LoggerConfig, PageSettingsConfig - Migration: v0.6 → v0.7 section covering all behavior changes (Logger now routes nine console.* sites, targeting timeout surfaces as ad:error) - CDN examples bumped @0.5 → @0.7 for WordPress + vanilla HTML
Combined entry covering PR #3 (GPT modernization) + PR #5 (Phase 3a diagnostics). All changes additive — no public API removals or renames. Sections: - Added: lifecycle events (ad:requested, ad:response, ad:loaded), ad:error CustomEvent + AdErrorPhase types, window.dataLayer bridge, debug toggle (3-tier precedence), DreamsAdConfig.openConsole(), Logger.dispatchAdError() helper, collapseEmptyDivs config, explicit SRA opt-in, PageSettingsConfig interface, CLS reserve fallback from sizing attribute, new exported types - Changed: console.* sites now route through Logger (prod-quiet by default), firstUpdated reordered for stable slotId, 11 GPT calls wrapped with granular phases, targeting timeout dispatches ad:error
This branch was cut from feat/gpt-modernization-phase-0-2 before #4 merged to main, so it still carried the stale package-lock.json that #4 deleted. Mirror that change here so the rebase onto main at merge time is conflict-free, and so this branch is correctly published from under pnpm only. Adds package-lock.json and yarn.lock to .gitignore — block accidental regeneration if someone runs `npm install` against the source tree.
Prerelease for cobertura360.mx staging verification. Combines PR #3 (GPT modernization — lifecycle events, SRA, collapseDiv, CLS reserve fallback) and PR #5 (Phase 3a diagnostics — ad:error, Logger wiring, debug toggle, openConsole, dataLayer bridge). Publish with: pnpm publish --tag next --access public Pinning consumers to @next isolates the RC from `latest` (still 0.6.4). After staging verifies, the real 0.7.0 cut bumps from RC and promotes to latest via a separate release commit on main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 3a: make every ad failure programmatically observable. Stacked on
top of #3 (
feat/gpt-modernization-phase-0-2) — rebase ontomainafter #3 lands.
Five additions, all opt-in, none of which existed before:
ad:errorCustomEvent on the host<dreams-ad-engine>elementwith typed payload:
slotId,adUnit,phase,error,recoverable.Logger— was shipped but imported bynothing. Now wired across 9 call sites (8 in
ad.component.ts, 1 inconfig.provider.ts).DreamsAdConfig.init({ debug: true | false })— explicit boolean wins?dae-debug=1URL param — parsed once at module loadwindow.__dreamsDebug = true— runtime toggleable (auto mode only)DreamsAdConfig.openConsole(slotId?)— wrapsgoogletag.openConsole()with
cmdqueueing and a safe fallback for builds without the API.ad:error→window.dataLayerasdreams_ad_error.Mirrors the existing
prebid_bid_wonpattern; GTM consumers geterrors with zero additional wiring.
Wrapped lifecycle phases
Previously-unprotected GPT calls now have granular try/catch:
config-resolutiontargeting-resolutionDreamsTargetingServicesilent timeout,slot.setConfig({ targeting })slot-definedefineSlot().addService(), outer catch-allslot-displaygoogletag.display(), container-not-in-DOM guardslot-refreshpubads().refresh([defineAdSlot])sitesapstag-initapstag.init(),apstag.setDisplayBids()prebid-initpbjs.que.push,pbjs.setTargetingForGPTAsync,pbjs.requestBidsout-of-page-definedefineOutOfPageSlot()size-mappingsizeMapping().addSize().build()Files touched
src/features/logging/logger.types.ts(new) —AdErrorPhase,AdErrorEventDetailsrc/features/logging/logger.ts—Logger.dispatchAdError(),__dreamsDebugruntime checksrc/features/logging/index.ts— export new typessrc/features/config/config.types.ts—debug?: booleanonAdConfigInitsrc/features/config/config.provider.ts— debug resolution,openConsole(), URL param parsing,console.warn→Logger.warnsrc/features/dreamsAdEngine/components/ad.component.ts— 8console.*→Logger.*, 11 try/catch additions, reorderfirstUpdatedsodivIdexists before targeting resolutionsrc/features/dreamsAdEngine/types/interfaces.ts—__dreamsDebug?: booleanonWindowdist/,types/— rebuiltBuild: ✓
pnpm buildclean. Bundle 82.86 kB / 20.96 kB gzipped.Consumer-facing event shape
Out of scope (deliberate)
ad:error.recoverableis informational; auto-retry is policy.Test plan
Combined cobertura360.mx staging verification (with #3) when MVP is ready:
ad:errorfires on injected failures — e.g. pass a malformed ad unit pathwindow.dataLayerreceivesdreams_ad_erroreventsDreamsAdConfig.openConsole()opens the GPT console overlay?dae-debug=1enables verbose logging in prodwindow.__dreamsDebug = truetoggles logging at runtimead:error(recoverable: true)