@bidspark/analytics 0.46.0 → 0.46.1
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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +73 -153
- package/dist/index.mjs +72 -153
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __export(src_exports, {
|
|
|
42
42
|
getPrebidEventKey: () => getPrebidEventKey,
|
|
43
43
|
idToBytes: () => idToBytes,
|
|
44
44
|
idToString: () => idToString,
|
|
45
|
+
installImaAutoInterception: () => installImaAutoInterception,
|
|
45
46
|
isAutomatedClient: () => isAutomatedClient,
|
|
46
47
|
isSessionActive: () => isSessionActive,
|
|
47
48
|
isTrustedEndpoint: () => isTrustedEndpoint,
|
|
@@ -79,18 +80,6 @@ var COLORS = {
|
|
|
79
80
|
eventError: "color: #ef4444; font-weight: bold",
|
|
80
81
|
reset: "color: inherit"
|
|
81
82
|
};
|
|
82
|
-
var logCounter = 0;
|
|
83
|
-
var localGlobalListeners = /* @__PURE__ */ new Set();
|
|
84
|
-
function getGlobalListeners() {
|
|
85
|
-
if (typeof window !== "undefined") {
|
|
86
|
-
const win = window;
|
|
87
|
-
if (!win.__bidsparkLogListeners) {
|
|
88
|
-
win.__bidsparkLogListeners = /* @__PURE__ */ new Set();
|
|
89
|
-
}
|
|
90
|
-
return win.__bidsparkLogListeners;
|
|
91
|
-
}
|
|
92
|
-
return localGlobalListeners;
|
|
93
|
-
}
|
|
94
83
|
function formatTime(ms) {
|
|
95
84
|
if (ms < 0 || !Number.isFinite(ms)) ms = 0;
|
|
96
85
|
if (ms < 1e3) return `${ms.toFixed(2)}ms`;
|
|
@@ -116,15 +105,11 @@ var Logger = class {
|
|
|
116
105
|
_loadedAt;
|
|
117
106
|
_now;
|
|
118
107
|
_console;
|
|
119
|
-
_listeners = /* @__PURE__ */ new Set();
|
|
120
108
|
constructor(options = {}) {
|
|
121
109
|
this._prefix = options.prefix ?? "[ads]";
|
|
122
110
|
this._level = normalizeLogLevel(options.logLevel ?? LogLevel.INFO);
|
|
123
111
|
this._now = options.now;
|
|
124
112
|
this._console = options.console;
|
|
125
|
-
if (options.onLog) {
|
|
126
|
-
this._listeners.add(options.onLog);
|
|
127
|
-
}
|
|
128
113
|
this._loadedAt = options.loadedAt ?? (this._now ? this._now() : typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now());
|
|
129
114
|
}
|
|
130
115
|
get prefix() {
|
|
@@ -157,15 +142,6 @@ var Logger = class {
|
|
|
157
142
|
getLoadedAt() {
|
|
158
143
|
return this._loadedAt;
|
|
159
144
|
}
|
|
160
|
-
addListener(listener) {
|
|
161
|
-
this._listeners.add(listener);
|
|
162
|
-
return () => {
|
|
163
|
-
this._listeners.delete(listener);
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
removeListener(listener) {
|
|
167
|
-
this._listeners.delete(listener);
|
|
168
|
-
}
|
|
169
145
|
isEnabled(level) {
|
|
170
146
|
const target = normalizeLogLevel(level);
|
|
171
147
|
return (LOG_LEVEL_MAP[target] ?? 20) >= (LOG_LEVEL_MAP[this._level] ?? 20);
|
|
@@ -179,23 +155,6 @@ var Logger = class {
|
|
|
179
155
|
const current = this._now ? this._now() : typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
180
156
|
return Math.max(0, current - this._loadedAt);
|
|
181
157
|
}
|
|
182
|
-
_dispatchRecord(record) {
|
|
183
|
-
for (const l of this._listeners) {
|
|
184
|
-
try {
|
|
185
|
-
l(record);
|
|
186
|
-
} catch {
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
const globalListeners = getGlobalListeners();
|
|
190
|
-
for (const gl of globalListeners) {
|
|
191
|
-
if (!this._listeners.has(gl)) {
|
|
192
|
-
try {
|
|
193
|
-
gl(record);
|
|
194
|
-
} catch {
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
158
|
log(level, nameOrMsg, ...args) {
|
|
200
159
|
const normLevel = normalizeLogLevel(level);
|
|
201
160
|
if (!this.isEnabled(normLevel)) {
|
|
@@ -203,19 +162,6 @@ var Logger = class {
|
|
|
203
162
|
}
|
|
204
163
|
const elapsed = this._getElapsed();
|
|
205
164
|
const formattedTimeStr = formatTime(elapsed);
|
|
206
|
-
const nowEpoch = Date.now();
|
|
207
|
-
const recordId = `bk_log_${nowEpoch}_${++logCounter}`;
|
|
208
|
-
const record = {
|
|
209
|
-
id: recordId,
|
|
210
|
-
timestamp: nowEpoch,
|
|
211
|
-
elapsedMs: elapsed,
|
|
212
|
-
level: normLevel,
|
|
213
|
-
prefix: this._prefix,
|
|
214
|
-
message: nameOrMsg,
|
|
215
|
-
args,
|
|
216
|
-
data: args.length === 1 ? args[0] : args.length > 1 ? args : void 0
|
|
217
|
-
};
|
|
218
|
-
this._dispatchRecord(record);
|
|
219
165
|
const c = this._getConsole();
|
|
220
166
|
if (!c) return;
|
|
221
167
|
let badgeStyle = COLORS.badge;
|
|
@@ -4033,6 +3979,8 @@ function registerPrebidAnalytics(pbjsGlobalName = "pbjs", defaults) {
|
|
|
4033
3979
|
var internals = (analytics) => analytics;
|
|
4034
3980
|
var adsLoaderListenerMap = /* @__PURE__ */ new WeakMap();
|
|
4035
3981
|
var adsLoadersWithErrorListener = /* @__PURE__ */ new WeakSet();
|
|
3982
|
+
var hookedImaFns = /* @__PURE__ */ new WeakSet();
|
|
3983
|
+
var attachedImaManagers = /* @__PURE__ */ new WeakMap();
|
|
4036
3984
|
function describeImaError(event) {
|
|
4037
3985
|
const err = typeof event?.getError === "function" ? event.getError() : event?.error || event;
|
|
4038
3986
|
const call = (name) => err && typeof err[name] === "function" ? err[name]() : void 0;
|
|
@@ -4092,7 +4040,7 @@ function hookAdsManagerLoadedEvent(loadedEventCtor) {
|
|
|
4092
4040
|
if (!loadedEventCtor) return;
|
|
4093
4041
|
try {
|
|
4094
4042
|
const loadedProto = loadedEventCtor.prototype;
|
|
4095
|
-
if (loadedProto && typeof loadedProto.getAdsManager === "function" && !loadedProto.getAdsManager
|
|
4043
|
+
if (loadedProto && typeof loadedProto.getAdsManager === "function" && !hookedImaFns.has(loadedProto.getAdsManager)) {
|
|
4096
4044
|
const originalGetAdsManager = loadedProto.getAdsManager;
|
|
4097
4045
|
const hookedGetAdsManager = function(...args) {
|
|
4098
4046
|
const adsManager = originalGetAdsManager.apply(this, args);
|
|
@@ -4106,7 +4054,7 @@ function hookAdsManagerLoadedEvent(loadedEventCtor) {
|
|
|
4106
4054
|
}
|
|
4107
4055
|
return adsManager;
|
|
4108
4056
|
};
|
|
4109
|
-
hookedGetAdsManager
|
|
4057
|
+
hookedImaFns.add(hookedGetAdsManager);
|
|
4110
4058
|
loadedProto.getAdsManager = hookedGetAdsManager;
|
|
4111
4059
|
}
|
|
4112
4060
|
} catch {
|
|
@@ -4116,7 +4064,7 @@ function hookAdsManagerPrototype(adsManagerCtorOrProto) {
|
|
|
4116
4064
|
if (!adsManagerCtorOrProto) return;
|
|
4117
4065
|
try {
|
|
4118
4066
|
const proto = adsManagerCtorOrProto.prototype || adsManagerCtorOrProto;
|
|
4119
|
-
if (proto && typeof proto.init === "function" && !proto.init
|
|
4067
|
+
if (proto && typeof proto.init === "function" && !hookedImaFns.has(proto.init)) {
|
|
4120
4068
|
const origInit = proto.init;
|
|
4121
4069
|
const hookedInit = function(...args) {
|
|
4122
4070
|
for (const instance of BidsparkPrebidAnalytics.getActiveInstances()) {
|
|
@@ -4127,10 +4075,10 @@ function hookAdsManagerPrototype(adsManagerCtorOrProto) {
|
|
|
4127
4075
|
}
|
|
4128
4076
|
return origInit.apply(this, args);
|
|
4129
4077
|
};
|
|
4130
|
-
hookedInit
|
|
4078
|
+
hookedImaFns.add(hookedInit);
|
|
4131
4079
|
proto.init = hookedInit;
|
|
4132
4080
|
}
|
|
4133
|
-
if (proto && typeof proto.start === "function" && !proto.start
|
|
4081
|
+
if (proto && typeof proto.start === "function" && !hookedImaFns.has(proto.start)) {
|
|
4134
4082
|
const origStart = proto.start;
|
|
4135
4083
|
const hookedStart = function(...args) {
|
|
4136
4084
|
for (const instance of BidsparkPrebidAnalytics.getActiveInstances()) {
|
|
@@ -4141,7 +4089,7 @@ function hookAdsManagerPrototype(adsManagerCtorOrProto) {
|
|
|
4141
4089
|
}
|
|
4142
4090
|
return origStart.apply(this, args);
|
|
4143
4091
|
};
|
|
4144
|
-
hookedStart
|
|
4092
|
+
hookedImaFns.add(hookedStart);
|
|
4145
4093
|
proto.start = hookedStart;
|
|
4146
4094
|
}
|
|
4147
4095
|
} catch {
|
|
@@ -4152,7 +4100,7 @@ function hookAdsLoader(adsLoaderCtor) {
|
|
|
4152
4100
|
try {
|
|
4153
4101
|
const proto = adsLoaderCtor.prototype;
|
|
4154
4102
|
if (!proto) return;
|
|
4155
|
-
if (typeof proto.addEventListener === "function" && !proto.addEventListener
|
|
4103
|
+
if (typeof proto.addEventListener === "function" && !hookedImaFns.has(proto.addEventListener)) {
|
|
4156
4104
|
const origAddEventListener = proto.addEventListener;
|
|
4157
4105
|
const hookedAddEventListener = function(type, listener, ...rest) {
|
|
4158
4106
|
ensureAdsLoaderErrorListener(this, origAddEventListener);
|
|
@@ -4160,9 +4108,9 @@ function hookAdsLoader(adsLoaderCtor) {
|
|
|
4160
4108
|
let wrappedListener = adsLoaderListenerMap.get(listener);
|
|
4161
4109
|
if (!wrappedListener) {
|
|
4162
4110
|
wrappedListener = function(event) {
|
|
4163
|
-
if (event && typeof event.getAdsManager === "function" && !event.getAdsManager
|
|
4111
|
+
if (event && typeof event.getAdsManager === "function" && !hookedImaFns.has(event.getAdsManager)) {
|
|
4164
4112
|
const origGetAdsManager = event.getAdsManager;
|
|
4165
|
-
|
|
4113
|
+
const hookedGetAdsManager = function(...args) {
|
|
4166
4114
|
const adsManager = origGetAdsManager.apply(this, args);
|
|
4167
4115
|
if (adsManager) {
|
|
4168
4116
|
for (const sdk of BidsparkPrebidAnalytics.getActiveInstances()) {
|
|
@@ -4174,7 +4122,8 @@ function hookAdsLoader(adsLoaderCtor) {
|
|
|
4174
4122
|
}
|
|
4175
4123
|
return adsManager;
|
|
4176
4124
|
};
|
|
4177
|
-
|
|
4125
|
+
hookedImaFns.add(hookedGetAdsManager);
|
|
4126
|
+
event.getAdsManager = hookedGetAdsManager;
|
|
4178
4127
|
}
|
|
4179
4128
|
return listener.apply(this, arguments);
|
|
4180
4129
|
};
|
|
@@ -4184,16 +4133,16 @@ function hookAdsLoader(adsLoaderCtor) {
|
|
|
4184
4133
|
}
|
|
4185
4134
|
return origAddEventListener.call(this, type, listener, ...rest);
|
|
4186
4135
|
};
|
|
4187
|
-
hookedAddEventListener
|
|
4136
|
+
hookedImaFns.add(hookedAddEventListener);
|
|
4188
4137
|
proto.addEventListener = hookedAddEventListener;
|
|
4189
4138
|
}
|
|
4190
|
-
if (typeof proto.removeEventListener === "function" && !proto.removeEventListener
|
|
4139
|
+
if (typeof proto.removeEventListener === "function" && !hookedImaFns.has(proto.removeEventListener)) {
|
|
4191
4140
|
const origRemoveEventListener = proto.removeEventListener;
|
|
4192
4141
|
const hookedRemoveEventListener = function(type, listener, ...rest) {
|
|
4193
4142
|
const wrapped = typeof listener === "function" ? adsLoaderListenerMap.get(listener) : void 0;
|
|
4194
4143
|
return origRemoveEventListener.call(this, type, wrapped || listener, ...rest);
|
|
4195
4144
|
};
|
|
4196
|
-
hookedRemoveEventListener
|
|
4145
|
+
hookedImaFns.add(hookedRemoveEventListener);
|
|
4197
4146
|
proto.removeEventListener = hookedRemoveEventListener;
|
|
4198
4147
|
}
|
|
4199
4148
|
} catch {
|
|
@@ -4335,9 +4284,6 @@ function initImaInterception() {
|
|
|
4335
4284
|
}
|
|
4336
4285
|
}
|
|
4337
4286
|
}
|
|
4338
|
-
if (typeof window !== "undefined") {
|
|
4339
|
-
initImaInterception();
|
|
4340
|
-
}
|
|
4341
4287
|
function findCachedWinningBid(analytics, filter) {
|
|
4342
4288
|
const self = internals(analytics);
|
|
4343
4289
|
const now = Date.now();
|
|
@@ -4408,18 +4354,11 @@ function attachImaAdsManager(analytics, adsManager, options) {
|
|
|
4408
4354
|
return () => {
|
|
4409
4355
|
};
|
|
4410
4356
|
}
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
configurable: true,
|
|
4416
|
-
writable: true
|
|
4417
|
-
});
|
|
4418
|
-
} catch {
|
|
4419
|
-
adsManager.__bidsparkAttachedInstances = /* @__PURE__ */ new Map();
|
|
4420
|
-
}
|
|
4357
|
+
let attached = attachedImaManagers.get(adsManager);
|
|
4358
|
+
if (!attached) {
|
|
4359
|
+
attached = /* @__PURE__ */ new Map();
|
|
4360
|
+
attachedImaManagers.set(adsManager, attached);
|
|
4421
4361
|
}
|
|
4422
|
-
const attached = adsManager.__bidsparkAttachedInstances;
|
|
4423
4362
|
const previous = attached.get(analytics);
|
|
4424
4363
|
if (previous) {
|
|
4425
4364
|
if (!options) return () => {
|
|
@@ -4631,7 +4570,9 @@ function attachImaAdsManager(analytics, adsManager, options) {
|
|
|
4631
4570
|
}
|
|
4632
4571
|
const cleanup = () => {
|
|
4633
4572
|
activeAdSession = null;
|
|
4634
|
-
attached.
|
|
4573
|
+
if (attached.get(analytics) === cleanup) {
|
|
4574
|
+
attached.delete(analytics);
|
|
4575
|
+
}
|
|
4635
4576
|
for (const { type, handler } of listeners) {
|
|
4636
4577
|
try {
|
|
4637
4578
|
adsManager.removeEventListener(type, handler);
|
|
@@ -4676,14 +4617,22 @@ function attachVideoPlayer(analytics, target, options) {
|
|
|
4676
4617
|
const getWinningBid = () => {
|
|
4677
4618
|
return (auctionId ? self.getCachedBid(`${auctionId}:${adUnitCode}`) : void 0) || (auctionId && slotId !== adUnitCode ? self.getCachedBid(`${auctionId}:${slotId}`) : void 0) || self.getCachedBid(adUnitCode) || (slotId !== adUnitCode ? self.getCachedBid(slotId) : void 0);
|
|
4678
4619
|
};
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
videoEl = el.querySelector("video");
|
|
4620
|
+
const isVideoEl = Boolean(el?.tagName && el.tagName.toLowerCase() === "video");
|
|
4621
|
+
const resolveTargetVideo = (e) => {
|
|
4622
|
+
const target2 = e?.target;
|
|
4623
|
+
if (target2 && (typeof HTMLVideoElement !== "undefined" && target2 instanceof HTMLVideoElement || target2.tagName?.toLowerCase() === "video")) {
|
|
4624
|
+
return target2;
|
|
4685
4625
|
}
|
|
4686
|
-
|
|
4626
|
+
if (target2 && typeof target2.closest === "function") {
|
|
4627
|
+
const parentVideo = target2.closest("video");
|
|
4628
|
+
if (parentVideo) return parentVideo;
|
|
4629
|
+
}
|
|
4630
|
+
if (target2 && target2 !== el) {
|
|
4631
|
+
return null;
|
|
4632
|
+
}
|
|
4633
|
+
return isVideoEl ? el : el?.querySelector?.("video") ?? null;
|
|
4634
|
+
};
|
|
4635
|
+
const isForeignChildEvent = (e, targetVideo) => Boolean(e?.target && e.target !== el && !targetVideo);
|
|
4687
4636
|
const quartilesFired = {
|
|
4688
4637
|
q1: false,
|
|
4689
4638
|
q2: false,
|
|
@@ -4691,7 +4640,7 @@ function attachVideoPlayer(analytics, target, options) {
|
|
|
4691
4640
|
q4: false
|
|
4692
4641
|
};
|
|
4693
4642
|
const triggerPlaybackImpression = (activeVideo) => {
|
|
4694
|
-
const vEl = activeVideo ||
|
|
4643
|
+
const vEl = activeVideo || resolveTargetVideo();
|
|
4695
4644
|
const cached = getWinningBid();
|
|
4696
4645
|
const mergedBid = {
|
|
4697
4646
|
...cached?.rawBid || options?.bid,
|
|
@@ -4718,12 +4667,13 @@ function attachVideoPlayer(analytics, target, options) {
|
|
|
4718
4667
|
}
|
|
4719
4668
|
};
|
|
4720
4669
|
const handlePlaying = (e) => {
|
|
4670
|
+
const targetVideo = resolveTargetVideo(e);
|
|
4671
|
+
if (isForeignChildEvent(e, targetVideo)) return;
|
|
4721
4672
|
self.log("DEBUG", "HTML5 video playing event received");
|
|
4722
|
-
const targetVideo = e?.target instanceof HTMLVideoElement ? e.target : videoEl;
|
|
4723
4673
|
triggerPlaybackImpression(targetVideo);
|
|
4724
4674
|
};
|
|
4725
4675
|
const handleTimeUpdate = (e) => {
|
|
4726
|
-
const targetVideo = e
|
|
4676
|
+
const targetVideo = resolveTargetVideo(e);
|
|
4727
4677
|
if (targetVideo && targetVideo.currentTime > 0) {
|
|
4728
4678
|
triggerPlaybackImpression(targetVideo);
|
|
4729
4679
|
if (Number.isFinite(targetVideo.duration) && targetVideo.duration > 0) {
|
|
@@ -4743,15 +4693,17 @@ function attachVideoPlayer(analytics, target, options) {
|
|
|
4743
4693
|
}
|
|
4744
4694
|
}
|
|
4745
4695
|
};
|
|
4746
|
-
const handleEnded = () => {
|
|
4696
|
+
const handleEnded = (e) => {
|
|
4697
|
+
if (isForeignChildEvent(e, resolveTargetVideo(e))) return;
|
|
4747
4698
|
if (!quartilesFired.q4) {
|
|
4748
4699
|
quartilesFired.q4 = true;
|
|
4749
4700
|
options?.onMilestone?.("complete", slotId);
|
|
4750
4701
|
}
|
|
4751
4702
|
};
|
|
4752
4703
|
const handleError = (e) => {
|
|
4753
|
-
const targetVideo = e
|
|
4754
|
-
|
|
4704
|
+
const targetVideo = resolveTargetVideo(e);
|
|
4705
|
+
if (isForeignChildEvent(e, targetVideo)) return;
|
|
4706
|
+
const err = targetVideo?.error;
|
|
4755
4707
|
const cached = getWinningBid();
|
|
4756
4708
|
const msg = err ? `HTML5 video error code ${err.code}: ${err.message}` : "Video playback error";
|
|
4757
4709
|
self.log("WARN", msg);
|
|
@@ -4776,41 +4728,13 @@ function attachVideoPlayer(analytics, target, options) {
|
|
|
4776
4728
|
}
|
|
4777
4729
|
}
|
|
4778
4730
|
};
|
|
4779
|
-
const
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
const removeListenersFromVideo = (targetVideo) => {
|
|
4787
|
-
targetVideo.removeEventListener("playing", handlePlaying);
|
|
4788
|
-
targetVideo.removeEventListener("play", handlePlaying);
|
|
4789
|
-
targetVideo.removeEventListener("timeupdate", handleTimeUpdate);
|
|
4790
|
-
targetVideo.removeEventListener("ended", handleEnded);
|
|
4791
|
-
targetVideo.removeEventListener("error", handleError);
|
|
4792
|
-
};
|
|
4793
|
-
let mutationObserver = null;
|
|
4794
|
-
if (el && el !== videoEl) {
|
|
4795
|
-
el.addEventListener("playing", handlePlaying, true);
|
|
4796
|
-
el.addEventListener("play", handlePlaying, true);
|
|
4797
|
-
el.addEventListener("timeupdate", handleTimeUpdate, true);
|
|
4798
|
-
el.addEventListener("ended", handleEnded, true);
|
|
4799
|
-
el.addEventListener("error", handleError, true);
|
|
4800
|
-
}
|
|
4801
|
-
if (videoEl) {
|
|
4802
|
-
attachListenersToVideo(videoEl);
|
|
4803
|
-
}
|
|
4804
|
-
if (el && el.tagName?.toLowerCase() !== "video" && typeof MutationObserver !== "undefined") {
|
|
4805
|
-
mutationObserver = new MutationObserver(() => {
|
|
4806
|
-
const found = el.querySelector("video");
|
|
4807
|
-
if (found && found !== videoEl) {
|
|
4808
|
-
if (videoEl) removeListenersFromVideo(videoEl);
|
|
4809
|
-
videoEl = found;
|
|
4810
|
-
if (videoEl) attachListenersToVideo(videoEl);
|
|
4811
|
-
}
|
|
4812
|
-
});
|
|
4813
|
-
mutationObserver.observe(el, { childList: true, subtree: true });
|
|
4731
|
+
const useCapture = !isVideoEl;
|
|
4732
|
+
if (el) {
|
|
4733
|
+
el.addEventListener("playing", handlePlaying, useCapture);
|
|
4734
|
+
el.addEventListener("play", handlePlaying, useCapture);
|
|
4735
|
+
el.addEventListener("timeupdate", handleTimeUpdate, useCapture);
|
|
4736
|
+
el.addEventListener("ended", handleEnded, useCapture);
|
|
4737
|
+
el.addEventListener("error", handleError, useCapture);
|
|
4814
4738
|
}
|
|
4815
4739
|
const cachedInitial = getWinningBid();
|
|
4816
4740
|
if (options?.trackViewability !== false && el) {
|
|
@@ -4824,19 +4748,12 @@ function attachVideoPlayer(analytics, target, options) {
|
|
|
4824
4748
|
});
|
|
4825
4749
|
}
|
|
4826
4750
|
const cleanup = () => {
|
|
4827
|
-
if (
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
el.removeEventListener("
|
|
4833
|
-
el.removeEventListener("play", handlePlaying, true);
|
|
4834
|
-
el.removeEventListener("timeupdate", handleTimeUpdate, true);
|
|
4835
|
-
el.removeEventListener("ended", handleEnded, true);
|
|
4836
|
-
el.removeEventListener("error", handleError, true);
|
|
4837
|
-
}
|
|
4838
|
-
if (videoEl) {
|
|
4839
|
-
removeListenersFromVideo(videoEl);
|
|
4751
|
+
if (el) {
|
|
4752
|
+
el.removeEventListener("playing", handlePlaying, useCapture);
|
|
4753
|
+
el.removeEventListener("play", handlePlaying, useCapture);
|
|
4754
|
+
el.removeEventListener("timeupdate", handleTimeUpdate, useCapture);
|
|
4755
|
+
el.removeEventListener("ended", handleEnded, useCapture);
|
|
4756
|
+
el.removeEventListener("error", handleError, useCapture);
|
|
4840
4757
|
}
|
|
4841
4758
|
self.videoDetachCleanups.delete(cleanup);
|
|
4842
4759
|
};
|
|
@@ -4849,16 +4766,17 @@ BidsparkPrebidAnalytics.prototype.attachImaAdsManager = function(adsManager, opt
|
|
|
4849
4766
|
BidsparkPrebidAnalytics.prototype.attachVideoPlayer = function(target, options) {
|
|
4850
4767
|
return attachVideoPlayer(this, target, options);
|
|
4851
4768
|
};
|
|
4852
|
-
var
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4769
|
+
var imaAutoInterceptionInstalled = false;
|
|
4770
|
+
function installImaAutoInterception() {
|
|
4771
|
+
if (imaAutoInterceptionInstalled) return;
|
|
4772
|
+
imaAutoInterceptionInstalled = true;
|
|
4773
|
+
initImaInterception();
|
|
4774
|
+
const coreEnable = BidsparkPrebidAnalytics.prototype.enable;
|
|
4775
|
+
BidsparkPrebidAnalytics.prototype.enable = function() {
|
|
4776
|
+
coreEnable.call(this);
|
|
4856
4777
|
initImaInterception();
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
}
|
|
4860
|
-
}
|
|
4861
|
-
};
|
|
4778
|
+
};
|
|
4779
|
+
}
|
|
4862
4780
|
function normalizeImaEventName(name) {
|
|
4863
4781
|
if (!name) return "";
|
|
4864
4782
|
const lower = name.toLowerCase().replace(/[_-]/g, "");
|
|
@@ -4977,6 +4895,7 @@ var ImaAdsManagerStub = class {
|
|
|
4977
4895
|
};
|
|
4978
4896
|
|
|
4979
4897
|
// src/index.ts
|
|
4898
|
+
installImaAutoInterception();
|
|
4980
4899
|
function getAdsGlobal(alias = DEFAULT_ALIAS) {
|
|
4981
4900
|
if (typeof window === "undefined") {
|
|
4982
4901
|
return { q: [] };
|
|
@@ -5048,6 +4967,7 @@ function getAdsGlobal(alias = DEFAULT_ALIAS) {
|
|
|
5048
4967
|
getPrebidEventKey,
|
|
5049
4968
|
idToBytes,
|
|
5050
4969
|
idToString,
|
|
4970
|
+
installImaAutoInterception,
|
|
5051
4971
|
isAutomatedClient,
|
|
5052
4972
|
isSessionActive,
|
|
5053
4973
|
isTrustedEndpoint,
|