Skip to content

fix(prebid-analytics): sample once per auction, not twice - #314

Merged
mosherBT merged 1 commit into
masterfrom
fix/prebid-analytics-sampling-squared
Aug 10, 2026
Merged

fix(prebid-analytics): sample once per auction, not twice#314
mosherBT merged 1 commit into
masterfrom
fix/prebid-analytics-sampling-squared

Conversation

@mosherBT

@mosherBT mosherBT commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Why

samplingRate was applied twice per auction — in trackAuctionEnd and again in sendToWitnessAPI — with independent Math.random() draws. Effective rate was rate², so 0.1 sampled at 1%.

What Changed

  • addons/prebid/analytics: drop the sampling gate in sendToWitnessAPI. trackAuctionEnd already stores the decision on auction.sampled, and both the flush and visibilitychange paths honour it.
  • addons/prebid/analytics.test: the samplingRate: 0 case asserted the buggy contract, so it now expects the send to go through. Added a fractional-rate regression.

How to Test

Tests added.

  • Tested
  • Docs / README updated (if public API changed)

Notes

  • Breaking change
  • Requires release

samplingRate was applied at trackAuctionEnd and again in
sendToWitnessAPI, each with an independent Math.random(), so the
effective rate was rate^2 - 0.1 behaved as 0.01.

This was latent while every tenant ran at 1.0, since shouldSample()
short-circuits at >= 1. It surfaced when the sdk-bundles moved to 10%.

Drop the second gate. trackAuctionEnd stores the decision on
auction.sampled and the flush path already honours it.
@mosherBT mosherBT self-assigned this Aug 10, 2026
@mosherBT
mosherBT marked this pull request as ready for review August 10, 2026 19:15
@mosherBT
mosherBT requested review from a team as code owners August 10, 2026 19:15
@mosherBT
mosherBT requested a review from juanli16 August 10, 2026 19:15
juanli16
juanli16 previously approved these changes Aug 10, 2026
@juanli16
juanli16 dismissed their stale review August 10, 2026 19:50

honor existing check

Comment thread lib/addons/prebid/analytics.ts
@mosherBT
mosherBT merged commit e52c724 into master Aug 10, 2026
14 checks passed
@mosherBT
mosherBT deleted the fix/prebid-analytics-sampling-squared branch August 10, 2026 20:13
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.

2 participants