@workleap/logrocket 1.2.2 → 1.2.4
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/CHANGELOG.md +18 -0
- package/dist/LogRocketLogger.d.ts +13 -13
- package/dist/LogRocketLogger.js +53 -61
- package/dist/LogRocketLogger.js.map +1 -1
- package/dist/registerLogRocketInstrumentation.js +1 -1
- package/dist/registerLogRocketInstrumentation.js.map +1 -1
- package/package.json +3 -3
- package/src/LogRocketLogger.ts +59 -64
- package/src/registerLogRocketInstrumentation.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @workleap/logrocket
|
|
2
2
|
|
|
3
|
+
## 1.2.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#66](https://github.com/workleap/wl-telemetry/pull/66) [`6b79793`](https://github.com/workleap/wl-telemetry/commit/6b79793e26937f562f51193aedec1a7f57b1578c) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped dependencies and LogRocketLogger refactor.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`6b79793`](https://github.com/workleap/wl-telemetry/commit/6b79793e26937f562f51193aedec1a7f57b1578c)]:
|
|
10
|
+
- @workleap/telemetry@1.1.5
|
|
11
|
+
|
|
12
|
+
## 1.2.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#60](https://github.com/workleap/wl-telemetry/pull/60) [`ed078b6`](https://github.com/workleap/wl-telemetry/commit/ed078b698cfb78e9299f53d0580bf5c5751b9294) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Improved debug vs information logs.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`ed078b6`](https://github.com/workleap/wl-telemetry/commit/ed078b698cfb78e9299f53d0580bf5c5751b9294)]:
|
|
19
|
+
- @workleap/telemetry@1.1.4
|
|
20
|
+
|
|
3
21
|
## 1.2.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel
|
|
1
|
+
import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel } from "@workleap/logging";
|
|
2
2
|
/**
|
|
3
3
|
* An scope implementation for the LogRocket logger.
|
|
4
4
|
* @see {@link https://workleap.github.io/wl-telemetry}
|
|
@@ -12,7 +12,7 @@ export declare class LogRocketLoggerScope implements LoggerScope {
|
|
|
12
12
|
/**
|
|
13
13
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
14
14
|
*/
|
|
15
|
-
withText(text?: string
|
|
15
|
+
withText(text?: string): this;
|
|
16
16
|
/**
|
|
17
17
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
18
18
|
*/
|
|
@@ -29,27 +29,27 @@ export declare class LogRocketLoggerScope implements LoggerScope {
|
|
|
29
29
|
* Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
|
|
30
30
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
31
31
|
*/
|
|
32
|
-
debug(log?: string
|
|
32
|
+
debug(log?: string): void;
|
|
33
33
|
/**
|
|
34
34
|
* Write an information log. The log will be processed only if the logger LogLevel is >= information.
|
|
35
35
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
36
36
|
*/
|
|
37
|
-
information(log?: string
|
|
37
|
+
information(log?: string): void;
|
|
38
38
|
/**
|
|
39
39
|
* Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
|
|
40
40
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
41
41
|
*/
|
|
42
|
-
warning(log?: string
|
|
42
|
+
warning(log?: string): void;
|
|
43
43
|
/**
|
|
44
44
|
* Write an error log. The log will be processed only if the logger LogLevel is >= error.
|
|
45
45
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
46
46
|
*/
|
|
47
|
-
error(log?: string
|
|
47
|
+
error(log?: string): void;
|
|
48
48
|
/**
|
|
49
49
|
* Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
|
|
50
50
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
51
51
|
*/
|
|
52
|
-
critical(log?: string
|
|
52
|
+
critical(log?: string): void;
|
|
53
53
|
/**
|
|
54
54
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
55
55
|
*/
|
|
@@ -72,7 +72,7 @@ export declare class LogRocketLogger implements Logger {
|
|
|
72
72
|
/**
|
|
73
73
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
74
74
|
*/
|
|
75
|
-
withText(text?: string
|
|
75
|
+
withText(text?: string): this;
|
|
76
76
|
/**
|
|
77
77
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
78
78
|
*/
|
|
@@ -89,27 +89,27 @@ export declare class LogRocketLogger implements Logger {
|
|
|
89
89
|
* Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
|
|
90
90
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
91
91
|
*/
|
|
92
|
-
debug(log?: string
|
|
92
|
+
debug(log?: string): void;
|
|
93
93
|
/**
|
|
94
94
|
* Write an information log. The log will be processed only if the logger LogLevel is >= information.
|
|
95
95
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
96
96
|
*/
|
|
97
|
-
information(log?: string
|
|
97
|
+
information(log?: string): void;
|
|
98
98
|
/**
|
|
99
99
|
* Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
|
|
100
100
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
101
101
|
*/
|
|
102
|
-
warning(log?: string
|
|
102
|
+
warning(log?: string): void;
|
|
103
103
|
/**
|
|
104
104
|
* Write an error log. The log will be processed only if the logger LogLevel is >= error.
|
|
105
105
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
106
106
|
*/
|
|
107
|
-
error(log?: string
|
|
107
|
+
error(log?: string): void;
|
|
108
108
|
/**
|
|
109
109
|
* Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
|
|
110
110
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
111
111
|
*/
|
|
112
|
-
critical(log?: string
|
|
112
|
+
critical(log?: string): void;
|
|
113
113
|
/**
|
|
114
114
|
* Start a new logging scope. The scope will inherit the LogLevel of the root logger.
|
|
115
115
|
* @see {@link https://workleap.github.io/wl-logging}
|
package/dist/LogRocketLogger.js
CHANGED
|
@@ -8,20 +8,6 @@ import logrocket from "logrocket";
|
|
|
8
8
|
;// CONCATENATED MODULE: ./src/LogRocketLogger.ts
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
function parseSegments(segments) {
|
|
12
|
-
return segments.reduce((acc, x)=>{
|
|
13
|
-
if (x.text) {
|
|
14
|
-
acc.push(x.text);
|
|
15
|
-
} else if (x.obj) {
|
|
16
|
-
acc.push(x.obj);
|
|
17
|
-
} else if (x.error) {
|
|
18
|
-
acc.push(x.error);
|
|
19
|
-
} else if (x.lineChange) {
|
|
20
|
-
acc.push("\r\n");
|
|
21
|
-
}
|
|
22
|
-
return acc;
|
|
23
|
-
}, []);
|
|
24
|
-
}
|
|
25
11
|
/**
|
|
26
12
|
* An scope implementation for the LogRocket logger.
|
|
27
13
|
* @see {@link https://workleap.github.io/wl-telemetry}
|
|
@@ -46,9 +32,9 @@ function parseSegments(segments) {
|
|
|
46
32
|
// Required closure to preserved the current log items for when they will be formatted when the scope is ended.
|
|
47
33
|
const segments = this.#segments;
|
|
48
34
|
this.#pendingLogs.push(()=>{
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
fct(...
|
|
35
|
+
const values = segments.map((x)=>x.value);
|
|
36
|
+
values.unshift(`(${this.#label})`);
|
|
37
|
+
fct(...values);
|
|
52
38
|
});
|
|
53
39
|
}
|
|
54
40
|
this.#resetSegments();
|
|
@@ -56,11 +42,11 @@ function parseSegments(segments) {
|
|
|
56
42
|
}
|
|
57
43
|
/**
|
|
58
44
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
59
|
-
*/ withText(text
|
|
45
|
+
*/ withText(text) {
|
|
60
46
|
if (text) {
|
|
61
47
|
this.#segments.push({
|
|
62
|
-
text,
|
|
63
|
-
|
|
48
|
+
type: "text",
|
|
49
|
+
value: text
|
|
64
50
|
});
|
|
65
51
|
}
|
|
66
52
|
return this;
|
|
@@ -70,7 +56,8 @@ function parseSegments(segments) {
|
|
|
70
56
|
*/ withError(error) {
|
|
71
57
|
if (error) {
|
|
72
58
|
this.#segments.push({
|
|
73
|
-
error
|
|
59
|
+
type: "error",
|
|
60
|
+
value: error
|
|
74
61
|
});
|
|
75
62
|
}
|
|
76
63
|
return this;
|
|
@@ -80,7 +67,8 @@ function parseSegments(segments) {
|
|
|
80
67
|
*/ withObject(obj) {
|
|
81
68
|
if (obj) {
|
|
82
69
|
this.#segments.push({
|
|
83
|
-
|
|
70
|
+
type: "object",
|
|
71
|
+
value: obj
|
|
84
72
|
});
|
|
85
73
|
}
|
|
86
74
|
return this;
|
|
@@ -89,18 +77,19 @@ function parseSegments(segments) {
|
|
|
89
77
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
90
78
|
*/ withLineChange() {
|
|
91
79
|
this.#segments.push({
|
|
92
|
-
|
|
80
|
+
type: "line-change",
|
|
81
|
+
value: "\r\n"
|
|
93
82
|
});
|
|
94
83
|
return this;
|
|
95
84
|
}
|
|
96
85
|
/**
|
|
97
86
|
* Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
|
|
98
87
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
99
|
-
*/ debug(log
|
|
88
|
+
*/ debug(log) {
|
|
100
89
|
if (log) {
|
|
101
90
|
this.#segments.push({
|
|
102
|
-
|
|
103
|
-
|
|
91
|
+
type: "text",
|
|
92
|
+
value: log
|
|
104
93
|
});
|
|
105
94
|
}
|
|
106
95
|
this.#log(logrocket.log, LogLevel.debug);
|
|
@@ -108,11 +97,11 @@ function parseSegments(segments) {
|
|
|
108
97
|
/**
|
|
109
98
|
* Write an information log. The log will be processed only if the logger LogLevel is >= information.
|
|
110
99
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
111
|
-
*/ information(log
|
|
100
|
+
*/ information(log) {
|
|
112
101
|
if (log) {
|
|
113
102
|
this.#segments.push({
|
|
114
|
-
|
|
115
|
-
|
|
103
|
+
type: "text",
|
|
104
|
+
value: log
|
|
116
105
|
});
|
|
117
106
|
}
|
|
118
107
|
this.#log(logrocket.log, LogLevel.information);
|
|
@@ -120,11 +109,11 @@ function parseSegments(segments) {
|
|
|
120
109
|
/**
|
|
121
110
|
* Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
|
|
122
111
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
123
|
-
*/ warning(log
|
|
112
|
+
*/ warning(log) {
|
|
124
113
|
if (log) {
|
|
125
114
|
this.#segments.push({
|
|
126
|
-
|
|
127
|
-
|
|
115
|
+
type: "text",
|
|
116
|
+
value: log
|
|
128
117
|
});
|
|
129
118
|
}
|
|
130
119
|
this.#log(logrocket.warn, LogLevel.warning);
|
|
@@ -132,11 +121,11 @@ function parseSegments(segments) {
|
|
|
132
121
|
/**
|
|
133
122
|
* Write an error log. The log will be processed only if the logger LogLevel is >= error.
|
|
134
123
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
135
|
-
*/ error(log
|
|
124
|
+
*/ error(log) {
|
|
136
125
|
if (log) {
|
|
137
126
|
this.#segments.push({
|
|
138
|
-
|
|
139
|
-
|
|
127
|
+
type: "text",
|
|
128
|
+
value: log
|
|
140
129
|
});
|
|
141
130
|
}
|
|
142
131
|
this.#log(logrocket.error, LogLevel.error);
|
|
@@ -144,11 +133,11 @@ function parseSegments(segments) {
|
|
|
144
133
|
/**
|
|
145
134
|
* Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
|
|
146
135
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
147
|
-
*/ critical(log
|
|
136
|
+
*/ critical(log) {
|
|
148
137
|
if (log) {
|
|
149
138
|
this.#segments.push({
|
|
150
|
-
|
|
151
|
-
|
|
139
|
+
type: "text",
|
|
140
|
+
value: log
|
|
152
141
|
});
|
|
153
142
|
}
|
|
154
143
|
this.#log(logrocket.error, LogLevel.critical);
|
|
@@ -188,8 +177,8 @@ function parseSegments(segments) {
|
|
|
188
177
|
#log(fct, threshold) {
|
|
189
178
|
if (this.#segments.length > 0) {
|
|
190
179
|
if (this.#logLevel <= threshold) {
|
|
191
|
-
const
|
|
192
|
-
fct(...
|
|
180
|
+
const values = this.#segments.map((x)=>x.value);
|
|
181
|
+
fct(...values);
|
|
193
182
|
}
|
|
194
183
|
this.#resetSegments();
|
|
195
184
|
}
|
|
@@ -201,11 +190,11 @@ function parseSegments(segments) {
|
|
|
201
190
|
}
|
|
202
191
|
/**
|
|
203
192
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
204
|
-
*/ withText(text
|
|
193
|
+
*/ withText(text) {
|
|
205
194
|
if (text) {
|
|
206
195
|
this.#segments.push({
|
|
207
|
-
text,
|
|
208
|
-
|
|
196
|
+
type: "text",
|
|
197
|
+
value: text
|
|
209
198
|
});
|
|
210
199
|
}
|
|
211
200
|
return this;
|
|
@@ -215,7 +204,8 @@ function parseSegments(segments) {
|
|
|
215
204
|
*/ withError(error) {
|
|
216
205
|
if (error) {
|
|
217
206
|
this.#segments.push({
|
|
218
|
-
error
|
|
207
|
+
type: "error",
|
|
208
|
+
value: error
|
|
219
209
|
});
|
|
220
210
|
}
|
|
221
211
|
return this;
|
|
@@ -225,7 +215,8 @@ function parseSegments(segments) {
|
|
|
225
215
|
*/ withObject(obj) {
|
|
226
216
|
if (obj) {
|
|
227
217
|
this.#segments.push({
|
|
228
|
-
|
|
218
|
+
type: "object",
|
|
219
|
+
value: obj
|
|
229
220
|
});
|
|
230
221
|
}
|
|
231
222
|
return this;
|
|
@@ -234,18 +225,19 @@ function parseSegments(segments) {
|
|
|
234
225
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
235
226
|
*/ withLineChange() {
|
|
236
227
|
this.#segments.push({
|
|
237
|
-
|
|
228
|
+
type: "line-change",
|
|
229
|
+
value: "\r\n"
|
|
238
230
|
});
|
|
239
231
|
return this;
|
|
240
232
|
}
|
|
241
233
|
/**
|
|
242
234
|
* Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
|
|
243
235
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
244
|
-
*/ debug(log
|
|
236
|
+
*/ debug(log) {
|
|
245
237
|
if (log) {
|
|
246
238
|
this.#segments.push({
|
|
247
|
-
|
|
248
|
-
|
|
239
|
+
type: "text",
|
|
240
|
+
value: log
|
|
249
241
|
});
|
|
250
242
|
}
|
|
251
243
|
this.#log(logrocket.log, LogLevel.debug);
|
|
@@ -253,11 +245,11 @@ function parseSegments(segments) {
|
|
|
253
245
|
/**
|
|
254
246
|
* Write an information log. The log will be processed only if the logger LogLevel is >= information.
|
|
255
247
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
256
|
-
*/ information(log
|
|
248
|
+
*/ information(log) {
|
|
257
249
|
if (log) {
|
|
258
250
|
this.#segments.push({
|
|
259
|
-
|
|
260
|
-
|
|
251
|
+
type: "text",
|
|
252
|
+
value: log
|
|
261
253
|
});
|
|
262
254
|
}
|
|
263
255
|
this.#log(logrocket.log, LogLevel.information);
|
|
@@ -265,11 +257,11 @@ function parseSegments(segments) {
|
|
|
265
257
|
/**
|
|
266
258
|
* Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
|
|
267
259
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
268
|
-
*/ warning(log
|
|
260
|
+
*/ warning(log) {
|
|
269
261
|
if (log) {
|
|
270
262
|
this.#segments.push({
|
|
271
|
-
|
|
272
|
-
|
|
263
|
+
type: "text",
|
|
264
|
+
value: log
|
|
273
265
|
});
|
|
274
266
|
}
|
|
275
267
|
this.#log(logrocket.warn, LogLevel.warning);
|
|
@@ -277,11 +269,11 @@ function parseSegments(segments) {
|
|
|
277
269
|
/**
|
|
278
270
|
* Write an error log. The log will be processed only if the logger LogLevel is >= error.
|
|
279
271
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
280
|
-
*/ error(log
|
|
272
|
+
*/ error(log) {
|
|
281
273
|
if (log) {
|
|
282
274
|
this.#segments.push({
|
|
283
|
-
|
|
284
|
-
|
|
275
|
+
type: "text",
|
|
276
|
+
value: log
|
|
285
277
|
});
|
|
286
278
|
}
|
|
287
279
|
this.#log(logrocket.error, LogLevel.error);
|
|
@@ -289,11 +281,11 @@ function parseSegments(segments) {
|
|
|
289
281
|
/**
|
|
290
282
|
* Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
|
|
291
283
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
292
|
-
*/ critical(log
|
|
284
|
+
*/ critical(log) {
|
|
293
285
|
if (log) {
|
|
294
286
|
this.#segments.push({
|
|
295
|
-
|
|
296
|
-
|
|
287
|
+
type: "text",
|
|
288
|
+
value: log
|
|
297
289
|
});
|
|
298
290
|
}
|
|
299
291
|
this.#log(logrocket.error, LogLevel.critical);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogRocketLogger.js","sources":["webpack://@workleap/logrocket/./src/LogRocketLogger.ts"],"sourcesContent":["import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel, type LogOptions, type Segment } from \"@workleap/logging\";\nimport LogRocket from \"logrocket\";\n\ntype LogFunction = (...rest: unknown[]) => void;\ntype PendingLog = () => void;\n\nfunction parseSegments(segments: Segment[]) {\n return segments.reduce<unknown[]>((acc, x) => {\n if (x.text) {\n acc.push(x.text);\n } else if (x.obj) {\n acc.push(x.obj);\n } else if (x.error) {\n acc.push(x.error);\n } else if (x.lineChange) {\n acc.push(\"\\r\\n\");\n }\n\n return acc;\n }, []);\n}\n\n/**\n * An scope implementation for the LogRocket logger.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLoggerScope implements LoggerScope {\n readonly #logLevel: LogLevel;\n readonly #label: string;\n\n #segments: Segment[] = [];\n #pendingLogs: PendingLog[] = [];\n #hasEnded: boolean = false;\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(label: string, logLevel: LogLevel) {\n this.#logLevel = logLevel;\n this.#label = label;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n // Required closure to preserved the current log items for when they will be formatted when the scope is ended.\n const segments = this.#segments;\n\n this.#pendingLogs.push(() => {\n const parsedSegments = parseSegments(segments);\n parsedSegments.unshift(`(${this.#label})`);\n\n fct(...parsedSegments);\n });\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options: LogOptions = {}) {\n if (text) {\n this.#segments.push({\n text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n lineChange: true\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n end(options: LoggerScopeEndOptions = {}) {\n const {\n dismiss = false\n } = options;\n\n if (!this.#hasEnded) {\n this.#hasEnded = true;\n\n if (!dismiss) {\n if (this.#pendingLogs.length > 0) {\n this.#pendingLogs.forEach(x => {\n x();\n });\n\n this.#pendingLogs = [];\n }\n }\n }\n }\n}\n\n/**\n * A logger implementation for LogRocket.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLogger implements Logger {\n readonly #logLevel: LogLevel;\n #segments: Segment[] = [];\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(options: LoggerOptions = {}) {\n const {\n logLevel = LogLevel.debug\n } = options;\n\n this.#logLevel = logLevel;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n const parsedSegments = parseSegments(this.#segments);\n\n fct(...parsedSegments);\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n getName() {\n return LogRocketLogger.name;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options: LogOptions = {}) {\n if (text) {\n this.#segments.push({\n text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n lineChange: true\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * Start a new logging scope. The scope will inherit the LogLevel of the root logger.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n startScope(label: string) {\n return new LogRocketLoggerScope(label, this.#logLevel);\n }\n}\n"],"names":["LogLevel","LogRocket","parseSegments","segments","acc","x","LogRocketLoggerScope","label","logLevel","fct","threshold","parsedSegments","text","options","error","obj","log","dismiss","LogRocketLogger"],"mappings":";;;;;;;;AAA2J;AACzH;AAKlC,SAASE,cAAcC,QAAmB;IACtC,OAAOA,SAAS,MAAM,CAAY,CAACC,KAAKC;QACpC,IAAIA,EAAE,IAAI,EAAE;YACRD,IAAI,IAAI,CAACC,EAAE,IAAI;QACnB,OAAO,IAAIA,EAAE,GAAG,EAAE;YACdD,IAAI,IAAI,CAACC,EAAE,GAAG;QAClB,OAAO,IAAIA,EAAE,KAAK,EAAE;YAChBD,IAAI,IAAI,CAACC,EAAE,KAAK;QACpB,OAAO,IAAIA,EAAE,UAAU,EAAE;YACrBD,IAAI,IAAI,CAAC;QACb;QAEA,OAAOA;IACX,GAAG,EAAE;AACT;AAEA;;;CAGC,GACM,MAAME;IACA,SAAS,CAAW;IACpB,MAAM,CAAS;IAExB,SAAS,GAAc,EAAE,CAAC;IAC1B,YAAY,GAAiB,EAAE,CAAC;IAChC,SAAS,GAAY,MAAM;IAE3B;;KAEC,GACD,YAAYC,KAAa,EAAEC,QAAkB,CAAE;QAC3C,IAAI,CAAC,SAAS,GAAGA;QACjB,IAAI,CAAC,MAAM,GAAGD;IAClB;IAEA,cAAc;QACV,IAAI,CAAC,SAAS,GAAG,EAAE;IACvB;IAEA,IAAI,CAACE,GAAgB,EAAEC,SAAmB;QACtC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,GAAG;YAC3B,IAAI,IAAI,CAAC,SAAS,IAAIA,WAAW;gBAC7B,+GAA+G;gBAC/G,MAAMP,WAAW,IAAI,CAAC,SAAS;gBAE/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;oBACnB,MAAMQ,iBAAiBT,cAAcC;oBACrCQ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AAoB,EAAE;QACxC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,cAAc,EAAED,gBAAgB;IAC9C;IAEA;;;KAGC,GACD,MAAMgB,GAAY,EAAEH,OAAoB,EAAE;QACtC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,cAAc;IAC7C;IAEA;;;KAGC,GACD,SAASgB,GAAY,EAAEH,OAAoB,EAAE;QACzC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,iBAAiB;IAChD;IAEA;;;KAGC,GACD,WAAWO,KAAa,EAAE;QACtB,OAAO,IAAID,qBAAqBC,OAAO,IAAI,CAAC,SAAS;IACzD;AACJ"}
|
|
1
|
+
{"version":3,"file":"LogRocketLogger.js","sources":["webpack://@workleap/logrocket/./src/LogRocketLogger.ts"],"sourcesContent":["import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel } from \"@workleap/logging\";\nimport LogRocket from \"logrocket\";\n\ninterface Segment {\n type: \"text\" | \"object\" | \"error\" | \"line-change\";\n value: unknown;\n}\n\ntype LogFunction = (...rest: unknown[]) => void;\ntype PendingLog = () => void;\n\n/**\n * An scope implementation for the LogRocket logger.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLoggerScope implements LoggerScope {\n readonly #logLevel: LogLevel;\n readonly #label: string;\n\n #segments: Segment[] = [];\n #pendingLogs: PendingLog[] = [];\n #hasEnded: boolean = false;\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(label: string, logLevel: LogLevel) {\n this.#logLevel = logLevel;\n this.#label = label;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n // Required closure to preserved the current log items for when they will be formatted when the scope is ended.\n const segments = this.#segments;\n\n this.#pendingLogs.push(() => {\n const values = segments.map(x => x.value);\n values.unshift(`(${this.#label})`);\n\n fct(...values);\n });\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string) {\n if (text) {\n this.#segments.push({\n type: \"text\",\n value: text\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n type: \"error\",\n value: error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n type: \"object\",\n value: obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n type: \"line-change\",\n value: \"\\r\\n\"\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n end(options: LoggerScopeEndOptions = {}) {\n const {\n dismiss = false\n } = options;\n\n if (!this.#hasEnded) {\n this.#hasEnded = true;\n\n if (!dismiss) {\n if (this.#pendingLogs.length > 0) {\n this.#pendingLogs.forEach(x => {\n x();\n });\n\n this.#pendingLogs = [];\n }\n }\n }\n }\n}\n\n/**\n * A logger implementation for LogRocket.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLogger implements Logger {\n readonly #logLevel: LogLevel;\n #segments: Segment[] = [];\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(options: LoggerOptions = {}) {\n const {\n logLevel = LogLevel.debug\n } = options;\n\n this.#logLevel = logLevel;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n const values = this.#segments.map(x => x.value);\n\n fct(...values);\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n getName() {\n return LogRocketLogger.name;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string) {\n if (text) {\n this.#segments.push({\n type: \"text\",\n value: text\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n type: \"error\",\n value: error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n type: \"object\",\n value: obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n type: \"line-change\",\n value: \"\\r\\n\"\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * Start a new logging scope. The scope will inherit the LogLevel of the root logger.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n startScope(label: string) {\n return new LogRocketLoggerScope(label, this.#logLevel);\n }\n}\n"],"names":["LogLevel","LogRocket","LogRocketLoggerScope","label","logLevel","fct","threshold","segments","values","x","text","error","obj","log","options","dismiss","LogRocketLogger"],"mappings":";;;;;;;;AAA4H;AAC1F;AAUlC;;;CAGC,GACM,MAAME;IACA,SAAS,CAAW;IACpB,MAAM,CAAS;IAExB,SAAS,GAAc,EAAE,CAAC;IAC1B,YAAY,GAAiB,EAAE,CAAC;IAChC,SAAS,GAAY,MAAM;IAE3B;;KAEC,GACD,YAAYC,KAAa,EAAEC,QAAkB,CAAE;QAC3C,IAAI,CAAC,SAAS,GAAGA;QACjB,IAAI,CAAC,MAAM,GAAGD;IAClB;IAEA,cAAc;QACV,IAAI,CAAC,SAAS,GAAG,EAAE;IACvB;IAEA,IAAI,CAACE,GAAgB,EAAEC,SAAmB;QACtC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,GAAG;YAC3B,IAAI,IAAI,CAAC,SAAS,IAAIA,WAAW;gBAC7B,+GAA+G;gBAC/G,MAAMC,WAAW,IAAI,CAAC,SAAS;gBAE/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;oBACnB,MAAMC,SAASD,SAAS,GAAG,CAACE,CAAAA,IAAKA,EAAE,KAAK;oBACxCD,OAAO,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;oBAEjCH,OAAOG;gBACX;YACJ;YAEA,IAAI,CAAC,cAAc;QACvB;IACJ;IAEA;;KAEC,GACD,SAASE,IAAa,EAAE;QACpB,IAAIA,MAAM;YACN,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,OAAO,IAAI;IACf;IAEA;;KAEC,GACD,UAAUC,KAAa,EAAE;QACrB,IAAIA,OAAO;YACP,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,OAAO,IAAI;IACf;IAEA;;KAEC,GACD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OA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,iBAAiB;IAChD;IAEA;;;KAGC,GACD,WAAWG,KAAa,EAAE;QACtB,OAAO,IAAID,qBAAqBC,OAAO,IAAI,CAAC,SAAS;IACzD;AACJ"}
|
|
@@ -141,7 +141,7 @@ function __resetRegistrationGuard() {
|
|
|
141
141
|
bootstrappingStore.dispatch({
|
|
142
142
|
type: "logrocket-ready"
|
|
143
143
|
});
|
|
144
|
-
logger.
|
|
144
|
+
logger.information("[logrocket] LogRocket instrumentation is registered.");
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
export { IsRegisteredVariableName, RegisterGetSessionUrlFunctionName, __resetRegistrationGuard, getLogRocketSdkOptions, registerLogRocketInstrumentation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerLogRocketInstrumentation.js","sources":["webpack://@workleap/logrocket/./src/registerLogRocketInstrumentation.ts"],"sourcesContent":["import { createCompositeLogger, type RootLogger } from \"@workleap/logging\";\nimport { createBootstrappingStore, createTelemetryContext } from \"@workleap/telemetry\";\nimport LogRocket from \"logrocket\";\nimport LogrocketFuzzySanitizer from \"logrocket-fuzzy-search-sanitizer\";\nimport { applyTransformers, type LogRocketSdkOptionsTransformer } from \"./applyTransformers.ts\";\nimport { DeviceIdTrait, TelemetryIdTrait } from \"./createDefaultUserTraits.ts\";\nimport { createRequestSanitizer } from \"./createRequestSanitizer.ts\";\nimport { createResponseSanitizer } from \"./createResponseSanitizer.ts\";\nimport { createUrlSanitizer } from \"./createUrlSanitizer.ts\";\nimport { HasExecutedGuard } from \"./HasExecutedGuard.ts\";\nimport type { LogRocketSdkOptions } from \"./logRocketTypes.ts\";\n\nexport const IsRegisteredVariableName = \"__WLP_LOGROCKET_INSTRUMENTATION_IS_REGISTERED__\";\nexport const RegisterGetSessionUrlFunctionName = \"__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__\";\n\nconst DefaultPrivateFieldNames = [\n \"email\",\n \"personalEmail\",\n \"phoneNumber\",\n \"password\",\n \"firstName\",\n \"lastName\",\n \"givenName\",\n \"fullName\",\n \"gender\",\n \"timeZone\",\n \"birthday\"\n];\n\nconst DefaultPrivateQueryParameterNames = [\n \"token\",\n \"email\",\n \"password\"\n];\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface RegisterLogRocketInstrumentationOptions {\n /**\n * A root hostname to track sessions across subdomains. Set this option to capture traffic from all subdomains under one session: https://docs.logrocket.com/reference/roothostname.\n */\n rootHostname?: LogRocketSdkOptions[\"rootHostname\"];\n /**\n * Names of additional fields to exclude from session replays. These fields will be removed from network requests, responses using a fuzzy-matching algorithm.\n */\n privateFieldNames?: string[];\n /**\n * Names of additional fields to exclude from session replays. These fields will be removed from query parameters using a fuzzy-matching algorithm.\n */\n privateQueryParameterNames?: string[];\n /**\n * Indicates whether or not debug information should be logged to the console.\n */\n verbose?: boolean;\n /**\n * The logger instances that will output messages.\n */\n loggers?: RootLogger[];\n /**\n * Hooks to transform the resulting LogRocket SDK options.\n */\n transformers?: LogRocketSdkOptionsTransformer[];\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function getLogRocketSdkOptions(userOptions: RegisterLogRocketInstrumentationOptions, logger: RootLogger): LogRocketSdkOptions {\n const {\n rootHostname = \"workleap.com\",\n privateFieldNames = [],\n privateQueryParameterNames = [],\n verbose = false,\n transformers = []\n } = userOptions;\n\n const mergedPrivateFieldNames = DefaultPrivateFieldNames.concat(privateFieldNames);\n const mergedPrivateQueryParameterNames = DefaultPrivateQueryParameterNames.concat(privateQueryParameterNames);\n\n // The \"LogrocketFuzzySearch.setup\" code is awkward. For now, we prefer to play it safe and call it once here, then forward the sanitize functions\n // to the appropriate factories.\n // No clue why the \"setup\" method is not available. This package is shady.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const { requestSanitizer: fuzzyRequestSanitizer, responseSanitizer: fuzzyResponseSanitizer } = LogrocketFuzzySanitizer.setup(mergedPrivateFieldNames);\n\n const sdkOptions = {\n console: {\n // Prevent console logs from being visible in LogRocket session replays and leaking PII.\n // To capture logs in a session replay, use the LogRocketLogger class.\n isEnabled: false\n },\n rootHostname,\n dom: {\n textSanitizer: true,\n inputSanitizer: true\n },\n network: {\n requestSanitizer: createRequestSanitizer(fuzzyRequestSanitizer),\n responseSanitizer: createResponseSanitizer(fuzzyResponseSanitizer)\n },\n browser: {\n urlSanitizer: createUrlSanitizer(mergedPrivateQueryParameterNames)\n },\n shouldDebugLog: verbose\n } satisfies LogRocketSdkOptions;\n\n return applyTransformers(sdkOptions, transformers, {\n verbose,\n logger\n });\n}\n\nconst registrationGuard = new HasExecutedGuard();\n\n// This function should only be used by tests.\nexport function __resetRegistrationGuard() {\n registrationGuard.reset();\n}\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function registerLogRocketInstrumentation(appId: string, options: RegisterLogRocketInstrumentationOptions = {}) {\n const {\n verbose = false,\n loggers = []\n } = options;\n\n const logger = createCompositeLogger(verbose, loggers);\n\n registrationGuard.throw(\"[logrocket] The LogRocket instrumentation has already been registered. Did you call the \\\"registerLogRocketInstrumentation\\\" function twice?\");\n\n const sdkOptions = getLogRocketSdkOptions(options, logger);\n\n // Session starts anonymously when LogRocket.init() is called.\n LogRocket.init(appId, sdkOptions);\n\n const telemetryContext = createTelemetryContext(logger);\n\n // LogRocket maintains the same session even if the user starts as anonymous and later becomes identified via LogRocket.identify().\n // If LogRocket.identify is called multiple times during a recording, you can search for any of the identified users in the session.\n LogRocket.identify(telemetryContext.deviceId, {\n [DeviceIdTrait]: telemetryContext.deviceId,\n [TelemetryIdTrait]: telemetryContext.telemetryId\n });\n\n LogRocket.getSessionURL(url => {\n logger\n .withText(\"[logrocket] Session replay URL is now available:\")\n .withText(url)\n .debug();\n });\n\n // Indicates to the host applications that logrocket has been initialized.\n // It's useful in cases where an \"add-on\", like the platform widgets needs\n // to know whether or not the host application is using LogRocket.\n // While there are ways that the host application could tell to an \"add-on\" if\n // it's using LogRocket or not, doing it this way is transparent for the consumer,\n // which is great for DX.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[IsRegisteredVariableName] = true;\n\n // While consumers could directly call LogRocket.getSessionURL, by doing it this way,\n // it allow consumers to not take a direct dependency on the \"logrocket\" package.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[RegisterGetSessionUrlFunctionName] = listener => {\n LogRocket.getSessionURL(listener);\n };\n\n const bootstrappingStore = createBootstrappingStore(logger);\n // Let the other telemetry libraries know that LogRocket instrumentation is ready.\n bootstrappingStore.dispatch({ type: \"logrocket-ready\" });\n\n logger.debug(\"[logrocket] LogRocket instrumentation is registered.\");\n}\n"],"names":["createCompositeLogger","createBootstrappingStore","createTelemetryContext","LogRocket","LogrocketFuzzySanitizer","applyTransformers","DeviceIdTrait","TelemetryIdTrait","createRequestSanitizer","createResponseSanitizer","createUrlSanitizer","HasExecutedGuard","IsRegisteredVariableName","RegisterGetSessionUrlFunctionName","DefaultPrivateFieldNames","DefaultPrivateQueryParameterNames","getLogRocketSdkOptions","userOptions","logger","rootHostname","privateFieldNames","privateQueryParameterNames","verbose","transformers","mergedPrivateFieldNames","mergedPrivateQueryParameterNames","fuzzyRequestSanitizer","fuzzyResponseSanitizer","sdkOptions","registrationGuard","__resetRegistrationGuard","registerLogRocketInstrumentation","appId","options","loggers","telemetryContext","url","globalThis","listener","bootstrappingStore"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA2E;AACY;AACrD;AACqC;AACyB;AACjB;AACV;AACE;AACV;AACJ;AAGlD,MAAMY,2BAA2B,kDAAkD;AACnF,MAAMC,oCAAoC,sEAAsE;AAEvH,MAAMC,2BAA2B;IAC7B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAED,MAAMC,oCAAoC;IACtC;IACA;IACA;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oIAAoI;IACpIf,kBAAkB,CAACgC,iBAAiB,QAAQ,EAAE;QAC1C,CAAC7B,aAAaA,CAAC,EAAE6B,iBAAiB,QAAQ;QAC1C,CAAC5B,gBAAgBA,CAAC,EAAE4B,iBAAiB,WAAW;IACpD;IAEAhC,uBAAuB,CAACiC,CAAAA;QACpBlB,OACK,QAAQ,CAAC,oDACT,QAAQ,CAACkB,KACT,KAAK;IACd;IAEA,0EAA0E;IAC1E,0EAA0E;IAC1E,kEAAkE;IAClE,8EAA8E;IAC9E,kFAAkF;IAClF,yBAAyB;IACzB,6DAA6D;IAC7D,aAAa;IACbC,UAAU,CAACzB,yBAAyB,GAAG;IAEvC,qFAAqF;IACrF,iFAAiF;IACjF,6DAA6D;IAC7D,aAAa;IACbyB,UAAU,CAACxB,kCAAkC,GAAGyB,CAAAA;QAC5CnC,uBAAuB,CAACmC;IAC5B;IAEA,MAAMC,qBAAqBtC,wBAAwBA,CAACiB;IACpD,kFAAkF;IAClFqB,mBAAmB,QAAQ,CAAC;QAAE,MAAM;IAAkB;IAEtDrB,OAAO,KAAK,CAAC;AACjB"}
|
|
1
|
+
{"version":3,"file":"registerLogRocketInstrumentation.js","sources":["webpack://@workleap/logrocket/./src/registerLogRocketInstrumentation.ts"],"sourcesContent":["import { createCompositeLogger, type RootLogger } from \"@workleap/logging\";\nimport { createBootstrappingStore, createTelemetryContext } from \"@workleap/telemetry\";\nimport LogRocket from \"logrocket\";\nimport LogrocketFuzzySanitizer from \"logrocket-fuzzy-search-sanitizer\";\nimport { applyTransformers, type LogRocketSdkOptionsTransformer } from \"./applyTransformers.ts\";\nimport { DeviceIdTrait, TelemetryIdTrait } from \"./createDefaultUserTraits.ts\";\nimport { createRequestSanitizer } from \"./createRequestSanitizer.ts\";\nimport { createResponseSanitizer } from \"./createResponseSanitizer.ts\";\nimport { createUrlSanitizer } from \"./createUrlSanitizer.ts\";\nimport { HasExecutedGuard } from \"./HasExecutedGuard.ts\";\nimport type { LogRocketSdkOptions } from \"./logRocketTypes.ts\";\n\nexport const IsRegisteredVariableName = \"__WLP_LOGROCKET_INSTRUMENTATION_IS_REGISTERED__\";\nexport const RegisterGetSessionUrlFunctionName = \"__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__\";\n\nconst DefaultPrivateFieldNames = [\n \"email\",\n \"personalEmail\",\n \"phoneNumber\",\n \"password\",\n \"firstName\",\n \"lastName\",\n \"givenName\",\n \"fullName\",\n \"gender\",\n \"timeZone\",\n \"birthday\"\n];\n\nconst DefaultPrivateQueryParameterNames = [\n \"token\",\n \"email\",\n \"password\"\n];\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface RegisterLogRocketInstrumentationOptions {\n /**\n * A root hostname to track sessions across subdomains. Set this option to capture traffic from all subdomains under one session: https://docs.logrocket.com/reference/roothostname.\n */\n rootHostname?: LogRocketSdkOptions[\"rootHostname\"];\n /**\n * Names of additional fields to exclude from session replays. These fields will be removed from network requests, responses using a fuzzy-matching algorithm.\n */\n privateFieldNames?: string[];\n /**\n * Names of additional fields to exclude from session replays. These fields will be removed from query parameters using a fuzzy-matching algorithm.\n */\n privateQueryParameterNames?: string[];\n /**\n * Indicates whether or not debug information should be logged to the console.\n */\n verbose?: boolean;\n /**\n * The logger instances that will output messages.\n */\n loggers?: RootLogger[];\n /**\n * Hooks to transform the resulting LogRocket SDK options.\n */\n transformers?: LogRocketSdkOptionsTransformer[];\n}\n\n// The function return type is mandatory, otherwise we got an error TS4058.\nexport function getLogRocketSdkOptions(userOptions: RegisterLogRocketInstrumentationOptions, logger: RootLogger): LogRocketSdkOptions {\n const {\n rootHostname = \"workleap.com\",\n privateFieldNames = [],\n privateQueryParameterNames = [],\n verbose = false,\n transformers = []\n } = userOptions;\n\n const mergedPrivateFieldNames = DefaultPrivateFieldNames.concat(privateFieldNames);\n const mergedPrivateQueryParameterNames = DefaultPrivateQueryParameterNames.concat(privateQueryParameterNames);\n\n // The \"LogrocketFuzzySearch.setup\" code is awkward. For now, we prefer to play it safe and call it once here, then forward the sanitize functions\n // to the appropriate factories.\n // No clue why the \"setup\" method is not available. This package is shady.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const { requestSanitizer: fuzzyRequestSanitizer, responseSanitizer: fuzzyResponseSanitizer } = LogrocketFuzzySanitizer.setup(mergedPrivateFieldNames);\n\n const sdkOptions = {\n console: {\n // Prevent console logs from being visible in LogRocket session replays and leaking PII.\n // To capture logs in a session replay, use the LogRocketLogger class.\n isEnabled: false\n },\n rootHostname,\n dom: {\n textSanitizer: true,\n inputSanitizer: true\n },\n network: {\n requestSanitizer: createRequestSanitizer(fuzzyRequestSanitizer),\n responseSanitizer: createResponseSanitizer(fuzzyResponseSanitizer)\n },\n browser: {\n urlSanitizer: createUrlSanitizer(mergedPrivateQueryParameterNames)\n },\n shouldDebugLog: verbose\n } satisfies LogRocketSdkOptions;\n\n return applyTransformers(sdkOptions, transformers, {\n verbose,\n logger\n });\n}\n\nconst registrationGuard = new HasExecutedGuard();\n\n// This function should only be used by tests.\nexport function __resetRegistrationGuard() {\n registrationGuard.reset();\n}\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function registerLogRocketInstrumentation(appId: string, options: RegisterLogRocketInstrumentationOptions = {}) {\n const {\n verbose = false,\n loggers = []\n } = options;\n\n const logger = createCompositeLogger(verbose, loggers);\n\n registrationGuard.throw(\"[logrocket] The LogRocket instrumentation has already been registered. Did you call the \\\"registerLogRocketInstrumentation\\\" function twice?\");\n\n const sdkOptions = getLogRocketSdkOptions(options, logger);\n\n // Session starts anonymously when LogRocket.init() is called.\n LogRocket.init(appId, sdkOptions);\n\n const telemetryContext = createTelemetryContext(logger);\n\n // LogRocket maintains the same session even if the user starts as anonymous and later becomes identified via LogRocket.identify().\n // If LogRocket.identify is called multiple times during a recording, you can search for any of the identified users in the session.\n LogRocket.identify(telemetryContext.deviceId, {\n [DeviceIdTrait]: telemetryContext.deviceId,\n [TelemetryIdTrait]: telemetryContext.telemetryId\n });\n\n LogRocket.getSessionURL(url => {\n logger\n .withText(\"[logrocket] Session replay URL is now available:\")\n .withText(url)\n .debug();\n });\n\n // Indicates to the host applications that logrocket has been initialized.\n // It's useful in cases where an \"add-on\", like the platform widgets needs\n // to know whether or not the host application is using LogRocket.\n // While there are ways that the host application could tell to an \"add-on\" if\n // it's using LogRocket or not, doing it this way is transparent for the consumer,\n // which is great for DX.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[IsRegisteredVariableName] = true;\n\n // While consumers could directly call LogRocket.getSessionURL, by doing it this way,\n // it allow consumers to not take a direct dependency on the \"logrocket\" package.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[RegisterGetSessionUrlFunctionName] = listener => {\n LogRocket.getSessionURL(listener);\n };\n\n const bootstrappingStore = createBootstrappingStore(logger);\n // Let the other telemetry libraries know that LogRocket instrumentation is ready.\n bootstrappingStore.dispatch({ type: \"logrocket-ready\" });\n\n logger.information(\"[logrocket] LogRocket instrumentation is registered.\");\n}\n"],"names":["createCompositeLogger","createBootstrappingStore","createTelemetryContext","LogRocket","LogrocketFuzzySanitizer","applyTransformers","DeviceIdTrait","TelemetryIdTrait","createRequestSanitizer","createResponseSanitizer","createUrlSanitizer","HasExecutedGuard","IsRegisteredVariableName","RegisterGetSessionUrlFunctionName","DefaultPrivateFieldNames","DefaultPrivateQueryParameterNames","getLogRocketSdkOptions","userOptions","logger","rootHostname","privateFieldNames","privateQueryParameterNames","verbose","transformers","mergedPrivateFieldNames","mergedPrivateQueryParameterNames","fuzzyRequestSanitizer","fuzzyResponseSanitizer","sdkOptions","registrationGuard","__resetRegistrationGuard","registerLogRocketInstrumentation","appId","options","loggers","telemetryContext","url","globalThis","listener","bootstrappingStore"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA2E;AACY;AACrD;AACqC;AACyB;AACjB;AACV;AACE;AACV;A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,SAASY;IAE9CL,kBAAkB,KAAK,CAAC;IAExB,MAAMD,aAAaZ,uBAAuBiB,SAASf;IAEnD,8DAA8D;IAC9Df,cAAc,CAAC6B,OAAOJ;IAEtB,MAAMO,mBAAmBjC,sBAAsBA,CAACgB;IAEhD,mIAAmI;IACnI,oIAAoI;IACpIf,kBAAkB,CAACgC,iBAAiB,QAAQ,EAAE;QAC1C,CAAC7B,aAAaA,CAAC,EAAE6B,iBAAiB,QAAQ;QAC1C,CAAC5B,gBAAgBA,CAAC,EAAE4B,iBAAiB,WAAW;IACpD;IAEAhC,uBAAuB,CAACiC,CAAAA;QACpBlB,OACK,QAAQ,CAAC,oDACT,QAAQ,CAACkB,KACT,KAAK;IACd;IAEA,0EAA0E;IAC1E,0EAA0E;IAC1E,kEAAkE;IAClE,8EAA8E;IAC9E,kFAAkF;IAClF,yBAAyB;IACzB,6DAA6D;IAC7D,aAAa;IACbC,UAAU,CAACzB,yBAAyB,GAAG;IAEvC,qFAAqF;IACrF,iFAAiF;IACjF,6DAA6D;IAC7D,aAAa;IACbyB,UAAU,CAACxB,kCAAkC,GAAGyB,CAAAA;QAC5CnC,uBAAuB,CAACmC;IAC5B;IAEA,MAAMC,qBAAqBtC,wBAAwBA,CAACiB;IACpD,kFAAkF;IAClFqB,mBAAmB,QAAQ,CAAC;QAAE,MAAM;IAAkB;IAEtDrB,OAAO,WAAW,CAAC;AACvB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workleap/logrocket",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.4",
|
|
5
5
|
"description": "A package containing utilities for LogRocket.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"logrocket": "^10.1.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@workleap/logging": "^1.2.
|
|
34
|
+
"@workleap/logging": "^1.2.3",
|
|
35
35
|
"logrocket-fuzzy-search-sanitizer": "0.0.2",
|
|
36
|
-
"@workleap/telemetry": "1.1.
|
|
36
|
+
"@workleap/telemetry": "1.1.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@rsbuild/core": "1.4.6",
|
package/src/LogRocketLogger.ts
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel
|
|
1
|
+
import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel } from "@workleap/logging";
|
|
2
2
|
import LogRocket from "logrocket";
|
|
3
3
|
|
|
4
|
+
interface Segment {
|
|
5
|
+
type: "text" | "object" | "error" | "line-change";
|
|
6
|
+
value: unknown;
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
type LogFunction = (...rest: unknown[]) => void;
|
|
5
10
|
type PendingLog = () => void;
|
|
6
11
|
|
|
7
|
-
function parseSegments(segments: Segment[]) {
|
|
8
|
-
return segments.reduce<unknown[]>((acc, x) => {
|
|
9
|
-
if (x.text) {
|
|
10
|
-
acc.push(x.text);
|
|
11
|
-
} else if (x.obj) {
|
|
12
|
-
acc.push(x.obj);
|
|
13
|
-
} else if (x.error) {
|
|
14
|
-
acc.push(x.error);
|
|
15
|
-
} else if (x.lineChange) {
|
|
16
|
-
acc.push("\r\n");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return acc;
|
|
20
|
-
}, []);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
12
|
/**
|
|
24
13
|
* An scope implementation for the LogRocket logger.
|
|
25
14
|
* @see {@link https://workleap.github.io/wl-telemetry}
|
|
@@ -51,10 +40,10 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
51
40
|
const segments = this.#segments;
|
|
52
41
|
|
|
53
42
|
this.#pendingLogs.push(() => {
|
|
54
|
-
const
|
|
55
|
-
|
|
43
|
+
const values = segments.map(x => x.value);
|
|
44
|
+
values.unshift(`(${this.#label})`);
|
|
56
45
|
|
|
57
|
-
fct(...
|
|
46
|
+
fct(...values);
|
|
58
47
|
});
|
|
59
48
|
}
|
|
60
49
|
|
|
@@ -65,11 +54,11 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
65
54
|
/**
|
|
66
55
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
67
56
|
*/
|
|
68
|
-
withText(text?: string
|
|
57
|
+
withText(text?: string) {
|
|
69
58
|
if (text) {
|
|
70
59
|
this.#segments.push({
|
|
71
|
-
text,
|
|
72
|
-
|
|
60
|
+
type: "text",
|
|
61
|
+
value: text
|
|
73
62
|
});
|
|
74
63
|
}
|
|
75
64
|
|
|
@@ -82,7 +71,8 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
82
71
|
withError(error?: Error) {
|
|
83
72
|
if (error) {
|
|
84
73
|
this.#segments.push({
|
|
85
|
-
error
|
|
74
|
+
type: "error",
|
|
75
|
+
value: error
|
|
86
76
|
});
|
|
87
77
|
}
|
|
88
78
|
|
|
@@ -95,7 +85,8 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
95
85
|
withObject(obj?: unknown) {
|
|
96
86
|
if (obj) {
|
|
97
87
|
this.#segments.push({
|
|
98
|
-
|
|
88
|
+
type: "object",
|
|
89
|
+
value: obj
|
|
99
90
|
});
|
|
100
91
|
}
|
|
101
92
|
|
|
@@ -107,7 +98,8 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
107
98
|
*/
|
|
108
99
|
withLineChange() {
|
|
109
100
|
this.#segments.push({
|
|
110
|
-
|
|
101
|
+
type: "line-change",
|
|
102
|
+
value: "\r\n"
|
|
111
103
|
});
|
|
112
104
|
|
|
113
105
|
return this;
|
|
@@ -117,11 +109,11 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
117
109
|
* Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
|
|
118
110
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
119
111
|
*/
|
|
120
|
-
debug(log?: string
|
|
112
|
+
debug(log?: string) {
|
|
121
113
|
if (log) {
|
|
122
114
|
this.#segments.push({
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
type: "text",
|
|
116
|
+
value: log
|
|
125
117
|
});
|
|
126
118
|
}
|
|
127
119
|
|
|
@@ -132,11 +124,11 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
132
124
|
* Write an information log. The log will be processed only if the logger LogLevel is >= information.
|
|
133
125
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
134
126
|
*/
|
|
135
|
-
information(log?: string
|
|
127
|
+
information(log?: string) {
|
|
136
128
|
if (log) {
|
|
137
129
|
this.#segments.push({
|
|
138
|
-
|
|
139
|
-
|
|
130
|
+
type: "text",
|
|
131
|
+
value: log
|
|
140
132
|
});
|
|
141
133
|
}
|
|
142
134
|
|
|
@@ -147,11 +139,11 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
147
139
|
* Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
|
|
148
140
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
149
141
|
*/
|
|
150
|
-
warning(log?: string
|
|
142
|
+
warning(log?: string) {
|
|
151
143
|
if (log) {
|
|
152
144
|
this.#segments.push({
|
|
153
|
-
|
|
154
|
-
|
|
145
|
+
type: "text",
|
|
146
|
+
value: log
|
|
155
147
|
});
|
|
156
148
|
}
|
|
157
149
|
|
|
@@ -162,11 +154,11 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
162
154
|
* Write an error log. The log will be processed only if the logger LogLevel is >= error.
|
|
163
155
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
164
156
|
*/
|
|
165
|
-
error(log?: string
|
|
157
|
+
error(log?: string) {
|
|
166
158
|
if (log) {
|
|
167
159
|
this.#segments.push({
|
|
168
|
-
|
|
169
|
-
|
|
160
|
+
type: "text",
|
|
161
|
+
value: log
|
|
170
162
|
});
|
|
171
163
|
}
|
|
172
164
|
|
|
@@ -177,11 +169,11 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
177
169
|
* Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
|
|
178
170
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
179
171
|
*/
|
|
180
|
-
critical(log?: string
|
|
172
|
+
critical(log?: string) {
|
|
181
173
|
if (log) {
|
|
182
174
|
this.#segments.push({
|
|
183
|
-
|
|
184
|
-
|
|
175
|
+
type: "text",
|
|
176
|
+
value: log
|
|
185
177
|
});
|
|
186
178
|
}
|
|
187
179
|
|
|
@@ -238,9 +230,9 @@ export class LogRocketLogger implements Logger {
|
|
|
238
230
|
#log(fct: LogFunction, threshold: LogLevel) {
|
|
239
231
|
if (this.#segments.length > 0) {
|
|
240
232
|
if (this.#logLevel <= threshold) {
|
|
241
|
-
const
|
|
233
|
+
const values = this.#segments.map(x => x.value);
|
|
242
234
|
|
|
243
|
-
fct(...
|
|
235
|
+
fct(...values);
|
|
244
236
|
}
|
|
245
237
|
|
|
246
238
|
this.#resetSegments();
|
|
@@ -257,11 +249,11 @@ export class LogRocketLogger implements Logger {
|
|
|
257
249
|
/**
|
|
258
250
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
259
251
|
*/
|
|
260
|
-
withText(text?: string
|
|
252
|
+
withText(text?: string) {
|
|
261
253
|
if (text) {
|
|
262
254
|
this.#segments.push({
|
|
263
|
-
text,
|
|
264
|
-
|
|
255
|
+
type: "text",
|
|
256
|
+
value: text
|
|
265
257
|
});
|
|
266
258
|
}
|
|
267
259
|
|
|
@@ -274,7 +266,8 @@ export class LogRocketLogger implements Logger {
|
|
|
274
266
|
withError(error?: Error) {
|
|
275
267
|
if (error) {
|
|
276
268
|
this.#segments.push({
|
|
277
|
-
error
|
|
269
|
+
type: "error",
|
|
270
|
+
value: error
|
|
278
271
|
});
|
|
279
272
|
}
|
|
280
273
|
|
|
@@ -287,7 +280,8 @@ export class LogRocketLogger implements Logger {
|
|
|
287
280
|
withObject(obj?: unknown) {
|
|
288
281
|
if (obj) {
|
|
289
282
|
this.#segments.push({
|
|
290
|
-
|
|
283
|
+
type: "object",
|
|
284
|
+
value: obj
|
|
291
285
|
});
|
|
292
286
|
}
|
|
293
287
|
|
|
@@ -299,7 +293,8 @@ export class LogRocketLogger implements Logger {
|
|
|
299
293
|
*/
|
|
300
294
|
withLineChange() {
|
|
301
295
|
this.#segments.push({
|
|
302
|
-
|
|
296
|
+
type: "line-change",
|
|
297
|
+
value: "\r\n"
|
|
303
298
|
});
|
|
304
299
|
|
|
305
300
|
return this;
|
|
@@ -309,11 +304,11 @@ export class LogRocketLogger implements Logger {
|
|
|
309
304
|
* Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
|
|
310
305
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
311
306
|
*/
|
|
312
|
-
debug(log?: string
|
|
307
|
+
debug(log?: string) {
|
|
313
308
|
if (log) {
|
|
314
309
|
this.#segments.push({
|
|
315
|
-
|
|
316
|
-
|
|
310
|
+
type: "text",
|
|
311
|
+
value: log
|
|
317
312
|
});
|
|
318
313
|
}
|
|
319
314
|
|
|
@@ -324,11 +319,11 @@ export class LogRocketLogger implements Logger {
|
|
|
324
319
|
* Write an information log. The log will be processed only if the logger LogLevel is >= information.
|
|
325
320
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
326
321
|
*/
|
|
327
|
-
information(log?: string
|
|
322
|
+
information(log?: string) {
|
|
328
323
|
if (log) {
|
|
329
324
|
this.#segments.push({
|
|
330
|
-
|
|
331
|
-
|
|
325
|
+
type: "text",
|
|
326
|
+
value: log
|
|
332
327
|
});
|
|
333
328
|
}
|
|
334
329
|
|
|
@@ -339,11 +334,11 @@ export class LogRocketLogger implements Logger {
|
|
|
339
334
|
* Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
|
|
340
335
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
341
336
|
*/
|
|
342
|
-
warning(log?: string
|
|
337
|
+
warning(log?: string) {
|
|
343
338
|
if (log) {
|
|
344
339
|
this.#segments.push({
|
|
345
|
-
|
|
346
|
-
|
|
340
|
+
type: "text",
|
|
341
|
+
value: log
|
|
347
342
|
});
|
|
348
343
|
}
|
|
349
344
|
|
|
@@ -354,11 +349,11 @@ export class LogRocketLogger implements Logger {
|
|
|
354
349
|
* Write an error log. The log will be processed only if the logger LogLevel is >= error.
|
|
355
350
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
356
351
|
*/
|
|
357
|
-
error(log?: string
|
|
352
|
+
error(log?: string) {
|
|
358
353
|
if (log) {
|
|
359
354
|
this.#segments.push({
|
|
360
|
-
|
|
361
|
-
|
|
355
|
+
type: "text",
|
|
356
|
+
value: log
|
|
362
357
|
});
|
|
363
358
|
}
|
|
364
359
|
|
|
@@ -369,11 +364,11 @@ export class LogRocketLogger implements Logger {
|
|
|
369
364
|
* Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
|
|
370
365
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
371
366
|
*/
|
|
372
|
-
critical(log?: string
|
|
367
|
+
critical(log?: string) {
|
|
373
368
|
if (log) {
|
|
374
369
|
this.#segments.push({
|
|
375
|
-
|
|
376
|
-
|
|
370
|
+
type: "text",
|
|
371
|
+
value: log
|
|
377
372
|
});
|
|
378
373
|
}
|
|
379
374
|
|
|
@@ -173,5 +173,5 @@ export function registerLogRocketInstrumentation(appId: string, options: Registe
|
|
|
173
173
|
// Let the other telemetry libraries know that LogRocket instrumentation is ready.
|
|
174
174
|
bootstrappingStore.dispatch({ type: "logrocket-ready" });
|
|
175
175
|
|
|
176
|
-
logger.
|
|
176
|
+
logger.information("[logrocket] LogRocket instrumentation is registered.");
|
|
177
177
|
}
|