@crimson-education/browser-logger 2.0.1 → 2.0.2-cognito.1
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 +26 -26
- package/lib/index.js +140 -140
- package/lib/reporters/amplifyReporter.d.ts +51 -47
- package/lib/reporters/amplifyReporter.d.ts.map +1 -1
- package/lib/reporters/amplifyReporter.js +158 -156
- package/lib/reporters/amplifyReporter.js.map +1 -1
- package/lib/reporters/amplifyReporter.test.d.ts +1 -1
- package/lib/reporters/amplifyReporter.test.js +61 -61
- package/lib/reporters/datadogReporter.d.ts +26 -26
- package/lib/reporters/datadogReporter.js +177 -177
- package/lib/reporters/gtmReporter.d.ts +7 -7
- package/lib/reporters/gtmReporter.js +42 -42
- package/lib/reporters/index.d.ts +28 -28
- package/lib/reporters/index.js +2 -2
- package/lib/types.d.ts +47 -47
- package/lib/types.js +10 -10
- package/lib/utils.d.ts +4 -4
- package/lib/utils.js +46 -46
- package/package.json +1 -1
- package/src/reporters/amplifyReporter.ts +13 -7
|
@@ -1,157 +1,159 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.filterAttributeMap = exports.buildAttributeMap = exports.asAttributeMap = exports.amplifyReporter = void 0;
|
|
4
|
-
const auth_1 = require("@aws-amplify/auth");
|
|
5
|
-
const analytics_1 = require("@aws-amplify/analytics");
|
|
6
|
-
function amplifyReporter(info, config) {
|
|
7
|
-
var _a;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterAttributeMap = exports.buildAttributeMap = exports.asAttributeMap = exports.amplifyReporter = void 0;
|
|
4
|
+
const auth_1 = require("@aws-amplify/auth");
|
|
5
|
+
const analytics_1 = require("@aws-amplify/analytics");
|
|
6
|
+
function amplifyReporter(info, config) {
|
|
7
|
+
var _a;
|
|
8
|
+
if (config.identityPoolId !== false) {
|
|
9
|
+
auth_1.Auth.configure({
|
|
10
|
+
region: config.region,
|
|
11
|
+
identityPoolId: config.identityPoolId,
|
|
12
|
+
userPoolId: config.userPoolId,
|
|
13
|
+
userPoolWebClientId: config.userPoolWebClientId,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const allMetadata = asAttributeMap({
|
|
17
|
+
appName: info.service,
|
|
18
|
+
service: info.service,
|
|
19
|
+
domain: window.location.host,
|
|
20
|
+
environment: info.service,
|
|
21
|
+
version: info.version,
|
|
22
|
+
});
|
|
23
|
+
analytics_1.Analytics.configure({
|
|
24
|
+
region: config.region,
|
|
25
|
+
appId: config.analyticsAppId,
|
|
26
|
+
autoSessionRecord: config.autoTrackSessions,
|
|
27
|
+
endpoint: {
|
|
28
|
+
attributes: allMetadata,
|
|
29
|
+
},
|
|
30
|
+
...config.buffering,
|
|
31
|
+
});
|
|
32
|
+
if (config.autoTrackPageViews) {
|
|
33
|
+
analytics_1.Analytics.autoTrack('pageView', {
|
|
34
|
+
enable: true,
|
|
35
|
+
eventName: 'pageView',
|
|
36
|
+
type: 'SPA',
|
|
37
|
+
provider: 'AWSPinpoint',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (config.autoTrackEvents) {
|
|
41
|
+
analytics_1.Analytics.autoTrack('event', {
|
|
42
|
+
enable: true,
|
|
43
|
+
selectorPrefix: (_a = config.selectorPrefix) !== null && _a !== void 0 ? _a : 'data-analytics-',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const reporter = {
|
|
47
|
+
trackEvent: function (event) {
|
|
48
|
+
analytics_1.Analytics.record({
|
|
49
|
+
name: event.message,
|
|
50
|
+
attributes: asAttributeMap({
|
|
51
|
+
...event.metadata,
|
|
52
|
+
...event.tags,
|
|
53
|
+
}, false, config.ignoreMetadataPatterns),
|
|
54
|
+
metrics: event.metrics,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
addBreadcrumb: function (breadcrumb) {
|
|
58
|
+
var _a;
|
|
59
|
+
if (breadcrumb.category && ((_a = config.ignoreBreadcrumbCategories) === null || _a === void 0 ? void 0 : _a.includes(breadcrumb.category))) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
reporter.trackEvent({
|
|
63
|
+
message: breadcrumb.message,
|
|
64
|
+
metadata: {
|
|
65
|
+
category: breadcrumb.category,
|
|
66
|
+
...breadcrumb.metadata,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
addMetadata: function (metadata) {
|
|
71
|
+
Object.assign(allMetadata, asAttributeMap(metadata, true, config.ignoreMetadataPatterns));
|
|
72
|
+
analytics_1.Analytics.updateEndpoint({
|
|
73
|
+
attributes: allMetadata,
|
|
74
|
+
}).catch(() => {
|
|
75
|
+
// Swallow; see: https://crimsonhq.slack.com/archives/G4UN6Q4KF/p1648599302847539
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
setUser: function (user) {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
analytics_1.Analytics.updateEndpoint({
|
|
81
|
+
userId: (_a = user === null || user === void 0 ? void 0 : user.id) !== null && _a !== void 0 ? _a : '',
|
|
82
|
+
userAttributes: user
|
|
83
|
+
? asAttributeMap({
|
|
84
|
+
id: user.id,
|
|
85
|
+
email: user.email,
|
|
86
|
+
name: (_b = user.name) !== null && _b !== void 0 ? _b : user.email,
|
|
87
|
+
username: user.username,
|
|
88
|
+
})
|
|
89
|
+
: {},
|
|
90
|
+
}).catch(() => {
|
|
91
|
+
// Swallow; see: https://crimsonhq.slack.com/archives/G4UN6Q4KF/p1648599302847539
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
setRouteName: function (routeName) {
|
|
95
|
+
reporter.addMetadata({ routeName });
|
|
96
|
+
},
|
|
97
|
+
setPageName: function (pageName) {
|
|
98
|
+
reporter.addMetadata({ pageName });
|
|
99
|
+
},
|
|
100
|
+
reportError: function () { },
|
|
101
|
+
recordSession: function () { },
|
|
102
|
+
recordSessionStop: function () { },
|
|
103
|
+
};
|
|
104
|
+
return reporter;
|
|
105
|
+
}
|
|
106
|
+
exports.amplifyReporter = amplifyReporter;
|
|
107
|
+
/**
|
|
108
|
+
* Pinpoint has strict attribute name and value length limits
|
|
109
|
+
*/
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
function asAttributeMap(values, groupValues = true, ignorePatterns = []) {
|
|
112
|
+
const attributeMap = buildAttributeMap(values, undefined, groupValues);
|
|
113
|
+
const filteredAttributeMap = filterAttributeMap(attributeMap, ignorePatterns);
|
|
114
|
+
const checkedEntries = Object.entries(filteredAttributeMap).map(([key, value]) => {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
const truncatedKey = key.length > 50 ? `___${key.slice(-47)}` : key;
|
|
117
|
+
const truncatedValue = Array.isArray(value)
|
|
118
|
+
? (_a = value === null || value === void 0 ? void 0 : value.map((val) => val.slice(0, 100))) !== null && _a !== void 0 ? _a : null
|
|
119
|
+
: (_b = value === null || value === void 0 ? void 0 : value.slice(0, 100)) !== null && _b !== void 0 ? _b : null;
|
|
120
|
+
return [truncatedKey, truncatedValue];
|
|
121
|
+
});
|
|
122
|
+
return Object.fromEntries(checkedEntries);
|
|
123
|
+
}
|
|
124
|
+
exports.asAttributeMap = asAttributeMap;
|
|
125
|
+
/**
|
|
126
|
+
* Pinpoint expects `endpoint.attributes` and `endpoint.userAttributes` to have
|
|
127
|
+
* values which are string arrays. This function takes in an object and ensures
|
|
128
|
+
* all of its values are of type `string[]` to appease Pinpoint.
|
|
129
|
+
*/
|
|
130
|
+
function buildAttributeMap(
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
132
|
+
values, parentKey = undefined, groupValues = true) {
|
|
133
|
+
const valuesWithStringArrays = {};
|
|
134
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
135
|
+
const combinedKey = parentKey ? [parentKey, key].join('.') : key;
|
|
136
|
+
if (!value) {
|
|
137
|
+
valuesWithStringArrays[combinedKey] = null;
|
|
138
|
+
}
|
|
139
|
+
else if (groupValues && Array.isArray(value)) {
|
|
140
|
+
valuesWithStringArrays[combinedKey] = value.map((element) => typeof element === 'string' ? element : JSON.stringify(element));
|
|
141
|
+
}
|
|
142
|
+
else if (typeof value === 'object') {
|
|
143
|
+
const flattenedAttribute = buildAttributeMap(value, combinedKey, groupValues);
|
|
144
|
+
Object.assign(valuesWithStringArrays, flattenedAttribute);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const stringValue = typeof value === 'string' ? value : JSON.stringify(value);
|
|
148
|
+
valuesWithStringArrays[combinedKey] = groupValues ? [stringValue] : stringValue;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return valuesWithStringArrays;
|
|
152
|
+
}
|
|
153
|
+
exports.buildAttributeMap = buildAttributeMap;
|
|
154
|
+
function filterAttributeMap(attributes, ignorePatterns) {
|
|
155
|
+
const entries = Object.entries(attributes);
|
|
156
|
+
return Object.fromEntries(entries.filter(([key]) => !ignorePatterns.some((pattern) => pattern.test(key))));
|
|
157
|
+
}
|
|
158
|
+
exports.filterAttributeMap = filterAttributeMap;
|
|
157
159
|
//# sourceMappingURL=amplifyReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplifyReporter.js","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":";;;AAEA,4CAAyC;AACzC,sDAAmD;
|
|
1
|
+
{"version":3,"file":"amplifyReporter.js","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":";;;AAEA,4CAAyC;AACzC,sDAAmD;AAqCnD,SAAgB,eAAe,CAAC,IAAiB,EAAE,MAA6B;;IAC9E,IAAI,MAAM,CAAC,cAAc,KAAK,KAAK,EAAE;QACnC,WAAI,CAAC,SAAS,CAAC;YACb,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;SAChD,CAAC,CAAC;KACJ;IAED,MAAM,WAAW,GAAG,cAAc,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;QAC5B,WAAW,EAAE,IAAI,CAAC,OAAO;QACzB,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC,CAAC;IAEH,qBAAS,CAAC,SAAS,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,cAAc;QAC5B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,QAAQ,EAAE;YACR,UAAU,EAAE,WAAW;SACxB;QACD,GAAG,MAAM,CAAC,SAAS;KACpB,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,kBAAkB,EAAE;QAC7B,qBAAS,CAAC,SAAS,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
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=amplifyReporter.test.d.ts.map
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const amplifyReporter_1 = require("./amplifyReporter");
|
|
4
|
-
describe('amplifyReporter', () => {
|
|
5
|
-
it('should convert all attribute values to arrays of strings', () => {
|
|
6
|
-
const testMetadata = { a: 'a', d: ['e', 'f'] };
|
|
7
|
-
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
8
|
-
expect(attributeMap.a).toEqual(['a']);
|
|
9
|
-
expect(attributeMap.d).toEqual(['e', 'f']);
|
|
10
|
-
});
|
|
11
|
-
it('should handle undefined / null attributes', () => {
|
|
12
|
-
const testMetadata = { a: null, d: undefined };
|
|
13
|
-
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
14
|
-
expect(attributeMap.a).toBeNull();
|
|
15
|
-
expect(attributeMap.d).toBeNull();
|
|
16
|
-
});
|
|
17
|
-
it('should flatten hierarchies', () => {
|
|
18
|
-
const testMetadata = { foo: { bar: 'baz' } };
|
|
19
|
-
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
20
|
-
expect(attributeMap['foo.bar']).toEqual(['baz']);
|
|
21
|
-
});
|
|
22
|
-
it('should stringify non-string array members', () => {
|
|
23
|
-
var _a;
|
|
24
|
-
const testMetadata = { foo: 5, bar: [{ baz: 'maz' }] };
|
|
25
|
-
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
26
|
-
expect(attributeMap.foo).toEqual(['5']);
|
|
27
|
-
expect(typeof ((_a = attributeMap.bar) === null || _a === void 0 ? void 0 : _a[0])).toEqual('string');
|
|
28
|
-
});
|
|
29
|
-
it('should truncate attribute names', () => {
|
|
30
|
-
const testMetadata = { thisIsAVeryVeryLongAttributeNameThatNeedsToBeTruncated: 5 };
|
|
31
|
-
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
32
|
-
expect(attributeMap.___VeryVeryLongAttributeNameThatNeedsToBeTruncated).toEqual(['5']);
|
|
33
|
-
});
|
|
34
|
-
it('should truncate attribute values', () => {
|
|
35
|
-
const testMetadata = {
|
|
36
|
-
a: 'ThisIsAVeryLongStringThatNeedsToBeTruncatedTo100CharsOrElseThereWillBeAProblemWithSendingTheBeautifulDataToPinpoint',
|
|
37
|
-
};
|
|
38
|
-
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
39
|
-
expect(attributeMap.a).toEqual([
|
|
40
|
-
'ThisIsAVeryLongStringThatNeedsToBeTruncatedTo100CharsOrElseThereWillBeAProblemWithSendingTheBeautifu',
|
|
41
|
-
]);
|
|
42
|
-
});
|
|
43
|
-
it('should not group values into arrays when groupValues===false', () => {
|
|
44
|
-
const testMetadata = {
|
|
45
|
-
a: '5',
|
|
46
|
-
};
|
|
47
|
-
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata, false);
|
|
48
|
-
expect(attributeMap.a).toEqual('5');
|
|
49
|
-
});
|
|
50
|
-
it('should remove attributes which match the ignore patterns', () => {
|
|
51
|
-
const inputAttributeMap = {
|
|
52
|
-
includeme: '5',
|
|
53
|
-
excludeme: 'false',
|
|
54
|
-
differentProp: 'boo',
|
|
55
|
-
};
|
|
56
|
-
const filtered = (0, amplifyReporter_1.filterAttributeMap)(inputAttributeMap, [/exclude/g, /Prop/g]);
|
|
57
|
-
expect(filtered['includeme']).toBeTruthy();
|
|
58
|
-
expect(filtered['excludeme']).toBeFalsy();
|
|
59
|
-
expect(filtered['differentProp']).toBeFalsy();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const amplifyReporter_1 = require("./amplifyReporter");
|
|
4
|
+
describe('amplifyReporter', () => {
|
|
5
|
+
it('should convert all attribute values to arrays of strings', () => {
|
|
6
|
+
const testMetadata = { a: 'a', d: ['e', 'f'] };
|
|
7
|
+
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
8
|
+
expect(attributeMap.a).toEqual(['a']);
|
|
9
|
+
expect(attributeMap.d).toEqual(['e', 'f']);
|
|
10
|
+
});
|
|
11
|
+
it('should handle undefined / null attributes', () => {
|
|
12
|
+
const testMetadata = { a: null, d: undefined };
|
|
13
|
+
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
14
|
+
expect(attributeMap.a).toBeNull();
|
|
15
|
+
expect(attributeMap.d).toBeNull();
|
|
16
|
+
});
|
|
17
|
+
it('should flatten hierarchies', () => {
|
|
18
|
+
const testMetadata = { foo: { bar: 'baz' } };
|
|
19
|
+
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
20
|
+
expect(attributeMap['foo.bar']).toEqual(['baz']);
|
|
21
|
+
});
|
|
22
|
+
it('should stringify non-string array members', () => {
|
|
23
|
+
var _a;
|
|
24
|
+
const testMetadata = { foo: 5, bar: [{ baz: 'maz' }] };
|
|
25
|
+
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
26
|
+
expect(attributeMap.foo).toEqual(['5']);
|
|
27
|
+
expect(typeof ((_a = attributeMap.bar) === null || _a === void 0 ? void 0 : _a[0])).toEqual('string');
|
|
28
|
+
});
|
|
29
|
+
it('should truncate attribute names', () => {
|
|
30
|
+
const testMetadata = { thisIsAVeryVeryLongAttributeNameThatNeedsToBeTruncated: 5 };
|
|
31
|
+
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
32
|
+
expect(attributeMap.___VeryVeryLongAttributeNameThatNeedsToBeTruncated).toEqual(['5']);
|
|
33
|
+
});
|
|
34
|
+
it('should truncate attribute values', () => {
|
|
35
|
+
const testMetadata = {
|
|
36
|
+
a: 'ThisIsAVeryLongStringThatNeedsToBeTruncatedTo100CharsOrElseThereWillBeAProblemWithSendingTheBeautifulDataToPinpoint',
|
|
37
|
+
};
|
|
38
|
+
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata);
|
|
39
|
+
expect(attributeMap.a).toEqual([
|
|
40
|
+
'ThisIsAVeryLongStringThatNeedsToBeTruncatedTo100CharsOrElseThereWillBeAProblemWithSendingTheBeautifu',
|
|
41
|
+
]);
|
|
42
|
+
});
|
|
43
|
+
it('should not group values into arrays when groupValues===false', () => {
|
|
44
|
+
const testMetadata = {
|
|
45
|
+
a: '5',
|
|
46
|
+
};
|
|
47
|
+
const attributeMap = (0, amplifyReporter_1.asAttributeMap)(testMetadata, false);
|
|
48
|
+
expect(attributeMap.a).toEqual('5');
|
|
49
|
+
});
|
|
50
|
+
it('should remove attributes which match the ignore patterns', () => {
|
|
51
|
+
const inputAttributeMap = {
|
|
52
|
+
includeme: '5',
|
|
53
|
+
excludeme: 'false',
|
|
54
|
+
differentProp: 'boo',
|
|
55
|
+
};
|
|
56
|
+
const filtered = (0, amplifyReporter_1.filterAttributeMap)(inputAttributeMap, [/exclude/g, /Prop/g]);
|
|
57
|
+
expect(filtered['includeme']).toBeTruthy();
|
|
58
|
+
expect(filtered['excludeme']).toBeFalsy();
|
|
59
|
+
expect(filtered['differentProp']).toBeFalsy();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
62
|
//# sourceMappingURL=amplifyReporter.test.js.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { IReporter } from '.';
|
|
2
|
-
import { Metadata, ServiceInfo } from '../types';
|
|
3
|
-
import { DefaultPrivacyLevel } from '@datadog/browser-rum';
|
|
4
|
-
import { ILogger } from '..';
|
|
5
|
-
export declare type DatadogReporterConfig = {
|
|
6
|
-
applicationId: string;
|
|
7
|
-
clientToken: string;
|
|
8
|
-
version?: string;
|
|
9
|
-
site?: string;
|
|
10
|
-
proxyUrl?: string;
|
|
11
|
-
forwardConsoleLogs?: boolean;
|
|
12
|
-
trackInteractions?: boolean;
|
|
13
|
-
sampleRate?: number;
|
|
14
|
-
replaySampleRate?: number;
|
|
15
|
-
defaultPrivacyLevel?: DefaultPrivacyLevel;
|
|
16
|
-
useSecureSessionCookie?: boolean;
|
|
17
|
-
useCrossSiteSessionCookie?: boolean;
|
|
18
|
-
allowedTracingOrigins?: (string | RegExp)[];
|
|
19
|
-
trackSessionAcrossSubdomains?: boolean;
|
|
20
|
-
actionNameAttribute?: string;
|
|
21
|
-
trackViewsManually?: boolean;
|
|
22
|
-
};
|
|
23
|
-
export declare function datadogReporter(info: ServiceInfo, config: DatadogReporterConfig): IReporter;
|
|
24
|
-
export declare function datadogLogger(name?: string, options?: {
|
|
25
|
-
metadata?: Metadata;
|
|
26
|
-
}): ILogger;
|
|
1
|
+
import { IReporter } from '.';
|
|
2
|
+
import { Metadata, ServiceInfo } from '../types';
|
|
3
|
+
import { DefaultPrivacyLevel } from '@datadog/browser-rum';
|
|
4
|
+
import { ILogger } from '..';
|
|
5
|
+
export declare type DatadogReporterConfig = {
|
|
6
|
+
applicationId: string;
|
|
7
|
+
clientToken: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
site?: string;
|
|
10
|
+
proxyUrl?: string;
|
|
11
|
+
forwardConsoleLogs?: boolean;
|
|
12
|
+
trackInteractions?: boolean;
|
|
13
|
+
sampleRate?: number;
|
|
14
|
+
replaySampleRate?: number;
|
|
15
|
+
defaultPrivacyLevel?: DefaultPrivacyLevel;
|
|
16
|
+
useSecureSessionCookie?: boolean;
|
|
17
|
+
useCrossSiteSessionCookie?: boolean;
|
|
18
|
+
allowedTracingOrigins?: (string | RegExp)[];
|
|
19
|
+
trackSessionAcrossSubdomains?: boolean;
|
|
20
|
+
actionNameAttribute?: string;
|
|
21
|
+
trackViewsManually?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare function datadogReporter(info: ServiceInfo, config: DatadogReporterConfig): IReporter;
|
|
24
|
+
export declare function datadogLogger(name?: string, options?: {
|
|
25
|
+
metadata?: Metadata;
|
|
26
|
+
}): ILogger;
|
|
27
27
|
//# sourceMappingURL=datadogReporter.d.ts.map
|