@crimson-education/browser-logger 3.0.1-pinpoint-middleware.0 → 3.0.2
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/lib/index.d.ts +12 -12
- package/lib/index.js +69 -69
- package/lib/logger/consoleTransport.d.ts +36 -36
- package/lib/logger/consoleTransport.js +80 -80
- package/lib/logger/datadogTransport.d.ts +7 -7
- package/lib/logger/datadogTransport.js +20 -20
- package/lib/logger/index.d.ts +15 -15
- package/lib/logger/index.js +147 -147
- package/lib/logger/index.test.d.ts +1 -1
- package/lib/logger/index.test.js +59 -59
- package/lib/logger/utils.d.ts +14 -14
- package/lib/logger/utils.js +31 -31
- package/lib/reporters/amplifyReporter.d.ts +83 -83
- package/lib/reporters/amplifyReporter.d.ts.map +1 -1
- package/lib/reporters/amplifyReporter.js +162 -162
- package/lib/reporters/amplifyReporter.js.map +1 -1
- package/lib/reporters/amplifyReporter.test.d.ts +1 -1
- package/lib/reporters/amplifyReporter.test.js +50 -50
- package/lib/reporters/datadogReporter.d.ts +85 -76
- package/lib/reporters/datadogReporter.d.ts.map +1 -1
- package/lib/reporters/datadogReporter.js +124 -122
- package/lib/reporters/datadogReporter.js.map +1 -1
- package/lib/reporters/gtmReporter.d.ts +8 -8
- package/lib/reporters/gtmReporter.js +56 -56
- package/lib/reporters/index.d.ts +66 -66
- package/lib/reporters/index.js +212 -212
- package/lib/reporters/logReporter.d.ts +34 -34
- package/lib/reporters/logReporter.js +61 -61
- package/lib/types/index.d.ts +2 -2
- package/lib/types/index.js +18 -18
- package/lib/types/logger.d.ts +77 -77
- package/lib/types/logger.js +10 -10
- package/lib/types/reporter.d.ts +154 -154
- package/lib/types/reporter.js +2 -2
- package/lib/utils.d.ts +9 -9
- package/lib/utils.js +31 -31
- package/lib/utils.test.d.ts +1 -1
- package/lib/utils.test.js +31 -31
- package/package.json +1 -1
- package/src/reporters/amplifyReporter.ts +2 -2
- package/src/reporters/datadogReporter.ts +12 -2
package/lib/utils.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IReporter, Metadata } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Recursively filter reporter metadata.
|
|
4
|
-
* @param metadata Deep Metadata to filter.
|
|
5
|
-
* @param reporter Reporter with filter config.
|
|
6
|
-
* @param prefix Prefix for recusring nested metadata.
|
|
7
|
-
* @returns Filtered metadata.
|
|
8
|
-
*/
|
|
9
|
-
export declare function filterReporterMetadata<TMetadata extends Metadata | undefined>(metadata: TMetadata, reporter: Pick<IReporter, 'ignoreMetadataPatterns'>, prefix?: string): TMetadata;
|
|
1
|
+
import { IReporter, Metadata } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively filter reporter metadata.
|
|
4
|
+
* @param metadata Deep Metadata to filter.
|
|
5
|
+
* @param reporter Reporter with filter config.
|
|
6
|
+
* @param prefix Prefix for recusring nested metadata.
|
|
7
|
+
* @returns Filtered metadata.
|
|
8
|
+
*/
|
|
9
|
+
export declare function filterReporterMetadata<TMetadata extends Metadata | undefined>(metadata: TMetadata, reporter: Pick<IReporter, 'ignoreMetadataPatterns'>, prefix?: string): TMetadata;
|
|
10
10
|
//# sourceMappingURL=utils.d.ts.map
|
package/lib/utils.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.filterReporterMetadata = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Recursively filter reporter metadata.
|
|
6
|
-
* @param metadata Deep Metadata to filter.
|
|
7
|
-
* @param reporter Reporter with filter config.
|
|
8
|
-
* @param prefix Prefix for recusring nested metadata.
|
|
9
|
-
* @returns Filtered metadata.
|
|
10
|
-
*/
|
|
11
|
-
function filterReporterMetadata(metadata, reporter, prefix) {
|
|
12
|
-
const ignorePatterns = reporter.ignoreMetadataPatterns;
|
|
13
|
-
// No metadata, or no patterns.
|
|
14
|
-
if (metadata === undefined || !ignorePatterns) {
|
|
15
|
-
return metadata;
|
|
16
|
-
}
|
|
17
|
-
const entries = Object.entries(metadata);
|
|
18
|
-
return Object.fromEntries(entries
|
|
19
|
-
.filter(([key]) => {
|
|
20
|
-
const fullKey = prefix ? prefix + key : key;
|
|
21
|
-
return !ignorePatterns.some((pattern) => typeof pattern === 'string' ? pattern === fullKey : pattern.test(fullKey));
|
|
22
|
-
})
|
|
23
|
-
.map(([key, value]) => {
|
|
24
|
-
if (typeof value === 'object' && value !== null) {
|
|
25
|
-
const fullKey = prefix ? prefix + key : key;
|
|
26
|
-
return [key, filterReporterMetadata(value, reporter, `${fullKey}.`)];
|
|
27
|
-
}
|
|
28
|
-
return [key, value];
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
exports.filterReporterMetadata = filterReporterMetadata;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterReporterMetadata = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Recursively filter reporter metadata.
|
|
6
|
+
* @param metadata Deep Metadata to filter.
|
|
7
|
+
* @param reporter Reporter with filter config.
|
|
8
|
+
* @param prefix Prefix for recusring nested metadata.
|
|
9
|
+
* @returns Filtered metadata.
|
|
10
|
+
*/
|
|
11
|
+
function filterReporterMetadata(metadata, reporter, prefix) {
|
|
12
|
+
const ignorePatterns = reporter.ignoreMetadataPatterns;
|
|
13
|
+
// No metadata, or no patterns.
|
|
14
|
+
if (metadata === undefined || !ignorePatterns) {
|
|
15
|
+
return metadata;
|
|
16
|
+
}
|
|
17
|
+
const entries = Object.entries(metadata);
|
|
18
|
+
return Object.fromEntries(entries
|
|
19
|
+
.filter(([key]) => {
|
|
20
|
+
const fullKey = prefix ? prefix + key : key;
|
|
21
|
+
return !ignorePatterns.some((pattern) => typeof pattern === 'string' ? pattern === fullKey : pattern.test(fullKey));
|
|
22
|
+
})
|
|
23
|
+
.map(([key, value]) => {
|
|
24
|
+
if (typeof value === 'object' && value !== null) {
|
|
25
|
+
const fullKey = prefix ? prefix + key : key;
|
|
26
|
+
return [key, filterReporterMetadata(value, reporter, `${fullKey}.`)];
|
|
27
|
+
}
|
|
28
|
+
return [key, value];
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
exports.filterReporterMetadata = filterReporterMetadata;
|
|
32
32
|
//# sourceMappingURL=utils.js.map
|
package/lib/utils.test.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=utils.test.d.ts.map
|
package/lib/utils.test.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("./utils");
|
|
4
|
-
describe('utils', () => {
|
|
5
|
-
describe('filterReporterMetadata', () => {
|
|
6
|
-
it('should remove attributes which match the ignore patterns', () => {
|
|
7
|
-
const inputAttributeMap = {
|
|
8
|
-
includeme: '5',
|
|
9
|
-
excludeme: 'false',
|
|
10
|
-
differentProp: 'boo',
|
|
11
|
-
deep: {
|
|
12
|
-
includeme: '5',
|
|
13
|
-
excludeme: 'false',
|
|
14
|
-
deepExcludeStr: 'boo',
|
|
15
|
-
deepExcludeRegex: 'boo',
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
const filtered = (0, utils_1.filterReporterMetadata)(inputAttributeMap, {
|
|
19
|
-
ignoreMetadataPatterns: [/excludeme/g, /Prop/g, 'deep.deepExcludeStr', /deep\.deepExcludeRegex/g],
|
|
20
|
-
});
|
|
21
|
-
expect(filtered.includeme).toBeTruthy();
|
|
22
|
-
expect(filtered.excludeme).toBeFalsy();
|
|
23
|
-
expect(filtered.differentProp).toBeFalsy();
|
|
24
|
-
// deep
|
|
25
|
-
expect(filtered.deep.includeme).toBeTruthy();
|
|
26
|
-
expect(filtered.deep.excludeme).toBeFalsy();
|
|
27
|
-
expect(filtered.deep.deepExcludeStr).toBeFalsy();
|
|
28
|
-
expect(filtered.deep.deepExcludeRegex).toBeFalsy();
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("./utils");
|
|
4
|
+
describe('utils', () => {
|
|
5
|
+
describe('filterReporterMetadata', () => {
|
|
6
|
+
it('should remove attributes which match the ignore patterns', () => {
|
|
7
|
+
const inputAttributeMap = {
|
|
8
|
+
includeme: '5',
|
|
9
|
+
excludeme: 'false',
|
|
10
|
+
differentProp: 'boo',
|
|
11
|
+
deep: {
|
|
12
|
+
includeme: '5',
|
|
13
|
+
excludeme: 'false',
|
|
14
|
+
deepExcludeStr: 'boo',
|
|
15
|
+
deepExcludeRegex: 'boo',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const filtered = (0, utils_1.filterReporterMetadata)(inputAttributeMap, {
|
|
19
|
+
ignoreMetadataPatterns: [/excludeme/g, /Prop/g, 'deep.deepExcludeStr', /deep\.deepExcludeRegex/g],
|
|
20
|
+
});
|
|
21
|
+
expect(filtered.includeme).toBeTruthy();
|
|
22
|
+
expect(filtered.excludeme).toBeFalsy();
|
|
23
|
+
expect(filtered.differentProp).toBeFalsy();
|
|
24
|
+
// deep
|
|
25
|
+
expect(filtered.deep.includeme).toBeTruthy();
|
|
26
|
+
expect(filtered.deep.excludeme).toBeFalsy();
|
|
27
|
+
expect(filtered.deep.deepExcludeStr).toBeFalsy();
|
|
28
|
+
expect(filtered.deep.deepExcludeRegex).toBeFalsy();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
32
|
//# sourceMappingURL=utils.test.js.map
|
package/package.json
CHANGED
|
@@ -60,7 +60,7 @@ export interface AmplifyReporterConfig extends ReporterConfigBase {
|
|
|
60
60
|
* Optional function to run before autotracked analytics events are sent out.
|
|
61
61
|
* The returned metadata is attached to the event.
|
|
62
62
|
*/
|
|
63
|
-
beforeAutoTrack?(source: AmplifyAutoTrackSource): Metadata;
|
|
63
|
+
beforeAutoTrack?(source: AmplifyAutoTrackSource): Metadata | undefined;
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* The data tag prefix to use for attributing HTML elements. Defaults to data-analytics-
|
|
@@ -101,7 +101,7 @@ export function amplifyReporter(info: ServiceInfo, config: AmplifyReporterConfig
|
|
|
101
101
|
|
|
102
102
|
const wrapAutoTrackMiddleware = (source: AmplifyAutoTrackSource) => {
|
|
103
103
|
const { beforeAutoTrack } = config;
|
|
104
|
-
return typeof beforeAutoTrack === 'function' ? () => beforeAutoTrack(source) : undefined;
|
|
104
|
+
return typeof beforeAutoTrack === 'function' ? () => beforeAutoTrack(source) ?? {} : undefined;
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
const allMetadata = asAttributeMap({
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
ServiceInfo,
|
|
9
9
|
ReporterConfigBase,
|
|
10
10
|
} from '../types';
|
|
11
|
-
import { datadogLogs, HandlerType } from '@datadog/browser-logs';
|
|
12
|
-
import { datadogRum, DefaultPrivacyLevel } from '@datadog/browser-rum';
|
|
11
|
+
import { datadogLogs, HandlerType, LogsInitConfiguration } from '@datadog/browser-logs';
|
|
12
|
+
import { datadogRum, DefaultPrivacyLevel, RumInitConfiguration } from '@datadog/browser-rum';
|
|
13
13
|
import { logTransports } from '../logger';
|
|
14
14
|
import { DatadogLogTransportConfig, datadogTransport } from '../logger/datadogTransport';
|
|
15
15
|
|
|
@@ -72,12 +72,20 @@ export interface DatadogReporterConfig extends ReporterConfigBase {
|
|
|
72
72
|
* Defaults to `data-analytics-name` to coincide with analytics attributes used across reporters.
|
|
73
73
|
*/
|
|
74
74
|
actionNameAttribute?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Allows you to modify RUM events before they are sent to Datadog.
|
|
77
|
+
*/
|
|
78
|
+
beforeSend?: RumInitConfiguration['beforeSend'];
|
|
75
79
|
|
|
76
80
|
/**
|
|
77
81
|
* Toggles/configures the Datadog Log Transport.
|
|
78
82
|
* Defaults to true.
|
|
79
83
|
*/
|
|
80
84
|
logTransport?: boolean | DatadogLogTransportConfig;
|
|
85
|
+
/**
|
|
86
|
+
* Allows you to modify Log events before they are sent to Datadog (Can only be set at ).
|
|
87
|
+
*/
|
|
88
|
+
beforeLogsSend?: LogsInitConfiguration['beforeSend'];
|
|
81
89
|
|
|
82
90
|
/**
|
|
83
91
|
* By enabling Session Replay, you can automatically mask sensitive elements from being recorded through the RUM Browser SDK.
|
|
@@ -110,6 +118,7 @@ export function datadogReporter(info: ServiceInfo, config: DatadogReporterConfig
|
|
|
110
118
|
version: config.version ?? info.version,
|
|
111
119
|
|
|
112
120
|
sampleRate: config.sampleRate ?? 100,
|
|
121
|
+
beforeSend: config.beforeLogsSend,
|
|
113
122
|
|
|
114
123
|
useSecureSessionCookie: config.useSecureSessionCookie ?? !isLocalhost,
|
|
115
124
|
useCrossSiteSessionCookie: config.useCrossSiteSessionCookie ?? false,
|
|
@@ -145,6 +154,7 @@ export function datadogReporter(info: ServiceInfo, config: DatadogReporterConfig
|
|
|
145
154
|
trackFrustrations: config.trackFrustrations ?? false,
|
|
146
155
|
trackViewsManually: config.trackViewsManually ?? false,
|
|
147
156
|
actionNameAttribute: config.actionNameAttribute ?? 'data-analytics-name',
|
|
157
|
+
beforeSend: config.beforeSend,
|
|
148
158
|
|
|
149
159
|
defaultPrivacyLevel: config.defaultPrivacyLevel ?? 'mask-user-input',
|
|
150
160
|
allowedTracingOrigins: config.allowedTracingOrigins,
|