polyv-rum-sdk 0.1.16 → 0.1.17
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 +68 -44
- package/dist/index.mjs +68 -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",
|
|
@@ -612,53 +672,17 @@ var SLSWebTrackingAdapter = class {
|
|
|
612
672
|
}
|
|
613
673
|
}
|
|
614
674
|
addCustomFields(logData, data) {
|
|
615
|
-
if (data.
|
|
616
|
-
logData.custom_event_name = String(data.
|
|
617
|
-
}
|
|
618
|
-
if (data.action) {
|
|
619
|
-
logData.custom_event_action = String(data.action);
|
|
675
|
+
if (data.customEventName) {
|
|
676
|
+
logData.custom_event_name = String(data.customEventName);
|
|
620
677
|
}
|
|
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
|
-
}
|
|
678
|
+
if (data.customEventAction) {
|
|
679
|
+
logData.custom_event_action = String(data.customEventAction);
|
|
656
680
|
}
|
|
657
|
-
if (
|
|
658
|
-
logData.custom_event_fields =
|
|
681
|
+
if (data.customEventFields) {
|
|
682
|
+
logData.custom_event_fields = data.customEventFields;
|
|
659
683
|
}
|
|
660
|
-
if (data.
|
|
661
|
-
logData.custom_event_detail = String(data.
|
|
684
|
+
if (data.customEventDetail !== void 0) {
|
|
685
|
+
logData.custom_event_detail = String(data.customEventDetail);
|
|
662
686
|
}
|
|
663
687
|
}
|
|
664
688
|
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",
|
|
@@ -539,53 +599,17 @@ var SLSWebTrackingAdapter = class {
|
|
|
539
599
|
}
|
|
540
600
|
}
|
|
541
601
|
addCustomFields(logData, data) {
|
|
542
|
-
if (data.
|
|
543
|
-
logData.custom_event_name = String(data.
|
|
544
|
-
}
|
|
545
|
-
if (data.action) {
|
|
546
|
-
logData.custom_event_action = String(data.action);
|
|
602
|
+
if (data.customEventName) {
|
|
603
|
+
logData.custom_event_name = String(data.customEventName);
|
|
547
604
|
}
|
|
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
|
-
}
|
|
605
|
+
if (data.customEventAction) {
|
|
606
|
+
logData.custom_event_action = String(data.customEventAction);
|
|
583
607
|
}
|
|
584
|
-
if (
|
|
585
|
-
logData.custom_event_fields =
|
|
608
|
+
if (data.customEventFields) {
|
|
609
|
+
logData.custom_event_fields = data.customEventFields;
|
|
586
610
|
}
|
|
587
|
-
if (data.
|
|
588
|
-
logData.custom_event_detail = String(data.
|
|
611
|
+
if (data.customEventDetail !== void 0) {
|
|
612
|
+
logData.custom_event_detail = String(data.customEventDetail);
|
|
589
613
|
}
|
|
590
614
|
}
|
|
591
615
|
filterSensitiveData(data) {
|