@bidkernel/analytics 0.23.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics.global.js +1 -1
- package/dist/index.d.mts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +171 -24
- package/dist/index.mjs +169 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(src_exports, {
|
|
|
23
23
|
BidkernelPrebidAnalytics: () => BidkernelPrebidAnalytics,
|
|
24
24
|
CACHED_BID_TTL_MS: () => CACHED_BID_TTL_MS,
|
|
25
25
|
ImaAdsManagerStub: () => ImaAdsManagerStub,
|
|
26
|
+
LogLevel: () => LogLevel,
|
|
26
27
|
PrebidEventDeduper: () => PrebidEventDeduper,
|
|
27
28
|
attachImaAdsManager: () => attachImaAdsManager,
|
|
28
29
|
attachVideoPlayer: () => attachVideoPlayer,
|
|
@@ -34,6 +35,7 @@ __export(src_exports, {
|
|
|
34
35
|
isSessionActive: () => isSessionActive,
|
|
35
36
|
isTrustedEndpoint: () => isTrustedEndpoint,
|
|
36
37
|
normalizeImaEventName: () => normalizeImaEventName,
|
|
38
|
+
normalizeLogLevel: () => normalizeLogLevel,
|
|
37
39
|
onSessionResume: () => onSessionResume,
|
|
38
40
|
registerPrebidAnalytics: () => registerPrebidAnalytics
|
|
39
41
|
});
|
|
@@ -1318,11 +1320,26 @@ function parseBidDimensions(bid) {
|
|
|
1318
1320
|
height: Number.isFinite(bid?.height) ? bid.height : 0
|
|
1319
1321
|
};
|
|
1320
1322
|
}
|
|
1323
|
+
var defaultLogger = createLogger({
|
|
1324
|
+
prefix: "[analytics]",
|
|
1325
|
+
logLevel: "INFO"
|
|
1326
|
+
});
|
|
1321
1327
|
var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
1322
1328
|
static activeInstances = /* @__PURE__ */ new Set();
|
|
1329
|
+
static allInstances = /* @__PURE__ */ new Set();
|
|
1323
1330
|
static getActiveInstances() {
|
|
1324
1331
|
return _BidkernelPrebidAnalytics.activeInstances;
|
|
1325
1332
|
}
|
|
1333
|
+
static setLogLevel(level) {
|
|
1334
|
+
const norm = normalizeLogLevel(level);
|
|
1335
|
+
defaultLogger.setLevel(norm);
|
|
1336
|
+
for (const inst of _BidkernelPrebidAnalytics.allInstances) {
|
|
1337
|
+
inst.setLogLevel(norm);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
static getLogLevel() {
|
|
1341
|
+
return defaultLogger.getLevel();
|
|
1342
|
+
}
|
|
1326
1343
|
/**
|
|
1327
1344
|
* Allows or forbids localStorage writes for every instance on the page.
|
|
1328
1345
|
* Collection and delivery are unaffected: only the persisted session id,
|
|
@@ -1361,6 +1378,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
1361
1378
|
slotViewabilityRecords = /* @__PURE__ */ new Map();
|
|
1362
1379
|
elementToSlotId = /* @__PURE__ */ new Map();
|
|
1363
1380
|
slotRefreshIndices = /* @__PURE__ */ new Map();
|
|
1381
|
+
slotAdSessionCounters = /* @__PURE__ */ new Map();
|
|
1364
1382
|
slotLastAuctionIds = /* @__PURE__ */ new Map();
|
|
1365
1383
|
pendingThresholdListeners = /* @__PURE__ */ new Map();
|
|
1366
1384
|
pendingViewableListeners = /* @__PURE__ */ new Map();
|
|
@@ -1404,13 +1422,14 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
1404
1422
|
errorsEnabled: config.errorsEnabled ?? true,
|
|
1405
1423
|
viewabilityEnabled: config.viewabilityEnabled ?? true,
|
|
1406
1424
|
storageAllowed: config.storageAllowed ?? true,
|
|
1407
|
-
logLevel: config.logLevel
|
|
1425
|
+
logLevel: config.logLevel ? normalizeLogLevel(config.logLevel) : defaultLogger.getLevel(),
|
|
1408
1426
|
pbjsGlobalName: config.pbjsGlobalName || "pbjs",
|
|
1409
1427
|
attachPbjsListeners: config.attachPbjsListeners ?? true,
|
|
1410
1428
|
revenueFlushDelayMs: Number.isFinite(config.revenueFlushDelayMs) && config.revenueFlushDelayMs >= 0 ? config.revenueFlushDelayMs : REVENUE_FLUSH_DELAY_MS
|
|
1411
1429
|
};
|
|
1430
|
+
_BidkernelPrebidAnalytics.allInstances.add(this);
|
|
1412
1431
|
this.logger = createLogger({
|
|
1413
|
-
prefix: "[
|
|
1432
|
+
prefix: "[analytics]",
|
|
1414
1433
|
logLevel: this.config.logLevel
|
|
1415
1434
|
});
|
|
1416
1435
|
recordActivity();
|
|
@@ -1428,6 +1447,15 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
1428
1447
|
};
|
|
1429
1448
|
this.boundVisibilityChange = () => this.handleVisibilityChange();
|
|
1430
1449
|
}
|
|
1450
|
+
setLogLevel(level) {
|
|
1451
|
+
const norm = normalizeLogLevel(level);
|
|
1452
|
+
this.config.logLevel = norm;
|
|
1453
|
+
this.logger.setLevel(norm);
|
|
1454
|
+
defaultLogger.setLevel(norm);
|
|
1455
|
+
}
|
|
1456
|
+
getLogLevel() {
|
|
1457
|
+
return this.logger.getLevel();
|
|
1458
|
+
}
|
|
1431
1459
|
enable() {
|
|
1432
1460
|
if (this.isEnabled) return;
|
|
1433
1461
|
this.isEnabled = true;
|
|
@@ -2064,6 +2092,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2064
2092
|
this.unobserveSlot(slotId);
|
|
2065
2093
|
this.slotViewabilityRecords.delete(slotId);
|
|
2066
2094
|
this.slotRefreshIndices.delete(slotId);
|
|
2095
|
+
this.slotAdSessionCounters.delete(slotId);
|
|
2067
2096
|
this.slotLastAuctionIds.delete(slotId);
|
|
2068
2097
|
this.pendingThresholdListeners.delete(slotId);
|
|
2069
2098
|
this.pendingViewableListeners.delete(slotId);
|
|
@@ -2141,9 +2170,41 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2141
2170
|
}
|
|
2142
2171
|
return auctionMap;
|
|
2143
2172
|
}
|
|
2144
|
-
|
|
2173
|
+
nextSlotAdSession(slotId) {
|
|
2174
|
+
const next = (this.slotAdSessionCounters.get(slotId) ?? 0) + 1;
|
|
2175
|
+
this.slotAdSessionCounters.set(slotId, next);
|
|
2176
|
+
return `ad-session-${next}`;
|
|
2177
|
+
}
|
|
2178
|
+
hasImpressionEmitted(slotId, refreshIndex, auctionId, creativeId, adId) {
|
|
2145
2179
|
const rIndex = refreshIndex ?? this.slotRefreshIndices.get(slotId) ?? 0;
|
|
2146
2180
|
const baseSlotKey = `${escapeKeyPart(slotId)}:${rIndex}`;
|
|
2181
|
+
if (adId) {
|
|
2182
|
+
if (auctionId) {
|
|
2183
|
+
if (this.slotEmittedImpressionKeys.has(
|
|
2184
|
+
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:ad:${escapeKeyPart(adId)}`
|
|
2185
|
+
) || this.slotEmittedImpressionKeys.has(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`) || // Compat: pre-0.26.0 adapters stored keys without :ad: prefix; release once all in-flight keys expire.
|
|
2186
|
+
this.slotEmittedImpressionKeys.has(
|
|
2187
|
+
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:${escapeKeyPart(adId)}`
|
|
2188
|
+
) || this.slotEmittedImpressionKeys.has(`${baseSlotKey}:${escapeKeyPart(adId)}`)) {
|
|
2189
|
+
return true;
|
|
2190
|
+
}
|
|
2191
|
+
} else if (this.slotEmittedImpressionKeys.has(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`) || // Compat: pre-0.26.0 adapters stored keys without :ad: prefix; release once all in-flight keys expire.
|
|
2192
|
+
this.slotEmittedImpressionKeys.has(`${baseSlotKey}:${escapeKeyPart(adId)}`)) {
|
|
2193
|
+
return true;
|
|
2194
|
+
}
|
|
2195
|
+
if (creativeId && creativeId !== adId) {
|
|
2196
|
+
if (auctionId) {
|
|
2197
|
+
if (this.slotEmittedImpressionKeys.has(
|
|
2198
|
+
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:${escapeKeyPart(creativeId)}`
|
|
2199
|
+
) || this.slotEmittedImpressionKeys.has(`${baseSlotKey}:${escapeKeyPart(creativeId)}`)) {
|
|
2200
|
+
return true;
|
|
2201
|
+
}
|
|
2202
|
+
} else if (this.slotEmittedImpressionKeys.has(`${baseSlotKey}:${escapeKeyPart(creativeId)}`)) {
|
|
2203
|
+
return true;
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
return false;
|
|
2207
|
+
}
|
|
2147
2208
|
if (creativeId) {
|
|
2148
2209
|
if (auctionId) {
|
|
2149
2210
|
return this.slotEmittedImpressionKeys.has(
|
|
@@ -2157,18 +2218,37 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2157
2218
|
}
|
|
2158
2219
|
return this.slotEmittedImpressionKeys.has(baseSlotKey);
|
|
2159
2220
|
}
|
|
2160
|
-
markImpressionEmitted(slotId, refreshIndex, auctionId, creativeId) {
|
|
2221
|
+
markImpressionEmitted(slotId, refreshIndex, auctionId, creativeId, adId) {
|
|
2161
2222
|
const baseSlotKey = `${escapeKeyPart(slotId)}:${refreshIndex}`;
|
|
2162
|
-
|
|
2163
|
-
if (
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2223
|
+
const hasIdentity = Boolean(adId || creativeId);
|
|
2224
|
+
if (hasIdentity) {
|
|
2225
|
+
if (adId) {
|
|
2226
|
+
this.addImpressionKey(`${baseSlotKey}:ad:${escapeKeyPart(adId)}`);
|
|
2227
|
+
this.addImpressionKey(`${baseSlotKey}:${escapeKeyPart(adId)}`);
|
|
2228
|
+
if (auctionId) {
|
|
2229
|
+
this.addImpressionKey(
|
|
2230
|
+
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:ad:${escapeKeyPart(adId)}`
|
|
2231
|
+
);
|
|
2232
|
+
this.addImpressionKey(
|
|
2233
|
+
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:${escapeKeyPart(adId)}`
|
|
2234
|
+
);
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
if (creativeId && creativeId !== adId) {
|
|
2238
|
+
this.addImpressionKey(`${baseSlotKey}:${escapeKeyPart(creativeId)}`);
|
|
2239
|
+
if (auctionId) {
|
|
2240
|
+
this.addImpressionKey(
|
|
2241
|
+
`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}:${escapeKeyPart(creativeId)}`
|
|
2242
|
+
);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
if (auctionId) {
|
|
2246
|
+
this.addImpressionKey(`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}`);
|
|
2247
|
+
}
|
|
2248
|
+
} else {
|
|
2249
|
+
this.addImpressionKey(baseSlotKey);
|
|
2250
|
+
if (auctionId) {
|
|
2251
|
+
this.addImpressionKey(`${baseSlotKey}:auc:${escapeKeyPart(auctionId)}`);
|
|
2172
2252
|
}
|
|
2173
2253
|
}
|
|
2174
2254
|
}
|
|
@@ -2181,6 +2261,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2181
2261
|
const auctionId = options?.auctionId || rawBid.auctionId || cached?.auctionId || "";
|
|
2182
2262
|
const transactionId = options?.transactionId || rawBid.transactionId || cached?.transactionId || "";
|
|
2183
2263
|
const creativeId = rawBid.creativeId || cached?.bidTrace?.creativeId || options?.bid?.creativeId || "";
|
|
2264
|
+
const adId = options?.adId || rawBid.adId || options?.bid?.adId || "";
|
|
2184
2265
|
const mediaType = options?.mediaType || rawBid.mediaType || cached?.bidTrace?.mediaType || "banner";
|
|
2185
2266
|
const targetSlot = resolvedSlotId || adUnitCode;
|
|
2186
2267
|
const rec = (resolvedSlotId ? this.slotViewabilityRecords.get(resolvedSlotId) : void 0) || (adUnitCode ? this.slotViewabilityRecords.get(adUnitCode) : void 0);
|
|
@@ -2221,7 +2302,13 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2221
2302
|
}
|
|
2222
2303
|
}
|
|
2223
2304
|
const currentRefreshIndex = options?.refreshIndex ?? (resolvedSlotId ? this.slotRefreshIndices.get(resolvedSlotId) ?? (adUnitCode ? this.slotRefreshIndices.get(adUnitCode) : void 0) ?? (rec ? rec.refreshIndex : 0) : 0);
|
|
2224
|
-
const alreadyEmitted = resolvedSlotId && this.hasImpressionEmitted(
|
|
2305
|
+
const alreadyEmitted = resolvedSlotId && this.hasImpressionEmitted(
|
|
2306
|
+
resolvedSlotId,
|
|
2307
|
+
currentRefreshIndex,
|
|
2308
|
+
auctionId,
|
|
2309
|
+
creativeId,
|
|
2310
|
+
adId
|
|
2311
|
+
) || adUnitCode && adUnitCode !== resolvedSlotId && this.hasImpressionEmitted(adUnitCode, currentRefreshIndex, auctionId, creativeId, adId);
|
|
2225
2312
|
if (alreadyEmitted) {
|
|
2226
2313
|
this.log(
|
|
2227
2314
|
"DEBUG",
|
|
@@ -2230,9 +2317,9 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2230
2317
|
return false;
|
|
2231
2318
|
}
|
|
2232
2319
|
if (resolvedSlotId)
|
|
2233
|
-
this.markImpressionEmitted(resolvedSlotId, currentRefreshIndex, auctionId, creativeId);
|
|
2320
|
+
this.markImpressionEmitted(resolvedSlotId, currentRefreshIndex, auctionId, creativeId, adId);
|
|
2234
2321
|
if (adUnitCode && adUnitCode !== resolvedSlotId)
|
|
2235
|
-
this.markImpressionEmitted(adUnitCode, currentRefreshIndex, auctionId, creativeId);
|
|
2322
|
+
this.markImpressionEmitted(adUnitCode, currentRefreshIndex, auctionId, creativeId, adId);
|
|
2236
2323
|
this.enqueue(TraceEventType.IMPRESSION, "impression", {
|
|
2237
2324
|
auctionId,
|
|
2238
2325
|
transactionId,
|
|
@@ -2371,6 +2458,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2371
2458
|
navigate(pageviewId, pageUrl) {
|
|
2372
2459
|
this.disable();
|
|
2373
2460
|
this.slotRefreshIndices.clear();
|
|
2461
|
+
this.slotAdSessionCounters.clear();
|
|
2374
2462
|
this.floorDecisions.clear();
|
|
2375
2463
|
this.pendingThresholdListeners.clear();
|
|
2376
2464
|
this.config.pageviewId = pageviewId || generateUUID();
|
|
@@ -3074,10 +3162,6 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
3074
3162
|
this.logger.log(level, msg, ...args);
|
|
3075
3163
|
}
|
|
3076
3164
|
};
|
|
3077
|
-
var defaultLogger = createLogger({
|
|
3078
|
-
prefix: "[bidkernel]",
|
|
3079
|
-
logLevel: "INFO"
|
|
3080
|
-
});
|
|
3081
3165
|
function extractAnalyticsOptions(config, allowProviderless = true) {
|
|
3082
3166
|
if (!config) return null;
|
|
3083
3167
|
if (Array.isArray(config)) {
|
|
@@ -3600,9 +3684,29 @@ function attachImaAdsManager(analytics, adsManager, options) {
|
|
|
3600
3684
|
return cached;
|
|
3601
3685
|
};
|
|
3602
3686
|
let adStarted = false;
|
|
3687
|
+
let activeAdSession = null;
|
|
3688
|
+
const mintAdSession = (initialAd) => {
|
|
3689
|
+
const nextSession = typeof self.nextSlotAdSession === "function" ? self.nextSlotAdSession(slotId) : `ad-session-${(self.slotAdSessionCounters?.get(slotId) ?? 0) + 1}`;
|
|
3690
|
+
if (self.slotAdSessionCounters && typeof self.nextSlotAdSession !== "function") {
|
|
3691
|
+
const c = (self.slotAdSessionCounters.get(slotId) ?? 0) + 1;
|
|
3692
|
+
self.slotAdSessionCounters.set(slotId, c);
|
|
3693
|
+
}
|
|
3694
|
+
const adId = (typeof initialAd?.getAdId === "function" ? initialAd.getAdId() : initialAd?.adId ?? initialAd?.id) || "";
|
|
3695
|
+
const creativeId = (typeof initialAd?.getCreativeId === "function" ? initialAd.getCreativeId() : initialAd?.creativeId) || "";
|
|
3696
|
+
activeAdSession = {
|
|
3697
|
+
sessionId: nextSession,
|
|
3698
|
+
adId: adId || void 0,
|
|
3699
|
+
creativeId: creativeId || void 0
|
|
3700
|
+
};
|
|
3701
|
+
return activeAdSession;
|
|
3702
|
+
};
|
|
3703
|
+
const onAdLoaded = (event) => {
|
|
3704
|
+
const ad = typeof event?.getAd === "function" ? event.getAd() : event?.ad;
|
|
3705
|
+
mintAdSession(ad);
|
|
3706
|
+
self.log("DEBUG", "IMA AdEvent.LOADED received", { slotId, activeAdSession });
|
|
3707
|
+
};
|
|
3603
3708
|
const onAdStartedOrImpression = (event) => {
|
|
3604
3709
|
adStarted = true;
|
|
3605
|
-
self.log("DEBUG", "IMA AdEvent.STARTED / IMPRESSION received", event);
|
|
3606
3710
|
const ad = typeof event?.getAd === "function" ? event.getAd() : event?.ad;
|
|
3607
3711
|
const adData = {};
|
|
3608
3712
|
if (ad) {
|
|
@@ -3612,15 +3716,28 @@ function attachImaAdsManager(analytics, adsManager, options) {
|
|
|
3612
3716
|
adData.duration = typeof ad.getDuration === "function" ? ad.getDuration() : ad.duration;
|
|
3613
3717
|
adData.advertiserName = typeof ad.getAdvertiserName === "function" ? ad.getAdvertiserName() : "";
|
|
3614
3718
|
}
|
|
3719
|
+
if (!activeAdSession || adData.adId && activeAdSession.adId && activeAdSession.adId !== adData.adId) {
|
|
3720
|
+
mintAdSession(ad);
|
|
3721
|
+
} else {
|
|
3722
|
+
if (!activeAdSession.adId && adData.adId) {
|
|
3723
|
+
activeAdSession.adId = adData.adId;
|
|
3724
|
+
}
|
|
3725
|
+
if (!activeAdSession.creativeId && adData.creativeId) {
|
|
3726
|
+
activeAdSession.creativeId = adData.creativeId;
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
const session = activeAdSession || mintAdSession(ad);
|
|
3615
3730
|
const cached = getWinningBid(adData);
|
|
3616
3731
|
const resolvedSlotId = options?.slotId && options.slotId !== "video" ? options.slotId : options?.adUnitCode && options.adUnitCode !== "video" ? options.adUnitCode : cached?.adUnitCode || options?.slotId || options?.adUnitCode || "video";
|
|
3617
3732
|
const resolvedAdUnitCode = options?.adUnitCode && options.adUnitCode !== "video" ? options.adUnitCode : cached?.adUnitCode || resolvedSlotId;
|
|
3618
3733
|
const resolvedAuctionId = auctionId || cached?.auctionId || "";
|
|
3619
3734
|
const resolvedTransactionId = transactionId || cached?.transactionId || "";
|
|
3735
|
+
const creativeId = session.creativeId || adData.creativeId || cached?.bidTrace?.creativeId || options?.bid?.creativeId || "";
|
|
3736
|
+
const stableAdIdentity = session.adId || adData.adId || creativeId || session.sessionId;
|
|
3620
3737
|
const mergedBid = {
|
|
3621
3738
|
...cached?.rawBid || options?.bid,
|
|
3622
3739
|
mediaType: "video",
|
|
3623
|
-
creativeId
|
|
3740
|
+
creativeId
|
|
3624
3741
|
};
|
|
3625
3742
|
const emitted = self.recordImpression(resolvedSlotId, {
|
|
3626
3743
|
adUnitCode: resolvedAdUnitCode,
|
|
@@ -3628,6 +3745,7 @@ function attachImaAdsManager(analytics, adsManager, options) {
|
|
|
3628
3745
|
transactionId: resolvedTransactionId,
|
|
3629
3746
|
mediaType: "video",
|
|
3630
3747
|
bid: mergedBid,
|
|
3748
|
+
adId: stableAdIdentity,
|
|
3631
3749
|
metadata: {
|
|
3632
3750
|
...options?.metadata,
|
|
3633
3751
|
media_type: "video",
|
|
@@ -3635,6 +3753,16 @@ function attachImaAdsManager(analytics, adsManager, options) {
|
|
|
3635
3753
|
...Number.isFinite(adData.duration) ? { ad_duration_s: String(adData.duration) } : {}
|
|
3636
3754
|
}
|
|
3637
3755
|
});
|
|
3756
|
+
let rawType = typeof event?.type === "string" ? event.type : typeof event?.getType === "function" ? event.getType() : typeof event === "string" ? event : "";
|
|
3757
|
+
if (rawType.toLowerCase().startsWith("adevent.")) {
|
|
3758
|
+
rawType = rawType.slice(8);
|
|
3759
|
+
}
|
|
3760
|
+
const eventName = rawType ? rawType.toUpperCase() : "STARTED/IMPRESSION";
|
|
3761
|
+
self.log(
|
|
3762
|
+
"DEBUG",
|
|
3763
|
+
`IMA AdEvent.${eventName} received${emitted ? "" : " (second event for this ad, already counted)"}`,
|
|
3764
|
+
event
|
|
3765
|
+
);
|
|
3638
3766
|
if (emitted && options?.onImpression) {
|
|
3639
3767
|
try {
|
|
3640
3768
|
options.onImpression(resolvedSlotId, { ad, bid: mergedBid });
|
|
@@ -3669,6 +3797,7 @@ function attachImaAdsManager(analytics, adsManager, options) {
|
|
|
3669
3797
|
});
|
|
3670
3798
|
};
|
|
3671
3799
|
const onAdError = (event) => {
|
|
3800
|
+
activeAdSession = null;
|
|
3672
3801
|
const cached = getWinningBid();
|
|
3673
3802
|
const resolvedAdUnitCode = options?.adUnitCode && options.adUnitCode !== "video" ? options.adUnitCode : cached?.adUnitCode || slotId;
|
|
3674
3803
|
const err = recordImaAdError(analytics, event, {
|
|
@@ -3691,6 +3820,7 @@ function attachImaAdsManager(analytics, adsManager, options) {
|
|
|
3691
3820
|
const adEventType = googleIma?.AdEvent?.Type || {};
|
|
3692
3821
|
const adErrorEventType = googleIma?.AdErrorEvent?.Type || {};
|
|
3693
3822
|
const rawListeners = [
|
|
3823
|
+
{ type: adEventType.LOADED || "loaded", handler: onAdLoaded },
|
|
3694
3824
|
{ type: adEventType.STARTED || "started", handler: onAdStartedOrImpression },
|
|
3695
3825
|
{ type: adEventType.IMPRESSION || "impression", handler: onAdStartedOrImpression },
|
|
3696
3826
|
{
|
|
@@ -3702,7 +3832,19 @@ function attachImaAdsManager(analytics, adsManager, options) {
|
|
|
3702
3832
|
type: adEventType.THIRD_QUARTILE || "thirdQuartile",
|
|
3703
3833
|
handler: () => onMilestone("thirdQuartile")
|
|
3704
3834
|
},
|
|
3705
|
-
{
|
|
3835
|
+
{
|
|
3836
|
+
type: adEventType.COMPLETE || "complete",
|
|
3837
|
+
handler: () => {
|
|
3838
|
+
activeAdSession = null;
|
|
3839
|
+
onMilestone("complete");
|
|
3840
|
+
}
|
|
3841
|
+
},
|
|
3842
|
+
{
|
|
3843
|
+
type: adEventType.ALL_ADS_COMPLETED || "allAdsCompleted",
|
|
3844
|
+
handler: () => {
|
|
3845
|
+
activeAdSession = null;
|
|
3846
|
+
}
|
|
3847
|
+
},
|
|
3706
3848
|
{ type: adEventType.CLICK || "click", handler: onAdClick },
|
|
3707
3849
|
{ type: adErrorEventType.AD_ERROR || "adError", handler: onAdError }
|
|
3708
3850
|
];
|
|
@@ -3721,6 +3863,7 @@ function attachImaAdsManager(analytics, adsManager, options) {
|
|
|
3721
3863
|
}
|
|
3722
3864
|
}
|
|
3723
3865
|
const cleanup = () => {
|
|
3866
|
+
activeAdSession = null;
|
|
3724
3867
|
attached.delete(analytics);
|
|
3725
3868
|
for (const { type, handler } of listeners) {
|
|
3726
3869
|
try {
|
|
@@ -3987,6 +4130,8 @@ function normalizeImaEventName(name) {
|
|
|
3987
4130
|
return "volumeChanged";
|
|
3988
4131
|
case "loaded":
|
|
3989
4132
|
return "loaded";
|
|
4133
|
+
case "alladscompleted":
|
|
4134
|
+
return "allAdsCompleted";
|
|
3990
4135
|
case "aderror":
|
|
3991
4136
|
case "error":
|
|
3992
4137
|
return "adError";
|
|
@@ -4102,6 +4247,7 @@ function getbidkernel(alias = "bidkernel") {
|
|
|
4102
4247
|
BidkernelPrebidAnalytics,
|
|
4103
4248
|
CACHED_BID_TTL_MS,
|
|
4104
4249
|
ImaAdsManagerStub,
|
|
4250
|
+
LogLevel,
|
|
4105
4251
|
PrebidEventDeduper,
|
|
4106
4252
|
attachImaAdsManager,
|
|
4107
4253
|
attachVideoPlayer,
|
|
@@ -4113,6 +4259,7 @@ function getbidkernel(alias = "bidkernel") {
|
|
|
4113
4259
|
isSessionActive,
|
|
4114
4260
|
isTrustedEndpoint,
|
|
4115
4261
|
normalizeImaEventName,
|
|
4262
|
+
normalizeLogLevel,
|
|
4116
4263
|
onSessionResume,
|
|
4117
4264
|
registerPrebidAnalytics
|
|
4118
4265
|
});
|