Tercept Analytics Adapter: single request per auction, concurrent auction isolation & payload optimisation#14679
Conversation
- Replace shared events object with per-auctionId Map to fix data loss when multiple auctions run concurrently - Accumulate BID_WON, AD_RENDER_SUCCEEDED, AD_RENDER_FAILED and BIDDER_ERROR into the bids array; flush once 1.5s after AUCTION_END - Use navigator.sendBeacon on visibilitychange so data survives page exit - Add disableAnalytics to clear pending timers and maps on teardown - Add try/catch around track() to prevent adapter errors disrupting page - Remove ad, native and adUrl fields from bid payloads to reduce size - Limit auctionInit.bidderRequests to first entry (device/site data is identical across all bidder requests) - Add is_pl flag (true on first bid of first auction per page load)
Replace tests that assumed multiple requests per auction and separate top-level keys (bidWon, adRenderSucceeded, etc.) with tests matching the new single-request-per-auction design. Covers: - Request timing: no send before 1.5s timer, one request per auction - Payload structure: top-level shape, bidderRequests trimmed to first, host/path/search attached at send time, ad/native/adUrl absent - All event handlers: BID_REQUESTED, BID_RESPONSE, BID_TIMEOUT, NO_BID, BID_WON, AD_RENDER_SUCCEEDED, AD_RENDER_FAILED, BIDDER_ERROR - is_pl flag: true on first bid of first auction only, reset on disable - Concurrent auction isolation: separate bids and auctionInit per id - visibilitychange flush via sendBeacon - disableAnalytics: cancels timers, clears maps, resets firstSent - Error resilience: unknown auctionIds and undefined args do not throw
|
Tread carefully! This PR adds 81 linter errors (possibly disabled through directives):
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a55a159699
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Coverage Report for CI Build 24229648318Coverage increased (+0.003%) to 96.347%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats💛 - Coveralls |
…mport - Fix 81 indent errors by properly indenting the try block body - Replace window.addEventListener with document.addEventListener for visibilitychange — the event is non-bubbling and fires on document, so window never received it in Firefox/Safari - Replace navigator.sendBeacon with the ajax.js sendBeacon wrapper as required by Prebid.js linting rules - Update test to stub ajax.sendBeacon and dispatch event on document
Split multi-property spread objects onto separate lines to satisfy the @stylistic/object-property-newline ESLint rule.
|
@jefftmahoney Had already resolved the codex review comments. Would it be possible to perhaps expedite the review? |
|
@patmmccann was really hoping this could be part of the next release, would it be possible to have this reviewed sooner? |
Type of change
Description of change
Refactored the Tercept Analytics Adapter to fix a data-loss bug with concurrent auctions, reduce request volume from ~4 per auction to 1, and trim payload size.
Concurrent auction isolation (bug fix):
eventsobject with aMapkeyed byauctionIdAUCTION_INITwould reset shared state, silently dropping data from any in-flight auction; each auction is now fully isolatedSingle request per auction:
BID_WON,AD_RENDER_SUCCEEDED,AD_RENDER_FAILED,BIDDER_ERROR) are now accumulated into the bids array and flushed in one POST ~1.5s afterAUCTION_ENDPage-exit reliability via
sendBeacon:visibilitychangehandler flushes pending auctions usingnavigator.sendBeaconinstead ofajax, guaranteeing delivery when the user navigates away before the 1.5s timer firesPayload size reduction:
ad(full creative markup, 10–50 KB per bid),nativepayload, andadUrlfrom bid objectsauctionInit.bidderRequeststrimmed to first entry only — device and site data is identical across all bidder requestsResilience and cleanup:
try/catcharoundtrack()so any unexpected error does not disrupt the publisher pagedisableAnalyticsto cancel pending timers and clear maps on teardown, preventing state leaking across SPA navigations