polyv-rum-sdk 0.1.15 → 0.1.16

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.d.mts CHANGED
@@ -122,6 +122,7 @@ declare class SLSWebTrackingAdapter {
122
122
  private addErrorFields;
123
123
  private addApiFields;
124
124
  private addClickFields;
125
+ private addCustomFields;
125
126
  private filterSensitiveData;
126
127
  private handleSendError;
127
128
  private retryFailedLogs;
package/dist/index.d.ts CHANGED
@@ -122,6 +122,7 @@ declare class SLSWebTrackingAdapter {
122
122
  private addErrorFields;
123
123
  private addApiFields;
124
124
  private addClickFields;
125
+ private addCustomFields;
125
126
  private filterSensitiveData;
126
127
  private handleSendError;
127
128
  private retryFailedLogs;
package/dist/index.js CHANGED
@@ -533,6 +533,8 @@ var SLSWebTrackingAdapter = class {
533
533
  this.addApiFields(logData, data);
534
534
  } else if (logData.event_type === "click") {
535
535
  this.addClickFields(logData, data);
536
+ } else if (logData.event_type === "custom") {
537
+ this.addCustomFields(logData, data);
536
538
  }
537
539
  try {
538
540
  let hash = "";
@@ -609,6 +611,56 @@ var SLSWebTrackingAdapter = class {
609
611
  logData.click_y = Number(data.y);
610
612
  }
611
613
  }
614
+ addCustomFields(logData, data) {
615
+ if (data.name) {
616
+ logData.custom_event_name = String(data.name);
617
+ }
618
+ if (data.action) {
619
+ logData.custom_event_action = String(data.action);
620
+ }
621
+ const customFields = {};
622
+ let fieldCount = 0;
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
+ }
656
+ }
657
+ if (Object.keys(customFields).length > 0) {
658
+ logData.custom_event_fields = JSON.stringify(customFields);
659
+ }
660
+ if (data.detail !== void 0) {
661
+ logData.custom_event_detail = String(data.detail);
662
+ }
663
+ }
612
664
  filterSensitiveData(data) {
613
665
  const sensitivePatterns = [
614
666
  /password/i,
package/dist/index.mjs CHANGED
@@ -460,6 +460,8 @@ var SLSWebTrackingAdapter = class {
460
460
  this.addApiFields(logData, data);
461
461
  } else if (logData.event_type === "click") {
462
462
  this.addClickFields(logData, data);
463
+ } else if (logData.event_type === "custom") {
464
+ this.addCustomFields(logData, data);
463
465
  }
464
466
  try {
465
467
  let hash = "";
@@ -536,6 +538,56 @@ var SLSWebTrackingAdapter = class {
536
538
  logData.click_y = Number(data.y);
537
539
  }
538
540
  }
541
+ addCustomFields(logData, data) {
542
+ if (data.name) {
543
+ logData.custom_event_name = String(data.name);
544
+ }
545
+ if (data.action) {
546
+ logData.custom_event_action = String(data.action);
547
+ }
548
+ const customFields = {};
549
+ let fieldCount = 0;
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
+ }
583
+ }
584
+ if (Object.keys(customFields).length > 0) {
585
+ logData.custom_event_fields = JSON.stringify(customFields);
586
+ }
587
+ if (data.detail !== void 0) {
588
+ logData.custom_event_detail = String(data.detail);
589
+ }
590
+ }
539
591
  filterSensitiveData(data) {
540
592
  const sensitivePatterns = [
541
593
  /password/i,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polyv-rum-sdk",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",