Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/addons/prototypes/analytics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-param-reassign */
/* eslint-disable no-console */
const STATUS = {
REQUESTED: "REQUESTED",
RECEIVED: "RECEIVED",
Expand All @@ -24,6 +23,8 @@ class OptablePrebidAnalytics {
this.auctions = {};
this.maxAuctionDataSize = 20;

sessionStorage.optableSessionDepth = (Number(sessionStorage?.optableSessionDepth) || 0) + 1;

this.log("OptablePrebidAnalytics initialized");
}

Expand All @@ -32,7 +33,7 @@ class OptablePrebidAnalytics {
*/
log(...args) {
if (this.config.debug) {
console.log("[OptablePrebidAnalytics]", ...args);
console.log("[OptablePrebidAnalytics]", ...args); /* eslint-disable-line no-console */
}
}

Expand Down Expand Up @@ -84,6 +85,7 @@ class OptablePrebidAnalytics {
*/
hookIntoPrebid(prebidInstance = window.pbjs) {
const pbjs = prebidInstance;
this.prebidInstance = pbjs;
if (typeof pbjs === "undefined") {
this.log("Prebid.js not found");
return false;
Expand All @@ -101,6 +103,8 @@ class OptablePrebidAnalytics {
async trackAuctionEnd(event, missed) {
const { auctionId, timeout, bidderRequests = [], bidsReceived = [], noBids = [], timeoutBids = [] } = event;

window.optable.pageAuctionsCount = (Number(window.optable.pageAuctionsCount) || 0) + 1;

this.log(`Processing auction ${auctionId} with ${bidderRequests.length} bidder requests`);

// Build auction object with bidder requests and EID flags
Expand Down Expand Up @@ -269,8 +273,10 @@ class OptablePrebidAnalytics {
missed,
url: `${window.location.hostname}${window.location.pathname}`,
tenant: this.config.tenant,
// eslint-disable-next-line no-undef
optableWrapperVersion: SDK_WRAPPER_VERSION,
optableWrapperVersion: SDK_WRAPPER_VERSION, // eslint-disable-line no-undef
prebidjsVersion: this.prebidInstance?.version || "unknown",
sessionDepth: sessionStorage?.optableSessionDepth || 1,
pageAuctionsCount: window.optable?.pageAuctionsCount || 1,
};
// Log summary with bid counts
this.log(
Expand Down