@crimson-education/browser-logger 1.4.4 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +29 -29
- package/lib/index.js +144 -144
- package/lib/reporters/amplifyReporter.d.ts +43 -41
- package/lib/reporters/amplifyReporter.d.ts.map +1 -1
- package/lib/reporters/amplifyReporter.js +144 -141
- 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 +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/reporters/newrelicReporter.d.ts +3 -3
- package/lib/reporters/newrelicReporter.js +51 -51
- package/lib/reporters/sentryReporter.d.ts +10 -10
- package/lib/reporters/sentryReporter.js +102 -102
- 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 +3 -2
|
@@ -1,142 +1,145 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildAttributeMap = exports.asAttributeMap = exports.amplifyReporter = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
region: config.region,
|
|
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
|
-
reporter.addMetadata({
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
valuesWithStringArrays[combinedKey] =
|
|
129
|
-
}
|
|
130
|
-
else if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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
|
+
auth_1.Auth.configure({
|
|
9
|
+
region: config.region,
|
|
10
|
+
identityPoolId: config.identityPoolId,
|
|
11
|
+
userPoolId: config.userPoolId,
|
|
12
|
+
userPoolWebClientId: config.userPoolWebClientId,
|
|
13
|
+
});
|
|
14
|
+
const allMetadata = asAttributeMap({
|
|
15
|
+
service: info.service,
|
|
16
|
+
environment: info.service,
|
|
17
|
+
version: info.version,
|
|
18
|
+
});
|
|
19
|
+
analytics_1.Analytics.configure({
|
|
20
|
+
region: config.region,
|
|
21
|
+
appId: config.analyticsAppId,
|
|
22
|
+
autoSessionRecord: config.autoTrackSessions,
|
|
23
|
+
endpoint: {
|
|
24
|
+
attributes: allMetadata,
|
|
25
|
+
},
|
|
26
|
+
...config.buffering,
|
|
27
|
+
});
|
|
28
|
+
if (config.autoTrackPageViews) {
|
|
29
|
+
analytics_1.Analytics.autoTrack('pageView', {
|
|
30
|
+
enable: true,
|
|
31
|
+
eventName: 'pageView',
|
|
32
|
+
type: 'SPA',
|
|
33
|
+
provider: 'AWSPinpoint',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (config.autoTrackEvents) {
|
|
37
|
+
analytics_1.Analytics.autoTrack('event', {
|
|
38
|
+
enable: true,
|
|
39
|
+
selectorPrefix: (_a = config.selectorPrefix) !== null && _a !== void 0 ? _a : 'data-analytics-',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const reporter = {
|
|
43
|
+
trackEvent: function (event) {
|
|
44
|
+
analytics_1.Analytics.record({
|
|
45
|
+
name: event.message,
|
|
46
|
+
attributes: asAttributeMap({
|
|
47
|
+
...event.metadata,
|
|
48
|
+
...event.tags,
|
|
49
|
+
}, false),
|
|
50
|
+
metrics: event.metrics,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
addBreadcrumb: function (breadcrumb) {
|
|
54
|
+
var _a;
|
|
55
|
+
if (breadcrumb.category && ((_a = config.ignoreBreadcrumbCategories) === null || _a === void 0 ? void 0 : _a.includes(breadcrumb.category))) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
reporter.trackEvent({
|
|
59
|
+
message: breadcrumb.message,
|
|
60
|
+
metadata: {
|
|
61
|
+
category: breadcrumb.category,
|
|
62
|
+
...breadcrumb.metadata,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
addMetadata: function (metadata) {
|
|
67
|
+
Object.assign(allMetadata, asAttributeMap(metadata));
|
|
68
|
+
analytics_1.Analytics.updateEndpoint({
|
|
69
|
+
attributes: allMetadata,
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
setUser: function (user) {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
analytics_1.Analytics.updateEndpoint({
|
|
75
|
+
userId: (_a = user === null || user === void 0 ? void 0 : user.id) !== null && _a !== void 0 ? _a : '',
|
|
76
|
+
userAttributes: user
|
|
77
|
+
? asAttributeMap({
|
|
78
|
+
id: user.id,
|
|
79
|
+
email: user.email,
|
|
80
|
+
name: (_b = user.name) !== null && _b !== void 0 ? _b : user.email,
|
|
81
|
+
username: user.username,
|
|
82
|
+
})
|
|
83
|
+
: {},
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
setRouteName: function (routeName) {
|
|
87
|
+
reporter.addMetadata({ routeName });
|
|
88
|
+
},
|
|
89
|
+
setPageName: function (pageName) {
|
|
90
|
+
reporter.addMetadata({ pageName });
|
|
91
|
+
},
|
|
92
|
+
reportError: function () { },
|
|
93
|
+
recordSession: function () { },
|
|
94
|
+
recordSessionStop: function () { },
|
|
95
|
+
};
|
|
96
|
+
return reporter;
|
|
97
|
+
}
|
|
98
|
+
exports.amplifyReporter = amplifyReporter;
|
|
99
|
+
/**
|
|
100
|
+
* Pinpoint has strict attribute name and value length limits
|
|
101
|
+
*/
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
function asAttributeMap(values, groupValues = true) {
|
|
104
|
+
const attributeMap = buildAttributeMap(values, undefined, groupValues);
|
|
105
|
+
const checkedEntries = Object.entries(attributeMap).map(([key, value]) => {
|
|
106
|
+
var _a, _b;
|
|
107
|
+
const truncatedKey = key.length > 50 ? `___${key.slice(-47)}` : key;
|
|
108
|
+
const truncatedValue = Array.isArray(value)
|
|
109
|
+
? (_a = value === null || value === void 0 ? void 0 : value.map((val) => val.slice(0, 100))) !== null && _a !== void 0 ? _a : null
|
|
110
|
+
: (_b = value === null || value === void 0 ? void 0 : value.slice(0, 100)) !== null && _b !== void 0 ? _b : null;
|
|
111
|
+
return [truncatedKey, truncatedValue];
|
|
112
|
+
});
|
|
113
|
+
return Object.fromEntries(checkedEntries);
|
|
114
|
+
}
|
|
115
|
+
exports.asAttributeMap = asAttributeMap;
|
|
116
|
+
/**
|
|
117
|
+
* Pinpoint expects `endpoint.attributes` and `endpoint.userAttributes` to have
|
|
118
|
+
* values which are string arrays. This function takes in an object and ensures
|
|
119
|
+
* all of its values are of type `string[]` to appease Pinpoint.
|
|
120
|
+
*/
|
|
121
|
+
function buildAttributeMap(
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
123
|
+
values, parentKey = undefined, groupValues = true) {
|
|
124
|
+
const valuesWithStringArrays = {};
|
|
125
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
126
|
+
const combinedKey = parentKey ? [parentKey, key].join('.') : key;
|
|
127
|
+
if (!value) {
|
|
128
|
+
valuesWithStringArrays[combinedKey] = null;
|
|
129
|
+
}
|
|
130
|
+
else if (groupValues && Array.isArray(value)) {
|
|
131
|
+
valuesWithStringArrays[combinedKey] = value.map((element) => typeof element === 'string' ? element : JSON.stringify(element));
|
|
132
|
+
}
|
|
133
|
+
else if (typeof value === 'object') {
|
|
134
|
+
const flattenedAttribute = buildAttributeMap(value, combinedKey, groupValues);
|
|
135
|
+
Object.assign(valuesWithStringArrays, flattenedAttribute);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
const stringValue = typeof value === 'string' ? value : JSON.stringify(value);
|
|
139
|
+
valuesWithStringArrays[combinedKey] = groupValues ? [stringValue] : stringValue;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return valuesWithStringArrays;
|
|
143
|
+
}
|
|
144
|
+
exports.buildAttributeMap = buildAttributeMap;
|
|
142
145
|
//# sourceMappingURL=amplifyReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amplifyReporter.js","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"amplifyReporter.js","sourceRoot":"","sources":["../../src/reporters/amplifyReporter.ts"],"names":[],"mappings":";;;AAEA,4CAAyC;AACzC,sDAAmD;AAgCnD,SAAgB,eAAe,CAAC,IAAiB,EAAE,MAA6B;;IAC9E,WAAI,CAAC,SAAS,CAAC;QACb,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;KAChD,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,cAAc,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,WAAW,EAAE,IAAI,CAAC,OAAO;QACzB,OAA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AAC,CAAC,GAAG,CAAC;QAEjE,IAAI,CAAC,KAAK,EAAE;YACV,sBAAsB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;SAC5C;aAAM,IAAI,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC9C,sBAAsB,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAC1D,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAChE,CAAC;SACH;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YACpC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;YAC9E,MAAM,CAAC,MAAM,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAAC;SAC3D;aAAM;YACL,MAAM,WAAW,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAC9E,sBAAsB,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;SACjF;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,sBAAsB,CAAC;AAChC,CAAC;AA3BD,8CA2BC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=amplifyReporter.test.d.ts.map
|
|
@@ -1,51 +1,51 @@
|
|
|
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 = 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 = 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 = 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 = 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 = 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 = 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 = amplifyReporter_1.asAttributeMap(testMetadata, false);
|
|
48
|
-
expect(attributeMap.a).toEqual('5');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
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 = 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 = 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 = 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 = 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 = 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 = 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 = amplifyReporter_1.asAttributeMap(testMetadata, false);
|
|
48
|
+
expect(attributeMap.a).toEqual('5');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
51
|
//# 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
|