@crimson-education/browser-logger 5.0.1-beta.2 → 5.0.1-beta.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/README.md +63 -85
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +46 -22
- package/lib/index.js.map +1 -1
- package/lib/logger/consoleTransport.d.ts +1 -1
- package/lib/logger/consoleTransport.d.ts.map +1 -1
- package/lib/logger/consoleTransport.js +22 -16
- package/lib/logger/consoleTransport.js.map +1 -1
- package/lib/logger/datadogTransport.d.ts +1 -1
- package/lib/logger/datadogTransport.d.ts.map +1 -1
- package/lib/logger/datadogTransport.js +8 -4
- package/lib/logger/datadogTransport.js.map +1 -1
- package/lib/logger/index.js +49 -29
- package/lib/logger/index.js.map +1 -1
- package/lib/logger/index.test.js +18 -16
- package/lib/logger/index.test.js.map +1 -1
- package/lib/logger/utils.js +9 -4
- package/lib/logger/utils.js.map +1 -1
- package/lib/reporters/amplifyReporter.d.ts +4 -4
- package/lib/reporters/amplifyReporter.d.ts.map +1 -1
- package/lib/reporters/amplifyReporter.js +133 -230
- package/lib/reporters/amplifyReporter.js.map +1 -1
- package/lib/reporters/amplifyReporter.test.js +12 -9
- package/lib/reporters/amplifyReporter.test.js.map +1 -1
- package/lib/reporters/datadogReporter.d.ts +1 -13
- package/lib/reporters/datadogReporter.d.ts.map +1 -1
- package/lib/reporters/datadogReporter.js +49 -122
- package/lib/reporters/datadogReporter.js.map +1 -1
- package/lib/reporters/gtmReporter.d.ts +1 -1
- package/lib/reporters/gtmReporter.d.ts.map +1 -1
- package/lib/reporters/gtmReporter.js +5 -1
- package/lib/reporters/gtmReporter.js.map +1 -1
- package/lib/reporters/index.js +71 -46
- package/lib/reporters/index.js.map +1 -1
- package/lib/reporters/logReporter.js +34 -24
- package/lib/reporters/logReporter.js.map +1 -1
- package/lib/reporters/posthogReporter.d.ts +51 -0
- package/lib/reporters/posthogReporter.d.ts.map +1 -0
- package/lib/reporters/posthogReporter.js +254 -0
- package/lib/reporters/posthogReporter.js.map +1 -0
- package/lib/reporters/posthogReporter.test.d.ts +2 -0
- package/lib/reporters/posthogReporter.test.d.ts.map +1 -0
- package/lib/reporters/posthogReporter.test.js +197 -0
- package/lib/reporters/posthogReporter.test.js.map +1 -0
- package/lib/types/index.js +18 -2
- package/lib/types/index.js.map +1 -1
- package/lib/types/logger.d.ts +3 -3
- package/lib/types/logger.d.ts.map +1 -1
- package/lib/types/logger.js +5 -2
- package/lib/types/logger.js.map +1 -1
- package/lib/types/reporter.d.ts +14 -6
- package/lib/types/reporter.d.ts.map +1 -1
- package/lib/types/reporter.js +2 -1
- package/lib/utils.js +5 -1
- package/lib/utils.js.map +1 -1
- package/lib/utils.test.js +4 -2
- package/lib/utils.test.js.map +1 -1
- package/package.json +17 -15
- package/src/index.ts +6 -0
- package/src/reporters/amplifyReporter.ts +140 -264
- package/src/reporters/datadogReporter.ts +22 -133
- package/src/reporters/posthogReporter.test.ts +244 -0
- package/src/reporters/posthogReporter.ts +374 -0
- package/src/types/reporter.ts +9 -0
package/README.md
CHANGED
|
@@ -6,11 +6,6 @@ This library contains a number of reporters that is will send analytics to.
|
|
|
6
6
|
|
|
7
7
|
These must be enabled by calling `Logger.init()`, as seen below.
|
|
8
8
|
|
|
9
|
-
> **Note**: This library has been upgraded to support Node.js 22. Some features have been removed or modified during the upgrade process. See the [Upgrade Notes](#upgrade-notes) section for details.
|
|
10
|
-
|
|
11
|
-
**!!IMPORTANT NOTICE: for the legacy lib of Datadog V4.X and others, please see the main branch, this is the one upgraded.**
|
|
12
|
-
|
|
13
|
-
|
|
14
9
|
## Install
|
|
15
10
|
|
|
16
11
|
```bash
|
|
@@ -33,10 +28,11 @@ import { config } from '../configuration';
|
|
|
33
28
|
|
|
34
29
|
Logger.init({
|
|
35
30
|
service: 'test-project',
|
|
31
|
+
application: 'crimson-app',
|
|
36
32
|
environment: config.environment,
|
|
37
33
|
version: config.version,
|
|
38
34
|
defaultMetadata: {
|
|
39
|
-
|
|
35
|
+
domain: window.location.hostname,
|
|
40
36
|
},
|
|
41
37
|
|
|
42
38
|
reporters: {
|
|
@@ -58,8 +54,16 @@ Logger.init({
|
|
|
58
54
|
logTransport: {
|
|
59
55
|
level: Logger.LogLevel.Info,
|
|
60
56
|
},
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
trackInteractions: true,
|
|
58
|
+
trackFrustrations: true,
|
|
59
|
+
allowedTracingOrigins: ['https://my.api.domain']
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
posthog: {
|
|
63
|
+
apiKey: config.posthogApiKey,
|
|
64
|
+
apiHost: config.posthogApiHost,
|
|
65
|
+
capturePageview: 'history_change',
|
|
66
|
+
replaySampleRate: 0,
|
|
63
67
|
},
|
|
64
68
|
|
|
65
69
|
amplify: {
|
|
@@ -70,8 +74,8 @@ Logger.init({
|
|
|
70
74
|
autoTrackEvents: true,
|
|
71
75
|
autoTrackPageViews: true,
|
|
72
76
|
autoTrackSessions: true,
|
|
73
|
-
}
|
|
74
|
-
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
75
79
|
});
|
|
76
80
|
|
|
77
81
|
Logger.setUser({
|
|
@@ -108,6 +112,7 @@ Global metadata about the service will be added for transport usage after callin
|
|
|
108
112
|
|
|
109
113
|
You can add more Global Metadata at any time by calling `addMetadata()`.
|
|
110
114
|
|
|
115
|
+
|
|
111
116
|
```ts
|
|
112
117
|
export const logger = Logger.createLogger();
|
|
113
118
|
|
|
@@ -136,7 +141,7 @@ E.g. On calls
|
|
|
136
141
|
Logger.trackEvent({
|
|
137
142
|
message: 'my-event',
|
|
138
143
|
toReporters: ['log', 'datadog'],
|
|
139
|
-
excludeReporters: ['datadog']
|
|
144
|
+
excludeReporters: ['datadog']
|
|
140
145
|
});
|
|
141
146
|
```
|
|
142
147
|
|
|
@@ -168,9 +173,13 @@ You can use `.` to traverse metadata.
|
|
|
168
173
|
Logger.init({
|
|
169
174
|
reporters: {
|
|
170
175
|
log: {
|
|
171
|
-
ignoreMetadataPatterns: [
|
|
172
|
-
|
|
173
|
-
|
|
176
|
+
ignoreMetadataPatterns: [
|
|
177
|
+
'internalError',
|
|
178
|
+
'user.email',
|
|
179
|
+
/error\.stack.*/g
|
|
180
|
+
]
|
|
181
|
+
}
|
|
182
|
+
}
|
|
174
183
|
});
|
|
175
184
|
```
|
|
176
185
|
|
|
@@ -219,9 +228,9 @@ Logger.init({
|
|
|
219
228
|
endpoints: {
|
|
220
229
|
recordSession: false,
|
|
221
230
|
recordSessionStop: false,
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
225
234
|
});
|
|
226
235
|
```
|
|
227
236
|
|
|
@@ -251,10 +260,10 @@ Logger.init({
|
|
|
251
260
|
logTransport: {
|
|
252
261
|
level: Logger.LogLevel.Info,
|
|
253
262
|
},
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
}
|
|
263
|
+
trackInteractions: true,
|
|
264
|
+
allowedTracingOrigins: ['https://my.api.domain']
|
|
265
|
+
}
|
|
266
|
+
}
|
|
258
267
|
});
|
|
259
268
|
```
|
|
260
269
|
|
|
@@ -262,6 +271,31 @@ Check out the [`DatadogReporterConfig`](https://github.com/crimson-education/bro
|
|
|
262
271
|
|
|
263
272
|
This automatically adds a Datadog Log Transport that transmits Log data to Datadog, this can be customized in `DatadogReporterConfig` with `logTransport`, or disabled by setting `logTransport` to `false`.
|
|
264
273
|
|
|
274
|
+
#### PostHog
|
|
275
|
+
|
|
276
|
+
To configure PostHog, this requires at least `apiKey` and `apiHost`.
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
import { config } from '../configuration';
|
|
280
|
+
import * as Logger from '@crimson-education/browser-logger';
|
|
281
|
+
|
|
282
|
+
Logger.init({
|
|
283
|
+
reporters: {
|
|
284
|
+
posthog: {
|
|
285
|
+
apiKey: config.posthogApiKey,
|
|
286
|
+
apiHost: config.posthogApiHost,
|
|
287
|
+
capturePageview: 'history_change',
|
|
288
|
+
replaySampleRate: 0,
|
|
289
|
+
trackViewsManually: false,
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
`replaySampleRate` is provided as a compatibility alias for existing Datadog-style config. Values less than or equal to `0` disable session recording at startup, while `Logger.recordSession()` can still enable replay later for allowlisted users.
|
|
296
|
+
|
|
297
|
+
When multiple repos write into the same PostHog project, prefer setting `application` at `Logger.init(...)`. This ensures a stable product-level dimension is present on all events independently of each app's `service` name.
|
|
298
|
+
|
|
265
299
|
#### Amplify/Pinpoint
|
|
266
300
|
|
|
267
301
|
To configure Amplify, this requires at least `region`, `identityPoolId` and `analyticsAppId`.
|
|
@@ -271,7 +305,6 @@ To configure Amplify, this requires at least `region`, `identityPoolId` and `ana
|
|
|
271
305
|
> You will need to set identityPoolId in your Auth.configure function yourself, otherwise Pinpoint won't work.
|
|
272
306
|
|
|
273
307
|
Auto `Auth.configure`:
|
|
274
|
-
|
|
275
308
|
```ts
|
|
276
309
|
import { config } from '../configuration';
|
|
277
310
|
import * as Logger from '@crimson-education/browser-logger';
|
|
@@ -286,13 +319,12 @@ Logger.init({
|
|
|
286
319
|
autoTrackEvents: true,
|
|
287
320
|
autoTrackPageViews: true,
|
|
288
321
|
autoTrackSessions: true,
|
|
289
|
-
}
|
|
290
|
-
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
291
324
|
});
|
|
292
325
|
```
|
|
293
326
|
|
|
294
327
|
Manual `Auth.configure`:
|
|
295
|
-
|
|
296
328
|
```ts
|
|
297
329
|
import { Auth } from '@aws-amplify/auth';
|
|
298
330
|
import { config } from '../configuration';
|
|
@@ -315,8 +347,8 @@ Logger.init({
|
|
|
315
347
|
autoTrackEvents: true,
|
|
316
348
|
autoTrackPageViews: true,
|
|
317
349
|
autoTrackSessions: true,
|
|
318
|
-
}
|
|
319
|
-
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
320
352
|
});
|
|
321
353
|
```
|
|
322
354
|
|
|
@@ -335,16 +367,16 @@ import * as Logger from '@crimson-education/browser-logger';
|
|
|
335
367
|
Logger.init({
|
|
336
368
|
reporters: {
|
|
337
369
|
gtm: true,
|
|
338
|
-
}
|
|
370
|
+
}
|
|
339
371
|
});
|
|
340
372
|
|
|
341
373
|
// With configuration
|
|
342
374
|
Logger.init({
|
|
343
375
|
reporters: {
|
|
344
376
|
gtm: {
|
|
345
|
-
ignoreBreadcrumbCategories: ['fetch']
|
|
346
|
-
}
|
|
347
|
-
}
|
|
377
|
+
ignoreBreadcrumbCategories: ['fetch']
|
|
378
|
+
}
|
|
379
|
+
}
|
|
348
380
|
});
|
|
349
381
|
```
|
|
350
382
|
|
|
@@ -365,57 +397,3 @@ This is valuable if the content is dynamic, e.g. a user's name:
|
|
|
365
397
|
```
|
|
366
398
|
|
|
367
399
|
This will result in the session saying something like, **clicked on "MyUserName"**.
|
|
368
|
-
|
|
369
|
-
## Upgrade Notes
|
|
370
|
-
|
|
371
|
-
### Node.js 22 Upgrade Changes
|
|
372
|
-
|
|
373
|
-
This library has been upgraded to support Node.js 22. The following changes were made during the upgrade process:
|
|
374
|
-
|
|
375
|
-
#### Datadog Reporter Changes
|
|
376
|
-
|
|
377
|
-
- `trackInteractions` → `trackUserInteractions` (renamed for clarity)
|
|
378
|
-
- `trackFrustrations` → Removed (replaced with custom frustration detection implementation)
|
|
379
|
-
- `allowedTracingOrigins` → `allowedTrackingOrigins` (corrected spelling)
|
|
380
|
-
|
|
381
|
-
#### Amplify Reporter Changes
|
|
382
|
-
|
|
383
|
-
- Updated to use Amplify Gen2 APIs (`@aws-amplify/analytics@7.x`, `@aws-amplify/auth@6.x`)
|
|
384
|
-
- Enhanced auto-tracking capabilities for page views, user interactions, and session state
|
|
385
|
-
- Improved error handling and configuration validation
|
|
386
|
-
|
|
387
|
-
#### Removed Features
|
|
388
|
-
|
|
389
|
-
The following features were removed during the upgrade and have been replaced with custom implementations:
|
|
390
|
-
|
|
391
|
-
1. **Automatic Frustration Detection**: Replaced with custom implementation that detects:
|
|
392
|
-
- Rapid clicks (potential frustration)
|
|
393
|
-
- Form validation errors
|
|
394
|
-
- 404 and network errors
|
|
395
|
-
|
|
396
|
-
2. **Enhanced Auto-tracking**: Replaced with custom implementation that tracks:
|
|
397
|
-
- Page views and route changes
|
|
398
|
-
- User interactions with analytics-enabled elements
|
|
399
|
-
- Session state changes (active/inactive)
|
|
400
|
-
|
|
401
|
-
#### Configuration Updates Required
|
|
402
|
-
|
|
403
|
-
If you're upgrading from a previous version, update your configuration:
|
|
404
|
-
|
|
405
|
-
```ts
|
|
406
|
-
// Old configuration
|
|
407
|
-
datadog: {
|
|
408
|
-
trackInteractions: true,
|
|
409
|
-
trackFrustrations: true,
|
|
410
|
-
allowedTracingOrigins: ['https://my.api.domain']
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// New configuration
|
|
414
|
-
datadog: {
|
|
415
|
-
trackUserInteractions: true,
|
|
416
|
-
allowedTrackingOrigins: ['https://my.api.domain']
|
|
417
|
-
// trackFrustrations is now handled automatically
|
|
418
|
-
}
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
For more details about the upgrade process and custom implementations, see the individual reporter configuration files.
|
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ReporterConfigurations, ServiceInfo } from './types';
|
|
|
2
2
|
export * from './types';
|
|
3
3
|
export * from './reporters';
|
|
4
4
|
export * from './logger';
|
|
5
|
-
export type LoggerConfig = ServiceInfo & {
|
|
5
|
+
export declare type LoggerConfig = ServiceInfo & {
|
|
6
6
|
reporters?: ReporterConfigurations;
|
|
7
7
|
};
|
|
8
8
|
/**
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAS9D,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AAEzB,oBAAY,YAAY,GAAG,WAAW,GAAG;IAAE,SAAS,CAAC,EAAE,sBAAsB,CAAA;CAAE,CAAC;AAIhF;;;GAGG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,YAAY,QAgDxC"}
|
package/lib/index.js
CHANGED
|
@@ -1,51 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.init = void 0;
|
|
18
|
+
const logger_1 = require("./logger");
|
|
19
|
+
const reporters_1 = require("./reporters");
|
|
20
|
+
const gtmReporter_1 = require("./reporters/gtmReporter");
|
|
21
|
+
const amplifyReporter_1 = require("./reporters/amplifyReporter");
|
|
22
|
+
const datadogReporter_1 = require("./reporters/datadogReporter");
|
|
23
|
+
const logReporter_1 = require("./reporters/logReporter");
|
|
24
|
+
const posthogReporter_1 = require("./reporters/posthogReporter");
|
|
25
|
+
__exportStar(require("./types"), exports);
|
|
26
|
+
__exportStar(require("./reporters"), exports);
|
|
27
|
+
__exportStar(require("./logger"), exports);
|
|
10
28
|
let initialized = false;
|
|
11
29
|
/**
|
|
12
30
|
* Initializes the logger and reporters.
|
|
13
31
|
* @param config Reporter config options.
|
|
14
32
|
*/
|
|
15
|
-
|
|
33
|
+
function init(config) {
|
|
34
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
16
35
|
// Some reporters don't like being initialized multiple times.
|
|
17
36
|
if (initialized) {
|
|
18
37
|
return;
|
|
19
38
|
}
|
|
20
39
|
initialized = true;
|
|
21
40
|
// Log Reporter enabled by default.
|
|
22
|
-
const logReporterConfig = config.reporters
|
|
41
|
+
const logReporterConfig = (_b = (_a = config.reporters) === null || _a === void 0 ? void 0 : _a.log) !== null && _b !== void 0 ? _b : true;
|
|
23
42
|
if (logReporterConfig !== false) {
|
|
24
|
-
reporters['log'] = logReporter(config, typeof logReporterConfig === 'boolean' ? {} : logReporterConfig);
|
|
43
|
+
reporters_1.reporters['log'] = (0, logReporter_1.logReporter)(config, typeof logReporterConfig === 'boolean' ? {} : logReporterConfig);
|
|
44
|
+
}
|
|
45
|
+
if ((_c = config.reporters) === null || _c === void 0 ? void 0 : _c.datadog) {
|
|
46
|
+
reporters_1.reporters['datadog'] = (0, datadogReporter_1.datadogReporter)(config, config.reporters.datadog);
|
|
25
47
|
}
|
|
26
|
-
if (config.reporters
|
|
27
|
-
reporters['
|
|
48
|
+
if ((_d = config.reporters) === null || _d === void 0 ? void 0 : _d.amplify) {
|
|
49
|
+
reporters_1.reporters['amplify'] = (0, amplifyReporter_1.amplifyReporter)(config, config.reporters.amplify);
|
|
28
50
|
}
|
|
29
|
-
if (config.reporters
|
|
30
|
-
reporters['
|
|
51
|
+
if ((_e = config.reporters) === null || _e === void 0 ? void 0 : _e.posthog) {
|
|
52
|
+
reporters_1.reporters['posthog'] = (0, posthogReporter_1.posthogReporter)(config, config.reporters.posthog);
|
|
31
53
|
}
|
|
32
|
-
if (config.reporters
|
|
33
|
-
reporters['gtm'] = gtmReporter(config, typeof config.reporters.gtm === 'boolean' ? {} : config.reporters.gtm);
|
|
54
|
+
if ((_f = config.reporters) === null || _f === void 0 ? void 0 : _f.gtm) {
|
|
55
|
+
reporters_1.reporters['gtm'] = (0, gtmReporter_1.gtmReporter)(config, typeof config.reporters.gtm === 'boolean' ? {} : config.reporters.gtm);
|
|
34
56
|
}
|
|
35
57
|
const defaultMetadata = {
|
|
36
|
-
...(config.defaultMetadata
|
|
58
|
+
...((_g = config.defaultMetadata) !== null && _g !== void 0 ? _g : {}),
|
|
59
|
+
application: (_h = config.application) !== null && _h !== void 0 ? _h : (_j = config.defaultMetadata) === null || _j === void 0 ? void 0 : _j.application,
|
|
37
60
|
service: config.service,
|
|
38
61
|
environment: config.environment,
|
|
39
62
|
version: config.version,
|
|
40
63
|
};
|
|
41
64
|
// Sets the global log level, if specified.
|
|
42
65
|
if (config.logLevel) {
|
|
43
|
-
setLogLevel(config.logLevel);
|
|
66
|
+
(0, logger_1.setLogLevel)(config.logLevel);
|
|
44
67
|
}
|
|
45
68
|
// Sets the global event level, if specified.
|
|
46
69
|
if (config.eventLevel) {
|
|
47
|
-
setEventLevel(config.eventLevel);
|
|
70
|
+
(0, reporters_1.setEventLevel)(config.eventLevel);
|
|
48
71
|
}
|
|
49
|
-
addMetadata(defaultMetadata);
|
|
72
|
+
(0, reporters_1.addMetadata)(defaultMetadata);
|
|
50
73
|
}
|
|
74
|
+
exports.init = init;
|
|
51
75
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,qCAAuC;AACvC,2CAAoE;AACpE,yDAAsD;AACtD,iEAA8D;AAC9D,iEAA8D;AAC9D,yDAAsD;AACtD,iEAA8D;AAE9D,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AAIzB,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB;;;GAGG;AACH,SAAgB,IAAI,CAAC,MAAoB;;IACvC,8DAA8D;IAC9D,IAAI,WAAW,EAAE;QACf,OAAO;KACR;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,mCAAmC;IACnC,MAAM,iBAAiB,GAAG,MAAA,MAAA,MAAM,CAAC,SAAS,0CAAE,GAAG,mCAAI,IAAI,CAAC;IACxD,IAAI,iBAAiB,KAAK,KAAK,EAAE;QAC/B,qBAAS,CAAC,KAAK,CAAC,GAAG,IAAA,yBAAW,EAAC,MAAM,EAAE,OAAO,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;KACzG;IAED,IAAI,MAAA,MAAM,CAAC,SAAS,0CAAE,OAAO,EAAE;QAC7B,qBAAS,CAAC,SAAS,CAAC,GAAG,IAAA,iCAAe,EAAC,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;KAC1E;IAED,IAAI,MAAA,MAAM,CAAC,SAAS,0CAAE,OAAO,EAAE;QAC7B,qBAAS,CAAC,SAAS,CAAC,GAAG,IAAA,iCAAe,EAAC,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;KAC1E;IAED,IAAI,MAAA,MAAM,CAAC,SAAS,0CAAE,OAAO,EAAE;QAC7B,qBAAS,CAAC,SAAS,CAAC,GAAG,IAAA,iCAAe,EAAC,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;KAC1E;IAED,IAAI,MAAA,MAAM,CAAC,SAAS,0CAAE,GAAG,EAAE;QACzB,qBAAS,CAAC,KAAK,CAAC,GAAG,IAAA,yBAAW,EAAC,MAAM,EAAE,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;KAC/G;IAED,MAAM,eAAe,GAAG;QACtB,GAAG,CAAC,MAAA,MAAM,CAAC,eAAe,mCAAI,EAAE,CAAC;QACjC,WAAW,EAAE,MAAA,MAAM,CAAC,WAAW,mCAAI,MAAA,MAAM,CAAC,eAAe,0CAAE,WAAW;QACtE,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;IAEF,2CAA2C;IAC3C,IAAI,MAAM,CAAC,QAAQ,EAAE;QACnB,IAAA,oBAAW,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;KAC9B;IAED,6CAA6C;IAC7C,IAAI,MAAM,CAAC,UAAU,EAAE;QACrB,IAAA,yBAAa,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KAClC;IAED,IAAA,uBAAW,EAAC,eAAe,CAAC,CAAC;AAC/B,CAAC;AAhDD,oBAgDC"}
|
|
@@ -14,7 +14,7 @@ declare const colors: {
|
|
|
14
14
|
red: number[];
|
|
15
15
|
yellow: number[];
|
|
16
16
|
};
|
|
17
|
-
export type ColorizeColor = keyof typeof colors;
|
|
17
|
+
export declare type ColorizeColor = keyof typeof colors;
|
|
18
18
|
/**
|
|
19
19
|
* Colorize a string with a specified color.
|
|
20
20
|
* @param str String to colorize
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleTransport.d.ts","sourceRoot":"","sources":["../../src/logger/consoleTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAG3E,QAAA,MAAM,MAAM;;;;;;;;;;;;;;CAcX,CAAC;AACF,
|
|
1
|
+
{"version":3,"file":"consoleTransport.d.ts","sourceRoot":"","sources":["../../src/logger/consoleTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAG3E,QAAA,MAAM,MAAM;;;;;;;;;;;;;;CAcX,CAAC;AACF,oBAAY,aAAa,GAAG,MAAM,OAAO,MAAM,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,UAGzD;AAWD,MAAM,WAAW,yBAA0B,SAAQ,sBAAsB;IACvE;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,QAAQ,CAAC;IAEnC;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,aAAa,CAAC;CACvD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,yBAA8B,6CAgDtE"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.consoleTransport = exports.colorize = void 0;
|
|
1
4
|
// from browser-util-inspect
|
|
2
5
|
const colors = {
|
|
3
6
|
bold: [1, 22],
|
|
@@ -20,37 +23,39 @@ const colors = {
|
|
|
20
23
|
* @param color Color to colorize the string with
|
|
21
24
|
* @returns Colorized string
|
|
22
25
|
*/
|
|
23
|
-
|
|
26
|
+
function colorize(str, color) {
|
|
24
27
|
const colorData = colors[color];
|
|
25
28
|
return '\u001b[' + colorData[0] + 'm' + str + '\u001b[' + colorData[1] + 'm';
|
|
26
29
|
}
|
|
30
|
+
exports.colorize = colorize;
|
|
27
31
|
/**
|
|
28
32
|
* Gets a stack trace from metadata or accompanying error.
|
|
29
33
|
*/
|
|
30
34
|
function getStackTrace(data) {
|
|
31
|
-
|
|
35
|
+
var _a;
|
|
36
|
+
const stack = ((_a = data === null || data === void 0 ? void 0 : data.err) === null || _a === void 0 ? void 0 : _a.stack) || data.stack || data['error.stack'];
|
|
32
37
|
delete data.stack;
|
|
33
|
-
return stack
|
|
38
|
+
return stack !== null && stack !== void 0 ? stack : '';
|
|
34
39
|
}
|
|
35
|
-
|
|
40
|
+
function consoleTransport(config = {}) {
|
|
41
|
+
var _a, _b, _c;
|
|
36
42
|
// Default ignore patterns
|
|
37
|
-
config.ignoreMetadataPatterns
|
|
43
|
+
(_a = config.ignoreMetadataPatterns) !== null && _a !== void 0 ? _a : (config.ignoreMetadataPatterns = ['application', 'service', 'environment', 'version']);
|
|
38
44
|
// Get the colorizer function, or a no-op if not enabled.
|
|
39
|
-
const colorizer = config.colorize !== false ? config.colorize
|
|
45
|
+
const colorizer = config.colorize !== false ? (_b = config.colorize) !== null && _b !== void 0 ? _b : colorize : (str) => str;
|
|
40
46
|
// Get the log level color function, or use the default colors.
|
|
41
|
-
const getLogLevelColor = config.getLogLevelColor
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
47
|
+
const getLogLevelColor = (_c = config.getLogLevelColor) !== null && _c !== void 0 ? _c : ((level) => {
|
|
48
|
+
return {
|
|
49
|
+
error: 'red',
|
|
50
|
+
warn: 'yellow',
|
|
51
|
+
info: 'cyan',
|
|
52
|
+
debug: 'green',
|
|
53
|
+
}[level];
|
|
54
|
+
});
|
|
50
55
|
const transport = {
|
|
51
56
|
...config,
|
|
52
57
|
log: ({ level, message, timestamp, splat, ...metadata }) => {
|
|
53
|
-
let splatData = splat
|
|
58
|
+
let splatData = splat !== null && splat !== void 0 ? splat : [];
|
|
54
59
|
const stackTrace = getStackTrace(metadata);
|
|
55
60
|
const strippedInfo = { ...metadata };
|
|
56
61
|
delete strippedInfo['level'];
|
|
@@ -72,4 +77,5 @@ export function consoleTransport(config = {}) {
|
|
|
72
77
|
};
|
|
73
78
|
return transport;
|
|
74
79
|
}
|
|
80
|
+
exports.consoleTransport = consoleTransport;
|
|
75
81
|
//# sourceMappingURL=consoleTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleTransport.js","sourceRoot":"","sources":["../../src/logger/consoleTransport.ts"],"names":[],"mappings":"AAEA,4BAA4B;AAC5B,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;IACb,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;IACf,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;IAClB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;IAChB,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACf,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACd,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACf,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACd,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACd,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACf,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACjB,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IACb,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;CACjB,CAAC;AAGF;;;;;GAKG;AACH,
|
|
1
|
+
{"version":3,"file":"consoleTransport.js","sourceRoot":"","sources":["../../src/logger/consoleTransport.ts"],"names":[],"mappings":";;;AAEA,4BAA4B;AAC5B,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,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E;gBACxC,SAAS,GAAG,CAAC,YAAY,EAAE,GAAG,SAAS,CAAC,CAAC;aAC1C;YAED,IAAI,OAAO,EAAE;gBACX,SAAS,GAAG,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,CAAC;aACrC;YAED,IAAI,UAAU,EAAE;gBACd,SAAS,GAAG,CAAC,GAAG,SAAS,EAAE,UAAU,CAAC,CAAC;aACxC;YAED,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,SAAS,CAAC,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,GAAG,SAAS,CAAC,CAAC;QACjH,CAAC;KACF,CAAC;IACF,OAAO,SAAS,CAAC;AACnB,CAAC;AAhDD,4CAgDC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ILogTransport, LogTransportConfigBase } from '../types';
|
|
2
|
-
export type DatadogLogTransportConfig = LogTransportConfigBase;
|
|
2
|
+
export declare type DatadogLogTransportConfig = LogTransportConfigBase;
|
|
3
3
|
/**
|
|
4
4
|
* A transport that sends logs to Datadog.
|
|
5
5
|
* Note: This requires the datadog reporter to be initialized for it to work.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datadogTransport.d.ts","sourceRoot":"","sources":["../../src/logger/datadogTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAIjE,
|
|
1
|
+
{"version":3,"file":"datadogTransport.d.ts","sourceRoot":"","sources":["../../src/logger/datadogTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAIjE,oBAAY,yBAAyB,GAAG,sBAAsB,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,yBAA8B,iBAStE"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.datadogTransport = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const browser_logs_1 = require("@datadog/browser-logs");
|
|
3
6
|
/**
|
|
4
7
|
* A transport that sends logs to Datadog.
|
|
5
8
|
* Note: This requires the datadog reporter to be initialized for it to work.
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
function datadogTransport(config = {}) {
|
|
8
11
|
const transport = {
|
|
9
12
|
...config,
|
|
10
13
|
log: ({ level, message, ...metadata }) => {
|
|
11
14
|
// Datadog expects a string message.
|
|
12
|
-
datadogLogs.logger[level](getLogMessage(message), metadata);
|
|
15
|
+
browser_logs_1.datadogLogs.logger[level]((0, utils_1.getLogMessage)(message), metadata);
|
|
13
16
|
},
|
|
14
17
|
};
|
|
15
18
|
return transport;
|
|
16
19
|
}
|
|
20
|
+
exports.datadogTransport = datadogTransport;
|
|
17
21
|
//# sourceMappingURL=datadogTransport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datadogTransport.js","sourceRoot":"","sources":["../../src/logger/datadogTransport.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"datadogTransport.js","sourceRoot":"","sources":["../../src/logger/datadogTransport.ts"],"names":[],"mappings":";;;AACA,mCAAwC;AACxC,wDAAoD;AAIpD;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,SAAoC,EAAE;IACrE,MAAM,SAAS,GAAkB;QAC/B,GAAG,MAAM;QACT,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,EAAE,EAAE;YACvC,oCAAoC;YACpC,0BAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAA,qBAAa,EAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC9D,CAAC;KACF,CAAC;IACF,OAAO,SAAS,CAAC;AACnB,CAAC;AATD,4CASC"}
|