@bidkernel/analytics 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics.global.js +1 -1
- package/dist/index.js +96 -121
- package/dist/index.mjs +96 -121
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -290,7 +290,6 @@ var TraceEventType = {
|
|
|
290
290
|
TRACE_EVENT_TYPE_UNSPECIFIED: 0,
|
|
291
291
|
AUCTION_START: 1,
|
|
292
292
|
AUCTION_END: 2,
|
|
293
|
-
BID_RESPONSE: 3,
|
|
294
293
|
BID_WIN: 4,
|
|
295
294
|
/** IMPRESSION - ad rendered into DOM */
|
|
296
295
|
IMPRESSION: 5,
|
|
@@ -321,14 +320,14 @@ var BidderOutcome = {
|
|
|
321
320
|
};
|
|
322
321
|
function createBaseTraceEventBatch() {
|
|
323
322
|
return {
|
|
324
|
-
propertyId:
|
|
325
|
-
pageviewId:
|
|
326
|
-
sessionId:
|
|
323
|
+
propertyId: new Uint8Array(0),
|
|
324
|
+
pageviewId: new Uint8Array(0),
|
|
325
|
+
sessionId: new Uint8Array(0),
|
|
327
326
|
pageUrl: "",
|
|
328
327
|
country: "",
|
|
329
328
|
region: "",
|
|
330
329
|
deviceType: "",
|
|
331
|
-
userId:
|
|
330
|
+
userId: new Uint8Array(0),
|
|
332
331
|
domain: "",
|
|
333
332
|
events: [],
|
|
334
333
|
browser: "",
|
|
@@ -340,14 +339,14 @@ function createBaseTraceEventBatch() {
|
|
|
340
339
|
}
|
|
341
340
|
var TraceEventBatch = {
|
|
342
341
|
encode(message, writer = new BinaryWriter()) {
|
|
343
|
-
if (message.propertyId !== void 0 && message.propertyId !==
|
|
344
|
-
writer.uint32(10).
|
|
342
|
+
if (message.propertyId !== void 0 && message.propertyId.length !== 0) {
|
|
343
|
+
writer.uint32(10).bytes(message.propertyId);
|
|
345
344
|
}
|
|
346
|
-
if (message.pageviewId !== void 0 && message.pageviewId !==
|
|
347
|
-
writer.uint32(18).
|
|
345
|
+
if (message.pageviewId !== void 0 && message.pageviewId.length !== 0) {
|
|
346
|
+
writer.uint32(18).bytes(message.pageviewId);
|
|
348
347
|
}
|
|
349
|
-
if (message.sessionId !== void 0 && message.sessionId !==
|
|
350
|
-
writer.uint32(26).
|
|
348
|
+
if (message.sessionId !== void 0 && message.sessionId.length !== 0) {
|
|
349
|
+
writer.uint32(26).bytes(message.sessionId);
|
|
351
350
|
}
|
|
352
351
|
if (message.pageUrl !== void 0 && message.pageUrl !== "") {
|
|
353
352
|
writer.uint32(34).string(message.pageUrl);
|
|
@@ -361,8 +360,8 @@ var TraceEventBatch = {
|
|
|
361
360
|
if (message.deviceType !== void 0 && message.deviceType !== "") {
|
|
362
361
|
writer.uint32(58).string(message.deviceType);
|
|
363
362
|
}
|
|
364
|
-
if (message.userId !== void 0 && message.userId !==
|
|
365
|
-
writer.uint32(66).
|
|
363
|
+
if (message.userId !== void 0 && message.userId.length !== 0) {
|
|
364
|
+
writer.uint32(66).bytes(message.userId);
|
|
366
365
|
}
|
|
367
366
|
if (message.domain !== void 0 && message.domain !== "") {
|
|
368
367
|
writer.uint32(74).string(message.domain);
|
|
@@ -400,21 +399,21 @@ var TraceEventBatch = {
|
|
|
400
399
|
if (tag !== 10) {
|
|
401
400
|
break;
|
|
402
401
|
}
|
|
403
|
-
message.propertyId = reader.
|
|
402
|
+
message.propertyId = reader.bytes();
|
|
404
403
|
continue;
|
|
405
404
|
}
|
|
406
405
|
case 2: {
|
|
407
406
|
if (tag !== 18) {
|
|
408
407
|
break;
|
|
409
408
|
}
|
|
410
|
-
message.pageviewId = reader.
|
|
409
|
+
message.pageviewId = reader.bytes();
|
|
411
410
|
continue;
|
|
412
411
|
}
|
|
413
412
|
case 3: {
|
|
414
413
|
if (tag !== 26) {
|
|
415
414
|
break;
|
|
416
415
|
}
|
|
417
|
-
message.sessionId = reader.
|
|
416
|
+
message.sessionId = reader.bytes();
|
|
418
417
|
continue;
|
|
419
418
|
}
|
|
420
419
|
case 4: {
|
|
@@ -449,7 +448,7 @@ var TraceEventBatch = {
|
|
|
449
448
|
if (tag !== 66) {
|
|
450
449
|
break;
|
|
451
450
|
}
|
|
452
|
-
message.userId = reader.
|
|
451
|
+
message.userId = reader.bytes();
|
|
453
452
|
continue;
|
|
454
453
|
}
|
|
455
454
|
case 9: {
|
|
@@ -518,12 +517,12 @@ function createBaseTraceEvent() {
|
|
|
518
517
|
timestampMs: 0,
|
|
519
518
|
type: 0,
|
|
520
519
|
eventName: "",
|
|
521
|
-
auctionId:
|
|
522
|
-
transactionId:
|
|
520
|
+
auctionId: new Uint8Array(0),
|
|
521
|
+
transactionId: new Uint8Array(0),
|
|
523
522
|
adUnitCode: "",
|
|
524
523
|
bid: void 0,
|
|
525
524
|
namespace: "",
|
|
526
|
-
eventId:
|
|
525
|
+
eventId: new Uint8Array(0),
|
|
527
526
|
metadata: {},
|
|
528
527
|
viewableDurationMs: void 0,
|
|
529
528
|
bidderOutcomes: []
|
|
@@ -540,11 +539,11 @@ var TraceEvent = {
|
|
|
540
539
|
if (message.eventName !== void 0 && message.eventName !== "") {
|
|
541
540
|
writer.uint32(26).string(message.eventName);
|
|
542
541
|
}
|
|
543
|
-
if (message.auctionId !== void 0 && message.auctionId !==
|
|
544
|
-
writer.uint32(34).
|
|
542
|
+
if (message.auctionId !== void 0 && message.auctionId.length !== 0) {
|
|
543
|
+
writer.uint32(34).bytes(message.auctionId);
|
|
545
544
|
}
|
|
546
|
-
if (message.transactionId !== void 0 && message.transactionId !==
|
|
547
|
-
writer.uint32(42).
|
|
545
|
+
if (message.transactionId !== void 0 && message.transactionId.length !== 0) {
|
|
546
|
+
writer.uint32(42).bytes(message.transactionId);
|
|
548
547
|
}
|
|
549
548
|
if (message.adUnitCode !== void 0 && message.adUnitCode !== "") {
|
|
550
549
|
writer.uint32(50).string(message.adUnitCode);
|
|
@@ -555,8 +554,8 @@ var TraceEvent = {
|
|
|
555
554
|
if (message.namespace !== void 0 && message.namespace !== "") {
|
|
556
555
|
writer.uint32(66).string(message.namespace);
|
|
557
556
|
}
|
|
558
|
-
if (message.eventId !== void 0 && message.eventId !==
|
|
559
|
-
writer.uint32(74).
|
|
557
|
+
if (message.eventId !== void 0 && message.eventId.length !== 0) {
|
|
558
|
+
writer.uint32(74).bytes(message.eventId);
|
|
560
559
|
}
|
|
561
560
|
globalThis.Object.entries(message.metadata || {}).forEach(([key, value]) => {
|
|
562
561
|
TraceEvent_MetadataEntry.encode({ key, value }, writer.uint32(82).fork()).join();
|
|
@@ -603,14 +602,14 @@ var TraceEvent = {
|
|
|
603
602
|
if (tag !== 34) {
|
|
604
603
|
break;
|
|
605
604
|
}
|
|
606
|
-
message.auctionId = reader.
|
|
605
|
+
message.auctionId = reader.bytes();
|
|
607
606
|
continue;
|
|
608
607
|
}
|
|
609
608
|
case 5: {
|
|
610
609
|
if (tag !== 42) {
|
|
611
610
|
break;
|
|
612
611
|
}
|
|
613
|
-
message.transactionId = reader.
|
|
612
|
+
message.transactionId = reader.bytes();
|
|
614
613
|
continue;
|
|
615
614
|
}
|
|
616
615
|
case 6: {
|
|
@@ -638,7 +637,7 @@ var TraceEvent = {
|
|
|
638
637
|
if (tag !== 74) {
|
|
639
638
|
break;
|
|
640
639
|
}
|
|
641
|
-
message.eventId = reader.
|
|
640
|
+
message.eventId = reader.bytes();
|
|
642
641
|
continue;
|
|
643
642
|
}
|
|
644
643
|
case 10: {
|
|
@@ -721,24 +720,18 @@ var TraceEvent_MetadataEntry = {
|
|
|
721
720
|
}
|
|
722
721
|
};
|
|
723
722
|
function createBaseBidderOutcomeEntry() {
|
|
724
|
-
return {
|
|
723
|
+
return { adUnitCode: "", outcome: 0, bid: void 0 };
|
|
725
724
|
}
|
|
726
725
|
var BidderOutcomeEntry = {
|
|
727
726
|
encode(message, writer = new BinaryWriter()) {
|
|
728
|
-
if (message.bidder !== void 0 && message.bidder !== "") {
|
|
729
|
-
writer.uint32(10).string(message.bidder);
|
|
730
|
-
}
|
|
731
727
|
if (message.adUnitCode !== void 0 && message.adUnitCode !== "") {
|
|
732
728
|
writer.uint32(18).string(message.adUnitCode);
|
|
733
729
|
}
|
|
734
|
-
if (message.mediaType !== void 0 && message.mediaType !== "") {
|
|
735
|
-
writer.uint32(26).string(message.mediaType);
|
|
736
|
-
}
|
|
737
730
|
if (message.outcome !== void 0 && message.outcome !== 0) {
|
|
738
731
|
writer.uint32(32).int32(message.outcome);
|
|
739
732
|
}
|
|
740
|
-
if (message.
|
|
741
|
-
writer.uint32(
|
|
733
|
+
if (message.bid !== void 0) {
|
|
734
|
+
BidTrace.encode(message.bid, writer.uint32(50).fork()).join();
|
|
742
735
|
}
|
|
743
736
|
return writer;
|
|
744
737
|
},
|
|
@@ -749,13 +742,6 @@ var BidderOutcomeEntry = {
|
|
|
749
742
|
while (reader.pos < end) {
|
|
750
743
|
const tag = reader.uint32();
|
|
751
744
|
switch (tag >>> 3) {
|
|
752
|
-
case 1: {
|
|
753
|
-
if (tag !== 10) {
|
|
754
|
-
break;
|
|
755
|
-
}
|
|
756
|
-
message.bidder = reader.string();
|
|
757
|
-
continue;
|
|
758
|
-
}
|
|
759
745
|
case 2: {
|
|
760
746
|
if (tag !== 18) {
|
|
761
747
|
break;
|
|
@@ -763,13 +749,6 @@ var BidderOutcomeEntry = {
|
|
|
763
749
|
message.adUnitCode = reader.string();
|
|
764
750
|
continue;
|
|
765
751
|
}
|
|
766
|
-
case 3: {
|
|
767
|
-
if (tag !== 26) {
|
|
768
|
-
break;
|
|
769
|
-
}
|
|
770
|
-
message.mediaType = reader.string();
|
|
771
|
-
continue;
|
|
772
|
-
}
|
|
773
752
|
case 4: {
|
|
774
753
|
if (tag !== 32) {
|
|
775
754
|
break;
|
|
@@ -777,11 +756,11 @@ var BidderOutcomeEntry = {
|
|
|
777
756
|
message.outcome = reader.int32();
|
|
778
757
|
continue;
|
|
779
758
|
}
|
|
780
|
-
case
|
|
781
|
-
if (tag !==
|
|
759
|
+
case 6: {
|
|
760
|
+
if (tag !== 50) {
|
|
782
761
|
break;
|
|
783
762
|
}
|
|
784
|
-
message.
|
|
763
|
+
message.bid = BidTrace.decode(reader, reader.uint32());
|
|
785
764
|
continue;
|
|
786
765
|
}
|
|
787
766
|
}
|
|
@@ -928,8 +907,28 @@ var BidTrace = {
|
|
|
928
907
|
}
|
|
929
908
|
};
|
|
930
909
|
|
|
910
|
+
// src/ids.ts
|
|
911
|
+
var CANONICAL_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
912
|
+
var UUID_BYTES = 16;
|
|
913
|
+
var utf8Encoder = typeof TextEncoder !== "undefined" ? new TextEncoder() : null;
|
|
914
|
+
var utf8Decoder = typeof TextDecoder !== "undefined" ? new TextDecoder() : null;
|
|
915
|
+
function idToBytes(id) {
|
|
916
|
+
if (!id) return new Uint8Array(0);
|
|
917
|
+
if (CANONICAL_UUID.test(id)) {
|
|
918
|
+
const hex = id.replace(/-/g, "");
|
|
919
|
+
const out2 = new Uint8Array(UUID_BYTES);
|
|
920
|
+
for (let i = 0; i < UUID_BYTES; i++) {
|
|
921
|
+
out2[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
922
|
+
}
|
|
923
|
+
return out2;
|
|
924
|
+
}
|
|
925
|
+
if (utf8Encoder) return utf8Encoder.encode(id);
|
|
926
|
+
const out = new Uint8Array(id.length);
|
|
927
|
+
for (let i = 0; i < id.length; i++) out[i] = id.charCodeAt(i) & 255;
|
|
928
|
+
return out;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
931
|
// src/prebid-analytics.ts
|
|
932
|
-
var BATCH_SIZE = 20;
|
|
933
932
|
var FLUSH_INTERVAL_MS = 1e4;
|
|
934
933
|
var MAX_ERRORS_PER_SESSION = 50;
|
|
935
934
|
var MAX_QUEUE_SIZE = 200;
|
|
@@ -946,7 +945,6 @@ var PENDING_BATCH_CLEANUP_DELAY_MS = 1e4;
|
|
|
946
945
|
var EVENT_NAME_TO_TYPE = {
|
|
947
946
|
auctionStart: TraceEventType.AUCTION_START,
|
|
948
947
|
auctionEnd: TraceEventType.AUCTION_END,
|
|
949
|
-
bidResponse: TraceEventType.BID_RESPONSE,
|
|
950
948
|
bidWin: TraceEventType.BID_WIN,
|
|
951
949
|
adRenderFailed: TraceEventType.AD_RENDER_FAILED,
|
|
952
950
|
click: TraceEventType.CLICK,
|
|
@@ -2206,7 +2204,8 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2206
2204
|
}
|
|
2207
2205
|
}
|
|
2208
2206
|
trackRawEvent(level, eventName, data) {
|
|
2209
|
-
const eventType = EVENT_NAME_TO_TYPE[eventName] ?? (level === "ERROR" ? TraceEventType.ERROR :
|
|
2207
|
+
const eventType = EVENT_NAME_TO_TYPE[eventName] ?? (level === "ERROR" ? TraceEventType.ERROR : void 0);
|
|
2208
|
+
if (eventType === void 0) return;
|
|
2210
2209
|
this.enqueue(eventType, eventName, data, level);
|
|
2211
2210
|
}
|
|
2212
2211
|
setUserId(userId) {
|
|
@@ -2277,11 +2276,9 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2277
2276
|
const key = `${bidder}:${adUnitCode}`;
|
|
2278
2277
|
if (!auctionMap.has(key)) {
|
|
2279
2278
|
auctionMap.set(key, {
|
|
2280
|
-
bidder,
|
|
2281
2279
|
adUnitCode,
|
|
2282
|
-
mediaType,
|
|
2283
2280
|
outcome: BidderOutcome.BIDDER_OUTCOME_NO_RESPONSE,
|
|
2284
|
-
latencyMs: 0
|
|
2281
|
+
bid: { bidder, mediaType, latencyMs: 0 }
|
|
2285
2282
|
});
|
|
2286
2283
|
}
|
|
2287
2284
|
});
|
|
@@ -2297,43 +2294,23 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2297
2294
|
const latencyMs = Number.isFinite(data.timeToRespond) ? data.timeToRespond : 0;
|
|
2298
2295
|
const resMediaTypes = Object.keys(data.mediaTypes || {});
|
|
2299
2296
|
const mediaType = data.mediaType || (data.mediaTypes?.video ? "video" : resMediaTypes.length > 0 ? resMediaTypes[0] : "banner");
|
|
2300
|
-
if (auctionId
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
if (cpm > 0) {
|
|
2320
|
-
this.enqueue(TraceEventType.BID_RESPONSE, "bidResponse", {
|
|
2321
|
-
auctionId,
|
|
2322
|
-
transactionId: data.transactionId || "",
|
|
2323
|
-
adUnitCode,
|
|
2324
|
-
bid: {
|
|
2325
|
-
bidder,
|
|
2326
|
-
cpm,
|
|
2327
|
-
currency: data.originalCurrency ?? data.currency ?? "USD",
|
|
2328
|
-
...parseBidDimensions(data),
|
|
2329
|
-
dealId: data.dealId || "",
|
|
2330
|
-
mediaType,
|
|
2331
|
-
latencyMs,
|
|
2332
|
-
advertiserDomain: data.meta?.advertiserDomains?.[0] || "",
|
|
2333
|
-
creativeId: data.creativeId || ""
|
|
2334
|
-
}
|
|
2335
|
-
});
|
|
2336
|
-
}
|
|
2297
|
+
if (!auctionId || !bidder) return;
|
|
2298
|
+
const bid = cpm > 0 ? {
|
|
2299
|
+
bidder,
|
|
2300
|
+
cpm,
|
|
2301
|
+
currency: data.originalCurrency ?? data.currency ?? "USD",
|
|
2302
|
+
...parseBidDimensions(data),
|
|
2303
|
+
dealId: data.dealId || "",
|
|
2304
|
+
mediaType,
|
|
2305
|
+
latencyMs,
|
|
2306
|
+
advertiserDomain: data.meta?.advertiserDomains?.[0] || "",
|
|
2307
|
+
creativeId: data.creativeId || ""
|
|
2308
|
+
} : { bidder, mediaType, latencyMs };
|
|
2309
|
+
this.getOrCreateAuctionOutcomes(auctionId).set(`${bidder}:${adUnitCode}`, {
|
|
2310
|
+
adUnitCode,
|
|
2311
|
+
outcome: cpm > 0 ? BidderOutcome.BIDDER_OUTCOME_BID : BidderOutcome.BIDDER_OUTCOME_NO_BID,
|
|
2312
|
+
bid
|
|
2313
|
+
});
|
|
2337
2314
|
}
|
|
2338
2315
|
handleBidTimeout(data) {
|
|
2339
2316
|
if (this.isDuplicate("bidTimeout", data)) return;
|
|
@@ -2350,14 +2327,12 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2350
2327
|
const entry = auctionMap.get(key);
|
|
2351
2328
|
if (entry) {
|
|
2352
2329
|
entry.outcome = BidderOutcome.BIDDER_OUTCOME_TIMEOUT;
|
|
2353
|
-
if (latencyMs > 0) entry.latencyMs = latencyMs;
|
|
2330
|
+
if (latencyMs > 0 && entry.bid) entry.bid.latencyMs = latencyMs;
|
|
2354
2331
|
} else {
|
|
2355
2332
|
auctionMap.set(key, {
|
|
2356
|
-
bidder,
|
|
2357
2333
|
adUnitCode,
|
|
2358
|
-
mediaType: "banner",
|
|
2359
2334
|
outcome: BidderOutcome.BIDDER_OUTCOME_TIMEOUT,
|
|
2360
|
-
latencyMs
|
|
2335
|
+
bid: { bidder, mediaType: "banner", latencyMs }
|
|
2361
2336
|
});
|
|
2362
2337
|
}
|
|
2363
2338
|
}
|
|
@@ -2426,11 +2401,9 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2426
2401
|
}
|
|
2427
2402
|
} else {
|
|
2428
2403
|
auctionMap.set(key, {
|
|
2429
|
-
bidder,
|
|
2430
2404
|
adUnitCode,
|
|
2431
|
-
mediaType: "banner",
|
|
2432
2405
|
outcome: BidderOutcome.BIDDER_OUTCOME_NO_BID,
|
|
2433
|
-
latencyMs: 0
|
|
2406
|
+
bid: { bidder, mediaType: "banner", latencyMs: 0 }
|
|
2434
2407
|
});
|
|
2435
2408
|
}
|
|
2436
2409
|
}
|
|
@@ -2593,12 +2566,14 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2593
2566
|
if (!this.shouldSample(type, level)) return;
|
|
2594
2567
|
extendSession();
|
|
2595
2568
|
const protoEvent = {
|
|
2596
|
-
eventId: generateUUID(),
|
|
2569
|
+
eventId: idToBytes(generateUUID()),
|
|
2597
2570
|
timestampMs: Date.now(),
|
|
2598
2571
|
type,
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2572
|
+
// Typed events have a fixed name that ingest derives from `type`; only
|
|
2573
|
+
// ERROR events carry theirs, which names the failure.
|
|
2574
|
+
eventName: type === TraceEventType.ERROR ? eventName : "",
|
|
2575
|
+
auctionId: idToBytes(String(data.auctionId || "")),
|
|
2576
|
+
transactionId: idToBytes(String(data.transactionId || "")),
|
|
2602
2577
|
adUnitCode: data.adUnitCode || data.elementId || "",
|
|
2603
2578
|
namespace: data.ns || data.namespace || ""
|
|
2604
2579
|
};
|
|
@@ -2606,9 +2581,9 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2606
2581
|
protoEvent.bid = {
|
|
2607
2582
|
bidder: data.bid.bidder || "",
|
|
2608
2583
|
cpm: Number.isFinite(data.bid.cpm) ? data.bid.cpm : 0,
|
|
2609
|
-
// No defaults here: handlers with a priced bid (
|
|
2610
|
-
//
|
|
2611
|
-
//
|
|
2584
|
+
// No defaults here: handlers with a priced bid (bidWon, impression)
|
|
2585
|
+
// set currency/mediaType themselves. Defaulting for the rest would
|
|
2586
|
+
// stamp fake "USD"/"banner" on rows that carried no bid.
|
|
2612
2587
|
currency: data.bid.currency || "",
|
|
2613
2588
|
width: Number.isFinite(data.bid.width) ? data.bid.width : 0,
|
|
2614
2589
|
height: Number.isFinite(data.bid.height) ? data.bid.height : 0,
|
|
@@ -2640,11 +2615,11 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2640
2615
|
protoEvent.metadata = boundedMetadata;
|
|
2641
2616
|
}
|
|
2642
2617
|
this.queue.push(protoEvent);
|
|
2643
|
-
if (this.queue.length
|
|
2644
|
-
this.queue.splice(0, this.queue.length - MAX_QUEUE_SIZE);
|
|
2645
|
-
}
|
|
2646
|
-
if (this.queue.length >= BATCH_SIZE) {
|
|
2618
|
+
if (this.queue.length >= MAX_QUEUE_SIZE) {
|
|
2647
2619
|
this.flush();
|
|
2620
|
+
if (this.queue.length > MAX_QUEUE_SIZE) {
|
|
2621
|
+
this.queue.splice(0, this.queue.length - MAX_QUEUE_SIZE);
|
|
2622
|
+
}
|
|
2648
2623
|
} else if (REVENUE_FLUSH_TYPES.has(type) && this.revenueFlushTimer === null) {
|
|
2649
2624
|
this.revenueFlushTimer = setTimeout(() => {
|
|
2650
2625
|
this.revenueFlushTimer = null;
|
|
@@ -2676,14 +2651,14 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2676
2651
|
if (this.queue.length === 0 || !this.config.endpoint) return null;
|
|
2677
2652
|
const domain = typeof window !== "undefined" ? window.location.hostname : "";
|
|
2678
2653
|
const buildBatch = (evts) => ({
|
|
2679
|
-
propertyId: this.config.propertyId,
|
|
2680
|
-
pageviewId: this.config.pageviewId,
|
|
2681
|
-
sessionId: this.config.sessionId,
|
|
2654
|
+
propertyId: idToBytes(this.config.propertyId),
|
|
2655
|
+
pageviewId: idToBytes(this.config.pageviewId),
|
|
2656
|
+
sessionId: idToBytes(this.config.sessionId),
|
|
2682
2657
|
pageUrl: this.pageUrl,
|
|
2683
2658
|
country: this.config.country,
|
|
2684
2659
|
region: this.config.region,
|
|
2685
2660
|
deviceType: this.config.deviceType,
|
|
2686
|
-
userId: this.config.userId,
|
|
2661
|
+
userId: idToBytes(this.config.userId),
|
|
2687
2662
|
domain,
|
|
2688
2663
|
events: evts
|
|
2689
2664
|
});
|
|
@@ -2703,7 +2678,7 @@ var BidkernelPrebidAnalytics = class _BidkernelPrebidAnalytics {
|
|
|
2703
2678
|
const [dropped] = this.queue.splice(0, 1);
|
|
2704
2679
|
this.log(
|
|
2705
2680
|
"WARN",
|
|
2706
|
-
`Dropping oversized event ${dropped?.
|
|
2681
|
+
`Dropping oversized event (type ${dropped?.type}, ${encoded.byteLength} bytes exceeds the ${MAX_PAYLOAD_BYTES}-byte cap on its own)`
|
|
2707
2682
|
);
|
|
2708
2683
|
continue;
|
|
2709
2684
|
}
|
package/package.json
CHANGED