@bidkernel/analytics 0.1.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/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 Bidkernel
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @bidkernel/analytics
2
+
3
+ Vanilla JS bindings, TypeScript types, and the standalone [Prebid.js](https://prebid.org/) analytics adapter for the [Bidkernel](https://bidkernel.io) ad SDK.
4
+
5
+ The analytics adapter collects auction telemetry (auctions, bid requests/responses, wins, timeouts, no-bids, render failures), batches it, and delivers it to your property's Bidkernel ingest endpoint as protobuf — with `sendBeacon` flushing on page hide and automatic re-queueing on delivery failure.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install @bidkernel/analytics
11
+ ```
12
+
13
+ Or, without a build step, load the self-registering bundle via a `<script>` tag. The copy served from your Bidkernel domain is preferred (the ingest endpoint is derived from the script's own origin, so custom domains work automatically):
14
+
15
+ ```html
16
+ <script async src="https://by.bidkernel.io/analytics.js"></script>
17
+ ```
18
+
19
+ The same bundle is published on npm CDNs as `https://unpkg.com/@bidkernel/analytics/dist/analytics.global.js`; when loaded from a CDN you must pass `endpoint` yourself via config.
20
+
21
+ ## Usage with Prebid.js
22
+
23
+ The adapter registers as a standard Prebid analytics provider:
24
+
25
+ ```js
26
+ import { registerPrebidAnalytics } from "@bidkernel/analytics";
27
+
28
+ registerPrebidAnalytics("pbjs", { endpoint: "https://by.bidkernel.io/t" });
29
+
30
+ pbjs.que.push(function () {
31
+ pbjs.enableAnalytics([{ provider: "bidkernel", options: { propertyId: "YOUR_PROPERTY_ID" } }]);
32
+ });
33
+ ```
34
+
35
+ If the adapter loads after auctions have already run, it replays Prebid's event history, so late installation does not lose data. Events are deduplicated across the replay/live boundary.
36
+
37
+ For direct control (no `enableAnalytics`), instantiate the class yourself:
38
+
39
+ ```js
40
+ import { BidkernelPrebidAnalytics } from "@bidkernel/analytics";
41
+
42
+ const analytics = new BidkernelPrebidAnalytics({
43
+ endpoint: "https://by.bidkernel.io/t",
44
+ propertyId: "YOUR_PROPERTY_ID",
45
+ });
46
+ analytics.enable();
47
+ ```
48
+
49
+ ## Configuration
50
+
51
+ | Option | Default | Description |
52
+ | ------------------------------------- | -------------- | -------------------------------------------------------------------- |
53
+ | `endpoint` | — | Ingest base URL; events POST to `{endpoint}/{propertyId}`. |
54
+ | `propertyId` | — | Your Bidkernel property ID. |
55
+ | `pbjsGlobalName` | `"pbjs"` | Window global holding the Prebid instance (for renamed installs). |
56
+ | `attachPbjsListeners` | `true` | Set `false` when events are fed via `trackRawEvent` (full SDK mode). |
57
+ | `auctionEnabled` | `true` | Collect auction lifecycle events. |
58
+ | `warningsEnabled` | `true` | Collect warning events. |
59
+ | `errorsEnabled` | `true` | Collect error events (capped per session). |
60
+ | `userId` / `sessionId` / `pageviewId` | generated | Override identity; a 30-minute rolling session is managed otherwise. |
61
+ | `deviceType` / `country` / `region` | server-derived | Optional client hints; ingest resolves these server-side. |
62
+ | `logLevel` | `"WARN"` | Console log verbosity. |
63
+
64
+ SPA navigations: call `analytics.navigate(newPageviewId, newUrl)` to flush the old pageview and continue under the new one.
65
+
66
+ ## Bidkernel SDK bindings
67
+
68
+ `getbidkernel()` returns the typed `window.bidkernel` command-queue stub (creating it if the loader snippet has not run yet), along with the `SlotConfig`/`AdsGlobal` types for pages integrating the full Bidkernel SDK.
69
+
70
+ ```js
71
+ import { getbidkernel } from "@bidkernel/analytics";
72
+
73
+ getbidkernel().q.push(() => {
74
+ // SDK is ready
75
+ });
76
+ ```
@@ -0,0 +1 @@
1
+ "use strict";var bidkernelPrebidAnalyticsBundle=(()=>{var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var le=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);function q(){let t=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<i,(r&128)==0)return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[t,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<i,(r&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function E(t,e,n){for(let s=0;s<28;s=s+7){let o=t>>>s,a=!(!(o>>>7)&&e==0),d=(a?o|128:o)&255;if(n.push(d),!a)return}let i=t>>>28&15|(e&7)<<4,r=e>>3!=0;if(n.push((r?i|128:i)&255),!!r){for(let s=3;s<31;s=s+7){let o=e>>>s,a=!!(o>>>7),d=(a?o|128:o)&255;if(n.push(d),!a)return}n.push(e>>>31&1)}}function D(t){let e=t[0]==="-";e&&(t=t.slice(1));let n=1e6,i=0,r=0;function s(o,a){let d=Number(t.slice(o,a));r*=n,i=i*n+d,i>=T&&(r=r+(i/T|0),i=i%T)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?W(i,r):k(i,r)}function V(t,e){let n=k(t,e),i=n.hi&2147483648;i&&(n=W(n.lo,n.hi));let r=A(n.lo,n.hi);return i?"-"+r:r}function A(t,e){if({lo:t,hi:e}=he(t,e),e<=2097151)return String(T*e+t);let n=t&16777215,i=(t>>>24|e<<8)&16777215,r=e>>16&65535,s=n+i*6777216+r*6710656,o=i+r*8147497,a=r*2,d=1e7;return s>=d&&(o+=Math.floor(s/d),s%=d),o>=d&&(a+=Math.floor(o/d),o%=d),a.toString()+$(o)+$(s)}function he(t,e){return{lo:t>>>0,hi:e>>>0}}function k(t,e){return{lo:t|0,hi:e|0}}function W(t,e){return e=~e,t?t=~t+1:e+=1,k(t,e)}function U(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function G(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)==0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;(t&128)!==0&&n<10;n++)t=this.buf[this.pos++];if((t&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var T,$,N=l(()=>{"use strict";T=4294967296;$=t=>{let e=String(t);return"0000000".slice(e.length)+e}});function pe(){let t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(!!globalThis.Deno||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let n=BigInt("-9223372036854775808"),i=BigInt("9223372036854775807"),r=BigInt("0"),s=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(o){let a=typeof o=="bigint"?o:BigInt(o);if(a>i||a<n)throw new Error(`invalid int64: ${o}`);return a},uParse(o){let a=typeof o=="bigint"?o:BigInt(o);if(a>s||a<r)throw new Error(`invalid uint64: ${o}`);return a},enc(o){return t.setBigInt64(0,this.parse(o),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(o){return t.setBigInt64(0,this.uParse(o),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec(o,a){return t.setInt32(0,o,!0),t.setInt32(4,a,!0),t.getBigInt64(0,!0)},uDec(o,a){return t.setInt32(0,o,!0),t.setInt32(4,a,!0),t.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(n){return typeof n!="string"&&(n=n.toString()),z(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),K(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),z(n),D(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),K(n),D(n)},dec(n,i){return V(n,i)},uDec(n,i){return A(n,i)}}}function z(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function K(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}var u,j=l(()=>{"use strict";N();u=pe()});function S(){if(globalThis[R]==null){let t=new globalThis.TextEncoder,e=new globalThis.TextDecoder;globalThis[R]={encodeUtf8(n){return t.encode(n)},decodeUtf8(n){return e.decode(n)},checkUtf8(n){try{return encodeURIComponent(n),!0}catch{return!1}}}}return globalThis[R]}var R,_=l(()=>{"use strict";R=Symbol.for("@bufbuild/protobuf/text-encoding")});function P(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid int32: "+typeof t);if(!Number.isInteger(t)||t>Te||t<Ee)throw new Error("invalid int32: "+t)}function H(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid uint32: "+typeof t);if(!Number.isInteger(t)||t>Ie||t<0)throw new Error("invalid uint32: "+t)}function ge(t){if(typeof t=="string"){let e=t;if(t=Number(t),Number.isNaN(t)&&e!=="NaN")throw new Error("invalid float32: "+e)}else if(typeof t!="number")throw new Error("invalid float32: "+typeof t);if(Number.isFinite(t)&&(t>ye||t<be))throw new Error("invalid float32: "+t)}var h,ye,be,Ie,Te,Ee,p,f,Y=l(()=>{"use strict";N();j();_();(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(h||(h={}));ye=34028234663852886e22,be=-34028234663852886e22,Ie=4294967295,Te=2147483647,Ee=-2147483648,p=class{constructor(e=S().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let n=new Uint8Array(e),i=0;for(let r=0;r<this.chunks.length;r++)n.set(this.chunks[r],i),i+=this.chunks[r].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(H(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return P(e),U(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.encodeUtf8(e);return this.uint32(n.byteLength),this.raw(n)}float(e){ge(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){H(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){P(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return P(e),e=(e<<1^e>>31)>>>0,U(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),i=new DataView(n.buffer),r=u.enc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),i=new DataView(n.buffer),r=u.uEnc(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=u.enc(e);return E(n.lo,n.hi,this.buf),this}sint64(e){let n=u.enc(e),i=n.hi>>31,r=n.lo<<1^i,s=(n.hi<<1|n.lo>>>31)^i;return E(r,s,this.buf),this}uint64(e){let n=u.uEnc(e);return E(n.lo,n.hi,this.buf),this}},f=class{constructor(e,n=S().decodeUtf8){this.decodeUtf8=n,this.varint64=q,this.uint32=G,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),n=e>>>3,i=e&7;if(n<=0||i<0||i>5)throw new Error("illegal tag: field no "+n+" wire type "+i);return[n,i]}skip(e,n){let i=this.pos;switch(e){case h.Varint:for(;this.buf[this.pos++]&128;);break;case h.Bit64:this.pos+=4;case h.Bit32:this.pos+=4;break;case h.LengthDelimited:let r=this.uint32();this.pos+=r;break;case h.StartGroup:for(;;){let[s,o]=this.tag();if(o===h.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(o,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return u.dec(...this.varint64())}uint64(){return u.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),i=-(e&1);return e=(e>>>1|(n&1)<<31)^i,n=n>>>1^i,u.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return u.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return u.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.decodeUtf8(this.bytes())}}});var X=l(()=>{"use strict"});var Q=l(()=>{"use strict"});var Z=l(()=>{"use strict"});var J=l(()=>{"use strict";Y();X();_();Q();Z()});function ee(){return{propertyId:"",pageviewId:"",sessionId:"",pageUrl:"",country:"",region:"",deviceType:"",userId:"",domain:"",events:[],browser:"",deviceManufacturer:"",deviceModel:"",city:"",postalCode:""}}function te(){return{timestampMs:0,type:0,eventName:"",auctionId:"",transactionId:"",adUnitCode:"",bid:void 0,namespace:"",eventId:"",metadata:{},viewableDurationMs:void 0}}function ne(){return{key:"",value:""}}function ie(){return{bidder:"",cpm:0,currency:"",width:0,height:0,dealId:"",mediaType:"",latencyMs:0,advertiserDomain:"",creativeId:""}}var c,M,g,C,v,re=l(()=>{"use strict";J();c={TRACE_EVENT_TYPE_UNSPECIFIED:0,AUCTION_START:1,AUCTION_END:2,BID_REQUEST:3,BID_RESPONSE:4,BID_WIN:5,BID_TIMEOUT:6,IMPRESSION:7,VIEWABLE:8,TIME_IN_VIEW:14,REFRESH:9,ERROR:10,SLOT_DEFINED:11,SLOT_DESTROYED:12,CLICK:13,NO_BID:15,AD_RENDER_FAILED:16,UNRECOGNIZED:-1};M={encode(t,e=new p){if(t.propertyId!==void 0&&t.propertyId!==""&&e.uint32(10).string(t.propertyId),t.pageviewId!==void 0&&t.pageviewId!==""&&e.uint32(18).string(t.pageviewId),t.sessionId!==void 0&&t.sessionId!==""&&e.uint32(26).string(t.sessionId),t.pageUrl!==void 0&&t.pageUrl!==""&&e.uint32(34).string(t.pageUrl),t.country!==void 0&&t.country!==""&&e.uint32(42).string(t.country),t.region!==void 0&&t.region!==""&&e.uint32(50).string(t.region),t.deviceType!==void 0&&t.deviceType!==""&&e.uint32(58).string(t.deviceType),t.userId!==void 0&&t.userId!==""&&e.uint32(66).string(t.userId),t.domain!==void 0&&t.domain!==""&&e.uint32(74).string(t.domain),t.events!==void 0&&t.events.length!==0)for(let n of t.events)g.encode(n,e.uint32(82).fork()).join();return t.browser!==void 0&&t.browser!==""&&e.uint32(90).string(t.browser),t.deviceManufacturer!==void 0&&t.deviceManufacturer!==""&&e.uint32(98).string(t.deviceManufacturer),t.deviceModel!==void 0&&t.deviceModel!==""&&e.uint32(106).string(t.deviceModel),t.city!==void 0&&t.city!==""&&e.uint32(114).string(t.city),t.postalCode!==void 0&&t.postalCode!==""&&e.uint32(122).string(t.postalCode),e},decode(t,e){let n=t instanceof f?t:new f(t),i=e===void 0?n.len:n.pos+e,r=ee();for(;n.pos<i;){let s=n.uint32();switch(s>>>3){case 1:{if(s!==10)break;r.propertyId=n.string();continue}case 2:{if(s!==18)break;r.pageviewId=n.string();continue}case 3:{if(s!==26)break;r.sessionId=n.string();continue}case 4:{if(s!==34)break;r.pageUrl=n.string();continue}case 5:{if(s!==42)break;r.country=n.string();continue}case 6:{if(s!==50)break;r.region=n.string();continue}case 7:{if(s!==58)break;r.deviceType=n.string();continue}case 8:{if(s!==66)break;r.userId=n.string();continue}case 9:{if(s!==74)break;r.domain=n.string();continue}case 10:{if(s!==82)break;let o=g.decode(n,n.uint32());o!==void 0&&r.events.push(o);continue}case 11:{if(s!==90)break;r.browser=n.string();continue}case 12:{if(s!==98)break;r.deviceManufacturer=n.string();continue}case 13:{if(s!==106)break;r.deviceModel=n.string();continue}case 14:{if(s!==114)break;r.city=n.string();continue}case 15:{if(s!==122)break;r.postalCode=n.string();continue}}if((s&7)===4||s===0)break;n.skip(s&7)}return r},create(t){return M.fromPartial(t??{})},fromPartial(t){let e=ee();return e.propertyId=t.propertyId??"",e.pageviewId=t.pageviewId??"",e.sessionId=t.sessionId??"",e.pageUrl=t.pageUrl??"",e.country=t.country??"",e.region=t.region??"",e.deviceType=t.deviceType??"",e.userId=t.userId??"",e.domain=t.domain??"",e.events=t.events?.map(n=>g.fromPartial(n))||[],e.browser=t.browser??"",e.deviceManufacturer=t.deviceManufacturer??"",e.deviceModel=t.deviceModel??"",e.city=t.city??"",e.postalCode=t.postalCode??"",e}};g={encode(t,e=new p){return t.timestampMs!==void 0&&t.timestampMs!==0&&e.uint32(9).double(t.timestampMs),t.type!==void 0&&t.type!==0&&e.uint32(16).int32(t.type),t.eventName!==void 0&&t.eventName!==""&&e.uint32(26).string(t.eventName),t.auctionId!==void 0&&t.auctionId!==""&&e.uint32(34).string(t.auctionId),t.transactionId!==void 0&&t.transactionId!==""&&e.uint32(42).string(t.transactionId),t.adUnitCode!==void 0&&t.adUnitCode!==""&&e.uint32(50).string(t.adUnitCode),t.bid!==void 0&&v.encode(t.bid,e.uint32(58).fork()).join(),t.namespace!==void 0&&t.namespace!==""&&e.uint32(66).string(t.namespace),t.eventId!==void 0&&t.eventId!==""&&e.uint32(74).string(t.eventId),globalThis.Object.entries(t.metadata||{}).forEach(([n,i])=>{C.encode({key:n,value:i},e.uint32(82).fork()).join()}),t.viewableDurationMs!==void 0&&e.uint32(89).double(t.viewableDurationMs),e},decode(t,e){let n=t instanceof f?t:new f(t),i=e===void 0?n.len:n.pos+e,r=te();for(;n.pos<i;){let s=n.uint32();switch(s>>>3){case 1:{if(s!==9)break;r.timestampMs=n.double();continue}case 2:{if(s!==16)break;r.type=n.int32();continue}case 3:{if(s!==26)break;r.eventName=n.string();continue}case 4:{if(s!==34)break;r.auctionId=n.string();continue}case 5:{if(s!==42)break;r.transactionId=n.string();continue}case 6:{if(s!==50)break;r.adUnitCode=n.string();continue}case 7:{if(s!==58)break;r.bid=v.decode(n,n.uint32());continue}case 8:{if(s!==66)break;r.namespace=n.string();continue}case 9:{if(s!==74)break;r.eventId=n.string();continue}case 10:{if(s!==82)break;let o=C.decode(n,n.uint32());o.value!==void 0&&(r.metadata[o.key]=o.value);continue}case 11:{if(s!==89)break;r.viewableDurationMs=n.double();continue}}if((s&7)===4||s===0)break;n.skip(s&7)}return r},create(t){return g.fromPartial(t??{})},fromPartial(t){let e=te();return e.timestampMs=t.timestampMs??0,e.type=t.type??0,e.eventName=t.eventName??"",e.auctionId=t.auctionId??"",e.transactionId=t.transactionId??"",e.adUnitCode=t.adUnitCode??"",e.bid=t.bid!==void 0&&t.bid!==null?v.fromPartial(t.bid):void 0,e.namespace=t.namespace??"",e.eventId=t.eventId??"",e.metadata=globalThis.Object.entries(t.metadata??{}).reduce((n,[i,r])=>(r!==void 0&&(n[i]=globalThis.String(r)),n),{}),e.viewableDurationMs=t.viewableDurationMs??void 0,e}};C={encode(t,e=new p){return t.key!==""&&e.uint32(10).string(t.key),t.value!==""&&e.uint32(18).string(t.value),e},decode(t,e){let n=t instanceof f?t:new f(t),i=e===void 0?n.len:n.pos+e,r=ne();for(;n.pos<i;){let s=n.uint32();switch(s>>>3){case 1:{if(s!==10)break;r.key=n.string();continue}case 2:{if(s!==18)break;r.value=n.string();continue}}if((s&7)===4||s===0)break;n.skip(s&7)}return r},create(t){return C.fromPartial(t??{})},fromPartial(t){let e=ne();return e.key=t.key??"",e.value=t.value??"",e}};v={encode(t,e=new p){return t.bidder!==void 0&&t.bidder!==""&&e.uint32(10).string(t.bidder),t.cpm!==void 0&&t.cpm!==0&&e.uint32(17).double(t.cpm),t.currency!==void 0&&t.currency!==""&&e.uint32(26).string(t.currency),t.width!==void 0&&t.width!==0&&e.uint32(32).int32(t.width),t.height!==void 0&&t.height!==0&&e.uint32(40).int32(t.height),t.dealId!==void 0&&t.dealId!==""&&e.uint32(50).string(t.dealId),t.mediaType!==void 0&&t.mediaType!==""&&e.uint32(58).string(t.mediaType),t.latencyMs!==void 0&&t.latencyMs!==0&&e.uint32(65).double(t.latencyMs),t.advertiserDomain!==void 0&&t.advertiserDomain!==""&&e.uint32(74).string(t.advertiserDomain),t.creativeId!==void 0&&t.creativeId!==""&&e.uint32(82).string(t.creativeId),e},decode(t,e){let n=t instanceof f?t:new f(t),i=e===void 0?n.len:n.pos+e,r=ie();for(;n.pos<i;){let s=n.uint32();switch(s>>>3){case 1:{if(s!==10)break;r.bidder=n.string();continue}case 2:{if(s!==17)break;r.cpm=n.double();continue}case 3:{if(s!==26)break;r.currency=n.string();continue}case 4:{if(s!==32)break;r.width=n.int32();continue}case 5:{if(s!==40)break;r.height=n.int32();continue}case 6:{if(s!==50)break;r.dealId=n.string();continue}case 7:{if(s!==58)break;r.mediaType=n.string();continue}case 8:{if(s!==65)break;r.latencyMs=n.double();continue}case 9:{if(s!==74)break;r.advertiserDomain=n.string();continue}case 10:{if(s!==82)break;r.creativeId=n.string();continue}}if((s&7)===4||s===0)break;n.skip(s&7)}return r},create(t){return v.fromPartial(t??{})},fromPartial(t){let e=ie();return e.bidder=t.bidder??"",e.cpm=t.cpm??0,e.currency=t.currency??"",e.width=t.width??0,e.height=t.height??0,e.dealId=t.dealId??"",e.mediaType=t.mediaType??"",e.latencyMs=t.latencyMs??0,e.advertiserDomain=t.advertiserDomain??"",e.creativeId=t.creativeId??"",e}}});function I(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Ae(){let t=Date.now();b=t;try{typeof localStorage<"u"&&localStorage.setItem(m,t.toString())}catch{}}function ke(){let t=Date.now();try{if(typeof localStorage<"u"){let e=localStorage.getItem(oe),n=localStorage.getItem(m),i=n&&parseInt(n,10)||0;if(e&&i&&t-i<=ae)return localStorage.setItem(m,t.toString()),e;let r=I();return localStorage.setItem(oe,r),localStorage.setItem(m,t.toString()),r}}catch{}return x&&b&&t-b<=ae?(b=t,x):(x=I(),b=t,x)}function Ue(t,e){switch(t){case"auctionInit":return`auctionInit:${e?.auctionId||""}`;case"auctionEnd":return`auctionEnd:${e?.auctionId||""}`;case"bidRequested":return`bidRequested:${e?.auctionId||""}:${e?.bidderCode||""}:${Array.isArray(e?.bids)?e.bids.map(n=>n?.bidId||n?.adUnitCode||"").join(","):""}`;case"bidResponse":return`bidResponse:${e?.auctionId||""}:${e?.adUnitCode||""}:${e?.bidderCode||e?.bidder||""}:${e?.creativeId||e?.adId||e?.requestId||""}:${e?.originalCpm??e?.cpm??""}`;case"bidTimeout":return Array.isArray(e)?"bidTimeout:"+e.map(n=>`${n?.auctionId||""}:${n?.bidder||n?.bidderCode||""}:${n?.bidId||n?.adUnitCode||""}`).join(","):`bidTimeout:${e?.auctionId||""}:${e?.bidder||e?.bidderCode||""}:${e?.bidId||e?.adUnitCode||""}`;case"bidWon":return`bidWon:${e?.auctionId||""}:${e?.adUnitCode||""}:${e?.bidderCode||e?.bidder||""}:${e?.creativeId||e?.adId||e?.requestId||""}:${e?.originalCpm??e?.cpm??""}`;case"noBid":return`noBid:${e?.auctionId||""}:${e?.adUnitCode||""}:${e?.bidderCode||e?.bidder||""}:${e?.bidId||""}`;case"adRenderFailed":return`adRenderFailed:${e?.bid?.auctionId||e?.auctionId||""}:${e?.bid?.adUnitCode||e?.adUnitCode||""}:${e?.bid?.bidderCode||e?.bid?.bidder||""}:${e?.reason||""}:${e?.message||""}`;case"adRenderSucceeded":return`adRenderSucceeded:${e?.bid?.auctionId||e?.auctionId||""}:${e?.bid?.adUnitCode||e?.adUnitCode||""}:${e?.bid?.bidderCode||e?.bid?.bidder||""}`;case"setTargeting":return`setTargeting:${Object.keys(e||{}).sort().join(",")}`;case"auctionDebug":return`auctionDebug:${e?.type||""}:${String(e?.arguments?.[0]??"").slice(0,50)}`;default:return""}}function de(t){if(!t)return{width:0,height:0};let e=t;for(;Array.isArray(e)&&e.length>0&&Array.isArray(e[0]);)e=e[0];if(Array.isArray(e)&&e.length>=2){let n=Number(e[0]),i=Number(e[1]);return{width:Number.isFinite(n)?n:0,height:Number.isFinite(i)?i:0}}return{width:0,height:0}}function y(t){if(!t)return null;if(Array.isArray(t)){let e=t.find(n=>n?.provider==="bidkernel")??t.find(n=>n&&typeof n=="object"&&n.provider===void 0);return e?y(e):null}if(typeof t=="object"){if(t.options&&typeof t.options=="object")return t.options;if(t.config&&typeof t.config=="object")return t.config;if(t.propertyId||t.endpoint)return t}return null}function Ne(t){if(!t)return null;if(t._bidkernelAnalyticsConfig){let e=y(t._bidkernelAnalyticsConfig);if(e)return e}if(t.bidkernelPrebidAnalytics){let e=t.bidkernelPrebidAnalytics;if(e.options){let n=y(e.options);if(n)return n}if(e.config){let n=y(e.config);if(n)return n}if(e.propertyId)return y(e)}return null}function L(t="pbjs",e){let n=typeof window<"u"?window:{};n[t]=n[t]||{};let i=n[t],r=o=>{if(n._bidkernelPrebidAnalytics)try{n._bidkernelPrebidAnalytics.disable()}catch(d){console.warn("[bidkernel] Failed to disable previous analytics instance:",d)}let a=new O({pbjsGlobalName:t,...e,...o});return a.enable(),n._bidkernelPrebidAnalytics=a,a},s=()=>{try{i.adapterManager&&typeof i.adapterManager.registerAnalyticsAdapter=="function"&&i.adapterManager.registerAnalyticsAdapter({adapter:{enableAnalytics:a=>{let d=y(a);d&&r(d)},disableAnalytics:()=>{n._bidkernelPrebidAnalytics&&n._bidkernelPrebidAnalytics.disable()}},code:"bidkernel"});let o=Ne(n);o&&(o.propertyId||e?.propertyId)&&r(o)}catch(o){console.warn("[bidkernel] Failed to register standard Prebid analytics adapter:",o)}};i.adapterManager&&typeof i.adapterManager.registerAnalyticsAdapter=="function"?s():(i.que=i.que||[],i.que.push(s))}var we,se,xe,w,me,Be,De,oe,m,ae,x,b,F,O,ce=l(()=>{"use strict";re();we=20,se=1e4,xe=50,w=200,me=300*1e3,Be=10,De={auctionStart:c.AUCTION_START,auctionEnd:c.AUCTION_END,bidRequest:c.BID_REQUEST,bidResponse:c.BID_RESPONSE,bidTimeout:c.BID_TIMEOUT,bidWin:c.BID_WIN,noBid:c.NO_BID,adRenderFailed:c.AD_RENDER_FAILED,click:c.CLICK,impression:c.IMPRESSION,refresh:c.REFRESH,timeInView:c.TIME_IN_VIEW,viewable:c.VIEWABLE},oe="_bidkernel_session",m="_bidkernel_session_ts",ae=1800*1e3,x=null,b=0;F=class{seenObjects=new WeakSet;seenKeys=new Set;isDuplicate(e,n){if(!n)return!1;if(typeof n=="object"){if(this.seenObjects.has(n))return!0;this.seenObjects.add(n)}let i=Ue(e,n);if(i){if(this.seenKeys.has(i))return!0;if(this.seenKeys.size>=1e3){let r=this.seenKeys.values().next().value;r!==void 0&&this.seenKeys.delete(r)}this.seenKeys.add(i)}return!1}};O=class{config;queue=[];errorCount=0;flushTimer=null;boundFlushBeacon;boundVisibilityChange;isEnabled=!1;boundPbjsHandlers=[];pageUrl="";deduper=new F;consecutiveSendFailures=0;nextSendAllowedAt=0;constructor(e){this.config={endpoint:e.endpoint||"",propertyId:e.propertyId||"",pageviewId:e.pageviewId||I(),sessionId:e.sessionId||ke(),userId:e.userId||"",deviceType:e.deviceType||"desktop",country:e.country||"",region:e.region||"",auctionEnabled:e.auctionEnabled??!0,warningsEnabled:e.warningsEnabled??!0,errorsEnabled:e.errorsEnabled??!0,logLevel:e.logLevel||"INFO",pbjsGlobalName:e.pbjsGlobalName||"pbjs",attachPbjsListeners:e.attachPbjsListeners??!0},this.boundFlushBeacon=()=>this.flushBeacon(),this.boundVisibilityChange=()=>this.handleVisibilityChange()}enable(){if(!this.isEnabled){if(this.isEnabled=!0,this.config.endpoint||this.log("WARN","Endpoint is empty. Analytics events will not be transmitted."),this.config.attachPbjsListeners){let n=(typeof window<"u"?window:{})[this.config.pbjsGlobalName]||{};if(typeof n.onEvent=="function"){this.log("DEBUG","Attaching event listeners to pbjs");let i=[["auctionInit",this.handleAuctionInit.bind(this)],["auctionEnd",this.handleAuctionEnd.bind(this)],["bidRequested",this.handleBidRequested.bind(this)],["bidResponse",this.handleBidResponse.bind(this)],["bidTimeout",this.handleBidTimeout.bind(this)],["bidWon",this.handleBidWon.bind(this)],["noBid",this.handleNoBid.bind(this)],["adRenderFailed",this.handleAdRenderFailed.bind(this)]];for(let[r,s]of i)n.onEvent(r,s),this.boundPbjsHandlers.push({event:r,handler:s})}else this.log("WARN","pbjs.onEvent is not defined. Prebid analytics will not function.");if(typeof n.getEvents=="function")try{let i=n.getEvents();if(Array.isArray(i)){this.log("DEBUG",`Replaying ${i.length} historical events from pbjs.getEvents()`);let r={auctionInit:this.handleAuctionInit.bind(this),auctionEnd:this.handleAuctionEnd.bind(this),bidRequested:this.handleBidRequested.bind(this),bidResponse:this.handleBidResponse.bind(this),bidTimeout:this.handleBidTimeout.bind(this),bidWon:this.handleBidWon.bind(this),noBid:this.handleNoBid.bind(this),adRenderFailed:this.handleAdRenderFailed.bind(this)};for(let s of i){if(!s)continue;let o=s.eventType||s.event||s.name,a=s.args!==void 0?s.args:s.data!==void 0?s.data:s,d=r[o];d&&d(a)}}}catch(i){this.log("WARN","Failed to replay historical events from pbjs.getEvents()",i)}}if(typeof window<"u"){if(!this.pageUrl)try{let e=new URL(window.location.href);this.pageUrl=e.origin+e.pathname}catch{this.pageUrl=window.location.href}window.addEventListener("pagehide",this.boundFlushBeacon),typeof document<"u"&&document.addEventListener("visibilitychange",this.boundVisibilityChange),this.flushTimer=setInterval(()=>this.flush(),se)}}}disable(){if(this.isEnabled){if(this.isEnabled=!1,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),typeof window<"u"&&(window.removeEventListener("pagehide",this.boundFlushBeacon),typeof document<"u"&&document.removeEventListener("visibilitychange",this.boundVisibilityChange)),this.boundPbjsHandlers.length>0){let n=(typeof window<"u"?window:{})[this.config.pbjsGlobalName]||{};if(typeof n.offEvent=="function")for(let{event:i,handler:r}of this.boundPbjsHandlers)n.offEvent(i,r);this.boundPbjsHandlers=[]}this.flush()}}handleVisibilityChange(){typeof document<"u"&&document.visibilityState==="hidden"&&this.flushBeacon()}trackRawEvent(e,n,i){let r=De[n]??(e==="ERROR"?c.ERROR:c.TRACE_EVENT_TYPE_UNSPECIFIED);this.enqueue(r,n,i,e)}setUserId(e){this.config.userId=e}setSessionId(e){this.config.sessionId=e}navigate(e,n){if(this.disable(),this.config.pageviewId=e||I(),n)try{let i=new URL(n);this.pageUrl=i.origin+i.pathname}catch{this.pageUrl=n}else this.pageUrl="";Ae(),this.enable()}handleAuctionInit(e){this.isDuplicate("auctionInit",e)||(this.log("DEBUG","auctionInit",e),this.enqueue(c.AUCTION_START,"auctionStart",{auctionId:e.auctionId||""}))}handleAuctionEnd(e){this.isDuplicate("auctionEnd",e)||(this.log("DEBUG","auctionEnd",e),this.enqueue(c.AUCTION_END,"auctionEnd",{auctionId:e.auctionId||""}))}handleBidRequested(e){if(this.isDuplicate("bidRequested",e))return;this.log("DEBUG","bidRequested",e);let n=e.auctionId||"",i=e.bidderCode||"";Array.isArray(e.bids)&&e.bids.forEach(r=>{let s=Object.keys(r.mediaTypes||{}),o=r.ortb2Imp?.ext?.gpid||r.gpid||e.gpid||"";if(s.length===0){let a=r.mediaType||"banner",{width:d,height:B}=de(r.sizes||r.playerSize);this.enqueue(c.BID_REQUEST,"bidRequest",{auctionId:n,adUnitCode:r.adUnitCode||"",gpid:o,bid:{bidder:i,mediaType:a,width:d,height:B}});return}s.forEach(a=>{let d=null;a==="banner"?d=r.mediaTypes?.banner?.sizes||r.sizes:a==="video"?d=r.mediaTypes?.video?.playerSize||r.mediaTypes?.video?.sizes||r.playerSize:d=r.mediaTypes?.[a]?.sizes;let{width:B,height:fe}=de(d);this.enqueue(c.BID_REQUEST,"bidRequest",{auctionId:n,adUnitCode:r.adUnitCode||"",gpid:o,bid:{bidder:i,mediaType:a,width:B,height:fe}})})})}handleBidResponse(e){this.isDuplicate("bidResponse",e)||(this.log("DEBUG","bidResponse",e),this.enqueue(c.BID_RESPONSE,"bidResponse",{auctionId:e.auctionId||"",adUnitCode:e.adUnitCode||"",bid:{bidder:e.bidderCode||e.bidder||"",cpm:Number.isFinite(e.originalCpm)?e.originalCpm:Number.isFinite(e.cpm)?e.cpm:0,currency:e.originalCurrency??e.currency??"USD",width:Number.isFinite(e.width)?e.width:0,height:Number.isFinite(e.height)?e.height:0,dealId:e.dealId||"",mediaType:e.mediaType||"banner",latencyMs:Number.isFinite(e.timeToRespond)?e.timeToRespond:0,advertiserDomain:e.meta?.advertiserDomains?.[0]||"",creativeId:e.creativeId||""}}))}handleBidTimeout(e){this.isDuplicate("bidTimeout",e)||(this.log("DEBUG","bidTimeout",e),Array.isArray(e)&&e.forEach(n=>{this.enqueue(c.BID_TIMEOUT,"bidTimeout",{auctionId:n.auctionId||"",adUnitCode:n.adUnitCode||"",bid:{bidder:n.bidder||""}})}))}handleBidWon(e){this.isDuplicate("bidWon",e)||(this.log("DEBUG","bidWon",e),this.enqueue(c.BID_WIN,"bidWon",{auctionId:e.auctionId||"",adUnitCode:e.adUnitCode||"",bid:{bidder:e.bidderCode||e.bidder||"",cpm:Number.isFinite(e.originalCpm)?e.originalCpm:Number.isFinite(e.cpm)?e.cpm:0,currency:e.originalCurrency??e.currency??"USD",width:Number.isFinite(e.width)?e.width:0,height:Number.isFinite(e.height)?e.height:0,dealId:e.dealId||"",mediaType:e.mediaType||"banner",latencyMs:Number.isFinite(e.timeToRespond)?e.timeToRespond:0,advertiserDomain:e.meta?.advertiserDomains?.[0]||"",creativeId:e.creativeId||""}}))}handleNoBid(e){this.isDuplicate("noBid",e)||(this.log("DEBUG","noBid",e),this.enqueue(c.NO_BID,"noBid",{auctionId:e.auctionId||"",adUnitCode:e.adUnitCode||"",bid:{bidder:e.bidderCode||e.bidder||""}}))}handleAdRenderFailed(e){this.isDuplicate("adRenderFailed",e)||(this.log("DEBUG","adRenderFailed",e),this.enqueue(c.AD_RENDER_FAILED,"adRenderFailed",{auctionId:e.bid?.auctionId||"",adUnitCode:e.bid?.adUnitCode||"",bid:{bidder:e.bid?.bidderCode||e.bid?.bidder||""},metadata:{reason:String(e.reason||""),message:String(e.message||"")}}))}isDuplicate(e,n){return this.deduper.isDuplicate(e,n)}enqueue(e,n,i,r){if(!this.isEnabled||!this.shouldSample(e,r))return;let s={eventId:I(),timestampMs:Date.now(),type:e,eventName:n,auctionId:i.auctionId||"",transactionId:i.transactionId||"",adUnitCode:i.adUnitCode||i.elementId||"",namespace:i.ns||i.namespace||""};i.bid&&(s.bid={bidder:i.bid.bidder||"",cpm:Number.isFinite(i.bid.cpm)?i.bid.cpm:0,currency:i.bid.currency||"USD",width:Number.isFinite(i.bid.width)?i.bid.width:0,height:Number.isFinite(i.bid.height)?i.bid.height:0,dealId:i.bid.dealId||"",mediaType:i.bid.mediaType||"banner",latencyMs:Number.isFinite(i.bid.latencyMs)?i.bid.latencyMs:0,advertiserDomain:i.bid.advertiserDomain||"",creativeId:i.bid.creativeId||""}),i.viewableDurationMs!==void 0&&(s.viewableDurationMs=Number.isFinite(i.viewableDurationMs)?i.viewableDurationMs:0);let o={...i.metadata};i.error!==void 0&&i.error!==null&&(o.error=typeof i.error=="object"&&i.error.message?String(i.error.message):String(i.error)),i.gpid&&(o.gpid=String(i.gpid)),Object.keys(o).length>0&&(s.metadata=o),this.queue.push(s),this.queue.length>w&&this.queue.splice(0,this.queue.length-w),this.queue.length>=we&&this.flush()}shouldSample(e,n){return e===c.ERROR?(this.errorCount++,this.errorCount>xe?!1:this.config.errorsEnabled):n==="WARN"?this.config.warningsEnabled:this.config.auctionEnabled}requeue(e){e.length&&(this.queue=e.concat(this.queue),this.queue.length>w&&this.queue.splice(0,this.queue.length-w))}drainBatch(){if(this.queue.length===0||!this.config.endpoint)return null;let e=this.queue;this.queue=[];let n=typeof window<"u"?window.location.hostname:"",i={propertyId:this.config.propertyId,pageviewId:this.config.pageviewId,sessionId:this.config.sessionId,pageUrl:this.pageUrl,country:this.config.country,region:this.config.region,deviceType:this.config.deviceType,userId:this.config.userId,domain:n,events:e};return{url:`${this.config.endpoint}/${this.config.propertyId}`,encoded:M.encode(i).finish(),events:e}}sendFetch(e){fetch(e.url,{method:"POST",headers:{"Content-Type":"application/x-protobuf"},body:e.encoded,keepalive:!0}).then(n=>{n.ok?(this.consecutiveSendFailures=0,this.nextSendAllowedAt=0):(this.log("WARN",`Failed to send batch: HTTP ${n.status}`),this.handleSendFailure(e.events))}).catch(n=>{this.log("ERROR","Failed to send batch",n),this.handleSendFailure(e.events)})}handleSendFailure(e){this.consecutiveSendFailures++;let n=Math.min(se*2**(this.consecutiveSendFailures-1),me);this.nextSendAllowedAt=Date.now()+n,this.consecutiveSendFailures<=Be?this.requeue(e):this.log("WARN",`Dropping ${e.length} events after ${this.consecutiveSendFailures} consecutive send failures`)}flush(){if(Date.now()<this.nextSendAllowedAt)return;let e=this.drainBatch();e&&this.sendFetch(e)}flushBeacon(){let e=this.drainBatch();if(!e)return;let n=!1;if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function")try{let i=new Blob([e.encoded],{type:"application/x-protobuf"});n=navigator.sendBeacon(e.url,i)}catch{n=!1}n||this.sendFetch(e)}log(e,n,...i){let r={DEBUG:10,INFO:20,WARN:30,ERROR:40};if(r[e]<r[this.config.logLevel])return;let s=`[bidkernel][prebid-analytics][${e}]`;switch(e){case"DEBUG":console.debug(s,n,...i);break;case"INFO":console.info(s,n,...i);break;case"WARN":console.warn(s,n,...i);break;case"ERROR":console.error(s,n,...i);break}}}});var Se=le(()=>{ce();var ue=(()=>{try{let t=document.currentScript?.src;if(t)return new URL(t).origin+"/t"}catch{}return"https://by.bidkernel.io/t"})(),Re=window._bidkernelPbjsGlobal||"pbjs";L(Re,{endpoint:ue});window.bidkernelPrebidAnalytics={...window.bidkernelPrebidAnalytics,register:(t,e)=>L(t,{endpoint:ue,...e})}});return Se();})();
@@ -0,0 +1,136 @@
1
+ interface AnalyticsConfig {
2
+ endpoint: string;
3
+ propertyId: string;
4
+ pageviewId?: string;
5
+ sessionId?: string;
6
+ userId?: string;
7
+ deviceType?: string;
8
+ country?: string;
9
+ region?: string;
10
+ auctionEnabled?: boolean;
11
+ warningsEnabled?: boolean;
12
+ errorsEnabled?: boolean;
13
+ logLevel?: "DEBUG" | "INFO" | "WARN" | "ERROR";
14
+ /** Window global holding the Prebid instance to attach to. Defaults to "pbjs". */
15
+ pbjsGlobalName?: string;
16
+ /** Whether to attach pbjs.onEvent listeners. Defaults to true. Set false for full SDK mode. */
17
+ attachPbjsListeners?: boolean;
18
+ }
19
+ /**
20
+ * Canonical duplicate-detection key for a Prebid event. Shared by the adapter
21
+ * and the diagnostic extension so the two can never drift apart. Covers the
22
+ * events the adapter forwards plus display-only events the extension shows.
23
+ */
24
+ declare function getPrebidEventKey(eventName: string, data: any): string;
25
+ /**
26
+ * Tracks Prebid events already seen, by object identity and by semantic key.
27
+ * Needed because pbjs.getEvents() replay and live listeners overlap.
28
+ */
29
+ declare class PrebidEventDeduper {
30
+ private seenObjects;
31
+ private seenKeys;
32
+ isDuplicate(eventName: string, data: any): boolean;
33
+ }
34
+ declare class BidkernelPrebidAnalytics {
35
+ private config;
36
+ private queue;
37
+ private errorCount;
38
+ private flushTimer;
39
+ private boundFlushBeacon;
40
+ private boundVisibilityChange;
41
+ private isEnabled;
42
+ private boundPbjsHandlers;
43
+ private pageUrl;
44
+ private deduper;
45
+ private consecutiveSendFailures;
46
+ private nextSendAllowedAt;
47
+ constructor(config: AnalyticsConfig);
48
+ enable(): void;
49
+ disable(): void;
50
+ private handleVisibilityChange;
51
+ trackRawEvent(level: string, eventName: string, data: any): void;
52
+ setUserId(userId: string): void;
53
+ setSessionId(sessionId: string): void;
54
+ navigate(pageviewId: string, pageUrl: string): void;
55
+ private handleAuctionInit;
56
+ private handleAuctionEnd;
57
+ private handleBidRequested;
58
+ private handleBidResponse;
59
+ private handleBidTimeout;
60
+ private handleBidWon;
61
+ private handleNoBid;
62
+ private handleAdRenderFailed;
63
+ private isDuplicate;
64
+ private enqueue;
65
+ private shouldSample;
66
+ private requeue;
67
+ private drainBatch;
68
+ private sendFetch;
69
+ private handleSendFailure;
70
+ private flush;
71
+ private flushBeacon;
72
+ private log;
73
+ }
74
+ declare function registerPrebidAnalytics(pbjsGlobalName?: string, defaults?: Partial<AnalyticsConfig>): void;
75
+
76
+ type SlotSize = [number, number];
77
+ type SlotSizes = SlotSize[];
78
+ interface SizeMapping {
79
+ minViewport: [number, number];
80
+ sizes: SlotSizes;
81
+ }
82
+ interface SlotConfig {
83
+ /** The internal slot name (alphanumeric/underscores), e.g., 'leaderboard' */
84
+ slot?: string;
85
+ /** A CSS selector to locate the ad divs, e.g., '.ad-slot' */
86
+ selector?: string;
87
+ /** The list of sizes this slot accepts, e.g., [[300, 250], [728, 90]] */
88
+ sizes: SlotSizes;
89
+ /** Responsive size mappings. Defines which sizes apply at which viewport width. */
90
+ sizeMappings?: SizeMapping[];
91
+ /** Optional string mapping to an Ad Unit path for the auction/adserver. */
92
+ adUnitPath?: string;
93
+ /** Labels to target or exclude certain campaigns. */
94
+ /** Allowed media types, e.g., ["banner", "video"]. Defaults to "banner". */
95
+ mediaTypes?: string[];
96
+ /** Per-slot refresh interval in ms. Overrides property-level default. 0 = disabled. */
97
+ refreshInterval?: number;
98
+ /** Unique ID for the slot config. */
99
+ id?: string;
100
+ }
101
+ interface AdsGlobal {
102
+ /** Command queue array. Push functions here to be executed after the SDK initializes. */
103
+ q?: any[];
104
+ /** Whether the SDK has fully loaded. */
105
+ loaded?: boolean;
106
+ /** Retrieves the current pageview and session IDs. */
107
+ getContext?: () => {
108
+ pageviewId: string;
109
+ sessionId: string;
110
+ };
111
+ /**
112
+ * Dynamically register and configure an ad slot based on a CSS selector.
113
+ * If config is omitted, it will attempt to read dimensions from the element.
114
+ */
115
+ defineSlot?: (selector: string, config?: Partial<SlotConfig>) => void;
116
+ /** Tear down a single slot by its assigned element ID. */
117
+ destroySlot?: (elementId: string) => void;
118
+ /** Clean up all slots. */
119
+ destroyAll?: () => void;
120
+ /** Force an immediate refresh of a single slot, skipping the timer. */
121
+ refreshSlot?: (elementId: string) => void;
122
+ /** Force an immediate refresh of all registered slots. */
123
+ refreshAll?: () => void;
124
+ /** Notify the SDK that an SPA route transition happened so analytics and tracking reset. */
125
+ navigate?: (url?: string) => void;
126
+ }
127
+ /**
128
+ * Returns the global bidkernel SDK object interface.
129
+ * If the stub has not yet been initialized by the snippet, this will automatically
130
+ * create the `window.bidkernel` command queue stub.
131
+ *
132
+ * @param alias The global window alias for the SDK (defaults to 'bidkernel').
133
+ */
134
+ declare function getbidkernel(alias?: string): AdsGlobal;
135
+
136
+ export { type AdsGlobal, type AnalyticsConfig, BidkernelPrebidAnalytics, PrebidEventDeduper, type SizeMapping, type SlotConfig, type SlotSize, type SlotSizes, getPrebidEventKey, getbidkernel, registerPrebidAnalytics };
@@ -0,0 +1,136 @@
1
+ interface AnalyticsConfig {
2
+ endpoint: string;
3
+ propertyId: string;
4
+ pageviewId?: string;
5
+ sessionId?: string;
6
+ userId?: string;
7
+ deviceType?: string;
8
+ country?: string;
9
+ region?: string;
10
+ auctionEnabled?: boolean;
11
+ warningsEnabled?: boolean;
12
+ errorsEnabled?: boolean;
13
+ logLevel?: "DEBUG" | "INFO" | "WARN" | "ERROR";
14
+ /** Window global holding the Prebid instance to attach to. Defaults to "pbjs". */
15
+ pbjsGlobalName?: string;
16
+ /** Whether to attach pbjs.onEvent listeners. Defaults to true. Set false for full SDK mode. */
17
+ attachPbjsListeners?: boolean;
18
+ }
19
+ /**
20
+ * Canonical duplicate-detection key for a Prebid event. Shared by the adapter
21
+ * and the diagnostic extension so the two can never drift apart. Covers the
22
+ * events the adapter forwards plus display-only events the extension shows.
23
+ */
24
+ declare function getPrebidEventKey(eventName: string, data: any): string;
25
+ /**
26
+ * Tracks Prebid events already seen, by object identity and by semantic key.
27
+ * Needed because pbjs.getEvents() replay and live listeners overlap.
28
+ */
29
+ declare class PrebidEventDeduper {
30
+ private seenObjects;
31
+ private seenKeys;
32
+ isDuplicate(eventName: string, data: any): boolean;
33
+ }
34
+ declare class BidkernelPrebidAnalytics {
35
+ private config;
36
+ private queue;
37
+ private errorCount;
38
+ private flushTimer;
39
+ private boundFlushBeacon;
40
+ private boundVisibilityChange;
41
+ private isEnabled;
42
+ private boundPbjsHandlers;
43
+ private pageUrl;
44
+ private deduper;
45
+ private consecutiveSendFailures;
46
+ private nextSendAllowedAt;
47
+ constructor(config: AnalyticsConfig);
48
+ enable(): void;
49
+ disable(): void;
50
+ private handleVisibilityChange;
51
+ trackRawEvent(level: string, eventName: string, data: any): void;
52
+ setUserId(userId: string): void;
53
+ setSessionId(sessionId: string): void;
54
+ navigate(pageviewId: string, pageUrl: string): void;
55
+ private handleAuctionInit;
56
+ private handleAuctionEnd;
57
+ private handleBidRequested;
58
+ private handleBidResponse;
59
+ private handleBidTimeout;
60
+ private handleBidWon;
61
+ private handleNoBid;
62
+ private handleAdRenderFailed;
63
+ private isDuplicate;
64
+ private enqueue;
65
+ private shouldSample;
66
+ private requeue;
67
+ private drainBatch;
68
+ private sendFetch;
69
+ private handleSendFailure;
70
+ private flush;
71
+ private flushBeacon;
72
+ private log;
73
+ }
74
+ declare function registerPrebidAnalytics(pbjsGlobalName?: string, defaults?: Partial<AnalyticsConfig>): void;
75
+
76
+ type SlotSize = [number, number];
77
+ type SlotSizes = SlotSize[];
78
+ interface SizeMapping {
79
+ minViewport: [number, number];
80
+ sizes: SlotSizes;
81
+ }
82
+ interface SlotConfig {
83
+ /** The internal slot name (alphanumeric/underscores), e.g., 'leaderboard' */
84
+ slot?: string;
85
+ /** A CSS selector to locate the ad divs, e.g., '.ad-slot' */
86
+ selector?: string;
87
+ /** The list of sizes this slot accepts, e.g., [[300, 250], [728, 90]] */
88
+ sizes: SlotSizes;
89
+ /** Responsive size mappings. Defines which sizes apply at which viewport width. */
90
+ sizeMappings?: SizeMapping[];
91
+ /** Optional string mapping to an Ad Unit path for the auction/adserver. */
92
+ adUnitPath?: string;
93
+ /** Labels to target or exclude certain campaigns. */
94
+ /** Allowed media types, e.g., ["banner", "video"]. Defaults to "banner". */
95
+ mediaTypes?: string[];
96
+ /** Per-slot refresh interval in ms. Overrides property-level default. 0 = disabled. */
97
+ refreshInterval?: number;
98
+ /** Unique ID for the slot config. */
99
+ id?: string;
100
+ }
101
+ interface AdsGlobal {
102
+ /** Command queue array. Push functions here to be executed after the SDK initializes. */
103
+ q?: any[];
104
+ /** Whether the SDK has fully loaded. */
105
+ loaded?: boolean;
106
+ /** Retrieves the current pageview and session IDs. */
107
+ getContext?: () => {
108
+ pageviewId: string;
109
+ sessionId: string;
110
+ };
111
+ /**
112
+ * Dynamically register and configure an ad slot based on a CSS selector.
113
+ * If config is omitted, it will attempt to read dimensions from the element.
114
+ */
115
+ defineSlot?: (selector: string, config?: Partial<SlotConfig>) => void;
116
+ /** Tear down a single slot by its assigned element ID. */
117
+ destroySlot?: (elementId: string) => void;
118
+ /** Clean up all slots. */
119
+ destroyAll?: () => void;
120
+ /** Force an immediate refresh of a single slot, skipping the timer. */
121
+ refreshSlot?: (elementId: string) => void;
122
+ /** Force an immediate refresh of all registered slots. */
123
+ refreshAll?: () => void;
124
+ /** Notify the SDK that an SPA route transition happened so analytics and tracking reset. */
125
+ navigate?: (url?: string) => void;
126
+ }
127
+ /**
128
+ * Returns the global bidkernel SDK object interface.
129
+ * If the stub has not yet been initialized by the snippet, this will automatically
130
+ * create the `window.bidkernel` command queue stub.
131
+ *
132
+ * @param alias The global window alias for the SDK (defaults to 'bidkernel').
133
+ */
134
+ declare function getbidkernel(alias?: string): AdsGlobal;
135
+
136
+ export { type AdsGlobal, type AnalyticsConfig, BidkernelPrebidAnalytics, PrebidEventDeduper, type SizeMapping, type SlotConfig, type SlotSize, type SlotSizes, getPrebidEventKey, getbidkernel, registerPrebidAnalytics };