Skip to content

analytics: capture customAnalytics at auctionEnd in V2 prebid analytics - #368

Closed
mosherBT wants to merge 1 commit into
masterfrom
prebid-analytics-custom-at-auction-end
Closed

mosherBT wants to merge 1 commit into
masterfrom
prebid-analytics-custom-at-auction-end

Conversation

@mosherBT

Copy link
Copy Markdown
Contributor

Why

V2 prebid analytics calls window.optable.customAnalytics when the bidWinTimeout timer fires, ~10s after auctionEnd. Fields that depend on page state at auction time are read stale. For example, a bundle that tags each auction with the frame it came from always reports the state left by whichever auction ran last.

What Changed

  • prebid/analytics.ts: call customAnalytics in trackAuctionEnd for sampled auctions, store the promise on the auction, and merge it in toWitness on both the timer and visibilitychange paths. A bare toWitness call still invokes customAnalytics itself.
  • prebid/analytics.test.ts: added a case where the value changes between auctionEnd and send.
  • prebid/analytics.md: documented when customAnalytics is called.

How to Test

pnpm test lib/addons/prebid/analytics.test.ts

  • Tested
  • Docs updated — if this adds, changes or removes anything a consumer calls, update the module's .md alongside the code (for example lib/addons/<addon>.md) and the matching README section. New addons ship with a new .md.

Notes

customAnalytics is no longer called for unsampled auctions.

  • Breaking change
  • Requires release

V2 called window.optable.customAnalytics when the bidWinTimeout timer
fired, so any field that depends on page state at auction time was read
~10s late. Call it in trackAuctionEnd for sampled auctions, keep the
result on the stored auction, and merge it in toWitness on both the
timer and visibilitychange paths.
@mosherBT
mosherBT requested review from a team as code owners October 15, 2026 19:00
@mosherBT mosherBT self-assigned this Oct 15, 2026
@mosherBT mosherBT closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant