@bidkernel/analytics 0.3.0 → 0.5.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/README.md +45 -12
- package/dist/analytics.global.js +1 -1
- package/dist/index.d.mts +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.js +749 -116
- package/dist/index.mjs +749 -116
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,21 +52,54 @@ analytics.enable();
|
|
|
52
52
|
|
|
53
53
|
## Configuration
|
|
54
54
|
|
|
55
|
-
| Option
|
|
56
|
-
|
|
|
57
|
-
| `endpoint`
|
|
58
|
-
| `propertyId`
|
|
59
|
-
| `pbjsGlobalName`
|
|
60
|
-
| `attachPbjsListeners`
|
|
61
|
-
| `auctionEnabled`
|
|
62
|
-
| `warningsEnabled`
|
|
63
|
-
| `errorsEnabled`
|
|
64
|
-
| `userId`
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
55
|
+
| Option | Default | Description |
|
|
56
|
+
| ----------------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `endpoint` | — | Ingest base URL; events POST to `{endpoint}/{propertyId}`. The standalone bundle defaults it to `https://by.bidkernel.io/t`. |
|
|
58
|
+
| `propertyId` | — | Your Bidkernel property ID. |
|
|
59
|
+
| `pbjsGlobalName` | `"pbjs"` | Window global holding the Prebid instance (for renamed installs). |
|
|
60
|
+
| `attachPbjsListeners` | `true` | Set `false` when events are fed via `trackRawEvent` (full SDK mode). |
|
|
61
|
+
| `auctionEnabled` | `true` | Collect auction lifecycle events. |
|
|
62
|
+
| `warningsEnabled` | `true` | Collect warning events. |
|
|
63
|
+
| `errorsEnabled` | `true` | Collect error events (capped per session). |
|
|
64
|
+
| `userId` | `""` (empty) | **Not generated — you must pass it.** See [User identity](#user-identity). |
|
|
65
|
+
| `sessionId` / `pageviewId` | generated | Override identity; a 30-minute rolling session is managed otherwise. |
|
|
66
|
+
| `deviceType` / `country` / `region` | server-derived | Optional client hints; ingest resolves these server-side. |
|
|
67
|
+
| `logLevel` | `"INFO"` | Console log verbosity. |
|
|
67
68
|
|
|
68
69
|
SPA navigations: call `analytics.navigate(newPageviewId, newUrl)` to flush the old pageview and continue under the new one.
|
|
69
70
|
|
|
71
|
+
## User identity
|
|
72
|
+
|
|
73
|
+
Unlike `sessionId` and `pageviewId`, the adapter never generates a `userId`.
|
|
74
|
+
The full edge-served Bidkernel SDK receives a persistent first-party user id
|
|
75
|
+
in its server-injected config; the npm adapter has no such source, so unless
|
|
76
|
+
you supply one, every event lands in the warehouse with a NULL `user_id` and
|
|
77
|
+
unique-user metrics are empty.
|
|
78
|
+
|
|
79
|
+
Pass your own stable identifier (a first-party cookie or your login user id —
|
|
80
|
+
never PII) when enabling analytics:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
pbjs.enableAnalytics([
|
|
84
|
+
{
|
|
85
|
+
provider: "bidkernel",
|
|
86
|
+
options: {
|
|
87
|
+
propertyId: "YOUR_PROPERTY_ID",
|
|
88
|
+
userId: getOrCreateFirstPartyUserId(), // e.g. a cookie-backed UUID
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
]);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Or set it later (e.g. once consent resolves) on a direct instance:
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
analytics.setUserId(userId);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Only events flushed after `setUserId` carry the id — batches are stamped at
|
|
101
|
+
send time, so set it as early as possible.
|
|
102
|
+
|
|
70
103
|
## Releasing
|
|
71
104
|
|
|
72
105
|
Publishing is automated by
|
package/dist/analytics.global.js
CHANGED
|
@@ -1 +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,d=!(!(o>>>7)&&e==0),a=(d?o|128:o)&255;if(n.push(a),!d)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,d=!!(o>>>7),a=(d?o|128:o)&255;if(n.push(a),!d)return}n.push(e>>>31&1)}}function B(t){let e=t[0]==="-";e&&(t=t.slice(1));let n=1e6,i=0,r=0;function s(o,d){let a=Number(t.slice(o,d));r*=n,i=i*n+a,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,d=r*2,a=1e7;return s>=a&&(o+=Math.floor(s/a),s%=a),o>=a&&(d+=Math.floor(o/a),o%=a),d.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 R(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,$,U=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 d=typeof o=="bigint"?o:BigInt(o);if(d>i||d<n)throw new Error(`invalid int64: ${o}`);return d},uParse(o){let d=typeof o=="bigint"?o:BigInt(o);if(d>s||d<r)throw new Error(`invalid uint64: ${o}`);return d},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,d){return t.setInt32(0,o,!0),t.setInt32(4,d,!0),t.getBigInt64(0,!0)},uDec(o,d){return t.setInt32(0,o,!0),t.setInt32(4,d,!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),B(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),K(n),B(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";U();u=pe()});function S(){if(globalThis[N]==null){let t=new globalThis.TextEncoder,e=new globalThis.TextDecoder;globalThis[N]={encodeUtf8(n){return t.encode(n)},decodeUtf8(n){return e.decode(n)},checkUtf8(n){try{return encodeURIComponent(n),!0}catch{return!1}}}}return globalThis[N]}var N,_=l(()=>{"use strict";N=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 Y(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,H=l(()=>{"use strict";U();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(Y(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return P(e),R(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){Y(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,R(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";H();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(x,t.toString())}catch{}}function ke(){let t=Date.now();try{if(typeof localStorage<"u"){let e=localStorage.getItem(oe),n=localStorage.getItem(x),i=n&&parseInt(n,10)||0;if(e&&i&&t-i<=de)return localStorage.setItem(x,t.toString()),e;let r=I();return localStorage.setItem(oe,r),localStorage.setItem(x,t.toString()),r}}catch{}return m&&b&&t-b<=de?(b=t,m):(m=I(),b=t,m)}function Re(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 ae(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 Ue(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(a){console.warn("[bidkernel] Failed to disable previous analytics instance:",a)}let d=new O({pbjsGlobalName:t,...e,...o});return d.enable(),n._bidkernelPrebidAnalytics=d,d},s=()=>{try{i.adapterManager&&typeof i.adapterManager.registerAnalyticsAdapter=="function"&&i.adapterManager.registerAnalyticsAdapter({adapter:{enableAnalytics:d=>{let a=y(d);a&&r(a)},disableAnalytics:()=>{n._bidkernelPrebidAnalytics&&n._bidkernelPrebidAnalytics.disable()}},code:"bidkernel"});let o=Ue(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,me,w,xe,De,Be,oe,x,de,m,b,F,O,ce=l(()=>{"use strict";re();we=20,se=1e4,me=50,w=200,xe=300*1e3,De=10,Be={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",x="_bidkernel_session_ts",de=1800*1e3,m=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=Re(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)],["adRenderSucceeded",this.handleAdRenderSucceeded.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),adRenderSucceeded:this.handleAdRenderSucceeded.bind(this)};for(let s of i){if(!s)continue;let o=s.eventType||s.event||s.name,d=s.args!==void 0?s.args:s.data!==void 0?s.data:s,a=r[o];a&&a(d)}}}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=Be[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 d=r.mediaType||"banner",{width:a,height:D}=ae(r.sizes||r.playerSize);this.enqueue(c.BID_REQUEST,"bidRequest",{auctionId:n,adUnitCode:r.adUnitCode||"",gpid:o,bid:{bidder:i,mediaType:d,width:a,height:D}});return}s.forEach(d=>{let a=null;d==="banner"?a=r.mediaTypes?.banner?.sizes||r.sizes:d==="video"?a=r.mediaTypes?.video?.playerSize||r.mediaTypes?.video?.sizes||r.playerSize:a=r.mediaTypes?.[d]?.sizes;let{width:D,height:fe}=ae(a);this.enqueue(c.BID_REQUEST,"bidRequest",{auctionId:n,adUnitCode:r.adUnitCode||"",gpid:o,bid:{bidder:i,mediaType:d,width:D,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||"")}}))}handleAdRenderSucceeded(e){if(this.isDuplicate("adRenderSucceeded",e))return;this.log("DEBUG","adRenderSucceeded",e);let n=e.bid||{};this.enqueue(c.IMPRESSION,"impression",{auctionId:n.auctionId||"",adUnitCode:e.adUnitCode||n.adUnitCode||"",bid:{bidder:n.bidderCode||n.bidder||"",cpm:Number.isFinite(n.originalCpm)?n.originalCpm:Number.isFinite(n.cpm)?n.cpm:0,currency:n.originalCurrency??n.currency??"USD",width:Number.isFinite(n.width)?n.width:0,height:Number.isFinite(n.height)?n.height:0,dealId:n.dealId||"",mediaType:n.mediaType||"banner",latencyMs:Number.isFinite(n.timeToRespond)?n.timeToRespond:0,advertiserDomain:n.meta?.advertiserDomains?.[0]||"",creativeId:n.creativeId||""}})}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>me?!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),xe);this.nextSendAllowedAt=Date.now()+n,this.consecutiveSendFailures<=De?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="https://by.bidkernel.io/t",Ne=window._bidkernelPbjsGlobal||"pbjs";L(Ne,{endpoint:ue});window.bidkernelPrebidAnalytics={...window.bidkernelPrebidAnalytics,register:(t,e)=>L(t,{endpoint:ue,...e})}});return Se();})();
|
|
1
|
+
"use strict";var bidkernelPrebidAnalyticsBundle=(()=>{var b=(i,e)=>()=>(i&&(e=i(i=0)),e);var Te=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);function H(){let i=0,e=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(i|=(r&127)<<n,(r&128)==0)return this.assertBounds(),[i,e]}let t=this.buf[this.pos++];if(i|=(t&15)<<28,e=(t&112)>>4,(t&128)==0)return this.assertBounds(),[i,e];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,(r&128)==0)return this.assertBounds(),[i,e]}throw new Error("invalid varint")}function w(i,e,t){for(let s=0;s<28;s=s+7){let o=i>>>s,a=!(!(o>>>7)&&e==0),d=(a?o|128:o)&255;if(t.push(d),!a)return}let n=i>>>28&15|(e&7)<<4,r=e>>3!=0;if(t.push((r?n|128:n)&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(t.push(d),!a)return}t.push(e>>>31&1)}}function U(i){let e=i[0]==="-";e&&(i=i.slice(1));let t=1e6,n=0,r=0;function s(o,a){let d=Number(i.slice(o,a));r*=t,n=n*t+d,n>=E&&(r=r+(n/E|0),n=n%E)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?Y(n,r):C(n,r)}function K(i,e){let t=C(i,e),n=t.hi&2147483648;n&&(t=Y(t.lo,t.hi));let r=N(t.lo,t.hi);return n?"-"+r:r}function N(i,e){if({lo:i,hi:e}=me(i,e),e<=2097151)return String(E*e+i);let t=i&16777215,n=(i>>>24|e<<8)&16777215,r=e>>16&65535,s=t+n*6777216+r*6710656,o=n+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()+z(o)+z(s)}function me(i,e){return{lo:i>>>0,hi:e>>>0}}function C(i,e){return{lo:i|0,hi:e|0}}function Y(i,e){return e=~e,i?i=~i+1:e+=1,C(i,e)}function P(i,e){if(i>=0){for(;i>127;)e.push(i&127|128),i=i>>>7;e.push(i)}else{for(let t=0;t<9;t++)e.push(i&127|128),i=i>>7;e.push(1)}}function j(){let i=this.buf[this.pos++],e=i&127;if((i&128)==0)return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<7,(i&128)==0)return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<14,(i&128)==0)return this.assertBounds(),e;if(i=this.buf[this.pos++],e|=(i&127)<<21,(i&128)==0)return this.assertBounds(),e;i=this.buf[this.pos++],e|=(i&15)<<28;for(let t=5;(i&128)!==0&&t<10;t++)i=this.buf[this.pos++];if((i&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var E,z,_=b(()=>{"use strict";E=4294967296;z=i=>{let e=String(i);return"0000000".slice(e.length)+e}});function ge(){let i=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof i.getBigInt64=="function"&&typeof i.getBigUint64=="function"&&typeof i.setBigInt64=="function"&&typeof i.setBigUint64=="function"&&(!!globalThis.Deno||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let t=BigInt("-9223372036854775808"),n=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>n||a<t)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 i.setBigInt64(0,this.parse(o),!0),{lo:i.getInt32(0,!0),hi:i.getInt32(4,!0)}},uEnc(o){return i.setBigInt64(0,this.uParse(o),!0),{lo:i.getInt32(0,!0),hi:i.getInt32(4,!0)}},dec(o,a){return i.setInt32(0,o,!0),i.setInt32(4,a,!0),i.getBigInt64(0,!0)},uDec(o,a){return i.setInt32(0,o,!0),i.setInt32(4,a,!0),i.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(t){return typeof t!="string"&&(t=t.toString()),X(t),t},uParse(t){return typeof t!="string"&&(t=t.toString()),Q(t),t},enc(t){return typeof t!="string"&&(t=t.toString()),X(t),U(t)},uEnc(t){return typeof t!="string"&&(t=t.toString()),Q(t),U(t)},dec(t,n){return K(t,n)},uDec(t,n){return N(t,n)}}}function X(i){if(!/^-?[0-9]+$/.test(i))throw new Error("invalid int64: "+i)}function Q(i){if(!/^[0-9]+$/.test(i))throw new Error("invalid uint64: "+i)}var h,Z=b(()=>{"use strict";_();h=ge()});function V(){if(globalThis[M]==null){let i=new globalThis.TextEncoder,e=new globalThis.TextDecoder;globalThis[M]={encodeUtf8(t){return i.encode(t)},decodeUtf8(t){return e.decode(t)},checkUtf8(t){try{return encodeURIComponent(t),!0}catch{return!1}}}}return globalThis[M]}var M,O=b(()=>{"use strict";M=Symbol.for("@bufbuild/protobuf/text-encoding")});function F(i){if(typeof i=="string")i=Number(i);else if(typeof i!="number")throw new Error("invalid int32: "+typeof i);if(!Number.isInteger(i)||i>xe||i<Se)throw new Error("invalid int32: "+i)}function J(i){if(typeof i=="string")i=Number(i);else if(typeof i!="number")throw new Error("invalid uint32: "+typeof i);if(!Number.isInteger(i)||i>we||i<0)throw new Error("invalid uint32: "+i)}function Re(i){if(typeof i=="string"){let e=i;if(i=Number(i),Number.isNaN(i)&&e!=="NaN")throw new Error("invalid float32: "+e)}else if(typeof i!="number")throw new Error("invalid float32: "+typeof i);if(Number.isFinite(i)&&(i>ve||i<Ee))throw new Error("invalid float32: "+i)}var I,ve,Ee,we,xe,Se,T,p,ee=b(()=>{"use strict";_();Z();O();(function(i){i[i.Varint=0]="Varint",i[i.Bit64=1]="Bit64",i[i.LengthDelimited=2]="LengthDelimited",i[i.StartGroup=3]="StartGroup",i[i.EndGroup=4]="EndGroup",i[i.Bit32=5]="Bit32"})(I||(I={}));ve=34028234663852886e22,Ee=-34028234663852886e22,we=4294967295,xe=2147483647,Se=-2147483648,T=class{constructor(e=V().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 t=new Uint8Array(e),n=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],n),n+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(J(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return F(e),P(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 t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Re(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){J(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){F(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return F(e),e=(e<<1^e>>31)>>>0,P(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=h.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=h.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=h.enc(e);return w(t.lo,t.hi,this.buf),this}sint64(e){let t=h.enc(e),n=t.hi>>31,r=t.lo<<1^n,s=(t.hi<<1|t.lo>>>31)^n;return w(r,s,this.buf),this}uint64(e){let t=h.uEnc(e);return w(t.lo,t.hi,this.buf),this}},p=class{constructor(e,t=V().decodeUtf8){this.decodeUtf8=t,this.varint64=H,this.uint32=j,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(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case I.Varint:for(;this.buf[this.pos++]&128;);break;case I.Bit64:this.pos+=4;case I.Bit32:this.pos+=4;break;case I.LengthDelimited:let r=this.uint32();this.pos+=r;break;case I.StartGroup:for(;;){let[s,o]=this.tag();if(o===I.EndGroup){if(t!==void 0&&s!==t)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(n,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 h.dec(...this.varint64())}uint64(){return h.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,h.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return h.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return h.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(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}}});var te=b(()=>{"use strict"});var ie=b(()=>{"use strict"});var ne=b(()=>{"use strict"});var re=b(()=>{"use strict";ee();te();O();ie();ne()});function se(){return{propertyId:"",pageviewId:"",sessionId:"",pageUrl:"",country:"",region:"",deviceType:"",userId:"",domain:"",events:[],browser:"",deviceManufacturer:"",deviceModel:"",city:"",postalCode:""}}function oe(){return{timestampMs:0,type:0,eventName:"",auctionId:"",transactionId:"",adUnitCode:"",bid:void 0,namespace:"",eventId:"",metadata:{},viewableDurationMs:void 0}}function ae(){return{key:"",value:""}}function de(){return{bidder:"",cpm:0,currency:"",width:0,height:0,dealId:"",mediaType:"",latencyMs:0,advertiserDomain:"",creativeId:""}}var u,R,x,L,S,ce=b(()=>{"use strict";re();u={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};R={encode(i,e=new T){if(i.propertyId!==void 0&&i.propertyId!==""&&e.uint32(10).string(i.propertyId),i.pageviewId!==void 0&&i.pageviewId!==""&&e.uint32(18).string(i.pageviewId),i.sessionId!==void 0&&i.sessionId!==""&&e.uint32(26).string(i.sessionId),i.pageUrl!==void 0&&i.pageUrl!==""&&e.uint32(34).string(i.pageUrl),i.country!==void 0&&i.country!==""&&e.uint32(42).string(i.country),i.region!==void 0&&i.region!==""&&e.uint32(50).string(i.region),i.deviceType!==void 0&&i.deviceType!==""&&e.uint32(58).string(i.deviceType),i.userId!==void 0&&i.userId!==""&&e.uint32(66).string(i.userId),i.domain!==void 0&&i.domain!==""&&e.uint32(74).string(i.domain),i.events!==void 0&&i.events.length!==0)for(let t of i.events)x.encode(t,e.uint32(82).fork()).join();return i.browser!==void 0&&i.browser!==""&&e.uint32(90).string(i.browser),i.deviceManufacturer!==void 0&&i.deviceManufacturer!==""&&e.uint32(98).string(i.deviceManufacturer),i.deviceModel!==void 0&&i.deviceModel!==""&&e.uint32(106).string(i.deviceModel),i.city!==void 0&&i.city!==""&&e.uint32(114).string(i.city),i.postalCode!==void 0&&i.postalCode!==""&&e.uint32(122).string(i.postalCode),e},decode(i,e){let t=i instanceof p?i:new p(i),n=e===void 0?t.len:t.pos+e,r=se();for(;t.pos<n;){let s=t.uint32();switch(s>>>3){case 1:{if(s!==10)break;r.propertyId=t.string();continue}case 2:{if(s!==18)break;r.pageviewId=t.string();continue}case 3:{if(s!==26)break;r.sessionId=t.string();continue}case 4:{if(s!==34)break;r.pageUrl=t.string();continue}case 5:{if(s!==42)break;r.country=t.string();continue}case 6:{if(s!==50)break;r.region=t.string();continue}case 7:{if(s!==58)break;r.deviceType=t.string();continue}case 8:{if(s!==66)break;r.userId=t.string();continue}case 9:{if(s!==74)break;r.domain=t.string();continue}case 10:{if(s!==82)break;let o=x.decode(t,t.uint32());o!==void 0&&r.events.push(o);continue}case 11:{if(s!==90)break;r.browser=t.string();continue}case 12:{if(s!==98)break;r.deviceManufacturer=t.string();continue}case 13:{if(s!==106)break;r.deviceModel=t.string();continue}case 14:{if(s!==114)break;r.city=t.string();continue}case 15:{if(s!==122)break;r.postalCode=t.string();continue}}if((s&7)===4||s===0)break;t.skip(s&7)}return r},create(i){return R.fromPartial(i??{})},fromPartial(i){let e=se();return e.propertyId=i.propertyId??"",e.pageviewId=i.pageviewId??"",e.sessionId=i.sessionId??"",e.pageUrl=i.pageUrl??"",e.country=i.country??"",e.region=i.region??"",e.deviceType=i.deviceType??"",e.userId=i.userId??"",e.domain=i.domain??"",e.events=i.events?.map(t=>x.fromPartial(t))||[],e.browser=i.browser??"",e.deviceManufacturer=i.deviceManufacturer??"",e.deviceModel=i.deviceModel??"",e.city=i.city??"",e.postalCode=i.postalCode??"",e}};x={encode(i,e=new T){return i.timestampMs!==void 0&&i.timestampMs!==0&&e.uint32(9).double(i.timestampMs),i.type!==void 0&&i.type!==0&&e.uint32(16).int32(i.type),i.eventName!==void 0&&i.eventName!==""&&e.uint32(26).string(i.eventName),i.auctionId!==void 0&&i.auctionId!==""&&e.uint32(34).string(i.auctionId),i.transactionId!==void 0&&i.transactionId!==""&&e.uint32(42).string(i.transactionId),i.adUnitCode!==void 0&&i.adUnitCode!==""&&e.uint32(50).string(i.adUnitCode),i.bid!==void 0&&S.encode(i.bid,e.uint32(58).fork()).join(),i.namespace!==void 0&&i.namespace!==""&&e.uint32(66).string(i.namespace),i.eventId!==void 0&&i.eventId!==""&&e.uint32(74).string(i.eventId),globalThis.Object.entries(i.metadata||{}).forEach(([t,n])=>{L.encode({key:t,value:n},e.uint32(82).fork()).join()}),i.viewableDurationMs!==void 0&&e.uint32(89).double(i.viewableDurationMs),e},decode(i,e){let t=i instanceof p?i:new p(i),n=e===void 0?t.len:t.pos+e,r=oe();for(;t.pos<n;){let s=t.uint32();switch(s>>>3){case 1:{if(s!==9)break;r.timestampMs=t.double();continue}case 2:{if(s!==16)break;r.type=t.int32();continue}case 3:{if(s!==26)break;r.eventName=t.string();continue}case 4:{if(s!==34)break;r.auctionId=t.string();continue}case 5:{if(s!==42)break;r.transactionId=t.string();continue}case 6:{if(s!==50)break;r.adUnitCode=t.string();continue}case 7:{if(s!==58)break;r.bid=S.decode(t,t.uint32());continue}case 8:{if(s!==66)break;r.namespace=t.string();continue}case 9:{if(s!==74)break;r.eventId=t.string();continue}case 10:{if(s!==82)break;let o=L.decode(t,t.uint32());o.value!==void 0&&(r.metadata[o.key]=o.value);continue}case 11:{if(s!==89)break;r.viewableDurationMs=t.double();continue}}if((s&7)===4||s===0)break;t.skip(s&7)}return r},create(i){return x.fromPartial(i??{})},fromPartial(i){let e=oe();return e.timestampMs=i.timestampMs??0,e.type=i.type??0,e.eventName=i.eventName??"",e.auctionId=i.auctionId??"",e.transactionId=i.transactionId??"",e.adUnitCode=i.adUnitCode??"",e.bid=i.bid!==void 0&&i.bid!==null?S.fromPartial(i.bid):void 0,e.namespace=i.namespace??"",e.eventId=i.eventId??"",e.metadata=globalThis.Object.entries(i.metadata??{}).reduce((t,[n,r])=>(r!==void 0&&(t[n]=globalThis.String(r)),t),{}),e.viewableDurationMs=i.viewableDurationMs??void 0,e}};L={encode(i,e=new T){return i.key!==""&&e.uint32(10).string(i.key),i.value!==""&&e.uint32(18).string(i.value),e},decode(i,e){let t=i instanceof p?i:new p(i),n=e===void 0?t.len:t.pos+e,r=ae();for(;t.pos<n;){let s=t.uint32();switch(s>>>3){case 1:{if(s!==10)break;r.key=t.string();continue}case 2:{if(s!==18)break;r.value=t.string();continue}}if((s&7)===4||s===0)break;t.skip(s&7)}return r},create(i){return L.fromPartial(i??{})},fromPartial(i){let e=ae();return e.key=i.key??"",e.value=i.value??"",e}};S={encode(i,e=new T){return i.bidder!==void 0&&i.bidder!==""&&e.uint32(10).string(i.bidder),i.cpm!==void 0&&i.cpm!==0&&e.uint32(17).double(i.cpm),i.currency!==void 0&&i.currency!==""&&e.uint32(26).string(i.currency),i.width!==void 0&&i.width!==0&&e.uint32(32).int32(i.width),i.height!==void 0&&i.height!==0&&e.uint32(40).int32(i.height),i.dealId!==void 0&&i.dealId!==""&&e.uint32(50).string(i.dealId),i.mediaType!==void 0&&i.mediaType!==""&&e.uint32(58).string(i.mediaType),i.latencyMs!==void 0&&i.latencyMs!==0&&e.uint32(65).double(i.latencyMs),i.advertiserDomain!==void 0&&i.advertiserDomain!==""&&e.uint32(74).string(i.advertiserDomain),i.creativeId!==void 0&&i.creativeId!==""&&e.uint32(82).string(i.creativeId),e},decode(i,e){let t=i instanceof p?i:new p(i),n=e===void 0?t.len:t.pos+e,r=de();for(;t.pos<n;){let s=t.uint32();switch(s>>>3){case 1:{if(s!==10)break;r.bidder=t.string();continue}case 2:{if(s!==17)break;r.cpm=t.double();continue}case 3:{if(s!==26)break;r.currency=t.string();continue}case 4:{if(s!==32)break;r.width=t.int32();continue}case 5:{if(s!==40)break;r.height=t.int32();continue}case 6:{if(s!==50)break;r.dealId=t.string();continue}case 7:{if(s!==58)break;r.mediaType=t.string();continue}case 8:{if(s!==65)break;r.latencyMs=t.double();continue}case 9:{if(s!==74)break;r.advertiserDomain=t.string();continue}case 10:{if(s!==82)break;r.creativeId=t.string();continue}}if((s&7)===4||s===0)break;t.skip(s&7)}return r},create(i){return S.fromPartial(i??{})},fromPartial(i){let e=de();return e.bidder=i.bidder??"",e.cpm=i.cpm??0,e.currency=i.currency??"",e.width=i.width??0,e.height=i.height??0,e.dealId=i.dealId??"",e.mediaType=i.mediaType??"",e.latencyMs=i.latencyMs??0,e.advertiserDomain=i.advertiserDomain??"",e.creativeId=i.creativeId??"",e}}});function m(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let e=Math.random()*16|0;return(i==="x"?e:e&3|8).toString(16)})}function he(){let i=Date.now();v=i;try{typeof localStorage<"u"&&localStorage.setItem(B,i.toString())}catch{}}function Pe(){let i=Date.now();try{if(typeof localStorage<"u"){let e=localStorage.getItem(le),t=localStorage.getItem(B),n=t&&parseInt(t,10)||0;if(e&&n&&i-n<=fe)return localStorage.setItem(B,i.toString()),e;let r=m();return localStorage.setItem(le,r),localStorage.setItem(B,i.toString()),r}}catch{}return D&&v&&i-v<=fe?(v=i,D):(D=m(),v=i,D)}function c(i){return String(i??"").replace(/%/g,"%25").replace(/:/g,"%3A")}function _e(i,e){switch(i){case"auctionInit":return`auctionInit:${c(e?.auctionId)}`;case"auctionEnd":return`auctionEnd:${c(e?.auctionId)}`;case"bidRequested":{let t=Array.isArray(e?.bids)?e.bids.map(n=>c(n?.bidId||n?.transactionId||n?.adUnitCode)).join(","):"";return`bidRequested:${c(e?.auctionId)}:${c(e?.bidderCode||e?.bidder)}:${t}`}case"bidResponse":{let t=e||{},n=t.creativeId||t.adId||t.requestId||t.bidId||"",r=t.originalCpm??t.cpm??"";return`bidResponse:${c(t.auctionId)}:${c(t.adUnitCode)}:${c(t.bidderCode||t.bidder)}:${c(n)}:${c(r)}`}case"bidTimeout":return"bidTimeout:"+(Array.isArray(e)?e:e?[e]:[]).map(n=>`${c(n?.auctionId)}:${c(n?.bidderCode||n?.bidder)}:${c(n?.bidId||n?.transactionId||n?.adUnitCode)}`).join(",");case"bidWon":{let t=e||{},n=t.creativeId||t.adId||t.requestId||t.bidId||"",r=t.originalCpm??t.cpm??"";return`bidWon:${c(t.auctionId)}:${c(t.adUnitCode)}:${c(t.bidderCode||t.bidder)}:${c(n)}:${c(r)}`}case"noBid":return`noBid:${c(e?.auctionId)}:${c(e?.adUnitCode)}:${c(e?.bidderCode||e?.bidder)}:${c(e?.bidId||e?.transactionId)}`;case"adRenderFailed":{let t=e?.bid||{};return`adRenderFailed:${c(t.auctionId||e?.auctionId)}:${c(t.adUnitCode||e?.adUnitCode)}:${c(t.bidderCode||t.bidder||e?.bidderCode||e?.bidder)}:${c(e?.reason)}:${c(e?.message)}`}case"adRenderSucceeded":{let t=e?.bid||e||{},n=t.creativeId||t.adId||e?.adId||"",r=t.originalCpm??t.cpm??"";return`adRenderSucceeded:${c(t.auctionId||e?.auctionId)}:${c(t.adUnitCode||e?.adUnitCode)}:${c(t.bidderCode||t.bidder)}:${c(n)}:${c(r)}`}case"setTargeting":return`setTargeting:${Object.keys(e||{}).sort().map(c).join(",")}`;case"auctionDebug":return`auctionDebug:${c(e?.type)}:${c(String(e?.arguments?.[0]??"").slice(0,50))}`;default:return""}}function pe(i){if(!i)return{width:0,height:0};let e=i;for(;Array.isArray(e)&&e.length>0&&Array.isArray(e[0]);)e=e[0];if(Array.isArray(e)&&e.length>=2){let t=Number(e[0]),n=Number(e[1]);return{width:Number.isFinite(t)?t:0,height:Number.isFinite(n)?n:0}}return{width:0,height:0}}function q(i){if(Number.isFinite(i?.width)&&Number.isFinite(i?.height))return{width:i.width,height:i.height};if(typeof i?.size=="string"){let e=i.size.match(/^(\d+)x(\d+)$/);if(e)return{width:Number(e[1]),height:Number(e[2])}}return{width:Number.isFinite(i?.width)?i.width:0,height:Number.isFinite(i?.height)?i.height:0}}function g(i){if(!i)return null;if(Array.isArray(i)){let e=i.find(t=>t?.provider==="bidkernel")??i.find(t=>t&&typeof t=="object"&&t.provider===void 0);return e?g(e):null}if(typeof i=="object"){if(i.options&&typeof i.options=="object")return i.options;if(i.config&&typeof i.config=="object")return i.config;if(i.propertyId||i.endpoint)return i}return null}function Me(i){if(!i)return null;if(i._bidkernelAnalyticsConfig){let e=g(i._bidkernelAnalyticsConfig);if(e)return e}if(i.bidkernelPrebidAnalytics){let e=i.bidkernelPrebidAnalytics;if(e.options){let t=g(e.options);if(t)return t}if(e.config){let t=g(e.config);if(t)return t}if(e.propertyId)return g(e)}return null}function G(i="pbjs",e){let t=typeof window<"u"?window:{};t[i]=t[i]||{};let n=t[i],r=o=>{if(t._bidkernelPrebidAnalytics)try{t._bidkernelPrebidAnalytics.disable()}catch(d){console.warn("[bidkernel] Failed to disable previous analytics instance:",d)}let a=new W({pbjsGlobalName:i,...e,...o});return a.enable(),t._bidkernelPrebidAnalytics=a,a},s=()=>{try{n.adapterManager&&typeof n.adapterManager.registerAnalyticsAdapter=="function"&&n.adapterManager.registerAnalyticsAdapter({adapter:{enableAnalytics:a=>{let d=g(a);d&&r(d)},disableAnalytics:()=>{t._bidkernelPrebidAnalytics&&t._bidkernelPrebidAnalytics.disable()}},code:"bidkernel"});let o=Me(t);o&&(o.propertyId||e?.propertyId)&&r(o)}catch(o){console.warn("[bidkernel] Failed to register standard Prebid analytics adapter:",o)}};n.adapterManager&&typeof n.adapterManager.registerAnalyticsAdapter=="function"?s():(n.que=n.que||[],n.que.push(s))}var De,ue,Be,A,ke,Ue,Ne,Ce,le,B,fe,D,v,$,W,be=b(()=>{"use strict";ce();De=20,ue=1e4,Be=50,A=200,ke=300*1e3,Ue=10,Ne=32*1024,Ce={auctionStart:u.AUCTION_START,auctionEnd:u.AUCTION_END,bidRequest:u.BID_REQUEST,bidResponse:u.BID_RESPONSE,bidTimeout:u.BID_TIMEOUT,bidWin:u.BID_WIN,noBid:u.NO_BID,adRenderFailed:u.AD_RENDER_FAILED,click:u.CLICK,impression:u.IMPRESSION,refresh:u.REFRESH,timeInView:u.TIME_IN_VIEW,viewable:u.VIEWABLE},le="_bidkernel_session",B="_bidkernel_session_ts",fe=1800*1e3,D=null,v=0;$=class{seenObjects=new WeakMap;seenKeys=new Set;isDuplicate(e,t){if(!t)return!1;if(typeof t=="object"){let r=this.seenObjects.get(t);if(r){if(r.has(e))return!0;r.add(e)}else this.seenObjects.set(t,new Set([e]))}let n=_e(e,t);if(n){if(this.seenKeys.has(n))return!0;if(this.seenKeys.size>=1e3){let r=this.seenKeys.values().next().value;r!==void 0&&this.seenKeys.delete(r)}this.seenKeys.add(n)}return!1}};W=class i{static activeInstances=new Set;config;queue=[];errorCount=0;flushTimer=null;boundFlushBeacon;boundVisibilityChange;isEnabled=!1;boundPbjsHandlers=[];pageUrl="";deduper=new $;consecutiveSendFailures=0;nextSendAllowedAt=0;replayedEventCount=0;intersectionObserver=null;slotViewabilityRecords=new Map;elementToSlotId=new Map;slotRefreshIndices=new Map;pendingThresholdListeners=new Map;constructor(e){this.config={endpoint:e.endpoint||"",propertyId:e.propertyId||"",pageviewId:e.pageviewId||m(),sessionId:e.sessionId||Pe(),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,viewabilityEnabled:e.viewabilityEnabled??!0,logLevel:e.logLevel||"INFO",pbjsGlobalName:e.pbjsGlobalName||"pbjs",attachPbjsListeners:e.attachPbjsListeners??!0},this.boundFlushBeacon=()=>{this.flushAllSlotsTimeInView(),this.flushBeacon()},this.boundVisibilityChange=()=>this.handleVisibilityChange()}enable(){if(!this.isEnabled){if(this.isEnabled=!0,i.activeInstances.add(this),this.config.endpoint||this.log("WARN","Endpoint is empty. Analytics events will not be transmitted."),this.config.viewabilityEnabled&&typeof IntersectionObserver<"u"){this.intersectionObserver=new IntersectionObserver(this.handleIntersection.bind(this),{threshold:[.5]});for(let e of this.slotViewabilityRecords.values())e.element&&this.intersectionObserver.observe(e.element)}if(this.config.attachPbjsListeners){let t=(typeof window<"u"?window:{})[this.config.pbjsGlobalName]||{};if(typeof t.onEvent=="function"){this.log("DEBUG","Attaching event listeners to pbjs");let n=[["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)],["adRenderSucceeded",this.handleAdRenderSucceeded.bind(this)]];for(let[r,s]of n)t.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 t.getEvents=="function")try{let n=t.getEvents();if(Array.isArray(n)){let r=n.slice(this.replayedEventCount);if(this.replayedEventCount=n.length,r.length>0){this.log("DEBUG",`Replaying ${r.length} historical events from pbjs.getEvents()`);let s={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),adRenderSucceeded:this.handleAdRenderSucceeded.bind(this)};for(let o of r){if(!o)continue;let a=o.eventType||o.event||o.name,d=o.args!==void 0?o.args:o.data!==void 0?o.data:o,f=s[a];f&&f(d)}}}}catch(n){this.log("WARN","Failed to replay historical events from pbjs.getEvents()",n)}}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(),ue)}}}disable(){if(this.isEnabled){this.flushAllSlotsTimeInView(),this.isEnabled=!1,i.activeInstances.delete(this);for(let e of this.slotViewabilityRecords.values()){e.dwellTimer&&(clearTimeout(e.dwellTimer),e.dwellTimer=null,e.dwellStartedAt=null);for(let t of e.thresholdListeners)t.timer&&(clearTimeout(t.timer),t.timer=null)}if(this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.slotViewabilityRecords.clear(),this.elementToSlotId.clear(),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 t=(typeof window<"u"?window:{})[this.config.pbjsGlobalName]||{};if(typeof t.offEvent=="function")for(let{event:n,handler:r}of this.boundPbjsHandlers)t.offEvent(n,r);this.boundPbjsHandlers=[]}this.flush()}}handleVisibilityChange(){if(!(typeof document>"u")){if(document.visibilityState==="hidden"){let e=typeof performance<"u"&&performance.now?performance.now():Date.now();for(let t of this.slotViewabilityRecords.values()){t.inView&&t.lastEnteredViewAt!==null&&(t.accumulatedTimeInViewMs+=Math.max(0,e-t.lastEnteredViewAt),t.lastEnteredViewAt=null,this.checkThresholdListeners(t)),t.dwellTimer&&(clearTimeout(t.dwellTimer),t.dwellTimer=null,t.dwellStartedAt=null);for(let r of t.thresholdListeners)r.timer&&(clearTimeout(r.timer),r.timer=null);let n=Math.round(t.accumulatedTimeInViewMs);n>0&&this.enqueue(u.TIME_IN_VIEW,"timeInView",{auctionId:t.auctionId,transactionId:t.transactionId,adUnitCode:t.adUnitCode,viewableDurationMs:n,bid:t.bidPayload,metadata:{...t.metadata,refresh_index:String(t.refreshIndex)}})}this.flushBeacon()}else if(document.visibilityState==="visible"){let e=typeof performance<"u"&&performance.now?performance.now():Date.now();for(let t of this.slotViewabilityRecords.values())if(t.inView){if(t.lastEnteredViewAt=e,!t.viewableFired&&t.dwellTimer===null){let n=t.mediaType==="video"?2e3:1e3;t.dwellStartedAt=e,t.dwellTimer=setTimeout(()=>{this.handleDwellComplete(t)},n)}this.scheduleThresholdTimers(t)}}}}handleIntersection(e){for(let t of e){let n=this.elementToSlotId.get(t.target);if(!n){for(let d of i.activeInstances)if(d!==this&&d.elementToSlotId.has(t.target)){d.handleIntersection([t]);break}continue}let r=this.slotViewabilityRecords.get(n);if(!r)continue;let s=t.isIntersecting&&(t.intersectionRatio===void 0||t.intersectionRatio>=.5),o=typeof document>"u"||document.visibilityState==="visible",a=typeof performance<"u"&&performance.now?performance.now():Date.now();if(s){if(!r.inView&&(r.inView=!0,o)){if(r.lastEnteredViewAt=a,!r.viewableFired&&r.dwellTimer===null){let d=r.mediaType==="video"?2e3:1e3;r.dwellStartedAt=a,r.dwellTimer=setTimeout(()=>{this.handleDwellComplete(r)},d)}this.scheduleThresholdTimers(r)}}else{r.inView&&(r.lastEnteredViewAt!==null&&(r.accumulatedTimeInViewMs+=Math.max(0,a-r.lastEnteredViewAt),r.lastEnteredViewAt=null),r.inView=!1,this.checkThresholdListeners(r)),r.dwellTimer!==null&&(clearTimeout(r.dwellTimer),r.dwellTimer=null,r.dwellStartedAt=null);for(let d of r.thresholdListeners)d.timer&&(clearTimeout(d.timer),d.timer=null)}}}handleDwellComplete(e){e.dwellTimer=null,e.dwellStartedAt=null,e.inView&&(typeof document<"u"&&document.visibilityState==="hidden"||e.viewableFired||(e.viewableFired=!0,this.enqueue(u.VIEWABLE,"viewable",{auctionId:e.auctionId,transactionId:e.transactionId,adUnitCode:e.adUnitCode,bid:e.bidPayload,metadata:{...e.metadata,refresh_index:String(e.refreshIndex)}})))}scheduleThresholdTimers(e){if(!e.inView||typeof document<"u"&&document.visibilityState==="hidden")return;let t=this.getCurrentTimeInView(e);for(let n of e.thresholdListeners)if(!n.fired)if(t>=n.thresholdMs){n.fired=!0,n.timer&&(clearTimeout(n.timer),n.timer=null);try{n.callback(e.slotId,t)}catch(r){this.log("ERROR","Error in threshold listener callback",r)}}else{n.timer&&clearTimeout(n.timer);let r=n.thresholdMs-t;n.timer=setTimeout(()=>{if(n.timer=null,!n.fired&&e.inView&&(typeof document>"u"||document.visibilityState==="visible")){let s=this.getCurrentTimeInView(e);if(s>=n.thresholdMs){n.fired=!0;try{n.callback(e.slotId,s)}catch(o){this.log("ERROR","Error in threshold listener callback",o)}}}},r)}}checkThresholdListeners(e){let t=this.getCurrentTimeInView(e);for(let n of e.thresholdListeners)if(!n.fired&&t>=n.thresholdMs){n.fired=!0,n.timer&&(clearTimeout(n.timer),n.timer=null);try{n.callback(e.slotId,t)}catch(r){this.log("ERROR","Error in threshold listener callback",r)}}}getCurrentTimeInView(e){let t=e.accumulatedTimeInViewMs;if(e.inView&&e.lastEnteredViewAt!==null){let n=typeof performance<"u"&&performance.now?performance.now():Date.now();t+=Math.max(0,n-e.lastEnteredViewAt)}return t}flushSlotTimeInView(e){let t=this.slotViewabilityRecords.get(e);if(!t)return;if(t.inView&&t.lastEnteredViewAt!==null){let r=typeof performance<"u"&&performance.now?performance.now():Date.now();t.accumulatedTimeInViewMs+=Math.max(0,r-t.lastEnteredViewAt),t.lastEnteredViewAt=null}let n=Math.round(t.accumulatedTimeInViewMs);n>0&&this.enqueue(u.TIME_IN_VIEW,"timeInView",{auctionId:t.auctionId,transactionId:t.transactionId,adUnitCode:t.adUnitCode,viewableDurationMs:n,bid:t.bidPayload,metadata:{...t.metadata,refresh_index:String(t.refreshIndex)}}),t.accumulatedTimeInViewMs=0}flushAllSlotsTimeInView(){for(let e of Array.from(this.slotViewabilityRecords.keys()))this.flushSlotTimeInView(e)}observeSlot(e,t,n){if(!this.config.viewabilityEnabled)return;let r=null;if(typeof e=="string"){if(typeof document<"u"){try{r=document.querySelector(e)||document.getElementById(e)}catch{r=document.getElementById(e)}r||(r=document.getElementById(e))}}else r=e;let s=t||n?.adUnitCode||(r?r.id:"")||m(),o=this.slotViewabilityRecords.get(s);if(o){if(n?.refreshIndex===void 0||n.refreshIndex>o.refreshIndex){this.flushSlotTimeInView(s);let d=n?.refreshIndex!==void 0?n.refreshIndex:(this.slotRefreshIndices.get(s)??o.refreshIndex)+1;this.slotRefreshIndices.set(s,d),n?.emitRefreshEvent!==!1&&this.enqueue(u.REFRESH,"refresh",{auctionId:n?.auctionId||o.auctionId,transactionId:n?.transactionId||o.transactionId,adUnitCode:s,bid:n?.bid??o.bidPayload,metadata:{...n?.metadata,refresh_index:String(d)}}),o.dwellTimer&&(clearTimeout(o.dwellTimer),o.dwellTimer=null,o.dwellStartedAt=null);for(let l of o.thresholdListeners)l.fired=!1,l.timer&&(clearTimeout(l.timer),l.timer=null);o.viewableFired=!1,o.accumulatedTimeInViewMs=0;let f=typeof performance<"u"&&performance.now?performance.now():Date.now();if(o.lastEnteredViewAt=o.inView?f:null,o.refreshIndex=d,o.auctionId=n?.auctionId||o.auctionId,o.transactionId=n?.transactionId||o.transactionId,o.mediaType=n?.mediaType||o.mediaType||"banner",o.bidPayload=n?.bid!==void 0?n.bid:o.bidPayload,o.metadata=n?.metadata??o.metadata,o.inView&&(typeof document>"u"||document.visibilityState==="visible")){let l=o.mediaType==="video"?2e3:1e3;o.dwellStartedAt=f,o.dwellTimer=setTimeout(()=>{this.handleDwellComplete(o)},l),this.scheduleThresholdTimers(o)}}else o.auctionId=n?.auctionId||o.auctionId,o.transactionId=n?.transactionId||o.transactionId,o.mediaType=n?.mediaType||o.mediaType,n?.bid!==void 0&&(o.bidPayload=n.bid),n?.metadata!==void 0&&(o.metadata=n.metadata);r&&(o.element&&o.element!==r&&this.intersectionObserver&&(this.intersectionObserver.unobserve(o.element),this.elementToSlotId.delete(o.element)),o.element=r,this.elementToSlotId.set(r,s),this.intersectionObserver?.observe(r))}else{let a=n?.refreshIndex??this.slotRefreshIndices.get(s)??0;this.slotRefreshIndices.set(s,a);let d=this.pendingThresholdListeners.get(s)||new Set;this.pendingThresholdListeners.delete(s);let f={slotId:s,element:r,adUnitCode:n?.adUnitCode||s,auctionId:n?.auctionId||"",transactionId:n?.transactionId||"",mediaType:n?.mediaType||"banner",bidPayload:n?.bid,metadata:n?.metadata,refreshIndex:a,inView:!1,lastEnteredViewAt:null,accumulatedTimeInViewMs:0,viewableFired:!1,dwellTimer:null,dwellStartedAt:null,thresholdListeners:d};this.slotViewabilityRecords.set(s,f),r&&(this.elementToSlotId.set(r,s),this.intersectionObserver?.observe(r))}}unobserveSlot(e){let t=this.slotViewabilityRecords.get(e);if(t){this.flushSlotTimeInView(e),t.dwellTimer&&(clearTimeout(t.dwellTimer),t.dwellTimer=null,t.dwellStartedAt=null);for(let n of t.thresholdListeners)n.timer&&(clearTimeout(n.timer),n.timer=null);t.thresholdListeners=new Set,t.element&&this.intersectionObserver&&(this.intersectionObserver.unobserve(t.element),this.elementToSlotId.delete(t.element),t.element=null),t.inView=!1,t.lastEnteredViewAt=null}}destroySlot(e){this.unobserveSlot(e),this.slotViewabilityRecords.delete(e),this.slotRefreshIndices.delete(e),this.pendingThresholdListeners.delete(e)}onTimeInViewThreshold(e,t,n){let r={thresholdMs:t,callback:n,timer:null,fired:!1},s=this.slotViewabilityRecords.get(e);if(s){s.thresholdListeners.add(r);let o=this.getCurrentTimeInView(s);if(o>=t){r.fired=!0;try{n(e,o)}catch(a){this.log("ERROR","Error in threshold callback",a)}}else if(s.inView&&(typeof document>"u"||document.visibilityState==="visible")){let a=t-o;r.timer=setTimeout(()=>{if(r.timer=null,!r.fired&&s.inView&&(typeof document>"u"||document.visibilityState==="visible")){let d=this.getCurrentTimeInView(s);if(d>=t){r.fired=!0;try{n(e,d)}catch(f){this.log("ERROR","Error in threshold callback",f)}}}},a)}}else this.pendingThresholdListeners.has(e)||this.pendingThresholdListeners.set(e,new Set),this.pendingThresholdListeners.get(e).add(r);return()=>{r.timer&&(clearTimeout(r.timer),r.timer=null),s&&s.thresholdListeners.delete(r);let o=this.pendingThresholdListeners.get(e);o&&o.delete(r)}}getViewabilityState(e){let t=this.slotViewabilityRecords.get(e);if(!t)return;let n=Math.round(this.getCurrentTimeInView(t));return{inView:t.inView,viewable:t.viewableFired,timeInViewMs:n,refreshIndex:t.refreshIndex}}getRefreshIndex(e){return this.slotRefreshIndices.get(e)??0}triggerSlotRefresh(e,t){let n=this.slotViewabilityRecords.get(e);n&&n.element&&this.observeSlot(n.element,e,t)}trackRawEvent(e,t,n){let r=Ce[t]??(e==="ERROR"?u.ERROR:u.TRACE_EVENT_TYPE_UNSPECIFIED);this.enqueue(r,t,n,e)}setUserId(e){this.config.userId=e}setSessionId(e){this.config.sessionId=e}navigate(e,t){if(this.disable(),this.slotRefreshIndices.clear(),this.pendingThresholdListeners.clear(),this.config.pageviewId=e||m(),t)try{let n=new URL(t);this.pageUrl=n.origin+n.pathname}catch{this.pageUrl=t}else this.pageUrl="";he(),this.enable()}handleAuctionInit(e){this.isDuplicate("auctionInit",e)||(this.log("DEBUG","auctionInit",e),this.enqueue(u.AUCTION_START,"auctionStart",{auctionId:e.auctionId||"",transactionId:e.transactionId||""}))}handleAuctionEnd(e){this.isDuplicate("auctionEnd",e)||(this.log("DEBUG","auctionEnd",e),this.enqueue(u.AUCTION_END,"auctionEnd",{auctionId:e.auctionId||"",transactionId:e.transactionId||""}))}handleBidRequested(e){if(this.isDuplicate("bidRequested",e))return;this.log("DEBUG","bidRequested",e);let t=e.auctionId||"",n=e.bidderCode||e.bidder||"";Array.isArray(e.bids)&&e.bids.forEach(r=>{let s=Object.keys(r.mediaTypes||{}),o=r.ortb2Imp?.ext?.gpid||r.gpid||e.gpid||"",a=r.transactionId||r.ortb2Imp?.id||e.transactionId||"";if(s.length===0){let d=r.mediaType||"banner",{width:f,height:l}=pe(r.sizes||r.playerSize);this.enqueue(u.BID_REQUEST,"bidRequest",{auctionId:t,transactionId:a,adUnitCode:r.adUnitCode||"",gpid:o,bid:{bidder:n,mediaType:d,width:f,height:l}});return}s.forEach(d=>{let f=null;d==="banner"?f=r.mediaTypes?.banner?.sizes||r.sizes:d==="video"?f=r.mediaTypes?.video?.playerSize||r.mediaTypes?.video?.sizes||r.playerSize:f=r.mediaTypes?.[d]?.sizes;let{width:l,height:y}=pe(f);this.enqueue(u.BID_REQUEST,"bidRequest",{auctionId:t,transactionId:a,adUnitCode:r.adUnitCode||"",gpid:o,bid:{bidder:n,mediaType:d,width:l,height:y}})})})}handleBidResponse(e){this.isDuplicate("bidResponse",e)||(this.log("DEBUG","bidResponse",e),this.enqueue(u.BID_RESPONSE,"bidResponse",{auctionId:e.auctionId||"",transactionId:e.transactionId||"",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",...q(e),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){if(this.isDuplicate("bidTimeout",e))return;this.log("DEBUG","bidTimeout",e);let t=Array.isArray(e)?e:e?[e]:[];for(let n of t)this.enqueue(u.BID_TIMEOUT,"bidTimeout",{auctionId:n.auctionId||"",transactionId:n.transactionId||"",adUnitCode:n.adUnitCode||"",bid:{bidder:n.bidderCode||n.bidder||"",latencyMs:Number.isFinite(n.timeout)?n.timeout:0}})}handleBidWon(e){this.isDuplicate("bidWon",e)||(this.log("DEBUG","bidWon",e),this.enqueue(u.BID_WIN,"bidWon",{auctionId:e.auctionId||"",transactionId:e.transactionId||"",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",...q(e),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(u.NO_BID,"noBid",{auctionId:e.auctionId||"",transactionId:e.transactionId||"",adUnitCode:e.adUnitCode||"",bid:{bidder:e.bidderCode||e.bidder||""}}))}handleAdRenderFailed(e){if(this.isDuplicate("adRenderFailed",e))return;this.log("DEBUG","adRenderFailed",e);let t=e.bid||{};this.enqueue(u.AD_RENDER_FAILED,"adRenderFailed",{auctionId:t.auctionId||e.auctionId||"",transactionId:t.transactionId||e.transactionId||"",adUnitCode:t.adUnitCode||e.adUnitCode||"",bid:{bidder:t.bidderCode||t.bidder||e.bidderCode||e.bidder||""},metadata:{reason:String(e.reason||""),message:String(e.message||e.error?.message||"")},error:e.error||(e.message?new Error(String(e.message)):void 0)})}handleAdRenderSucceeded(e){if(this.isDuplicate("adRenderSucceeded",e))return;this.log("DEBUG","adRenderSucceeded",e);let t=e.bid||e||{},n=e.adUnitCode||t.adUnitCode||"",r=t.auctionId||e.auctionId||"",s=t.transactionId||e.transactionId||"",o=t.mediaType||"banner",a={bidder:t.bidderCode||t.bidder||"",cpm:Number.isFinite(t.originalCpm)?t.originalCpm:Number.isFinite(t.cpm)?t.cpm:0,currency:t.originalCurrency??t.currency??"USD",...q(t),dealId:t.dealId||"",mediaType:o,latencyMs:Number.isFinite(t.timeToRespond)?t.timeToRespond:0,advertiserDomain:t.meta?.advertiserDomains?.[0]||"",creativeId:t.creativeId||""};if(n&&(this.slotViewabilityRecords.has(n)||this.slotRefreshIndices.has(n)&&this.slotRefreshIndices.get(n)>0)){this.flushSlotTimeInView(n);let l=(this.slotRefreshIndices.get(n)??0)+1;this.slotRefreshIndices.set(n,l),this.enqueue(u.REFRESH,"refresh",{auctionId:r,transactionId:s,adUnitCode:n,bid:a,metadata:{refresh_index:String(l)}})}else n&&!this.slotRefreshIndices.has(n)&&this.slotRefreshIndices.set(n,0);let f=n?this.slotRefreshIndices.get(n)??0:0;if(this.enqueue(u.IMPRESSION,"impression",{auctionId:r,transactionId:s,adUnitCode:n,bid:a,metadata:{refresh_index:String(f)}}),this.config.viewabilityEnabled&&typeof document<"u"){let l=null,y=n||e.adId||t.adId;if(y&&(l=document.getElementById(y)),!l&&typeof window<"u"&&window.googletag?.pubads)try{let Ie=window.googletag.pubads().getSlots();for(let k of Ie)if((k.getAdUnitPath?.()===n||k.getSlotElementId?.()===n)&&(l=document.getElementById(k.getSlotElementId()),l))break}catch{}if(!l&&y)try{l=document.querySelector(`[data-ad-slot="${y}"]`)||document.querySelector(`#${y}`)}catch{}l&&this.observeSlot(l,n||y,{adUnitCode:n,auctionId:r,transactionId:s,mediaType:o,bid:a,refreshIndex:f,emitRefreshEvent:!1})}}isDuplicate(e,t){return this.deduper.isDuplicate(e,t)}enqueue(e,t,n,r){if(!this.isEnabled||!this.shouldSample(e,r))return;he();let s={eventId:m(),timestampMs:Date.now(),type:e,eventName:t,auctionId:n.auctionId||"",transactionId:n.transactionId||"",adUnitCode:n.adUnitCode||n.elementId||"",namespace:n.ns||n.namespace||""};n.bid&&(s.bid={bidder:n.bid.bidder||"",cpm:Number.isFinite(n.bid.cpm)?n.bid.cpm:0,currency:n.bid.currency||"",width:Number.isFinite(n.bid.width)?n.bid.width:0,height:Number.isFinite(n.bid.height)?n.bid.height:0,dealId:n.bid.dealId||"",mediaType:n.bid.mediaType||"",latencyMs:Number.isFinite(n.bid.latencyMs)?n.bid.latencyMs:0,advertiserDomain:n.bid.advertiserDomain||"",creativeId:n.bid.creativeId||""}),n.viewableDurationMs!==void 0&&(s.viewableDurationMs=Number.isFinite(n.viewableDurationMs)?n.viewableDurationMs:0);let o={...n.metadata};n.error!==void 0&&n.error!==null&&(o.error=typeof n.error=="object"&&n.error.message?String(n.error.message):String(n.error)),n.gpid&&(o.gpid=String(n.gpid)),n.refreshIndex!==void 0&&o.refresh_index===void 0&&(o.refresh_index=String(n.refreshIndex)),Object.keys(o).length>0&&(s.metadata=o),this.queue.push(s),this.queue.length>A&&this.queue.splice(0,this.queue.length-A),this.queue.length>=De&&this.flush()}shouldSample(e,t){return e===u.ERROR?(this.errorCount++,this.errorCount>Be?!1:this.config.errorsEnabled):t==="WARN"?this.config.warningsEnabled:this.config.auctionEnabled}requeue(e){e.length&&(this.queue=e.concat(this.queue),this.queue.length>A&&this.queue.splice(0,this.queue.length-A))}drainBatch(){if(this.queue.length===0||!this.config.endpoint)return null;let e=this.queue,t=typeof window<"u"?window.location.hostname:"",n=s=>({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:t,events:s}),r=R.encode(n(e)).finish();for(;e.length>1&&r.byteLength>Ne;)e=e.slice(0,Math.floor(e.length/2)),r=R.encode(n(e)).finish();return this.queue=this.queue.slice(e.length),{url:`${this.config.endpoint}/${this.config.propertyId}`,encoded:r,events:e}}sendFetch(e,t=!1){let n={method:"POST",headers:{"Content-Type":"application/x-protobuf"},body:e.encoded};if(t&&(n.keepalive=!0),fetch(e.url,n).then(r=>{if(r.ok)this.consecutiveSendFailures=0,this.nextSendAllowedAt=0;else{if(this.log("WARN",`Failed to send batch: HTTP ${r.status}`),r.status>=400&&r.status<500){this.log("WARN",`Dropping batch due to non-retryable client error HTTP ${r.status}`);return}this.handleSendFailure(e.events)}}).catch(r=>{this.log("ERROR","Failed to send batch",r),this.handleSendFailure(e.events)}),typeof process<"u"&&typeof process._tickCallback=="function")try{process._tickCallback()}catch{}}handleSendFailure(e){this.consecutiveSendFailures++;let t=Math.min(ue*2**(this.consecutiveSendFailures-1),ke);this.nextSendAllowedAt=Date.now()+t,this.consecutiveSendFailures<=Ue?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();for(;e&&(this.sendFetch(e,!1),!(Date.now()<this.nextSendAllowedAt));)e=this.drainBatch()}flushBeacon(){let e=this.drainBatch();for(;e;){let t=!1;if(typeof navigator<"u"&&typeof navigator.sendBeacon=="function")try{let n=new Blob([e.encoded],{type:"application/x-protobuf"});t=navigator.sendBeacon(e.url,n)}catch{t=!1}t||this.sendFetch(e,!0),e=this.drainBatch()}}log(e,t,...n){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,t,...n);break;case"INFO":console.info(s,t,...n);break;case"WARN":console.warn(s,t,...n);break;case"ERROR":console.error(s,t,...n);break}}}});var Oe=Te(()=>{be();var ye="https://by.bidkernel.io/t",Ve=window._bidkernelPbjsGlobal||"pbjs";G(Ve,{endpoint:ye});window.bidkernelPrebidAnalytics={...window.bidkernelPrebidAnalytics,register:(i,e)=>G(i,{endpoint:ye,...e})}});return Oe();})();
|
package/dist/index.d.mts
CHANGED
|
@@ -10,12 +10,30 @@ interface AnalyticsConfig {
|
|
|
10
10
|
auctionEnabled?: boolean;
|
|
11
11
|
warningsEnabled?: boolean;
|
|
12
12
|
errorsEnabled?: boolean;
|
|
13
|
+
/** Whether to enable client-side IAB viewability and time-in-view measurement. Defaults to true. */
|
|
14
|
+
viewabilityEnabled?: boolean;
|
|
13
15
|
logLevel?: "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
14
16
|
/** Window global holding the Prebid instance to attach to. Defaults to "pbjs". */
|
|
15
17
|
pbjsGlobalName?: string;
|
|
16
18
|
/** Whether to attach pbjs.onEvent listeners. Defaults to true. Set false for full SDK mode. */
|
|
17
19
|
attachPbjsListeners?: boolean;
|
|
18
20
|
}
|
|
21
|
+
interface SlotObserveOptions {
|
|
22
|
+
adUnitCode?: string;
|
|
23
|
+
auctionId?: string;
|
|
24
|
+
transactionId?: string;
|
|
25
|
+
mediaType?: string;
|
|
26
|
+
bid?: any;
|
|
27
|
+
metadata?: Record<string, string>;
|
|
28
|
+
refreshIndex?: number;
|
|
29
|
+
emitRefreshEvent?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface SlotViewabilityState {
|
|
32
|
+
inView: boolean;
|
|
33
|
+
viewable: boolean;
|
|
34
|
+
timeInViewMs: number;
|
|
35
|
+
refreshIndex: number;
|
|
36
|
+
}
|
|
19
37
|
/**
|
|
20
38
|
* Canonical duplicate-detection key for a Prebid event. Shared by the adapter
|
|
21
39
|
* and the diagnostic extension so the two can never drift apart. Covers the
|
|
@@ -32,6 +50,7 @@ declare class PrebidEventDeduper {
|
|
|
32
50
|
isDuplicate(eventName: string, data: any): boolean;
|
|
33
51
|
}
|
|
34
52
|
declare class BidkernelPrebidAnalytics {
|
|
53
|
+
private static activeInstances;
|
|
35
54
|
private config;
|
|
36
55
|
private queue;
|
|
37
56
|
private errorCount;
|
|
@@ -44,10 +63,30 @@ declare class BidkernelPrebidAnalytics {
|
|
|
44
63
|
private deduper;
|
|
45
64
|
private consecutiveSendFailures;
|
|
46
65
|
private nextSendAllowedAt;
|
|
66
|
+
private replayedEventCount;
|
|
67
|
+
private intersectionObserver;
|
|
68
|
+
private slotViewabilityRecords;
|
|
69
|
+
private elementToSlotId;
|
|
70
|
+
private slotRefreshIndices;
|
|
71
|
+
private pendingThresholdListeners;
|
|
47
72
|
constructor(config: AnalyticsConfig);
|
|
48
73
|
enable(): void;
|
|
49
74
|
disable(): void;
|
|
50
75
|
private handleVisibilityChange;
|
|
76
|
+
private handleIntersection;
|
|
77
|
+
private handleDwellComplete;
|
|
78
|
+
private scheduleThresholdTimers;
|
|
79
|
+
private checkThresholdListeners;
|
|
80
|
+
private getCurrentTimeInView;
|
|
81
|
+
private flushSlotTimeInView;
|
|
82
|
+
private flushAllSlotsTimeInView;
|
|
83
|
+
observeSlot(element: HTMLElement | string, slotId?: string, options?: SlotObserveOptions): void;
|
|
84
|
+
unobserveSlot(slotId: string): void;
|
|
85
|
+
destroySlot(slotId: string): void;
|
|
86
|
+
onTimeInViewThreshold(slotId: string, thresholdMs: number, callback: (slotId: string, durationMs: number) => void): () => void;
|
|
87
|
+
getViewabilityState(slotId: string): SlotViewabilityState | undefined;
|
|
88
|
+
getRefreshIndex(slotId: string): number;
|
|
89
|
+
triggerSlotRefresh(slotId: string, options?: SlotObserveOptions): void;
|
|
51
90
|
trackRawEvent(level: string, eventName: string, data: any): void;
|
|
52
91
|
setUserId(userId: string): void;
|
|
53
92
|
setSessionId(sessionId: string): void;
|
|
@@ -134,4 +173,4 @@ interface AdsGlobal {
|
|
|
134
173
|
*/
|
|
135
174
|
declare function getbidkernel(alias?: string): AdsGlobal;
|
|
136
175
|
|
|
137
|
-
export { type AdsGlobal, type AnalyticsConfig, BidkernelPrebidAnalytics, PrebidEventDeduper, type SizeMapping, type SlotConfig, type SlotSize, type SlotSizes, getPrebidEventKey, getbidkernel, registerPrebidAnalytics };
|
|
176
|
+
export { type AdsGlobal, type AnalyticsConfig, BidkernelPrebidAnalytics, PrebidEventDeduper, type SizeMapping, type SlotConfig, type SlotObserveOptions, type SlotSize, type SlotSizes, type SlotViewabilityState, getPrebidEventKey, getbidkernel, registerPrebidAnalytics };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,12 +10,30 @@ interface AnalyticsConfig {
|
|
|
10
10
|
auctionEnabled?: boolean;
|
|
11
11
|
warningsEnabled?: boolean;
|
|
12
12
|
errorsEnabled?: boolean;
|
|
13
|
+
/** Whether to enable client-side IAB viewability and time-in-view measurement. Defaults to true. */
|
|
14
|
+
viewabilityEnabled?: boolean;
|
|
13
15
|
logLevel?: "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
14
16
|
/** Window global holding the Prebid instance to attach to. Defaults to "pbjs". */
|
|
15
17
|
pbjsGlobalName?: string;
|
|
16
18
|
/** Whether to attach pbjs.onEvent listeners. Defaults to true. Set false for full SDK mode. */
|
|
17
19
|
attachPbjsListeners?: boolean;
|
|
18
20
|
}
|
|
21
|
+
interface SlotObserveOptions {
|
|
22
|
+
adUnitCode?: string;
|
|
23
|
+
auctionId?: string;
|
|
24
|
+
transactionId?: string;
|
|
25
|
+
mediaType?: string;
|
|
26
|
+
bid?: any;
|
|
27
|
+
metadata?: Record<string, string>;
|
|
28
|
+
refreshIndex?: number;
|
|
29
|
+
emitRefreshEvent?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface SlotViewabilityState {
|
|
32
|
+
inView: boolean;
|
|
33
|
+
viewable: boolean;
|
|
34
|
+
timeInViewMs: number;
|
|
35
|
+
refreshIndex: number;
|
|
36
|
+
}
|
|
19
37
|
/**
|
|
20
38
|
* Canonical duplicate-detection key for a Prebid event. Shared by the adapter
|
|
21
39
|
* and the diagnostic extension so the two can never drift apart. Covers the
|
|
@@ -32,6 +50,7 @@ declare class PrebidEventDeduper {
|
|
|
32
50
|
isDuplicate(eventName: string, data: any): boolean;
|
|
33
51
|
}
|
|
34
52
|
declare class BidkernelPrebidAnalytics {
|
|
53
|
+
private static activeInstances;
|
|
35
54
|
private config;
|
|
36
55
|
private queue;
|
|
37
56
|
private errorCount;
|
|
@@ -44,10 +63,30 @@ declare class BidkernelPrebidAnalytics {
|
|
|
44
63
|
private deduper;
|
|
45
64
|
private consecutiveSendFailures;
|
|
46
65
|
private nextSendAllowedAt;
|
|
66
|
+
private replayedEventCount;
|
|
67
|
+
private intersectionObserver;
|
|
68
|
+
private slotViewabilityRecords;
|
|
69
|
+
private elementToSlotId;
|
|
70
|
+
private slotRefreshIndices;
|
|
71
|
+
private pendingThresholdListeners;
|
|
47
72
|
constructor(config: AnalyticsConfig);
|
|
48
73
|
enable(): void;
|
|
49
74
|
disable(): void;
|
|
50
75
|
private handleVisibilityChange;
|
|
76
|
+
private handleIntersection;
|
|
77
|
+
private handleDwellComplete;
|
|
78
|
+
private scheduleThresholdTimers;
|
|
79
|
+
private checkThresholdListeners;
|
|
80
|
+
private getCurrentTimeInView;
|
|
81
|
+
private flushSlotTimeInView;
|
|
82
|
+
private flushAllSlotsTimeInView;
|
|
83
|
+
observeSlot(element: HTMLElement | string, slotId?: string, options?: SlotObserveOptions): void;
|
|
84
|
+
unobserveSlot(slotId: string): void;
|
|
85
|
+
destroySlot(slotId: string): void;
|
|
86
|
+
onTimeInViewThreshold(slotId: string, thresholdMs: number, callback: (slotId: string, durationMs: number) => void): () => void;
|
|
87
|
+
getViewabilityState(slotId: string): SlotViewabilityState | undefined;
|
|
88
|
+
getRefreshIndex(slotId: string): number;
|
|
89
|
+
triggerSlotRefresh(slotId: string, options?: SlotObserveOptions): void;
|
|
51
90
|
trackRawEvent(level: string, eventName: string, data: any): void;
|
|
52
91
|
setUserId(userId: string): void;
|
|
53
92
|
setSessionId(sessionId: string): void;
|
|
@@ -134,4 +173,4 @@ interface AdsGlobal {
|
|
|
134
173
|
*/
|
|
135
174
|
declare function getbidkernel(alias?: string): AdsGlobal;
|
|
136
175
|
|
|
137
|
-
export { type AdsGlobal, type AnalyticsConfig, BidkernelPrebidAnalytics, PrebidEventDeduper, type SizeMapping, type SlotConfig, type SlotSize, type SlotSizes, getPrebidEventKey, getbidkernel, registerPrebidAnalytics };
|
|
176
|
+
export { type AdsGlobal, type AnalyticsConfig, BidkernelPrebidAnalytics, PrebidEventDeduper, type SizeMapping, type SlotConfig, type SlotObserveOptions, type SlotSize, type SlotSizes, type SlotViewabilityState, getPrebidEventKey, getbidkernel, registerPrebidAnalytics };
|