@crimson-education/browser-logger 4.1.4-next.0 → 5.0.0-beta.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/README.md +81 -29
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +22 -41
- 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 +16 -22
- 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 +4 -8
- package/lib/logger/datadogTransport.js.map +1 -1
- package/lib/logger/index.js +29 -49
- package/lib/logger/index.js.map +1 -1
- package/lib/logger/index.test.js +16 -18
- package/lib/logger/index.test.js.map +1 -1
- package/lib/logger/utils.js +4 -9
- package/lib/logger/utils.js.map +1 -1
- package/lib/reporters/amplifyReporter.d.ts +3 -3
- package/lib/reporters/amplifyReporter.d.ts.map +1 -1
- package/lib/reporters/amplifyReporter.js +154 -82
- package/lib/reporters/amplifyReporter.js.map +1 -1
- package/lib/reporters/amplifyReporter.test.js +9 -12
- package/lib/reporters/amplifyReporter.test.js.map +1 -1
- package/lib/reporters/datadogReporter.d.ts +1 -1
- package/lib/reporters/datadogReporter.d.ts.map +1 -1
- package/lib/reporters/datadogReporter.js +117 -48
- 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 +1 -5
- package/lib/reporters/gtmReporter.js.map +1 -1
- package/lib/reporters/index.js +46 -71
- package/lib/reporters/index.js.map +1 -1
- package/lib/reporters/logReporter.js +24 -34
- package/lib/reporters/logReporter.js.map +1 -1
- package/lib/types/index.js +2 -18
- 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 +2 -5
- package/lib/types/logger.js.map +1 -1
- package/lib/types/reporter.d.ts +6 -6
- package/lib/types/reporter.d.ts.map +1 -1
- package/lib/types/reporter.js +1 -2
- package/lib/utils.js +1 -5
- package/lib/utils.js.map +1 -1
- package/lib/utils.test.js +2 -4
- package/lib/utils.test.js.map +1 -1
- package/package.json +15 -13
- package/src/reporters/amplifyReporter.ts +165 -68
- package/src/reporters/datadogReporter.ts +106 -18
|
@@ -1,66 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { datadogLogs, HandlerType } from '@datadog/browser-logs';
|
|
2
|
+
import { datadogRum } from '@datadog/browser-rum';
|
|
3
|
+
import { logTransports } from '../logger';
|
|
4
|
+
import { datadogTransport } from '../logger/datadogTransport';
|
|
5
|
+
// User frustration detection for Datadog Gen2
|
|
6
|
+
class DatadogFrustrationDetector {
|
|
7
|
+
config;
|
|
8
|
+
frustrationEvents = [];
|
|
9
|
+
FRUSTRATION_THRESHOLD = 3; // Number of events to trigger frustration
|
|
10
|
+
FRUSTRATION_WINDOW = 5000; // Time window in ms
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
if (config.trackFrustrations) {
|
|
14
|
+
this.setupFrustrationDetection();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
setupFrustrationDetection() {
|
|
18
|
+
// Track rapid clicks (potential frustration)
|
|
19
|
+
let clickCount = 0;
|
|
20
|
+
let lastClickTime = 0;
|
|
21
|
+
document.addEventListener('click', (event) => {
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
if (now - lastClickTime < 1000) {
|
|
24
|
+
// Rapid clicks within 1 second
|
|
25
|
+
clickCount++;
|
|
26
|
+
if (clickCount >= 3) {
|
|
27
|
+
this.recordFrustrationEvent('rapid_clicks', event);
|
|
28
|
+
clickCount = 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
clickCount = 1;
|
|
33
|
+
}
|
|
34
|
+
lastClickTime = now;
|
|
35
|
+
});
|
|
36
|
+
// Track form errors (potential frustration)
|
|
37
|
+
document.addEventListener('invalid', (event) => {
|
|
38
|
+
this.recordFrustrationEvent('form_validation_error', event);
|
|
39
|
+
});
|
|
40
|
+
// Track 404 errors (potential frustration)
|
|
41
|
+
window.addEventListener('error', (event) => {
|
|
42
|
+
if (event.message.includes('404') || event.message.includes('Not Found')) {
|
|
43
|
+
this.recordFrustrationEvent('page_not_found', event);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
// Track network errors (potential frustration)
|
|
47
|
+
window.addEventListener('unhandledrejection', (event) => {
|
|
48
|
+
if (event.reason && typeof event.reason === 'object' && 'status' in event.reason) {
|
|
49
|
+
const status = event.reason.status;
|
|
50
|
+
if (status >= 400) {
|
|
51
|
+
this.recordFrustrationEvent('network_error', event);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
recordFrustrationEvent(type, originalEvent) {
|
|
57
|
+
const now = Date.now();
|
|
58
|
+
this.frustrationEvents.push({ type, timestamp: now });
|
|
59
|
+
// Clean old events outside the window
|
|
60
|
+
this.frustrationEvents = this.frustrationEvents.filter((event) => now - event.timestamp < this.FRUSTRATION_WINDOW);
|
|
61
|
+
// Check if we have enough events to trigger frustration
|
|
62
|
+
if (this.frustrationEvents.length >= this.FRUSTRATION_THRESHOLD) {
|
|
63
|
+
this.triggerFrustrationDetection();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
triggerFrustrationDetection() {
|
|
67
|
+
const frustrationData = {
|
|
68
|
+
frustrationType: 'user_frustration_detected',
|
|
69
|
+
frustrationEvents: this.frustrationEvents.map((e) => e.type),
|
|
70
|
+
frustrationCount: this.frustrationEvents.length,
|
|
71
|
+
pageUrl: window.location.href,
|
|
72
|
+
timestamp: new Date().toISOString(),
|
|
73
|
+
};
|
|
74
|
+
// Send frustration event to Datadog
|
|
75
|
+
if (typeof datadogRum !== 'undefined') {
|
|
76
|
+
datadogRum.addAction('User Frustration Detected', frustrationData);
|
|
77
|
+
}
|
|
78
|
+
// Clear events after reporting
|
|
79
|
+
this.frustrationEvents = [];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function datadogReporter(info, config) {
|
|
10
83
|
const isLocalhost = window.location.hostname === 'localhost';
|
|
11
84
|
// Don't forward error logs by default, do enable the log transport by default
|
|
12
85
|
// forwardErrorsToLogs incorrectly is called forwardConsoleLogs, this is for backwards compatibility
|
|
13
|
-
const forwardErrorsToLogs =
|
|
86
|
+
const forwardErrorsToLogs = config.forwardConsoleLogs ?? false;
|
|
14
87
|
const enableLogTransport = config.logTransport !== false;
|
|
15
88
|
// Only init datadog logs if something is using it.
|
|
16
89
|
if (forwardErrorsToLogs !== true && enableLogTransport !== true) {
|
|
17
|
-
|
|
90
|
+
datadogLogs.init({
|
|
18
91
|
site: config.site,
|
|
19
|
-
proxyUrl: config.proxyUrl,
|
|
20
92
|
clientToken: config.clientToken,
|
|
21
93
|
service: info.service,
|
|
22
94
|
env: info.environment,
|
|
23
|
-
version:
|
|
24
|
-
|
|
95
|
+
version: config.version ?? info.version,
|
|
96
|
+
// Note: sampleRate is not available in newer Datadog versions
|
|
25
97
|
beforeSend: config.beforeLogsSend,
|
|
26
|
-
useSecureSessionCookie:
|
|
27
|
-
|
|
98
|
+
useSecureSessionCookie: config.useSecureSessionCookie ?? !isLocalhost,
|
|
99
|
+
// Note: useCrossSiteSessionCookie is not available in newer Datadog versions
|
|
28
100
|
trackSessionAcrossSubdomains: config.trackSessionAcrossSubdomains,
|
|
29
101
|
forwardErrorsToLogs,
|
|
30
102
|
});
|
|
31
|
-
|
|
103
|
+
datadogLogs.logger.setHandler(HandlerType.http);
|
|
32
104
|
}
|
|
33
105
|
// Add the datadog log transport
|
|
34
106
|
if (enableLogTransport) {
|
|
35
|
-
|
|
107
|
+
logTransports.push(datadogTransport(typeof config.logTransport === 'boolean' ? {} : config.logTransport));
|
|
36
108
|
}
|
|
37
|
-
|
|
109
|
+
datadogRum.init({
|
|
38
110
|
enableExperimentalFeatures: ['feature_flags'],
|
|
39
111
|
site: config.site,
|
|
40
|
-
proxyUrl: config.proxyUrl,
|
|
41
112
|
clientToken: config.clientToken,
|
|
42
113
|
applicationId: config.applicationId,
|
|
43
114
|
service: info.service,
|
|
44
115
|
env: info.environment,
|
|
45
|
-
version:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
useSecureSessionCookie:
|
|
49
|
-
|
|
116
|
+
version: config.version ?? info.version,
|
|
117
|
+
// Note: sampleRate is not available in newer Datadog versions
|
|
118
|
+
// Note: replaySampleRate is not available in newer Datadog versions
|
|
119
|
+
useSecureSessionCookie: config.useSecureSessionCookie ?? !isLocalhost,
|
|
120
|
+
// Note: useCrossSiteSessionCookie is not available in newer Datadog versions
|
|
50
121
|
trackSessionAcrossSubdomains: config.trackSessionAcrossSubdomains,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
trackViewsManually: (_q = config.trackViewsManually) !== null && _q !== void 0 ? _q : false,
|
|
54
|
-
actionNameAttribute: (_r = config.actionNameAttribute) !== null && _r !== void 0 ? _r : 'data-analytics-name',
|
|
122
|
+
trackViewsManually: config.trackViewsManually ?? false,
|
|
123
|
+
actionNameAttribute: config.actionNameAttribute ?? 'data-analytics-name',
|
|
55
124
|
beforeSend: config.beforeSend,
|
|
56
|
-
defaultPrivacyLevel:
|
|
57
|
-
|
|
58
|
-
trackUserInteractions:
|
|
125
|
+
defaultPrivacyLevel: config.defaultPrivacyLevel ?? 'mask-user-input',
|
|
126
|
+
allowedTrackingOrigins: config.allowedTrackingOrigins,
|
|
127
|
+
trackUserInteractions: config.trackUserInteractions ?? false,
|
|
59
128
|
excludedActivityUrls: config.excludedActivityUrls,
|
|
60
129
|
});
|
|
130
|
+
// Initialize frustration detector
|
|
131
|
+
const frustrationDetector = new DatadogFrustrationDetector(config);
|
|
61
132
|
const reporter = {
|
|
62
133
|
trackEvent: function (event) {
|
|
63
|
-
|
|
134
|
+
datadogRum.addAction(event.message, {
|
|
64
135
|
level: event.level,
|
|
65
136
|
...event.metadata,
|
|
66
137
|
...event.tags,
|
|
@@ -68,7 +139,7 @@ function datadogReporter(info, config) {
|
|
|
68
139
|
});
|
|
69
140
|
},
|
|
70
141
|
addBreadcrumb: function (breadcrumb) {
|
|
71
|
-
|
|
142
|
+
datadogRum.addAction(breadcrumb.message, {
|
|
72
143
|
...breadcrumb.metadata,
|
|
73
144
|
category: breadcrumb.category,
|
|
74
145
|
});
|
|
@@ -76,30 +147,29 @@ function datadogReporter(info, config) {
|
|
|
76
147
|
addMetadata: function (metadata) {
|
|
77
148
|
for (const [key, value] of Object.entries(metadata)) {
|
|
78
149
|
if (value !== null) {
|
|
79
|
-
|
|
150
|
+
datadogRum.setGlobalContextProperty(key, value);
|
|
80
151
|
// Note, this will add duplicate context data in logs.
|
|
81
152
|
// But this is valuable for logs ingested outside of the browser logger.
|
|
82
|
-
|
|
153
|
+
datadogLogs.setGlobalContextProperty(key, value);
|
|
83
154
|
}
|
|
84
155
|
else {
|
|
85
|
-
|
|
156
|
+
datadogRum.removeGlobalContextProperty(key);
|
|
86
157
|
// But this is valuable for logs ingested outside of the browser logger.
|
|
87
|
-
|
|
158
|
+
datadogLogs.removeGlobalContextProperty(key);
|
|
88
159
|
}
|
|
89
160
|
}
|
|
90
161
|
},
|
|
91
162
|
setUser: function (user) {
|
|
92
|
-
var _a;
|
|
93
163
|
if (user) {
|
|
94
|
-
|
|
164
|
+
datadogRum.setUser({
|
|
95
165
|
...user,
|
|
96
166
|
id: user.id,
|
|
97
167
|
email: user.email,
|
|
98
|
-
name:
|
|
168
|
+
name: user.name ?? user.email,
|
|
99
169
|
});
|
|
100
170
|
}
|
|
101
171
|
else {
|
|
102
|
-
|
|
172
|
+
datadogRum.setUser({});
|
|
103
173
|
}
|
|
104
174
|
},
|
|
105
175
|
setRouteName: function (routeName) {
|
|
@@ -107,26 +177,25 @@ function datadogReporter(info, config) {
|
|
|
107
177
|
},
|
|
108
178
|
setPageName: function (pageName) {
|
|
109
179
|
if (config.trackViewsManually) {
|
|
110
|
-
|
|
180
|
+
datadogRum.startView(pageName);
|
|
111
181
|
}
|
|
112
182
|
else {
|
|
113
183
|
reporter.addMetadata({ pageName });
|
|
114
184
|
}
|
|
115
185
|
},
|
|
116
186
|
reportError: function (error, metadata) {
|
|
117
|
-
|
|
187
|
+
datadogRum.addError(error, metadata);
|
|
118
188
|
},
|
|
119
189
|
reportFeatureFlag: function (flag) {
|
|
120
|
-
|
|
190
|
+
datadogRum.addFeatureFlagEvaluation(flag.name, flag.value);
|
|
121
191
|
},
|
|
122
192
|
recordSession: function () {
|
|
123
|
-
|
|
193
|
+
datadogRum.startSessionReplayRecording();
|
|
124
194
|
},
|
|
125
195
|
recordSessionStop: function () {
|
|
126
|
-
|
|
196
|
+
datadogRum.stopSessionReplayRecording();
|
|
127
197
|
},
|
|
128
198
|
};
|
|
129
199
|
return reporter;
|
|
130
200
|
}
|
|
131
|
-
exports.datadogReporter = datadogReporter;
|
|
132
201
|
//# sourceMappingURL=datadogReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datadogReporter.js","sourceRoot":"","sources":["../../src/reporters/datadogReporter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"datadogReporter.js","sourceRoot":"","sources":["../../src/reporters/datadogReporter.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAyB,MAAM,uBAAuB,CAAC;AACxF,OAAO,EAAE,UAAU,EAA6C,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAA6B,gBAAgB,EAAE,MAAM,4BAA4B,C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B,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK;iBAC9B,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QACD,YAAY,EAAE,UAAU,SAAiB;YACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACtC,CAAC;QACD,WAAW,EAAE,UAAU,QAAgB;YACrC,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;gBAC9B,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QACD,WAAW,EAAE,UAAU,KAAkB,EAAE,QAAmB;YAC5D,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACvC,CAAC;QACD,iBAAiB,EAAE,UAAU,IAAkB;YAC7C,UAAU,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7D,CAAC;QACD,aAAa,EAAE;YACb,UAAU,CAAC,2BAA2B,EAAE,CAAC;QAC3C,CAAC;QACD,iBAAiB,EAAE;YACjB,UAAU,CAAC,0BAA0B,EAAE,CAAC;QAC1C,CAAC;KACF,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gtmReporter.d.ts","sourceRoot":"","sources":["../../src/reporters/gtmReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAKT,WAAW,EACX,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,
|
|
1
|
+
{"version":3,"file":"gtmReporter.d.ts","sourceRoot":"","sources":["../../src/reporters/gtmReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAKT,WAAW,EACX,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAEnD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;KACnC;CACF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAuDnF"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gtmReporter = void 0;
|
|
4
|
-
function gtmReporter(info, config) {
|
|
1
|
+
export function gtmReporter(info, config) {
|
|
5
2
|
let loadedDataLayer = !!window.dataLayer;
|
|
6
3
|
const baseMetadata = {
|
|
7
4
|
service: info.service,
|
|
@@ -53,5 +50,4 @@ function gtmReporter(info, config) {
|
|
|
53
50
|
}
|
|
54
51
|
return reporter;
|
|
55
52
|
}
|
|
56
|
-
exports.gtmReporter = gtmReporter;
|
|
57
53
|
//# sourceMappingURL=gtmReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gtmReporter.js","sourceRoot":"","sources":["../../src/reporters/gtmReporter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gtmReporter.js","sourceRoot":"","sources":["../../src/reporters/gtmReporter.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,WAAW,CAAC,IAAiB,EAAE,MAAyB;IACtE,IAAI,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;IACzC,MAAM,YAAY,GAAG;QACnB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;QAC5B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,OAAO,EAAE,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C,YAAY,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/lib/reporters/index.js
CHANGED
|
@@ -1,59 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const utils_2 = require("../utils");
|
|
6
|
-
exports.reporters = {};
|
|
1
|
+
import { isAboveLevel } from '../logger/utils';
|
|
2
|
+
import { filterReporterMetadata } from '../utils';
|
|
3
|
+
export const reporters = {};
|
|
4
|
+
export let globalEventLevel;
|
|
7
5
|
/**
|
|
8
6
|
* Sets the global event level.
|
|
9
7
|
*/
|
|
10
|
-
function setEventLevel(level) {
|
|
11
|
-
|
|
8
|
+
export function setEventLevel(level) {
|
|
9
|
+
globalEventLevel = level ?? undefined;
|
|
12
10
|
}
|
|
13
|
-
exports.setEventLevel = setEventLevel;
|
|
14
11
|
/**
|
|
15
12
|
* Gets reporters, optionally with filters.
|
|
16
13
|
* @param filters Filters to remove or specify specific reporters.
|
|
17
14
|
* @returns Selected reporters, or all registered reporters.
|
|
18
15
|
*/
|
|
19
16
|
function getReporters(filters) {
|
|
20
|
-
let result = Object.entries(
|
|
21
|
-
if (filters
|
|
22
|
-
result = result.filter(([key]) =>
|
|
17
|
+
let result = Object.entries(reporters);
|
|
18
|
+
if (filters?.excludeReporters) {
|
|
19
|
+
result = result.filter(([key]) => !filters?.excludeReporters?.includes(key));
|
|
23
20
|
}
|
|
24
|
-
if (filters
|
|
25
|
-
result = result.filter(([key]) =>
|
|
21
|
+
if (filters?.toReporters) {
|
|
22
|
+
result = result.filter(([key]) => filters?.toReporters?.includes(key));
|
|
26
23
|
}
|
|
27
24
|
return result.map(([, reporter]) => reporter);
|
|
28
25
|
}
|
|
29
26
|
/**
|
|
30
27
|
* Tracks an Analytics event.
|
|
31
28
|
*/
|
|
32
|
-
function trackEvent(event) {
|
|
33
|
-
|
|
34
|
-
if (exports.globalEventLevel && event.level && !(0, utils_1.isAboveLevel)(event.level, exports.globalEventLevel)) {
|
|
29
|
+
export function trackEvent(event) {
|
|
30
|
+
if (globalEventLevel && event.level && !isAboveLevel(event.level, globalEventLevel)) {
|
|
35
31
|
return;
|
|
36
32
|
}
|
|
37
33
|
for (const reporter of getReporters(event)) {
|
|
38
|
-
if (
|
|
34
|
+
if (reporter.endpoints?.trackEvent === false) {
|
|
39
35
|
continue;
|
|
40
36
|
}
|
|
41
|
-
else if (reporter.eventLevel && event.level && !
|
|
37
|
+
else if (reporter.eventLevel && event.level && !isAboveLevel(event.level, reporter.eventLevel)) {
|
|
42
38
|
return;
|
|
43
39
|
}
|
|
44
40
|
const reporterEvent = { ...event };
|
|
45
|
-
reporterEvent.metadata =
|
|
46
|
-
reporterEvent.metrics =
|
|
47
|
-
reporterEvent.tags =
|
|
41
|
+
reporterEvent.metadata = filterReporterMetadata(event.metadata, reporter);
|
|
42
|
+
reporterEvent.metrics = filterReporterMetadata(event.metrics, reporter);
|
|
43
|
+
reporterEvent.tags = filterReporterMetadata(event.tags, reporter);
|
|
48
44
|
reporter.trackEvent(reporterEvent);
|
|
49
45
|
}
|
|
50
46
|
}
|
|
51
|
-
exports.trackEvent = trackEvent;
|
|
52
47
|
/**
|
|
53
48
|
* Tracks an Analytics event, recording the time since the last event, if available.
|
|
54
49
|
*/
|
|
55
|
-
function trackEventSinceLastAction(event) {
|
|
56
|
-
if (
|
|
50
|
+
export function trackEventSinceLastAction(event) {
|
|
51
|
+
if (globalEventLevel && event.level && !isAboveLevel(event.level, globalEventLevel)) {
|
|
57
52
|
return;
|
|
58
53
|
}
|
|
59
54
|
const lastEvent = getLastTrackedEvent();
|
|
@@ -73,11 +68,10 @@ function trackEventSinceLastAction(event) {
|
|
|
73
68
|
}
|
|
74
69
|
sessionStorage.setItem('loggerLastEvent', JSON.stringify({ ...event, occurred: new Date() }));
|
|
75
70
|
}
|
|
76
|
-
exports.trackEventSinceLastAction = trackEventSinceLastAction;
|
|
77
71
|
/**
|
|
78
72
|
* Gets the last tracked event, if available.
|
|
79
73
|
*/
|
|
80
|
-
function getLastTrackedEvent() {
|
|
74
|
+
export function getLastTrackedEvent() {
|
|
81
75
|
const eventStr = sessionStorage.getItem('loggerLastEvent');
|
|
82
76
|
if (!eventStr)
|
|
83
77
|
return null;
|
|
@@ -85,145 +79,126 @@ function getLastTrackedEvent() {
|
|
|
85
79
|
event.occurred = new Date(event.occurred);
|
|
86
80
|
return event;
|
|
87
81
|
}
|
|
88
|
-
exports.getLastTrackedEvent = getLastTrackedEvent;
|
|
89
82
|
/**
|
|
90
83
|
* Breadcrumbs to create a trail of events that happened prior to an issue.
|
|
91
84
|
* These events are very similar to traditional logs, but can record more rich structured data.
|
|
92
85
|
*/
|
|
93
|
-
function addBreadcrumb(breadcrumb) {
|
|
94
|
-
var _a, _b;
|
|
86
|
+
export function addBreadcrumb(breadcrumb) {
|
|
95
87
|
for (const reporter of getReporters(breadcrumb)) {
|
|
96
|
-
if (
|
|
88
|
+
if (reporter.endpoints?.addBreadcrumb === false) {
|
|
97
89
|
continue;
|
|
98
90
|
}
|
|
99
|
-
else if (breadcrumb.category &&
|
|
91
|
+
else if (breadcrumb.category && reporter.ignoreBreadcrumbCategories?.includes(breadcrumb.category)) {
|
|
100
92
|
continue;
|
|
101
93
|
}
|
|
102
94
|
const reporterBreadcrumb = { ...breadcrumb };
|
|
103
|
-
reporterBreadcrumb.metadata =
|
|
95
|
+
reporterBreadcrumb.metadata = filterReporterMetadata(breadcrumb.metadata, reporter);
|
|
104
96
|
reporter.addBreadcrumb(reporterBreadcrumb);
|
|
105
97
|
}
|
|
106
98
|
}
|
|
107
|
-
exports.addBreadcrumb = addBreadcrumb;
|
|
108
99
|
/**
|
|
109
100
|
* Adds global metadata to all events and logs.
|
|
110
101
|
* @param metadata Metadata to add.
|
|
111
102
|
* @param filters Optional filters to specify which reporters to add metadata to.
|
|
112
103
|
*/
|
|
113
|
-
function addMetadata(metadata, filters) {
|
|
114
|
-
var _a;
|
|
104
|
+
export function addMetadata(metadata, filters) {
|
|
115
105
|
for (const reporter of getReporters(filters)) {
|
|
116
|
-
if (
|
|
106
|
+
if (reporter.endpoints?.addMetadata === false) {
|
|
117
107
|
continue;
|
|
118
108
|
}
|
|
119
|
-
reporter.addMetadata(
|
|
109
|
+
reporter.addMetadata(filterReporterMetadata(metadata, reporter));
|
|
120
110
|
}
|
|
121
111
|
}
|
|
122
|
-
exports.addMetadata = addMetadata;
|
|
123
112
|
/**
|
|
124
113
|
* Sets the user information in Analytics.
|
|
125
114
|
* @param user User information, or null to clear.
|
|
126
115
|
* @param filters Optional filters to specify which reporters to set the user for.
|
|
127
116
|
*/
|
|
128
|
-
function setUser(user, filters) {
|
|
129
|
-
var _a;
|
|
117
|
+
export function setUser(user, filters) {
|
|
130
118
|
for (const reporter of getReporters(filters)) {
|
|
131
|
-
if (
|
|
119
|
+
if (reporter.endpoints?.setUser === false) {
|
|
132
120
|
continue;
|
|
133
121
|
}
|
|
134
122
|
reporter.setUser(user);
|
|
135
123
|
}
|
|
136
124
|
}
|
|
137
|
-
exports.setUser = setUser;
|
|
138
125
|
/**
|
|
139
126
|
* Sets the route name in Analytics.
|
|
140
127
|
* Some Analytics services use this differentiate SPA Route vs Page changes.
|
|
141
128
|
* @param routeName Name of the Route.
|
|
142
129
|
* @param filters Optional filters to specify which reporters to set the route name for.
|
|
143
130
|
*/
|
|
144
|
-
function setRouteName(routeName, filters) {
|
|
145
|
-
var _a;
|
|
131
|
+
export function setRouteName(routeName, filters) {
|
|
146
132
|
for (const reporter of getReporters(filters)) {
|
|
147
|
-
if (
|
|
133
|
+
if (reporter.endpoints?.setRouteName === false) {
|
|
148
134
|
continue;
|
|
149
135
|
}
|
|
150
136
|
reporter.setRouteName(routeName);
|
|
151
137
|
}
|
|
152
138
|
}
|
|
153
|
-
exports.setRouteName = setRouteName;
|
|
154
139
|
/**
|
|
155
140
|
* Sets the page name in Analytics.
|
|
156
141
|
* @param pageName Name of the Page.
|
|
157
142
|
* @param filters Optional filters to specify which reporters to set the page name for.
|
|
158
143
|
*/
|
|
159
|
-
function setPageName(pageName, filters) {
|
|
160
|
-
var _a;
|
|
144
|
+
export function setPageName(pageName, filters) {
|
|
161
145
|
for (const reporter of getReporters(filters)) {
|
|
162
|
-
if (
|
|
146
|
+
if (reporter.endpoints?.setPageName === false) {
|
|
163
147
|
continue;
|
|
164
148
|
}
|
|
165
149
|
reporter.setPageName(pageName);
|
|
166
150
|
}
|
|
167
151
|
}
|
|
168
|
-
exports.setPageName = setPageName;
|
|
169
152
|
/**
|
|
170
153
|
* Reports an Error in Reporters that support error tracking.
|
|
171
154
|
* @param error Error data.
|
|
172
155
|
* @param metadata Metadata to add to the error.
|
|
173
156
|
* @param filters Optional filters to specify which reporters to report the error to.
|
|
174
157
|
*/
|
|
175
|
-
function reportError(error, metadata, filters) {
|
|
176
|
-
var _a, _b;
|
|
158
|
+
export function reportError(error, metadata, filters) {
|
|
177
159
|
for (const reporter of getReporters(filters)) {
|
|
178
|
-
if (
|
|
160
|
+
if (reporter.endpoints?.reportError === false) {
|
|
179
161
|
continue;
|
|
180
162
|
}
|
|
181
|
-
|
|
163
|
+
reporter.reportError?.(error, filterReporterMetadata(metadata, reporter));
|
|
182
164
|
}
|
|
183
165
|
}
|
|
184
|
-
exports.reportError = reportError;
|
|
185
166
|
/**
|
|
186
167
|
* Report a feature flag evaluation, e.g. for surfacing in Datadog RUM.
|
|
187
168
|
*
|
|
188
169
|
* @param flag Details about the feature flag evaluation
|
|
189
170
|
* @param filters Filters to specify which reporters to start a session recording for.
|
|
190
171
|
*/
|
|
191
|
-
function reportFeatureFlag(flag, filters) {
|
|
192
|
-
var _a, _b;
|
|
172
|
+
export function reportFeatureFlag(flag, filters) {
|
|
193
173
|
for (const reporter of getReporters(filters)) {
|
|
194
|
-
if (
|
|
174
|
+
if (reporter.endpoints?.reportFeatureFlag === false) {
|
|
195
175
|
continue;
|
|
196
176
|
}
|
|
197
|
-
|
|
177
|
+
reporter.reportFeatureFlag?.(flag);
|
|
198
178
|
}
|
|
199
179
|
}
|
|
200
|
-
exports.reportFeatureFlag = reportFeatureFlag;
|
|
201
180
|
/**
|
|
202
181
|
* Starts a session recording in Analytics, e.g. RUM Session Replay
|
|
203
182
|
* @param filters Optional filters to specify which reporters to start a session recording for.
|
|
204
183
|
*/
|
|
205
|
-
function recordSession(filters) {
|
|
206
|
-
var _a, _b;
|
|
184
|
+
export function recordSession(filters) {
|
|
207
185
|
for (const reporter of getReporters(filters)) {
|
|
208
|
-
if (
|
|
186
|
+
if (reporter.endpoints?.recordSession === false) {
|
|
209
187
|
continue;
|
|
210
188
|
}
|
|
211
|
-
|
|
189
|
+
reporter.recordSession?.();
|
|
212
190
|
}
|
|
213
191
|
}
|
|
214
|
-
exports.recordSession = recordSession;
|
|
215
192
|
/**
|
|
216
193
|
* Stops a session recording in Analytics, e.g. RUM Session Replay
|
|
217
194
|
* @param filters Optional filters to specify which reporters to stop a session recording for.
|
|
218
195
|
*/
|
|
219
|
-
function recordSessionStop(filters) {
|
|
220
|
-
var _a, _b;
|
|
196
|
+
export function recordSessionStop(filters) {
|
|
221
197
|
for (const reporter of getReporters(filters)) {
|
|
222
|
-
if (
|
|
198
|
+
if (reporter.endpoints?.recordSessionStop === false) {
|
|
223
199
|
continue;
|
|
224
200
|
}
|
|
225
|
-
|
|
201
|
+
reporter.recordSessionStop?.();
|
|
226
202
|
}
|
|
227
203
|
}
|
|
228
|
-
exports.recordSessionStop = recordSessionStop;
|
|
229
204
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAc/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,CAAC,MAA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