@affogatosoftware/recorder 1.0.9 → 1.2.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/browser/recorder.iife.js +3 -1
- package/dist/browser/recorder.iife.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/recorder/errorRecorder.d.ts +29 -0
- package/dist/recorder/errorRecorder.js +143 -0
- package/dist/recorder/networkRecorder.d.ts +55 -0
- package/dist/recorder/networkRecorder.js +390 -0
- package/dist/recorder/recorder.d.ts +21 -5
- package/dist/recorder/recorder.js +48 -10
- package/package.json +1 -1
|
@@ -1,31 +1,63 @@
|
|
|
1
1
|
import { SessionRecorder } from "./sessionRecorder";
|
|
2
2
|
import { EventRecorder } from "./eventRecorder";
|
|
3
|
+
import { ErrorRecorder } from "./errorRecorder";
|
|
4
|
+
import { NetworkRecorder } from "./networkRecorder";
|
|
3
5
|
import { post, put } from "../requests";
|
|
4
6
|
import { UAParser } from "ua-parser-js";
|
|
5
7
|
export class Recorder {
|
|
6
8
|
window;
|
|
7
9
|
publicToken;
|
|
8
|
-
recorderSettings;
|
|
9
10
|
sessionRecorder;
|
|
10
11
|
eventRecorder;
|
|
12
|
+
errorRecorder;
|
|
13
|
+
networkRecorder;
|
|
14
|
+
recorderSettings;
|
|
11
15
|
capturedSessionId = null;
|
|
12
16
|
pingIntervalMs = 20000;
|
|
13
17
|
pingTimeout = null;
|
|
14
|
-
constructor(window, publicToken,
|
|
18
|
+
constructor(window, publicToken, userSettings = {}) {
|
|
15
19
|
this.window = window;
|
|
16
20
|
this.publicToken = publicToken;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// Default settings
|
|
22
|
+
const defaultSettings = {
|
|
23
|
+
maskingLevel: "all",
|
|
24
|
+
consoleRecording: { enabled: false },
|
|
25
|
+
networkRecording: {
|
|
26
|
+
enabled: false,
|
|
27
|
+
maxRequestBodySize: 10 * 1024,
|
|
28
|
+
maxResponseBodySize: 50 * 1024,
|
|
29
|
+
excludeDomains: [],
|
|
30
|
+
captureHeaders: true,
|
|
31
|
+
captureRequestBodies: true,
|
|
32
|
+
captureResponseBodies: true,
|
|
33
|
+
excludeHeaders: []
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
// Merge user settings with defaults
|
|
37
|
+
this.recorderSettings = {
|
|
38
|
+
...defaultSettings,
|
|
39
|
+
...userSettings,
|
|
40
|
+
consoleRecording: {
|
|
41
|
+
...defaultSettings.consoleRecording,
|
|
42
|
+
...(userSettings.consoleRecording || {})
|
|
43
|
+
},
|
|
44
|
+
networkRecording: {
|
|
45
|
+
...defaultSettings.networkRecording,
|
|
46
|
+
...(userSettings.networkRecording || {})
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
this.sessionRecorder = new SessionRecorder(this.recorderSettings);
|
|
50
|
+
this.eventRecorder = new EventRecorder(window, this.recorderSettings);
|
|
51
|
+
this.errorRecorder = new ErrorRecorder(window, this.recorderSettings.consoleRecording);
|
|
52
|
+
this.networkRecorder = new NetworkRecorder(window, this.recorderSettings.networkRecording);
|
|
23
53
|
post(`public/captured-sessions`, { publicToken }, { withCredentials: false })
|
|
24
54
|
.then(response => {
|
|
25
55
|
const id = response.data;
|
|
26
56
|
this.capturedSessionId = id;
|
|
27
57
|
this.sessionRecorder.setCapturedSessionId(id);
|
|
28
58
|
this.eventRecorder.setCapturedSessionId(id);
|
|
59
|
+
this.errorRecorder.setCapturedSessionId(id);
|
|
60
|
+
this.networkRecorder.setCapturedSessionId(id);
|
|
29
61
|
this.schedulePing();
|
|
30
62
|
const capturedUserMetadata = this.collectCapturedUserMetadata();
|
|
31
63
|
post(`public/captured-sessions/${this.capturedSessionId}/captured-session/metadata`, capturedUserMetadata, { withCredentials: false });
|
|
@@ -34,6 +66,8 @@ export class Recorder {
|
|
|
34
66
|
console.error(error);
|
|
35
67
|
this.sessionRecorder.stop();
|
|
36
68
|
this.eventRecorder.stop();
|
|
69
|
+
this.errorRecorder.stop();
|
|
70
|
+
this.networkRecorder.stop();
|
|
37
71
|
});
|
|
38
72
|
}
|
|
39
73
|
schedulePing() {
|
|
@@ -47,18 +81,22 @@ export class Recorder {
|
|
|
47
81
|
this.schedulePing();
|
|
48
82
|
};
|
|
49
83
|
/**
|
|
50
|
-
* Start
|
|
84
|
+
* Start all recorders
|
|
51
85
|
*/
|
|
52
86
|
start() {
|
|
53
87
|
this.sessionRecorder.start();
|
|
54
88
|
this.eventRecorder.start();
|
|
89
|
+
this.errorRecorder.start();
|
|
90
|
+
this.networkRecorder.start();
|
|
55
91
|
}
|
|
56
92
|
/**
|
|
57
|
-
* Stop
|
|
93
|
+
* Stop all recorders
|
|
58
94
|
*/
|
|
59
95
|
stop() {
|
|
60
96
|
this.sessionRecorder.stop();
|
|
61
97
|
this.eventRecorder.stop();
|
|
98
|
+
this.errorRecorder.stop();
|
|
99
|
+
this.networkRecorder.stop();
|
|
62
100
|
}
|
|
63
101
|
collectCapturedUserMetadata = () => {
|
|
64
102
|
const ua = new UAParser();
|