feat: GPT modernization (Phase 0 + 2) — lifecycle events, SRA, collapseDiv, CLS reserve#3
Draft
LockeAG wants to merge 2 commits into
Draft
feat: GPT modernization (Phase 0 + 2) — lifecycle events, SRA, collapseDiv, CLS reserve#3LockeAG wants to merge 2 commits into
LockeAG wants to merge 2 commits into
Conversation
Adds three GPT slot lifecycle CustomEvents dispatched per dreams-ad-engine
instance:
- ad:requested → slotRequested (request sent to GAM)
- ad:response → slotResponseReceived (response received)
- ad:loaded → slotOnload (creative iframe finished loading)
Pairs with the existing ad:rendered / ad:viewable / ad:visibility events
to give consumers full funnel observability. All three filter by
container id and clean up in disconnectedCallback.
Also adds explicit pubads().enableSingleRequest() before enableServices().
SRA is GPT's default but documenting intent guards against future default
changes and matches Google's published best practice.
Fixes inaccurate JSDoc and inline comments that claimed Slot.setTargeting
was deprecated. It is not — slot.setConfig({ targeting }) is a newer batch
alternative, not a replacement.
Adds opt-in support for GPT's modern collapseDiv setConfig key, the
documented replacement for the deprecated pubads().collapseEmptyDivs()
call:
DreamsAdConfig.init({
collapseEmptyDivs: 'DISABLED' | 'AFTER_FETCH' | 'BEFORE_FETCH'
})
Default 'DISABLED' preserves the existing CLS-reserve behavior — no
change for current consumers.
Also consolidates page-level GPT settings (lazyLoad, threadYield,
collapseDiv) into a single atomic googletag.setConfig() call instead of
multiple separate invocations. setCentering and setPrivacySettings stay
on PubAdsService since current GPT docs do not provide a setConfig
equivalent; comment in the code explains why.
Hardens CLS reserve height computation: when a consumer passes only the
sizing attribute (no mapping), reserve now falls back to the max
non-tracking-pixel height from sizing instead of the previous 2px
default. Eliminates a guaranteed layout shift on fill for that consumer
pattern.
Introduces a typed PageSettingsConfig interface to replace the loose
Record<string, unknown> on Googletag.setConfig — typed-key autocomplete
for known fields with an index signature for forward compatibility.
This was referenced May 13, 2026
LockeAG
added a commit
that referenced
this pull request
May 14, 2026
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
LockeAG
added a commit
that referenced
this pull request
May 14, 2026
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
Two-phase GPT/PubAds modernization. Public-package safe — additive, opt-in, no API breakage. Forbes-MX and Fortuna y Poder unaffected.
Phase 0 — observability + SRA + truthful docs (
feat(gpt))ad:requested,ad:response,ad:loadedslotRequested/slotResponseReceived/slotOnload(filtered per-instance, cleaned up indisconnectedCallback)pubads().enableSingleRequest()opt-in beforeenableServices()@deprecatedJSDoc onSlot.setTargeting(it isn't) and corrects inline commentsPhase 2 —
collapseEmptyDivs+ CLS reserve + typed setConfig (feat(config))DreamsAdConfig.init({ collapseEmptyDivs })option → routes tosetConfig({ collapseDiv }), the modern replacement for the deprecatedpubads().collapseEmptyDivs(). DefaultDISABLEDpreserves current behavior.lazyLoad,threadYield,collapseDiv) consolidated into a single atomicsetConfigcall.setCenteringandsetPrivacySettingsstay onPubAdsService— no authoritativesetConfigequivalent exists yet.#computeReserveHeightfalls back tothis.sizingwhen nomappingis configured. Closes a guaranteed CLS spike for consumers using thesizing-only attribute pattern.PageSettingsConfiginterface replacesRecord<string, unknown>ongoogletag.setConfig. Forward-compat via index signature.Bundle impact
Compatibility
collapseEmptyDivsdefaults toDISABLED— current consumers see no behavior change unless they opt inenableSingleRequest()is idempotent per GPT docs — safe even if a publisher already enabled SRAWhat did NOT change (deliberately)
pubads().setCentering(true)— kept. No verifiedsetConfigequivalent.pubads().setPrivacySettings(...)— kept. Still the current Google API; migrating would risk compliance regressions.minHeight: 0onisEmpty/ tracking-pixel — kept. Existing UX behavior preserved regardless ofcollapseDivsetting.Verification
pnpm buildclean (verified)ad:requested/ad:response/ad:loadedfire in expected orderRelease plan
Suggest cutting
0.7.0once verified — minor bump becausecollapseEmptyDivsadds a new config field (semver minor for additive API).