polyv-rum-sdk 0.1.16 → 0.1.18
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/index.js +71 -44
- package/dist/index.mjs +71 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -286,6 +286,66 @@ var transformDataForSLS = (data, context = {}) => {
|
|
|
286
286
|
dimensions.clickX = data.x;
|
|
287
287
|
dimensions.clickY = data.y;
|
|
288
288
|
}
|
|
289
|
+
if (data.type === "custom") {
|
|
290
|
+
if (data.name) {
|
|
291
|
+
dimensions.customEventName = data.name;
|
|
292
|
+
}
|
|
293
|
+
if (data.action) {
|
|
294
|
+
dimensions.customEventAction = data.action;
|
|
295
|
+
}
|
|
296
|
+
const reservedKeys = [
|
|
297
|
+
"type",
|
|
298
|
+
"timestamp",
|
|
299
|
+
"name",
|
|
300
|
+
"action",
|
|
301
|
+
"eventType",
|
|
302
|
+
"category",
|
|
303
|
+
"level",
|
|
304
|
+
"userId",
|
|
305
|
+
"userName",
|
|
306
|
+
"userEmail",
|
|
307
|
+
"accountId",
|
|
308
|
+
"roles",
|
|
309
|
+
"pageTitle",
|
|
310
|
+
"path",
|
|
311
|
+
"search",
|
|
312
|
+
"hash",
|
|
313
|
+
"url",
|
|
314
|
+
"referrer",
|
|
315
|
+
"userAgent",
|
|
316
|
+
"customData",
|
|
317
|
+
"clickBizId",
|
|
318
|
+
"clickTargetTag",
|
|
319
|
+
"clickTargetId",
|
|
320
|
+
"clickTargetClass",
|
|
321
|
+
"clickTargetSelector",
|
|
322
|
+
"clickTargetText",
|
|
323
|
+
"clickPageUrl",
|
|
324
|
+
"clickPagePath",
|
|
325
|
+
"clickPageTitle",
|
|
326
|
+
"clickX",
|
|
327
|
+
"clickY"
|
|
328
|
+
];
|
|
329
|
+
const customFields = {};
|
|
330
|
+
let fieldCount = 0;
|
|
331
|
+
const maxFields = 10;
|
|
332
|
+
for (const [key, value] of Object.entries(data)) {
|
|
333
|
+
if (reservedKeys.includes(key))
|
|
334
|
+
continue;
|
|
335
|
+
if (fieldCount >= maxFields)
|
|
336
|
+
break;
|
|
337
|
+
if (value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
338
|
+
customFields[key] = value;
|
|
339
|
+
fieldCount++;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
if (Object.keys(customFields).length > 0) {
|
|
343
|
+
dimensions.customEventFields = JSON.stringify(customFields);
|
|
344
|
+
}
|
|
345
|
+
if (data.detail !== void 0) {
|
|
346
|
+
dimensions.customEventDetail = String(data.detail);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
289
349
|
return {
|
|
290
350
|
__time__: Math.floor(Date.now() / 1e3),
|
|
291
351
|
__source__: "live-admin-v3",
|
|
@@ -312,6 +372,9 @@ var transformDataForSLS = (data, context = {}) => {
|
|
|
312
372
|
};
|
|
313
373
|
};
|
|
314
374
|
var shouldReport = (data) => {
|
|
375
|
+
if (data.type === "init") {
|
|
376
|
+
return false;
|
|
377
|
+
}
|
|
315
378
|
const dataType = data.type;
|
|
316
379
|
const sampleRate = mitoConfig.sampleRate[dataType] || 0;
|
|
317
380
|
if (sampleRate === 0)
|
|
@@ -612,53 +675,17 @@ var SLSWebTrackingAdapter = class {
|
|
|
612
675
|
}
|
|
613
676
|
}
|
|
614
677
|
addCustomFields(logData, data) {
|
|
615
|
-
if (data.
|
|
616
|
-
logData.custom_event_name = String(data.
|
|
678
|
+
if (data.customEventName) {
|
|
679
|
+
logData.custom_event_name = String(data.customEventName);
|
|
617
680
|
}
|
|
618
|
-
if (data.
|
|
619
|
-
logData.custom_event_action = String(data.
|
|
681
|
+
if (data.customEventAction) {
|
|
682
|
+
logData.custom_event_action = String(data.customEventAction);
|
|
620
683
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
const maxFields = 10;
|
|
624
|
-
const reservedKeys = [
|
|
625
|
-
"type",
|
|
626
|
-
"timestamp",
|
|
627
|
-
"name",
|
|
628
|
-
"action",
|
|
629
|
-
"eventType",
|
|
630
|
-
"category",
|
|
631
|
-
"level",
|
|
632
|
-
"userId",
|
|
633
|
-
"userName",
|
|
634
|
-
"userEmail",
|
|
635
|
-
"accountId",
|
|
636
|
-
"roles",
|
|
637
|
-
"pageTitle",
|
|
638
|
-
"path",
|
|
639
|
-
"search",
|
|
640
|
-
"hash",
|
|
641
|
-
"url",
|
|
642
|
-
"referrer",
|
|
643
|
-
"userAgent",
|
|
644
|
-
"rawData",
|
|
645
|
-
"dimensions"
|
|
646
|
-
];
|
|
647
|
-
for (const [key, value] of Object.entries(data)) {
|
|
648
|
-
if (reservedKeys.includes(key))
|
|
649
|
-
continue;
|
|
650
|
-
if (fieldCount >= maxFields)
|
|
651
|
-
break;
|
|
652
|
-
if (value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
653
|
-
customFields[key] = value;
|
|
654
|
-
fieldCount++;
|
|
655
|
-
}
|
|
684
|
+
if (data.customEventFields) {
|
|
685
|
+
logData.custom_event_fields = data.customEventFields;
|
|
656
686
|
}
|
|
657
|
-
if (
|
|
658
|
-
logData.
|
|
659
|
-
}
|
|
660
|
-
if (data.detail !== void 0) {
|
|
661
|
-
logData.custom_event_detail = String(data.detail);
|
|
687
|
+
if (data.customEventDetail !== void 0) {
|
|
688
|
+
logData.custom_event_detail = String(data.customEventDetail);
|
|
662
689
|
}
|
|
663
690
|
}
|
|
664
691
|
filterSensitiveData(data) {
|
package/dist/index.mjs
CHANGED
|
@@ -213,6 +213,66 @@ var transformDataForSLS = (data, context = {}) => {
|
|
|
213
213
|
dimensions.clickX = data.x;
|
|
214
214
|
dimensions.clickY = data.y;
|
|
215
215
|
}
|
|
216
|
+
if (data.type === "custom") {
|
|
217
|
+
if (data.name) {
|
|
218
|
+
dimensions.customEventName = data.name;
|
|
219
|
+
}
|
|
220
|
+
if (data.action) {
|
|
221
|
+
dimensions.customEventAction = data.action;
|
|
222
|
+
}
|
|
223
|
+
const reservedKeys = [
|
|
224
|
+
"type",
|
|
225
|
+
"timestamp",
|
|
226
|
+
"name",
|
|
227
|
+
"action",
|
|
228
|
+
"eventType",
|
|
229
|
+
"category",
|
|
230
|
+
"level",
|
|
231
|
+
"userId",
|
|
232
|
+
"userName",
|
|
233
|
+
"userEmail",
|
|
234
|
+
"accountId",
|
|
235
|
+
"roles",
|
|
236
|
+
"pageTitle",
|
|
237
|
+
"path",
|
|
238
|
+
"search",
|
|
239
|
+
"hash",
|
|
240
|
+
"url",
|
|
241
|
+
"referrer",
|
|
242
|
+
"userAgent",
|
|
243
|
+
"customData",
|
|
244
|
+
"clickBizId",
|
|
245
|
+
"clickTargetTag",
|
|
246
|
+
"clickTargetId",
|
|
247
|
+
"clickTargetClass",
|
|
248
|
+
"clickTargetSelector",
|
|
249
|
+
"clickTargetText",
|
|
250
|
+
"clickPageUrl",
|
|
251
|
+
"clickPagePath",
|
|
252
|
+
"clickPageTitle",
|
|
253
|
+
"clickX",
|
|
254
|
+
"clickY"
|
|
255
|
+
];
|
|
256
|
+
const customFields = {};
|
|
257
|
+
let fieldCount = 0;
|
|
258
|
+
const maxFields = 10;
|
|
259
|
+
for (const [key, value] of Object.entries(data)) {
|
|
260
|
+
if (reservedKeys.includes(key))
|
|
261
|
+
continue;
|
|
262
|
+
if (fieldCount >= maxFields)
|
|
263
|
+
break;
|
|
264
|
+
if (value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
265
|
+
customFields[key] = value;
|
|
266
|
+
fieldCount++;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (Object.keys(customFields).length > 0) {
|
|
270
|
+
dimensions.customEventFields = JSON.stringify(customFields);
|
|
271
|
+
}
|
|
272
|
+
if (data.detail !== void 0) {
|
|
273
|
+
dimensions.customEventDetail = String(data.detail);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
216
276
|
return {
|
|
217
277
|
__time__: Math.floor(Date.now() / 1e3),
|
|
218
278
|
__source__: "live-admin-v3",
|
|
@@ -239,6 +299,9 @@ var transformDataForSLS = (data, context = {}) => {
|
|
|
239
299
|
};
|
|
240
300
|
};
|
|
241
301
|
var shouldReport = (data) => {
|
|
302
|
+
if (data.type === "init") {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
242
305
|
const dataType = data.type;
|
|
243
306
|
const sampleRate = mitoConfig.sampleRate[dataType] || 0;
|
|
244
307
|
if (sampleRate === 0)
|
|
@@ -539,53 +602,17 @@ var SLSWebTrackingAdapter = class {
|
|
|
539
602
|
}
|
|
540
603
|
}
|
|
541
604
|
addCustomFields(logData, data) {
|
|
542
|
-
if (data.
|
|
543
|
-
logData.custom_event_name = String(data.
|
|
605
|
+
if (data.customEventName) {
|
|
606
|
+
logData.custom_event_name = String(data.customEventName);
|
|
544
607
|
}
|
|
545
|
-
if (data.
|
|
546
|
-
logData.custom_event_action = String(data.
|
|
608
|
+
if (data.customEventAction) {
|
|
609
|
+
logData.custom_event_action = String(data.customEventAction);
|
|
547
610
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
const maxFields = 10;
|
|
551
|
-
const reservedKeys = [
|
|
552
|
-
"type",
|
|
553
|
-
"timestamp",
|
|
554
|
-
"name",
|
|
555
|
-
"action",
|
|
556
|
-
"eventType",
|
|
557
|
-
"category",
|
|
558
|
-
"level",
|
|
559
|
-
"userId",
|
|
560
|
-
"userName",
|
|
561
|
-
"userEmail",
|
|
562
|
-
"accountId",
|
|
563
|
-
"roles",
|
|
564
|
-
"pageTitle",
|
|
565
|
-
"path",
|
|
566
|
-
"search",
|
|
567
|
-
"hash",
|
|
568
|
-
"url",
|
|
569
|
-
"referrer",
|
|
570
|
-
"userAgent",
|
|
571
|
-
"rawData",
|
|
572
|
-
"dimensions"
|
|
573
|
-
];
|
|
574
|
-
for (const [key, value] of Object.entries(data)) {
|
|
575
|
-
if (reservedKeys.includes(key))
|
|
576
|
-
continue;
|
|
577
|
-
if (fieldCount >= maxFields)
|
|
578
|
-
break;
|
|
579
|
-
if (value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
580
|
-
customFields[key] = value;
|
|
581
|
-
fieldCount++;
|
|
582
|
-
}
|
|
611
|
+
if (data.customEventFields) {
|
|
612
|
+
logData.custom_event_fields = data.customEventFields;
|
|
583
613
|
}
|
|
584
|
-
if (
|
|
585
|
-
logData.
|
|
586
|
-
}
|
|
587
|
-
if (data.detail !== void 0) {
|
|
588
|
-
logData.custom_event_detail = String(data.detail);
|
|
614
|
+
if (data.customEventDetail !== void 0) {
|
|
615
|
+
logData.custom_event_detail = String(data.customEventDetail);
|
|
589
616
|
}
|
|
590
617
|
}
|
|
591
618
|
filterSensitiveData(data) {
|