action-lens 1.0.101 → 1.0.103
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 +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +135 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -76
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -81,16 +81,22 @@ declare class ActionLensRc {
|
|
|
81
81
|
email?: string;
|
|
82
82
|
};
|
|
83
83
|
metaData: Record<string, any>;
|
|
84
|
+
isRecordingPaused: boolean;
|
|
85
|
+
isSessionInitialized: boolean;
|
|
86
|
+
areAuxRecordersStarted: boolean;
|
|
84
87
|
constructor();
|
|
85
88
|
init(projectId: string | null, _db?: Firestore | null, prefix?: string): Promise<void>;
|
|
86
89
|
setUser(_userId: string | null, userMeta: {
|
|
87
90
|
name: string;
|
|
88
91
|
email: string;
|
|
89
92
|
}, metaData?: Record<string, any>): Promise<void>;
|
|
93
|
+
private shouldRecordCustomEvents;
|
|
90
94
|
startConsoleRecording(): void;
|
|
91
95
|
startTimelineRecording(): void;
|
|
92
96
|
startNetworkRecording(): void;
|
|
93
97
|
startRrwebRecordingForStore(): Promise<void>;
|
|
98
|
+
pauseRrwebRecordingForStore(): void;
|
|
99
|
+
resumeRrwebRecordingForStore(): Promise<void>;
|
|
94
100
|
stopRrwebRecordingForStore(): void;
|
|
95
101
|
updateActionRecordSession(): Promise<void>;
|
|
96
102
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -81,16 +81,22 @@ declare class ActionLensRc {
|
|
|
81
81
|
email?: string;
|
|
82
82
|
};
|
|
83
83
|
metaData: Record<string, any>;
|
|
84
|
+
isRecordingPaused: boolean;
|
|
85
|
+
isSessionInitialized: boolean;
|
|
86
|
+
areAuxRecordersStarted: boolean;
|
|
84
87
|
constructor();
|
|
85
88
|
init(projectId: string | null, _db?: Firestore | null, prefix?: string): Promise<void>;
|
|
86
89
|
setUser(_userId: string | null, userMeta: {
|
|
87
90
|
name: string;
|
|
88
91
|
email: string;
|
|
89
92
|
}, metaData?: Record<string, any>): Promise<void>;
|
|
93
|
+
private shouldRecordCustomEvents;
|
|
90
94
|
startConsoleRecording(): void;
|
|
91
95
|
startTimelineRecording(): void;
|
|
92
96
|
startNetworkRecording(): void;
|
|
93
97
|
startRrwebRecordingForStore(): Promise<void>;
|
|
98
|
+
pauseRrwebRecordingForStore(): void;
|
|
99
|
+
resumeRrwebRecordingForStore(): Promise<void>;
|
|
94
100
|
stopRrwebRecordingForStore(): void;
|
|
95
101
|
updateActionRecordSession(): Promise<void>;
|
|
96
102
|
}
|
package/dist/index.js
CHANGED
|
@@ -376,6 +376,9 @@ var ActionLensRc = class {
|
|
|
376
376
|
// 元のユーザーID(外部システムのIDなど)
|
|
377
377
|
userMeta = {};
|
|
378
378
|
metaData = {};
|
|
379
|
+
isRecordingPaused = false;
|
|
380
|
+
isSessionInitialized = false;
|
|
381
|
+
areAuxRecordersStarted = false;
|
|
379
382
|
constructor() {
|
|
380
383
|
this.db = db;
|
|
381
384
|
}
|
|
@@ -549,6 +552,9 @@ var ActionLensRc = class {
|
|
|
549
552
|
);
|
|
550
553
|
return;
|
|
551
554
|
}
|
|
555
|
+
shouldRecordCustomEvents() {
|
|
556
|
+
return !this.isRecordingPaused && !!this.stopFnForStore;
|
|
557
|
+
}
|
|
552
558
|
// コンソールログをキャプチャ
|
|
553
559
|
startConsoleRecording() {
|
|
554
560
|
try {
|
|
@@ -565,6 +571,7 @@ var ActionLensRc = class {
|
|
|
565
571
|
consoleMethods.forEach((method) => {
|
|
566
572
|
console[method] = (...args) => {
|
|
567
573
|
originalConsole[method](...args);
|
|
574
|
+
if (!this.shouldRecordCustomEvents()) return;
|
|
568
575
|
const fileName = new Error().stack?.split("\n")[2]?.trim() || "unknown";
|
|
569
576
|
import_rrweb2.record.addCustomEvent("console", { method, args, fileName });
|
|
570
577
|
};
|
|
@@ -586,6 +593,7 @@ var ActionLensRc = class {
|
|
|
586
593
|
console.error("Firestore\u304C\u521D\u671F\u5316\u3055\u308C\u3066\u3044\u307E\u305B\u3093");
|
|
587
594
|
return;
|
|
588
595
|
}
|
|
596
|
+
if (!this.shouldRecordCustomEvents()) return;
|
|
589
597
|
import_rrweb2.record.addCustomEvent("navigation", {
|
|
590
598
|
url: window.location.href,
|
|
591
599
|
state: event.state
|
|
@@ -593,6 +601,7 @@ var ActionLensRc = class {
|
|
|
593
601
|
});
|
|
594
602
|
if (window.performance) {
|
|
595
603
|
const observer = new PerformanceObserver((list) => {
|
|
604
|
+
if (!this.shouldRecordCustomEvents()) return;
|
|
596
605
|
for (const entry of list.getEntries()) {
|
|
597
606
|
if (entry.entryType === "resource") {
|
|
598
607
|
const resourceEntry = entry;
|
|
@@ -645,6 +654,7 @@ var ActionLensRc = class {
|
|
|
645
654
|
// ネットワークリクエストをキャプチャ(新規追加)
|
|
646
655
|
startNetworkRecording() {
|
|
647
656
|
try {
|
|
657
|
+
const shouldRecordCustomEvents = () => this.shouldRecordCustomEvents();
|
|
648
658
|
const shouldIgnoreNetwork = (url) => {
|
|
649
659
|
try {
|
|
650
660
|
const parsed = new URL(url, window.location.href);
|
|
@@ -673,7 +683,7 @@ var ActionLensRc = class {
|
|
|
673
683
|
method = init?.method || "GET";
|
|
674
684
|
requestBody = init?.body;
|
|
675
685
|
}
|
|
676
|
-
if (shouldIgnoreNetwork(urlStr)) {
|
|
686
|
+
if (shouldIgnoreNetwork(urlStr) || !shouldRecordCustomEvents()) {
|
|
677
687
|
return originalFetch(...args);
|
|
678
688
|
}
|
|
679
689
|
import_rrweb2.record.addCustomEvent("network_request", {
|
|
@@ -686,6 +696,9 @@ var ActionLensRc = class {
|
|
|
686
696
|
// 初期状態は保留中
|
|
687
697
|
});
|
|
688
698
|
return originalFetch(...args).then((response) => {
|
|
699
|
+
if (!shouldRecordCustomEvents()) {
|
|
700
|
+
return response;
|
|
701
|
+
}
|
|
689
702
|
const endTime = Date.now();
|
|
690
703
|
const duration = endTime - startTime;
|
|
691
704
|
const clonedResponse = response.clone();
|
|
@@ -707,6 +720,9 @@ var ActionLensRc = class {
|
|
|
707
720
|
});
|
|
708
721
|
return response;
|
|
709
722
|
}).catch((error) => {
|
|
723
|
+
if (!shouldRecordCustomEvents()) {
|
|
724
|
+
throw error;
|
|
725
|
+
}
|
|
710
726
|
const endTime = Date.now();
|
|
711
727
|
const duration = endTime - startTime;
|
|
712
728
|
import_rrweb2.record.addCustomEvent("network_error", {
|
|
@@ -734,7 +750,7 @@ var ActionLensRc = class {
|
|
|
734
750
|
this._method = method;
|
|
735
751
|
this._url = url.toString();
|
|
736
752
|
this._startTime = Date.now();
|
|
737
|
-
this._skipRecord = shouldIgnoreNetwork(this._url);
|
|
753
|
+
this._skipRecord = shouldIgnoreNetwork(this._url) || !shouldRecordCustomEvents();
|
|
738
754
|
if (!this._skipRecord) {
|
|
739
755
|
import_rrweb2.record.addCustomEvent("network_request", {
|
|
740
756
|
type: "xhr",
|
|
@@ -752,6 +768,7 @@ var ActionLensRc = class {
|
|
|
752
768
|
return super.send(body);
|
|
753
769
|
}
|
|
754
770
|
this.addEventListener("load", () => {
|
|
771
|
+
if (!shouldRecordCustomEvents()) return;
|
|
755
772
|
const endTime = Date.now();
|
|
756
773
|
const duration = endTime - (this._startTime || 0);
|
|
757
774
|
import_rrweb2.record.addCustomEvent("network_response", {
|
|
@@ -765,6 +782,7 @@ var ActionLensRc = class {
|
|
|
765
782
|
});
|
|
766
783
|
});
|
|
767
784
|
this.addEventListener("error", () => {
|
|
785
|
+
if (!shouldRecordCustomEvents()) return;
|
|
768
786
|
const endTime = Date.now();
|
|
769
787
|
const duration = endTime - (this._startTime || 0);
|
|
770
788
|
import_rrweb2.record.addCustomEvent("network_error", {
|
|
@@ -786,48 +804,53 @@ var ActionLensRc = class {
|
|
|
786
804
|
super(url, protocols);
|
|
787
805
|
const wsUrl = url.toString();
|
|
788
806
|
this._skipRecord = shouldIgnoreNetwork(wsUrl);
|
|
789
|
-
if (
|
|
807
|
+
if (this._skipRecord) return;
|
|
808
|
+
if (shouldRecordCustomEvents()) {
|
|
790
809
|
import_rrweb2.record.addCustomEvent("network_websocket_open", {
|
|
791
810
|
type: "websocket",
|
|
792
811
|
url: wsUrl,
|
|
793
812
|
startTime: Date.now()
|
|
794
813
|
});
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
this.addEventListener("close", (event) => {
|
|
804
|
-
import_rrweb2.record.addCustomEvent("network_websocket_close", {
|
|
805
|
-
type: "websocket",
|
|
806
|
-
url: wsUrl,
|
|
807
|
-
code: event.code,
|
|
808
|
-
reason: event.reason,
|
|
809
|
-
endTime: Date.now()
|
|
810
|
-
});
|
|
814
|
+
}
|
|
815
|
+
this.addEventListener("message", (event) => {
|
|
816
|
+
if (!shouldRecordCustomEvents()) return;
|
|
817
|
+
import_rrweb2.record.addCustomEvent("network_websocket_message", {
|
|
818
|
+
type: "websocket",
|
|
819
|
+
url: wsUrl,
|
|
820
|
+
data: event.data,
|
|
821
|
+
time: Date.now()
|
|
811
822
|
});
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
823
|
+
});
|
|
824
|
+
this.addEventListener("close", (event) => {
|
|
825
|
+
if (!shouldRecordCustomEvents()) return;
|
|
826
|
+
import_rrweb2.record.addCustomEvent("network_websocket_close", {
|
|
827
|
+
type: "websocket",
|
|
828
|
+
url: wsUrl,
|
|
829
|
+
code: event.code,
|
|
830
|
+
reason: event.reason,
|
|
831
|
+
endTime: Date.now()
|
|
819
832
|
});
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
import_rrweb2.record.addCustomEvent("network_websocket_send", {
|
|
833
|
+
});
|
|
834
|
+
this.addEventListener("error", (event) => {
|
|
835
|
+
if (!shouldRecordCustomEvents()) return;
|
|
836
|
+
import_rrweb2.record.addCustomEvent("network_websocket_error", {
|
|
825
837
|
type: "websocket",
|
|
826
|
-
url:
|
|
827
|
-
|
|
838
|
+
url: wsUrl,
|
|
839
|
+
error: "WebSocket error",
|
|
828
840
|
time: Date.now()
|
|
829
841
|
});
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
send(data) {
|
|
845
|
+
if (this._skipRecord || !shouldRecordCustomEvents()) {
|
|
846
|
+
return super.send(data);
|
|
830
847
|
}
|
|
848
|
+
import_rrweb2.record.addCustomEvent("network_websocket_send", {
|
|
849
|
+
type: "websocket",
|
|
850
|
+
url: this.url,
|
|
851
|
+
data,
|
|
852
|
+
time: Date.now()
|
|
853
|
+
});
|
|
831
854
|
return super.send(data);
|
|
832
855
|
}
|
|
833
856
|
};
|
|
@@ -850,52 +873,61 @@ var ActionLensRc = class {
|
|
|
850
873
|
console.error("Firestore\u304C\u521D\u671F\u5316\u3055\u308C\u3066\u3044\u307E\u305B\u3093");
|
|
851
874
|
return;
|
|
852
875
|
}
|
|
853
|
-
|
|
854
|
-
(0, import_firestore3.
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
(0, import_firestore3.collection)(this.db, "ActionRecordSession"),
|
|
879
|
-
this.sessionId
|
|
880
|
-
);
|
|
881
|
-
await (0, import_firestore3.getDoc)(docRef).then(async (doc3) => {
|
|
882
|
-
if (doc3.exists()) {
|
|
883
|
-
const data = doc3.data();
|
|
884
|
-
const ipAddress = data?.ipAddress || "";
|
|
885
|
-
const placeData = await getPlaceFromIp(ipAddress);
|
|
886
|
-
await (0, import_firestore3.updateDoc)(docRef, { place: placeData });
|
|
876
|
+
if (!this.isSessionInitialized) {
|
|
877
|
+
const ActionRecordSessionRef = (0, import_firestore3.doc)(
|
|
878
|
+
(0, import_firestore3.collection)(this.db, `${prefix}ActionRecordSession`),
|
|
879
|
+
_sessionId
|
|
880
|
+
);
|
|
881
|
+
await (0, import_firestore3.setDoc)(ActionRecordSessionRef, {
|
|
882
|
+
id: _sessionId,
|
|
883
|
+
startTime: /* @__PURE__ */ new Date(),
|
|
884
|
+
endTime: /* @__PURE__ */ new Date(),
|
|
885
|
+
recordTime: 0,
|
|
886
|
+
// 初期値は0
|
|
887
|
+
userId,
|
|
888
|
+
projectId: this.projectId || "",
|
|
889
|
+
organizationId: this.projectData?.organizationId || "",
|
|
890
|
+
createAt: /* @__PURE__ */ new Date(),
|
|
891
|
+
updateAt: /* @__PURE__ */ new Date(),
|
|
892
|
+
createdBy: userId,
|
|
893
|
+
updatedBy: userId
|
|
894
|
+
});
|
|
895
|
+
this.isSessionInitialized = true;
|
|
896
|
+
try {
|
|
897
|
+
console.log("setSessionDetail\u95A2\u6570\u3092\u547C\u3073\u51FA\u3057\u307E\u3059", this.sessionId);
|
|
898
|
+
await setSessionDetail({ sessionId: this.sessionId });
|
|
899
|
+
} catch (error) {
|
|
900
|
+
console.error("setSessionDetail\u95A2\u6570\u306E\u547C\u3073\u51FA\u3057\u306B\u5931\u6557:", error);
|
|
887
901
|
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
902
|
+
const docRef = (0, import_firestore3.doc)(
|
|
903
|
+
(0, import_firestore3.collection)(this.db, "ActionRecordSession"),
|
|
904
|
+
this.sessionId
|
|
905
|
+
);
|
|
906
|
+
await (0, import_firestore3.getDoc)(docRef).then(async (doc3) => {
|
|
907
|
+
if (doc3.exists()) {
|
|
908
|
+
const data = doc3.data();
|
|
909
|
+
const ipAddress = data?.ipAddress || "";
|
|
910
|
+
const placeData = await getPlaceFromIp(ipAddress);
|
|
911
|
+
await (0, import_firestore3.updateDoc)(docRef, { place: placeData });
|
|
912
|
+
}
|
|
913
|
+
}).catch((error) => {
|
|
914
|
+
console.error("IP\u30A2\u30C9\u30EC\u30B9\u306E\u53D6\u5F97\u306B\u5931\u6557:", error);
|
|
915
|
+
});
|
|
916
|
+
}
|
|
891
917
|
this.stopFnForStore = (0, import_rrweb2.record)({
|
|
892
918
|
packFn: import_packer2.pack,
|
|
893
919
|
collectFonts: false,
|
|
894
920
|
inlineImages: false,
|
|
895
|
-
checkoutEveryNth:
|
|
921
|
+
checkoutEveryNth: 4e3,
|
|
922
|
+
slimDOMOptions: {
|
|
923
|
+
script: true,
|
|
924
|
+
comment: true,
|
|
925
|
+
headFavicon: true,
|
|
926
|
+
headWhitespace: true
|
|
927
|
+
},
|
|
896
928
|
sampling: {
|
|
897
|
-
canvas:
|
|
898
|
-
mousemove:
|
|
929
|
+
canvas: 5e3,
|
|
930
|
+
mousemove: 500
|
|
899
931
|
// mousemoveCallback: 1000,
|
|
900
932
|
},
|
|
901
933
|
emit: async (event) => {
|
|
@@ -931,20 +963,47 @@ var ActionLensRc = class {
|
|
|
931
963
|
},
|
|
932
964
|
recordCanvas: false
|
|
933
965
|
});
|
|
934
|
-
this.
|
|
935
|
-
this.
|
|
936
|
-
|
|
966
|
+
this.isRecordingPaused = false;
|
|
967
|
+
if (!this.areAuxRecordersStarted) {
|
|
968
|
+
this.startConsoleRecording();
|
|
969
|
+
this.startTimelineRecording();
|
|
970
|
+
this.startNetworkRecording();
|
|
971
|
+
this.areAuxRecordersStarted = true;
|
|
972
|
+
}
|
|
937
973
|
} catch (error) {
|
|
938
974
|
console.error("rrweb\u9332\u753B\u30A8\u30E9\u30FC:", error);
|
|
939
975
|
throw error;
|
|
940
976
|
}
|
|
941
977
|
}
|
|
978
|
+
pauseRrwebRecordingForStore() {
|
|
979
|
+
try {
|
|
980
|
+
this.isRecordingPaused = true;
|
|
981
|
+
if (this.stopFnForStore) {
|
|
982
|
+
this.stopFnForStore();
|
|
983
|
+
this.stopFnForStore = null;
|
|
984
|
+
}
|
|
985
|
+
} catch (error) {
|
|
986
|
+
console.error("rrweb\u9332\u753B\u4E00\u6642\u505C\u6B62\u30A8\u30E9\u30FC:", error);
|
|
987
|
+
throw error;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
async resumeRrwebRecordingForStore() {
|
|
991
|
+
try {
|
|
992
|
+
if (this.stopFnForStore) return;
|
|
993
|
+
this.isRecordingPaused = false;
|
|
994
|
+
await this.startRrwebRecordingForStore();
|
|
995
|
+
} catch (error) {
|
|
996
|
+
console.error("rrweb\u9332\u753B\u518D\u958B\u30A8\u30E9\u30FC:", error);
|
|
997
|
+
throw error;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
942
1000
|
stopRrwebRecordingForStore() {
|
|
943
1001
|
try {
|
|
944
1002
|
if (this.stopFnForStore) {
|
|
945
1003
|
this.stopFnForStore();
|
|
946
1004
|
this.stopFnForStore = null;
|
|
947
1005
|
}
|
|
1006
|
+
this.isRecordingPaused = false;
|
|
948
1007
|
} catch (error) {
|
|
949
1008
|
console.error("rrweb\u9332\u753B\u505C\u6B62\u30A8\u30E9\u30FC:", error);
|
|
950
1009
|
throw error;
|