@bidkernel/analytics 0.12.0 → 0.17.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 +130 -56
- package/dist/index.d.ts +130 -56
- package/dist/index.js +1412 -1333
- package/dist/index.mjs +1408 -1333
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -23,21 +23,9 @@ interface BidTrace {
|
|
|
23
23
|
creativeId?: string | undefined;
|
|
24
24
|
}
|
|
25
25
|
declare const BidTrace: MessageFns<BidTrace>;
|
|
26
|
-
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
27
|
-
type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
28
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
29
|
-
} : Partial<T>;
|
|
30
|
-
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
31
|
-
type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
32
|
-
[K in keyof P]: Exact<P[K], I[K]>;
|
|
33
|
-
} & {
|
|
34
|
-
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
35
|
-
};
|
|
36
26
|
interface MessageFns<T> {
|
|
37
27
|
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
38
28
|
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
39
|
-
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
40
|
-
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
41
29
|
}
|
|
42
30
|
|
|
43
31
|
interface AnalyticsConfig {
|
|
@@ -54,6 +42,13 @@ interface AnalyticsConfig {
|
|
|
54
42
|
errorsEnabled?: boolean;
|
|
55
43
|
/** Whether to enable client-side IAB viewability and time-in-view measurement. Defaults to true. */
|
|
56
44
|
viewabilityEnabled?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether identifiers may be written to localStorage (session id and its
|
|
47
|
+
* timestamp, exit batches). Defaults to true. Set false until storage
|
|
48
|
+
* consent is known, then flip with setStorageAllowed(true); events are
|
|
49
|
+
* always collected and sent regardless.
|
|
50
|
+
*/
|
|
51
|
+
storageAllowed?: boolean;
|
|
57
52
|
logLevel?: "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
58
53
|
/** Window global holding the Prebid instance to attach to. Defaults to "pbjs". */
|
|
59
54
|
pbjsGlobalName?: string;
|
|
@@ -76,24 +71,6 @@ interface SlotObserveOptions {
|
|
|
76
71
|
refreshIndex?: number;
|
|
77
72
|
emitRefreshEvent?: boolean;
|
|
78
73
|
}
|
|
79
|
-
interface VideoPlayerOptions {
|
|
80
|
-
/** The ad unit code / slot identifier for analytics reporting */
|
|
81
|
-
adUnitCode?: string;
|
|
82
|
-
slotId?: string;
|
|
83
|
-
auctionId?: string;
|
|
84
|
-
transactionId?: string;
|
|
85
|
-
bid?: any;
|
|
86
|
-
metadata?: Record<string, string>;
|
|
87
|
-
refreshIndex?: number;
|
|
88
|
-
/** Whether to automatically track IAB video viewability (2s continuous >=50% in-view) and Time-in-View. Defaults to true. */
|
|
89
|
-
trackViewability?: boolean;
|
|
90
|
-
/** Custom callback when impression is triggered */
|
|
91
|
-
onImpression?: (slotId: string, details: any) => void;
|
|
92
|
-
/** Custom callback when playback milestone reached (25%, 50%, 75%, 100%) */
|
|
93
|
-
onMilestone?: (milestone: "firstQuartile" | "midpoint" | "thirdQuartile" | "complete", slotId: string) => void;
|
|
94
|
-
/** Custom callback when render / playback error occurs */
|
|
95
|
-
onError?: (error: any) => void;
|
|
96
|
-
}
|
|
97
74
|
interface CachedWinningBid {
|
|
98
75
|
bidTrace: BidTrace;
|
|
99
76
|
auctionId: string;
|
|
@@ -108,6 +85,7 @@ interface SlotViewabilityState {
|
|
|
108
85
|
timeInViewMs: number;
|
|
109
86
|
refreshIndex: number;
|
|
110
87
|
}
|
|
88
|
+
declare const CACHED_BID_TTL_MS: number;
|
|
111
89
|
/**
|
|
112
90
|
* The ingest endpoint decides where auction telemetry -- CPMs, deal IDs,
|
|
113
91
|
* advertiser domains, user and session IDs -- is shipped, and it arrives from
|
|
@@ -123,6 +101,15 @@ interface SlotViewabilityState {
|
|
|
123
101
|
* registerPrebidAnalytics.
|
|
124
102
|
*/
|
|
125
103
|
declare function isTrustedEndpoint(raw: string): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The visitor's session id: a 30-minute rolling session persisted in
|
|
106
|
+
* localStorage when storage is allowed, kept in memory otherwise. A session
|
|
107
|
+
* begun in memory (before storage consent) is adopted and persisted the
|
|
108
|
+
* first time this runs with storage allowed, so consent never splits a
|
|
109
|
+
* session. Exported so an integration can report the same id the adapter
|
|
110
|
+
* stamps on its batches.
|
|
111
|
+
*/
|
|
112
|
+
declare function getOrCreateSessionId(): string;
|
|
126
113
|
/**
|
|
127
114
|
* Canonical duplicate-detection key for a Prebid event. Shared by the adapter
|
|
128
115
|
* and the diagnostic extension so the two can never drift apart. Covers the
|
|
@@ -138,17 +125,16 @@ declare class PrebidEventDeduper {
|
|
|
138
125
|
private seenKeys;
|
|
139
126
|
isDuplicate(eventName: string, data: any): boolean;
|
|
140
127
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Hooks Google IMA SDK methods to automatically intercept AdsManager creation
|
|
143
|
-
* across active BidkernelPrebidAnalytics instances without requiring manual
|
|
144
|
-
* publisher calls to attachImaAdsManager.
|
|
145
|
-
*/
|
|
146
|
-
declare function hookImaPrototype(ima: any): void;
|
|
147
|
-
declare function initImaInterception(): void;
|
|
148
128
|
declare class BidkernelPrebidAnalytics {
|
|
149
129
|
private static activeInstances;
|
|
150
130
|
static getActiveInstances(): Set<BidkernelPrebidAnalytics>;
|
|
151
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Allows or forbids localStorage writes for every instance on the page.
|
|
133
|
+
* Collection and delivery are unaffected: only the persisted session id,
|
|
134
|
+
* its timestamp and exit batches are gated.
|
|
135
|
+
*/
|
|
136
|
+
static setStorageAllowed(allowed: boolean): void;
|
|
137
|
+
static isStorageAllowed(): boolean;
|
|
152
138
|
private config;
|
|
153
139
|
private queue;
|
|
154
140
|
private errorCount;
|
|
@@ -171,6 +157,10 @@ declare class BidkernelPrebidAnalytics {
|
|
|
171
157
|
private slotRefreshIndices;
|
|
172
158
|
private slotLastAuctionIds;
|
|
173
159
|
private pendingThresholdListeners;
|
|
160
|
+
private pendingViewableListeners;
|
|
161
|
+
private slotElements;
|
|
162
|
+
private clickDetachCleanups;
|
|
163
|
+
private lastClickAt;
|
|
174
164
|
private slotEmittedImpressionKeys;
|
|
175
165
|
private cachedWinningBids;
|
|
176
166
|
private videoDetachCleanups;
|
|
@@ -178,10 +168,48 @@ declare class BidkernelPrebidAnalytics {
|
|
|
178
168
|
private logger;
|
|
179
169
|
constructor(config: AnalyticsConfig);
|
|
180
170
|
enable(): void;
|
|
171
|
+
/**
|
|
172
|
+
* Binds the Prebid event handlers on the configured global and replays
|
|
173
|
+
* pbjs.getEvents() history. enable() calls this when attachPbjsListeners is
|
|
174
|
+
* true. An integration that loads Prebid lazily constructs the instance with
|
|
175
|
+
* attachPbjsListeners=false and calls this once pbjs exists; disable() (and
|
|
176
|
+
* therefore navigate()) drops the handlers, so call it again after either.
|
|
177
|
+
* Idempotent. Returns true when handlers are bound after the call, false
|
|
178
|
+
* when the instance is disabled or pbjs.onEvent is not available yet.
|
|
179
|
+
*/
|
|
180
|
+
attachPbjs(): boolean;
|
|
181
181
|
disable(): void;
|
|
182
182
|
private handleVisibilityChange;
|
|
183
183
|
private handleIntersection;
|
|
184
184
|
private handleDwellComplete;
|
|
185
|
+
private notifyViewable;
|
|
186
|
+
/**
|
|
187
|
+
* Calls back once per render cycle when the slot has met the IAB viewable
|
|
188
|
+
* standard this adapter measures (immediately if it already has). Works
|
|
189
|
+
* before the slot is observed: the listener waits for observeSlot. Returns
|
|
190
|
+
* an unsubscribe function.
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* Names the element to measure for a slot when the creative renders
|
|
194
|
+
* somewhere other than the slot element (a sticky bar, an interstitial).
|
|
195
|
+
* Applies to the current cycle at once and to every later render.
|
|
196
|
+
*/
|
|
197
|
+
setSlotElement(slotId: string, element: HTMLElement): void;
|
|
198
|
+
/**
|
|
199
|
+
* Records a click on the slot's current creative, attributed to the cached
|
|
200
|
+
* winning bid. Repeats within one second are one click. Returns whether a
|
|
201
|
+
* CLICK was recorded.
|
|
202
|
+
*/
|
|
203
|
+
recordClick(slotId: string, options?: {
|
|
204
|
+
metadata?: Record<string, string>;
|
|
205
|
+
}): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Detects clicks into a cross-origin creative frame: a click inside an
|
|
208
|
+
* iframe moves focus into it and blurs the window. Returns a detach
|
|
209
|
+
* function; every tracker is detached on disable().
|
|
210
|
+
*/
|
|
211
|
+
attachClickTracker(element: HTMLElement, slotId: string): () => void;
|
|
212
|
+
onViewable(slotId: string, callback: (slotId: string) => void): () => void;
|
|
185
213
|
private scheduleThresholdTimers;
|
|
186
214
|
private checkThresholdListeners;
|
|
187
215
|
private getCurrentTimeInView;
|
|
@@ -204,11 +232,6 @@ declare class BidkernelPrebidAnalytics {
|
|
|
204
232
|
* consecutively, so eviction takes a whole bid's aliases together.
|
|
205
233
|
*/
|
|
206
234
|
private pruneCachedWinningBids;
|
|
207
|
-
/**
|
|
208
|
-
* Searches cached winning bids for an entry matching the given filters (creativeId,
|
|
209
|
-
* adId, or mediaType), falling back to the most recent winning video bid.
|
|
210
|
-
*/
|
|
211
|
-
private findCachedWinningBid;
|
|
212
235
|
/** Records a dedup key, evicting oldest-first at the cap. */
|
|
213
236
|
private addImpressionKey;
|
|
214
237
|
/**
|
|
@@ -222,18 +245,6 @@ declare class BidkernelPrebidAnalytics {
|
|
|
222
245
|
recordImpression(slotId: string, options?: SlotObserveOptions & {
|
|
223
246
|
bid?: any;
|
|
224
247
|
}): boolean;
|
|
225
|
-
/**
|
|
226
|
-
* Bridges Google IMA SDK AdsManager events to Bidkernel analytics.
|
|
227
|
-
* Defers IMPRESSION emission until AdEvent.STARTED (or IMPRESSION),
|
|
228
|
-
* tracks milestones (FIRST_QUARTILE, MIDPOINT, THIRD_QUARTILE, COMPLETE),
|
|
229
|
-
* and handles AD_ERROR.
|
|
230
|
-
*/
|
|
231
|
-
attachImaAdsManager(adsManager: any, options?: VideoPlayerOptions): () => void;
|
|
232
|
-
/**
|
|
233
|
-
* Attaches render hooks and viewability tracking to a video player.
|
|
234
|
-
* Supports HTML5 <video> elements, container elements, or Google IMA AdsManager.
|
|
235
|
-
*/
|
|
236
|
-
attachVideoPlayer(target: any, options?: VideoPlayerOptions): () => void;
|
|
237
248
|
onTimeInViewThreshold(slotId: string, thresholdMs: number, callback: (slotId: string, durationMs: number) => void): () => void;
|
|
238
249
|
getViewabilityState(slotId: string): SlotViewabilityState | undefined;
|
|
239
250
|
/** The validated ingest endpoint in use, or "" when none passed validation. */
|
|
@@ -271,6 +282,69 @@ declare class BidkernelPrebidAnalytics {
|
|
|
271
282
|
}
|
|
272
283
|
declare function registerPrebidAnalytics(pbjsGlobalName?: string, defaults?: Partial<AnalyticsConfig>): void;
|
|
273
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Video and Google IMA support for the analytics adapter: render-triggered
|
|
287
|
+
* impressions from a video player or an IMA AdsManager, and the automatic
|
|
288
|
+
* IMA interception that hooks every AdsManager the page creates.
|
|
289
|
+
*
|
|
290
|
+
* Importing this module installs attachVideoPlayer and attachImaAdsManager
|
|
291
|
+
* on BidkernelPrebidAnalytics and starts the interception, so the package's
|
|
292
|
+
* public entry (index.ts) and the standalone bundle carry the full API. The
|
|
293
|
+
* display-only SDK imports the core module alone and ships none of this.
|
|
294
|
+
*/
|
|
295
|
+
interface VideoPlayerOptions {
|
|
296
|
+
/** The ad unit code / slot identifier for analytics reporting */
|
|
297
|
+
adUnitCode?: string;
|
|
298
|
+
slotId?: string;
|
|
299
|
+
auctionId?: string;
|
|
300
|
+
transactionId?: string;
|
|
301
|
+
bid?: any;
|
|
302
|
+
metadata?: Record<string, string>;
|
|
303
|
+
refreshIndex?: number;
|
|
304
|
+
/** Whether to automatically track IAB video viewability (2s continuous >=50% in-view) and Time-in-View. Defaults to true. */
|
|
305
|
+
trackViewability?: boolean;
|
|
306
|
+
/** Custom callback when impression is triggered */
|
|
307
|
+
onImpression?: (slotId: string, details: any) => void;
|
|
308
|
+
/** Custom callback when playback milestone reached (25%, 50%, 75%, 100%) */
|
|
309
|
+
onMilestone?: (milestone: "firstQuartile" | "midpoint" | "thirdQuartile" | "complete", slotId: string) => void;
|
|
310
|
+
/** Custom callback when render / playback error occurs */
|
|
311
|
+
onError?: (error: any) => void;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Hooks Google IMA SDK methods to automatically intercept AdsManager creation
|
|
315
|
+
* across active BidkernelPrebidAnalytics instances without requiring manual
|
|
316
|
+
* publisher calls to attachImaAdsManager.
|
|
317
|
+
*/
|
|
318
|
+
declare function hookImaPrototype(ima: any): void;
|
|
319
|
+
declare function initImaInterception(): void;
|
|
320
|
+
/**
|
|
321
|
+
* Bridges Google IMA SDK AdsManager events to Bidkernel analytics.
|
|
322
|
+
* Defers IMPRESSION emission until AdEvent.STARTED (or IMPRESSION),
|
|
323
|
+
* tracks milestones (FIRST_QUARTILE, MIDPOINT, THIRD_QUARTILE, COMPLETE),
|
|
324
|
+
* and handles AD_ERROR.
|
|
325
|
+
*/
|
|
326
|
+
declare function attachImaAdsManager(analytics: BidkernelPrebidAnalytics, adsManager: any, options?: VideoPlayerOptions): () => void;
|
|
327
|
+
/**
|
|
328
|
+
* Attaches render hooks and viewability tracking to a video player.
|
|
329
|
+
* Supports HTML5 <video> elements, container elements, or Google IMA AdsManager.
|
|
330
|
+
*/
|
|
331
|
+
declare function attachVideoPlayer(analytics: BidkernelPrebidAnalytics, target: any, options?: VideoPlayerOptions): () => void;
|
|
332
|
+
declare module "./prebid-analytics" {
|
|
333
|
+
interface BidkernelPrebidAnalytics {
|
|
334
|
+
/**
|
|
335
|
+
* Bridges Google IMA SDK AdsManager events to Bidkernel analytics: the
|
|
336
|
+
* IMPRESSION is deferred until AdEvent.STARTED (or IMPRESSION), quartile
|
|
337
|
+
* milestones are reported, and AD_ERROR becomes an adRenderFailed.
|
|
338
|
+
*/
|
|
339
|
+
attachImaAdsManager(adsManager: any, options?: VideoPlayerOptions): () => void;
|
|
340
|
+
/**
|
|
341
|
+
* Attaches render hooks and viewability tracking to a video player: an
|
|
342
|
+
* HTML5 <video> element, a container element, or an IMA AdsManager.
|
|
343
|
+
*/
|
|
344
|
+
attachVideoPlayer(target: any, options?: VideoPlayerOptions): () => void;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
274
348
|
type SlotSize = [number, number];
|
|
275
349
|
type SlotSizes = SlotSize[];
|
|
276
350
|
interface SizeMapping {
|
|
@@ -337,4 +411,4 @@ interface AdsGlobal {
|
|
|
337
411
|
*/
|
|
338
412
|
declare function getbidkernel(alias?: string): AdsGlobal;
|
|
339
413
|
|
|
340
|
-
export { type AdsGlobal, type AnalyticsConfig, BidkernelPrebidAnalytics, type CachedWinningBid, PrebidEventDeduper, type SizeMapping, type SlotConfig, type SlotObserveOptions, type SlotSize, type SlotSizes, type SlotViewabilityState, type VideoPlayerOptions, getPrebidEventKey, getbidkernel, hookImaPrototype, initImaInterception, isTrustedEndpoint, registerPrebidAnalytics };
|
|
414
|
+
export { type AdsGlobal, type AnalyticsConfig, BidkernelPrebidAnalytics, CACHED_BID_TTL_MS, type CachedWinningBid, PrebidEventDeduper, type SizeMapping, type SlotConfig, type SlotObserveOptions, type SlotSize, type SlotSizes, type SlotViewabilityState, type VideoPlayerOptions, attachImaAdsManager, attachVideoPlayer, getOrCreateSessionId, getPrebidEventKey, getbidkernel, hookImaPrototype, initImaInterception, isTrustedEndpoint, registerPrebidAnalytics };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,21 +23,9 @@ interface BidTrace {
|
|
|
23
23
|
creativeId?: string | undefined;
|
|
24
24
|
}
|
|
25
25
|
declare const BidTrace: MessageFns<BidTrace>;
|
|
26
|
-
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
27
|
-
type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
28
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
29
|
-
} : Partial<T>;
|
|
30
|
-
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
31
|
-
type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
32
|
-
[K in keyof P]: Exact<P[K], I[K]>;
|
|
33
|
-
} & {
|
|
34
|
-
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
35
|
-
};
|
|
36
26
|
interface MessageFns<T> {
|
|
37
27
|
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
38
28
|
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
39
|
-
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
40
|
-
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
41
29
|
}
|
|
42
30
|
|
|
43
31
|
interface AnalyticsConfig {
|
|
@@ -54,6 +42,13 @@ interface AnalyticsConfig {
|
|
|
54
42
|
errorsEnabled?: boolean;
|
|
55
43
|
/** Whether to enable client-side IAB viewability and time-in-view measurement. Defaults to true. */
|
|
56
44
|
viewabilityEnabled?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether identifiers may be written to localStorage (session id and its
|
|
47
|
+
* timestamp, exit batches). Defaults to true. Set false until storage
|
|
48
|
+
* consent is known, then flip with setStorageAllowed(true); events are
|
|
49
|
+
* always collected and sent regardless.
|
|
50
|
+
*/
|
|
51
|
+
storageAllowed?: boolean;
|
|
57
52
|
logLevel?: "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
58
53
|
/** Window global holding the Prebid instance to attach to. Defaults to "pbjs". */
|
|
59
54
|
pbjsGlobalName?: string;
|
|
@@ -76,24 +71,6 @@ interface SlotObserveOptions {
|
|
|
76
71
|
refreshIndex?: number;
|
|
77
72
|
emitRefreshEvent?: boolean;
|
|
78
73
|
}
|
|
79
|
-
interface VideoPlayerOptions {
|
|
80
|
-
/** The ad unit code / slot identifier for analytics reporting */
|
|
81
|
-
adUnitCode?: string;
|
|
82
|
-
slotId?: string;
|
|
83
|
-
auctionId?: string;
|
|
84
|
-
transactionId?: string;
|
|
85
|
-
bid?: any;
|
|
86
|
-
metadata?: Record<string, string>;
|
|
87
|
-
refreshIndex?: number;
|
|
88
|
-
/** Whether to automatically track IAB video viewability (2s continuous >=50% in-view) and Time-in-View. Defaults to true. */
|
|
89
|
-
trackViewability?: boolean;
|
|
90
|
-
/** Custom callback when impression is triggered */
|
|
91
|
-
onImpression?: (slotId: string, details: any) => void;
|
|
92
|
-
/** Custom callback when playback milestone reached (25%, 50%, 75%, 100%) */
|
|
93
|
-
onMilestone?: (milestone: "firstQuartile" | "midpoint" | "thirdQuartile" | "complete", slotId: string) => void;
|
|
94
|
-
/** Custom callback when render / playback error occurs */
|
|
95
|
-
onError?: (error: any) => void;
|
|
96
|
-
}
|
|
97
74
|
interface CachedWinningBid {
|
|
98
75
|
bidTrace: BidTrace;
|
|
99
76
|
auctionId: string;
|
|
@@ -108,6 +85,7 @@ interface SlotViewabilityState {
|
|
|
108
85
|
timeInViewMs: number;
|
|
109
86
|
refreshIndex: number;
|
|
110
87
|
}
|
|
88
|
+
declare const CACHED_BID_TTL_MS: number;
|
|
111
89
|
/**
|
|
112
90
|
* The ingest endpoint decides where auction telemetry -- CPMs, deal IDs,
|
|
113
91
|
* advertiser domains, user and session IDs -- is shipped, and it arrives from
|
|
@@ -123,6 +101,15 @@ interface SlotViewabilityState {
|
|
|
123
101
|
* registerPrebidAnalytics.
|
|
124
102
|
*/
|
|
125
103
|
declare function isTrustedEndpoint(raw: string): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The visitor's session id: a 30-minute rolling session persisted in
|
|
106
|
+
* localStorage when storage is allowed, kept in memory otherwise. A session
|
|
107
|
+
* begun in memory (before storage consent) is adopted and persisted the
|
|
108
|
+
* first time this runs with storage allowed, so consent never splits a
|
|
109
|
+
* session. Exported so an integration can report the same id the adapter
|
|
110
|
+
* stamps on its batches.
|
|
111
|
+
*/
|
|
112
|
+
declare function getOrCreateSessionId(): string;
|
|
126
113
|
/**
|
|
127
114
|
* Canonical duplicate-detection key for a Prebid event. Shared by the adapter
|
|
128
115
|
* and the diagnostic extension so the two can never drift apart. Covers the
|
|
@@ -138,17 +125,16 @@ declare class PrebidEventDeduper {
|
|
|
138
125
|
private seenKeys;
|
|
139
126
|
isDuplicate(eventName: string, data: any): boolean;
|
|
140
127
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Hooks Google IMA SDK methods to automatically intercept AdsManager creation
|
|
143
|
-
* across active BidkernelPrebidAnalytics instances without requiring manual
|
|
144
|
-
* publisher calls to attachImaAdsManager.
|
|
145
|
-
*/
|
|
146
|
-
declare function hookImaPrototype(ima: any): void;
|
|
147
|
-
declare function initImaInterception(): void;
|
|
148
128
|
declare class BidkernelPrebidAnalytics {
|
|
149
129
|
private static activeInstances;
|
|
150
130
|
static getActiveInstances(): Set<BidkernelPrebidAnalytics>;
|
|
151
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Allows or forbids localStorage writes for every instance on the page.
|
|
133
|
+
* Collection and delivery are unaffected: only the persisted session id,
|
|
134
|
+
* its timestamp and exit batches are gated.
|
|
135
|
+
*/
|
|
136
|
+
static setStorageAllowed(allowed: boolean): void;
|
|
137
|
+
static isStorageAllowed(): boolean;
|
|
152
138
|
private config;
|
|
153
139
|
private queue;
|
|
154
140
|
private errorCount;
|
|
@@ -171,6 +157,10 @@ declare class BidkernelPrebidAnalytics {
|
|
|
171
157
|
private slotRefreshIndices;
|
|
172
158
|
private slotLastAuctionIds;
|
|
173
159
|
private pendingThresholdListeners;
|
|
160
|
+
private pendingViewableListeners;
|
|
161
|
+
private slotElements;
|
|
162
|
+
private clickDetachCleanups;
|
|
163
|
+
private lastClickAt;
|
|
174
164
|
private slotEmittedImpressionKeys;
|
|
175
165
|
private cachedWinningBids;
|
|
176
166
|
private videoDetachCleanups;
|
|
@@ -178,10 +168,48 @@ declare class BidkernelPrebidAnalytics {
|
|
|
178
168
|
private logger;
|
|
179
169
|
constructor(config: AnalyticsConfig);
|
|
180
170
|
enable(): void;
|
|
171
|
+
/**
|
|
172
|
+
* Binds the Prebid event handlers on the configured global and replays
|
|
173
|
+
* pbjs.getEvents() history. enable() calls this when attachPbjsListeners is
|
|
174
|
+
* true. An integration that loads Prebid lazily constructs the instance with
|
|
175
|
+
* attachPbjsListeners=false and calls this once pbjs exists; disable() (and
|
|
176
|
+
* therefore navigate()) drops the handlers, so call it again after either.
|
|
177
|
+
* Idempotent. Returns true when handlers are bound after the call, false
|
|
178
|
+
* when the instance is disabled or pbjs.onEvent is not available yet.
|
|
179
|
+
*/
|
|
180
|
+
attachPbjs(): boolean;
|
|
181
181
|
disable(): void;
|
|
182
182
|
private handleVisibilityChange;
|
|
183
183
|
private handleIntersection;
|
|
184
184
|
private handleDwellComplete;
|
|
185
|
+
private notifyViewable;
|
|
186
|
+
/**
|
|
187
|
+
* Calls back once per render cycle when the slot has met the IAB viewable
|
|
188
|
+
* standard this adapter measures (immediately if it already has). Works
|
|
189
|
+
* before the slot is observed: the listener waits for observeSlot. Returns
|
|
190
|
+
* an unsubscribe function.
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* Names the element to measure for a slot when the creative renders
|
|
194
|
+
* somewhere other than the slot element (a sticky bar, an interstitial).
|
|
195
|
+
* Applies to the current cycle at once and to every later render.
|
|
196
|
+
*/
|
|
197
|
+
setSlotElement(slotId: string, element: HTMLElement): void;
|
|
198
|
+
/**
|
|
199
|
+
* Records a click on the slot's current creative, attributed to the cached
|
|
200
|
+
* winning bid. Repeats within one second are one click. Returns whether a
|
|
201
|
+
* CLICK was recorded.
|
|
202
|
+
*/
|
|
203
|
+
recordClick(slotId: string, options?: {
|
|
204
|
+
metadata?: Record<string, string>;
|
|
205
|
+
}): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* Detects clicks into a cross-origin creative frame: a click inside an
|
|
208
|
+
* iframe moves focus into it and blurs the window. Returns a detach
|
|
209
|
+
* function; every tracker is detached on disable().
|
|
210
|
+
*/
|
|
211
|
+
attachClickTracker(element: HTMLElement, slotId: string): () => void;
|
|
212
|
+
onViewable(slotId: string, callback: (slotId: string) => void): () => void;
|
|
185
213
|
private scheduleThresholdTimers;
|
|
186
214
|
private checkThresholdListeners;
|
|
187
215
|
private getCurrentTimeInView;
|
|
@@ -204,11 +232,6 @@ declare class BidkernelPrebidAnalytics {
|
|
|
204
232
|
* consecutively, so eviction takes a whole bid's aliases together.
|
|
205
233
|
*/
|
|
206
234
|
private pruneCachedWinningBids;
|
|
207
|
-
/**
|
|
208
|
-
* Searches cached winning bids for an entry matching the given filters (creativeId,
|
|
209
|
-
* adId, or mediaType), falling back to the most recent winning video bid.
|
|
210
|
-
*/
|
|
211
|
-
private findCachedWinningBid;
|
|
212
235
|
/** Records a dedup key, evicting oldest-first at the cap. */
|
|
213
236
|
private addImpressionKey;
|
|
214
237
|
/**
|
|
@@ -222,18 +245,6 @@ declare class BidkernelPrebidAnalytics {
|
|
|
222
245
|
recordImpression(slotId: string, options?: SlotObserveOptions & {
|
|
223
246
|
bid?: any;
|
|
224
247
|
}): boolean;
|
|
225
|
-
/**
|
|
226
|
-
* Bridges Google IMA SDK AdsManager events to Bidkernel analytics.
|
|
227
|
-
* Defers IMPRESSION emission until AdEvent.STARTED (or IMPRESSION),
|
|
228
|
-
* tracks milestones (FIRST_QUARTILE, MIDPOINT, THIRD_QUARTILE, COMPLETE),
|
|
229
|
-
* and handles AD_ERROR.
|
|
230
|
-
*/
|
|
231
|
-
attachImaAdsManager(adsManager: any, options?: VideoPlayerOptions): () => void;
|
|
232
|
-
/**
|
|
233
|
-
* Attaches render hooks and viewability tracking to a video player.
|
|
234
|
-
* Supports HTML5 <video> elements, container elements, or Google IMA AdsManager.
|
|
235
|
-
*/
|
|
236
|
-
attachVideoPlayer(target: any, options?: VideoPlayerOptions): () => void;
|
|
237
248
|
onTimeInViewThreshold(slotId: string, thresholdMs: number, callback: (slotId: string, durationMs: number) => void): () => void;
|
|
238
249
|
getViewabilityState(slotId: string): SlotViewabilityState | undefined;
|
|
239
250
|
/** The validated ingest endpoint in use, or "" when none passed validation. */
|
|
@@ -271,6 +282,69 @@ declare class BidkernelPrebidAnalytics {
|
|
|
271
282
|
}
|
|
272
283
|
declare function registerPrebidAnalytics(pbjsGlobalName?: string, defaults?: Partial<AnalyticsConfig>): void;
|
|
273
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Video and Google IMA support for the analytics adapter: render-triggered
|
|
287
|
+
* impressions from a video player or an IMA AdsManager, and the automatic
|
|
288
|
+
* IMA interception that hooks every AdsManager the page creates.
|
|
289
|
+
*
|
|
290
|
+
* Importing this module installs attachVideoPlayer and attachImaAdsManager
|
|
291
|
+
* on BidkernelPrebidAnalytics and starts the interception, so the package's
|
|
292
|
+
* public entry (index.ts) and the standalone bundle carry the full API. The
|
|
293
|
+
* display-only SDK imports the core module alone and ships none of this.
|
|
294
|
+
*/
|
|
295
|
+
interface VideoPlayerOptions {
|
|
296
|
+
/** The ad unit code / slot identifier for analytics reporting */
|
|
297
|
+
adUnitCode?: string;
|
|
298
|
+
slotId?: string;
|
|
299
|
+
auctionId?: string;
|
|
300
|
+
transactionId?: string;
|
|
301
|
+
bid?: any;
|
|
302
|
+
metadata?: Record<string, string>;
|
|
303
|
+
refreshIndex?: number;
|
|
304
|
+
/** Whether to automatically track IAB video viewability (2s continuous >=50% in-view) and Time-in-View. Defaults to true. */
|
|
305
|
+
trackViewability?: boolean;
|
|
306
|
+
/** Custom callback when impression is triggered */
|
|
307
|
+
onImpression?: (slotId: string, details: any) => void;
|
|
308
|
+
/** Custom callback when playback milestone reached (25%, 50%, 75%, 100%) */
|
|
309
|
+
onMilestone?: (milestone: "firstQuartile" | "midpoint" | "thirdQuartile" | "complete", slotId: string) => void;
|
|
310
|
+
/** Custom callback when render / playback error occurs */
|
|
311
|
+
onError?: (error: any) => void;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Hooks Google IMA SDK methods to automatically intercept AdsManager creation
|
|
315
|
+
* across active BidkernelPrebidAnalytics instances without requiring manual
|
|
316
|
+
* publisher calls to attachImaAdsManager.
|
|
317
|
+
*/
|
|
318
|
+
declare function hookImaPrototype(ima: any): void;
|
|
319
|
+
declare function initImaInterception(): void;
|
|
320
|
+
/**
|
|
321
|
+
* Bridges Google IMA SDK AdsManager events to Bidkernel analytics.
|
|
322
|
+
* Defers IMPRESSION emission until AdEvent.STARTED (or IMPRESSION),
|
|
323
|
+
* tracks milestones (FIRST_QUARTILE, MIDPOINT, THIRD_QUARTILE, COMPLETE),
|
|
324
|
+
* and handles AD_ERROR.
|
|
325
|
+
*/
|
|
326
|
+
declare function attachImaAdsManager(analytics: BidkernelPrebidAnalytics, adsManager: any, options?: VideoPlayerOptions): () => void;
|
|
327
|
+
/**
|
|
328
|
+
* Attaches render hooks and viewability tracking to a video player.
|
|
329
|
+
* Supports HTML5 <video> elements, container elements, or Google IMA AdsManager.
|
|
330
|
+
*/
|
|
331
|
+
declare function attachVideoPlayer(analytics: BidkernelPrebidAnalytics, target: any, options?: VideoPlayerOptions): () => void;
|
|
332
|
+
declare module "./prebid-analytics" {
|
|
333
|
+
interface BidkernelPrebidAnalytics {
|
|
334
|
+
/**
|
|
335
|
+
* Bridges Google IMA SDK AdsManager events to Bidkernel analytics: the
|
|
336
|
+
* IMPRESSION is deferred until AdEvent.STARTED (or IMPRESSION), quartile
|
|
337
|
+
* milestones are reported, and AD_ERROR becomes an adRenderFailed.
|
|
338
|
+
*/
|
|
339
|
+
attachImaAdsManager(adsManager: any, options?: VideoPlayerOptions): () => void;
|
|
340
|
+
/**
|
|
341
|
+
* Attaches render hooks and viewability tracking to a video player: an
|
|
342
|
+
* HTML5 <video> element, a container element, or an IMA AdsManager.
|
|
343
|
+
*/
|
|
344
|
+
attachVideoPlayer(target: any, options?: VideoPlayerOptions): () => void;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
274
348
|
type SlotSize = [number, number];
|
|
275
349
|
type SlotSizes = SlotSize[];
|
|
276
350
|
interface SizeMapping {
|
|
@@ -337,4 +411,4 @@ interface AdsGlobal {
|
|
|
337
411
|
*/
|
|
338
412
|
declare function getbidkernel(alias?: string): AdsGlobal;
|
|
339
413
|
|
|
340
|
-
export { type AdsGlobal, type AnalyticsConfig, BidkernelPrebidAnalytics, type CachedWinningBid, PrebidEventDeduper, type SizeMapping, type SlotConfig, type SlotObserveOptions, type SlotSize, type SlotSizes, type SlotViewabilityState, type VideoPlayerOptions, getPrebidEventKey, getbidkernel, hookImaPrototype, initImaInterception, isTrustedEndpoint, registerPrebidAnalytics };
|
|
414
|
+
export { type AdsGlobal, type AnalyticsConfig, BidkernelPrebidAnalytics, CACHED_BID_TTL_MS, type CachedWinningBid, PrebidEventDeduper, type SizeMapping, type SlotConfig, type SlotObserveOptions, type SlotSize, type SlotSizes, type SlotViewabilityState, type VideoPlayerOptions, attachImaAdsManager, attachVideoPlayer, getOrCreateSessionId, getPrebidEventKey, getbidkernel, hookImaPrototype, initImaInterception, isTrustedEndpoint, registerPrebidAnalytics };
|