@servicetitan/datadog-rum 40.0.0 → 40.2.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/dist/create-impl.d.ts.map +1 -1
- package/dist/create-impl.js +2 -0
- package/dist/create-impl.js.map +1 -1
- package/dist/element-service-recorder.d.ts +17 -0
- package/dist/element-service-recorder.d.ts.map +1 -0
- package/dist/element-service-recorder.js +39 -0
- package/dist/element-service-recorder.js.map +1 -0
- package/dist/enrich-event.d.ts.map +1 -1
- package/dist/enrich-event.js +82 -21
- package/dist/enrich-event.js.map +1 -1
- package/dist/resolve-path-service.d.ts +11 -0
- package/dist/resolve-path-service.d.ts.map +1 -0
- package/dist/resolve-path-service.js +71 -0
- package/dist/resolve-path-service.js.map +1 -0
- package/package.json +2 -2
- package/src/__mocks__/before-send-data.ts +361 -0
- package/src/__mocks__/index.ts +1 -0
- package/src/__mocks__/mfe-host.ts +7 -0
- package/src/__tests__/create-impl.test.ts +8 -0
- package/src/__tests__/element-service-recorder.test.ts +127 -0
- package/src/__tests__/enrich-event.test.ts +109 -4
- package/src/__tests__/resolve-path-service.test.ts +130 -0
- package/src/create-impl.ts +2 -0
- package/src/element-service-recorder.ts +45 -0
- package/src/enrich-event.ts +68 -20
- package/src/resolve-path-service.ts +83 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention -- RUM event fields are snake_case */
|
|
1
2
|
// These are real error messages that are used to verify service and version attribution.
|
|
2
3
|
|
|
3
4
|
import { RumEvent, RumEventDomainContext } from '@datadog/browser-rum';
|
|
@@ -82,6 +83,45 @@ const hostResourceUnpkgRequest = {
|
|
|
82
83
|
context: {},
|
|
83
84
|
};
|
|
84
85
|
|
|
86
|
+
const hostResourceUnpkgRequestHyphenatedPrerelease = {
|
|
87
|
+
resource: {
|
|
88
|
+
url: 'https://unpkg.servicetitan.com/@servicetitan/eh-my-tenants@5.0.1-master-rc-eb9d8e988.0/dist/bundle/full/runtime.42087bf59c5e718ff526.bundle.js',
|
|
89
|
+
},
|
|
90
|
+
context: {},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const hostResourceUnpkgRequestBranchAndHash = {
|
|
94
|
+
resource: {
|
|
95
|
+
url: 'https://unpkg.servicetitan.com/@servicetitan/eh-ccpro@1.7.2-master-48be403.0/dist/bundle/full/runtime.e648f9a4.bundle.js',
|
|
96
|
+
},
|
|
97
|
+
context: {},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const hostResourceUnpkgRequestBuildAndBranch = {
|
|
101
|
+
resource: {
|
|
102
|
+
url: 'https://unpkg.servicetitan.com/@servicetitan/pricebook-enterprisehub@0.0.0-1.0.532-master/dist/bundle/full/runtime.2df2b4c6001e8a11f406.bundle.js',
|
|
103
|
+
},
|
|
104
|
+
context: {},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const hostResourceUnpkgRequestGitDescribe = {
|
|
108
|
+
resource: {
|
|
109
|
+
url: 'https://unpkg.servicetitan.com/@servicetitan/customer-portal-estimates@0.0.0-1.0.1773-mockSupportForCPContainers.g19c652d3a4/dist/bundle/full/runtime.c58942f1a38b681d0249.bundle.js',
|
|
110
|
+
},
|
|
111
|
+
context: {},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const mfeErrorHyphenatedPrerelease = {
|
|
115
|
+
error: {
|
|
116
|
+
message: 'Role name already exists',
|
|
117
|
+
stack: `
|
|
118
|
+
Error: Role name already exists
|
|
119
|
+
at value @ https://unpkg.servicetitan.com/@servicetitan/eh-user-management-client@10.0.9-master-rc-eb9d8e988.0/dist/bundle/full/main.0bbcdbd062f391fda175.bundle.js:2:1368334
|
|
120
|
+
`,
|
|
121
|
+
},
|
|
122
|
+
context: {},
|
|
123
|
+
};
|
|
124
|
+
|
|
85
125
|
const mfeResourceXhrRequest = {
|
|
86
126
|
resource: { url: 'https://go.servicetitan.com/app/api/data/user' },
|
|
87
127
|
context: {
|
|
@@ -99,6 +139,193 @@ const mfeResourceXhrRequest = {
|
|
|
99
139
|
},
|
|
100
140
|
};
|
|
101
141
|
|
|
142
|
+
const renderErrorStack = `
|
|
143
|
+
TypeError: null is not an object (evaluating 'le.current.useState')
|
|
144
|
+
at <anonymous> @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:294096
|
|
145
|
+
at PortalProvider @ https://go.servicetitan.com/scripts/build/desktop/shared/servicetitan.6c43a628f29ef9f51511.bundle.js:2:1137664
|
|
146
|
+
at Nh @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:217660
|
|
147
|
+
at Po @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:273405
|
|
148
|
+
at Uk @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:269025
|
|
149
|
+
at Tk @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:268953
|
|
150
|
+
at Ik @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:268806
|
|
151
|
+
at Nk @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:265121
|
|
152
|
+
at Gk @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:264074
|
|
153
|
+
at J @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor.8d7a7328d8d1c168f888.bundle.js:2:122247
|
|
154
|
+
at R @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor.8d7a7328d8d1c168f888.bundle.js:2:122611
|
|
155
|
+
at run @ https://go.servicetitan.com/scripts/build/desktop/vendor.15b48c67111ee07c5b30.bundle.js:2:5670964
|
|
156
|
+
at runIfPresent @ https://go.servicetitan.com/scripts/build/desktop/vendor.15b48c67111ee07c5b30.bundle.js:2:5671192
|
|
157
|
+
at onGlobalMessage @ https://go.servicetitan.com/scripts/build/desktop/vendor.15b48c67111ee07c5b30.bundle.js:2:5671715
|
|
158
|
+
`;
|
|
159
|
+
|
|
160
|
+
const hostErrorRenderUnhandled = {
|
|
161
|
+
error: {
|
|
162
|
+
message: "null is not an object (evaluating 'le.current.useState')",
|
|
163
|
+
stack: renderErrorStack,
|
|
164
|
+
},
|
|
165
|
+
context: {},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const hostErrorRenderConsole = {
|
|
169
|
+
error: {
|
|
170
|
+
message: "TypeError: null is not an object (evaluating 'le.current.useState')",
|
|
171
|
+
stack: renderErrorStack,
|
|
172
|
+
},
|
|
173
|
+
context: {
|
|
174
|
+
handlingStack: `
|
|
175
|
+
HandlingStack: console error
|
|
176
|
+
at e @ https://edge.fullstory.com/s/fs.js:2:34743
|
|
177
|
+
at <anonymous> @ https://unpkg.servicetitan.com/@servicetitan/ti-assist@0.0.0-master.626f98a/dist/bundle/light/vendor.78723d74cfa02e68895a.bundle.js:2:200079
|
|
178
|
+
at Li @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:228973
|
|
179
|
+
at <anonymous> @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:229190
|
|
180
|
+
at sh @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:216201
|
|
181
|
+
at kk @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:261182
|
|
182
|
+
at ik @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:260585
|
|
183
|
+
at hk @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:260117
|
|
184
|
+
at Wk @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:270178
|
|
185
|
+
at Pk @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:269520
|
|
186
|
+
at Gk @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js:2:264384
|
|
187
|
+
at J @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor.8d7a7328d8d1c168f888.bundle.js:2:122247
|
|
188
|
+
at R @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor.8d7a7328d8d1c168f888.bundle.js:2:122611
|
|
189
|
+
at run @ https://go.servicetitan.com/scripts/build/desktop/vendor.15b48c67111ee07c5b30.bundle.js:2:5670964
|
|
190
|
+
at runIfPresent @ https://go.servicetitan.com/scripts/build/desktop/vendor.15b48c67111ee07c5b30.bundle.js:2:5671192
|
|
191
|
+
at onGlobalMessage @ https://go.servicetitan.com/scripts/build/desktop/vendor.15b48c67111ee07c5b30.bundle.js:2:5671715
|
|
192
|
+
`,
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const mfeErrorAxiosError401 = {
|
|
197
|
+
error: {
|
|
198
|
+
message: 'AxiosError: Request failed with status code 401',
|
|
199
|
+
stack: `
|
|
200
|
+
AxiosError: Request failed with status code 401
|
|
201
|
+
at settle @ https://unpkg.servicetitan.com/@servicetitan/dispatch-pro-console@0.0.0-master.8e05d88/dist/bundle/light/common.5178678e6dfc4f632bdb.bundle.js:2:31361
|
|
202
|
+
at XMLHttpRequest.onloadend @ https://unpkg.servicetitan.com/@servicetitan/dispatch-pro-console@0.0.0-master.8e05d88/dist/bundle/light/common.5178678e6dfc4f632bdb.bundle.js:2:40154
|
|
203
|
+
at Axios.request @ https://unpkg.servicetitan.com/@servicetitan/dispatch-pro-console@0.0.0-master.8e05d88/dist/bundle/light/common.5178678e6dfc4f632bdb.bundle.js:2:55248
|
|
204
|
+
at async makeCodedException @ https://unpkg.servicetitan.com/@servicetitan/dispatch-pro-console@0.0.0-master.8e05d88/dist/bundle/light/servicetitan.f1fe089245e6be8be424.bundle.js:2:76067
|
|
205
|
+
at async Object.queryFn @ https://unpkg.servicetitan.com/@servicetitan/dispatch-pro-console@0.0.0-master.8e05d88/dist/bundle/light/main.64019af64e0ecf97d613.bundle.js:2:579977
|
|
206
|
+
`,
|
|
207
|
+
},
|
|
208
|
+
context: {
|
|
209
|
+
handlingStack: `
|
|
210
|
+
HandlingStack: console error
|
|
211
|
+
at console.e @ https://edge.fullstory.com/s/fs.js:2:34738
|
|
212
|
+
at pe.e.<computed> [as error] @ https://unpkg.servicetitan.com/@servicetitan/ti-assist@0.0.0-master.4f470d3/dist/bundle/light/vendor.61a280ed9f0a0810f96c.bundle.js:2:381984
|
|
213
|
+
at <anonymous> @ https://unpkg.servicetitan.com/@servicetitan/dispatch-pro-console@0.0.0-master.8e05d88/dist/bundle/light/servicetitan.f1fe089245e6be8be424.bundle.js:2:792340
|
|
214
|
+
at executeAction @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.8048a9efb0bf24bfbf33.bundle.js:2:89974
|
|
215
|
+
at setQueryState @ https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.8048a9efb0bf24bfbf33.bundle.js:2:89747
|
|
216
|
+
at <anonymous> @ https://unpkg.servicetitan.com/@servicetitan/dispatch-pro-console@0.0.0-master.8e05d88/dist/bundle/light/main.64019af64e0ecf97d613.bundle.js:2:1032854
|
|
217
|
+
at Set.forEach @ <anonymous>
|
|
218
|
+
at <anonymous> @ https://unpkg.servicetitan.com/@servicetitan/dispatch-pro-console@0.0.0-master.8e05d88/dist/bundle/light/main.64019af64e0ecf97d613.bundle.js:2:1032835
|
|
219
|
+
`,
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const hostErrorStringNoStack = {
|
|
224
|
+
error: {
|
|
225
|
+
message: '[Post loadGuide request failed: Unable to find global css after delay]',
|
|
226
|
+
},
|
|
227
|
+
context: {
|
|
228
|
+
handlingStack: `
|
|
229
|
+
HandlingStack: console error
|
|
230
|
+
at console.e @ https://edge.fullstory.com/s/fs.js:2:34738
|
|
231
|
+
at pe.e.<computed> [as error] @ https://unpkg.servicetitan.com/@servicetitan/ti-assist@0.0.0-master.4f470d3/dist/bundle/light/vendor.61a280ed9f0a0810f96c.bundle.js:2:381984
|
|
232
|
+
at Q0 @ https://cdn.pendo.io/agent/static/0359ffe9-310c-40b2-6e51-9ad6adde51e0/pendo.js:10:400978
|
|
233
|
+
at write @ https://cdn.pendo.io/agent/static/0359ffe9-310c-40b2-6e51-9ad6adde51e0/pendo.js:10:449241
|
|
234
|
+
at Ke @ https://cdn.pendo.io/agent/static/0359ffe9-310c-40b2-6e51-9ad6adde51e0/pendo.js:10:19797
|
|
235
|
+
at s @ https://cdn.pendo.io/agent/static/0359ffe9-310c-40b2-6e51-9ad6adde51e0/pendo.js:10:19998
|
|
236
|
+
at dispatch @ https://cdn.pendo.io/agent/static/0359ffe9-310c-40b2-6e51-9ad6adde51e0/pendo.js:10:79967
|
|
237
|
+
at Ke @ https://cdn.pendo.io/agent/static/0359ffe9-310c-40b2-6e51-9ad6adde51e0/pendo.js:10:19797
|
|
238
|
+
`,
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const mfeHandlingStack = `
|
|
243
|
+
Error:
|
|
244
|
+
at addAction @ https://unpkg.servicetitan.com/@servicetitan/task-hub@1.4.0/dist/bundle/light/main.2a1f0c9d8e7b6a5f4e3d.bundle.js:2:10432
|
|
245
|
+
at onClick @ https://unpkg.servicetitan.com/@servicetitan/task-hub@1.4.0/dist/bundle/light/main.2a1f0c9d8e7b6a5f4e3d.bundle.js:2:88120
|
|
246
|
+
`;
|
|
247
|
+
|
|
248
|
+
const mfeManualView = {
|
|
249
|
+
view: { name: '/task-hub/{id}' },
|
|
250
|
+
context: { handlingStack: mfeHandlingStack },
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
/*
|
|
254
|
+
* A long animation frame that ran a short host script and a longer MFE script. The MFE script
|
|
255
|
+
* is listed second, so `scripts[0]` would name the host.
|
|
256
|
+
*/
|
|
257
|
+
const mfeLongAnimationFrame = {
|
|
258
|
+
long_task: {
|
|
259
|
+
entry_type: 'long-animation-frame' as const,
|
|
260
|
+
duration: 180,
|
|
261
|
+
scripts: [
|
|
262
|
+
{
|
|
263
|
+
duration: 12,
|
|
264
|
+
source_url:
|
|
265
|
+
'https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js',
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
duration: 140,
|
|
269
|
+
source_url:
|
|
270
|
+
'https://unpkg.servicetitan.com/@servicetitan/task-hub@1.4.0/dist/bundle/light/main.2a1f0c9d8e7b6a5f4e3d.bundle.js',
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
const hostLongAnimationFrame = {
|
|
277
|
+
long_task: {
|
|
278
|
+
entry_type: 'long-animation-frame' as const,
|
|
279
|
+
duration: 120,
|
|
280
|
+
scripts: [
|
|
281
|
+
{
|
|
282
|
+
duration: 10,
|
|
283
|
+
source_url:
|
|
284
|
+
'https://unpkg.servicetitan.com/@servicetitan/task-hub@1.4.0/dist/bundle/light/main.2a1f0c9d8e7b6a5f4e3d.bundle.js',
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
duration: 95,
|
|
288
|
+
source_url:
|
|
289
|
+
'https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js',
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
const mfeLongAnimationFrameWithoutDurations = {
|
|
296
|
+
long_task: {
|
|
297
|
+
entry_type: 'long-animation-frame' as const,
|
|
298
|
+
duration: 60,
|
|
299
|
+
scripts: [
|
|
300
|
+
{
|
|
301
|
+
source_url:
|
|
302
|
+
'https://unpkg.servicetitan.com/@servicetitan/task-hub@1.4.0/dist/bundle/light/main.2a1f0c9d8e7b6a5f4e3d.bundle.js',
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
source_url:
|
|
306
|
+
'https://go.servicetitan.com/scripts/build/desktop/shared/vendor-core.bb011922ab999eb4885e.bundle.js',
|
|
307
|
+
},
|
|
308
|
+
],
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
const longAnimationFrameWithoutScripts = {
|
|
313
|
+
long_task: { entry_type: 'long-animation-frame' as const, duration: 60 },
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const legacyLongTask = {
|
|
317
|
+
long_task: { entry_type: 'long-task' as const, duration: 80 },
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const mfeActionCustom = {
|
|
321
|
+
context: {
|
|
322
|
+
handlingStack: `
|
|
323
|
+
Error:
|
|
324
|
+
at addAction @ https://unpkg.servicetitan.com/@servicetitan/global-search-bar@0.0.0-HEAD.c8fa2a6/dist/bundle/light/main.a7d8d964f5d244d802a4.bundle.js:2:582407
|
|
325
|
+
`,
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
|
|
102
329
|
type DeepPartial<T> = T extends object
|
|
103
330
|
? {
|
|
104
331
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
@@ -174,4 +401,138 @@ export const rumEvents: {
|
|
|
174
401
|
service: 'global-search-bar',
|
|
175
402
|
version: '0.0.0-HEAD.c8fa2a6',
|
|
176
403
|
},
|
|
404
|
+
{
|
|
405
|
+
event: {
|
|
406
|
+
type: 'resource',
|
|
407
|
+
resource: hostResourceUnpkgRequestHyphenatedPrerelease.resource,
|
|
408
|
+
},
|
|
409
|
+
context: hostResourceUnpkgRequestHyphenatedPrerelease.context,
|
|
410
|
+
title: 'host sends request to unpkg for a prerelease with a hyphen',
|
|
411
|
+
service: 'eh-my-tenants',
|
|
412
|
+
version: '5.0.1-master-rc-eb9d8e988.0',
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
event: {
|
|
416
|
+
type: 'resource',
|
|
417
|
+
resource: hostResourceUnpkgRequestBranchAndHash.resource,
|
|
418
|
+
},
|
|
419
|
+
context: hostResourceUnpkgRequestBranchAndHash.context,
|
|
420
|
+
title: 'host sends request to unpkg for a prerelease with a branch and a hash',
|
|
421
|
+
service: 'eh-ccpro',
|
|
422
|
+
version: '1.7.2-master-48be403.0',
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
event: {
|
|
426
|
+
type: 'resource',
|
|
427
|
+
resource: hostResourceUnpkgRequestBuildAndBranch.resource,
|
|
428
|
+
},
|
|
429
|
+
context: hostResourceUnpkgRequestBuildAndBranch.context,
|
|
430
|
+
title: 'host sends request to unpkg for a prerelease with a build number and a branch',
|
|
431
|
+
service: 'pricebook-enterprisehub',
|
|
432
|
+
version: '0.0.0-1.0.532-master',
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
event: {
|
|
436
|
+
type: 'resource',
|
|
437
|
+
resource: hostResourceUnpkgRequestGitDescribe.resource,
|
|
438
|
+
},
|
|
439
|
+
context: hostResourceUnpkgRequestGitDescribe.context,
|
|
440
|
+
title: 'host sends request to unpkg for a prerelease with a git describe suffix',
|
|
441
|
+
service: 'customer-portal-estimates',
|
|
442
|
+
version: '0.0.0-1.0.1773-mockSupportForCPContainers.g19c652d3a4',
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
event: {
|
|
446
|
+
type: 'error',
|
|
447
|
+
error: mfeErrorHyphenatedPrerelease.error,
|
|
448
|
+
},
|
|
449
|
+
context: mfeErrorHyphenatedPrerelease.context,
|
|
450
|
+
title: 'MFE error from a prerelease with a hyphen',
|
|
451
|
+
service: 'eh-user-management-client',
|
|
452
|
+
version: '10.0.9-master-rc-eb9d8e988.0',
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
event: {
|
|
456
|
+
type: 'error',
|
|
457
|
+
error: hostErrorRenderUnhandled.error,
|
|
458
|
+
},
|
|
459
|
+
context: hostErrorRenderUnhandled.context,
|
|
460
|
+
title: 'host render error is unhandled',
|
|
461
|
+
service: undefined,
|
|
462
|
+
version: undefined,
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
event: {
|
|
466
|
+
type: 'error',
|
|
467
|
+
error: hostErrorRenderConsole.error,
|
|
468
|
+
},
|
|
469
|
+
context: hostErrorRenderConsole.context,
|
|
470
|
+
title: 'host render error is logged through the ti-assist console wrapper',
|
|
471
|
+
service: undefined,
|
|
472
|
+
version: undefined,
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
event: {
|
|
476
|
+
type: 'error',
|
|
477
|
+
error: mfeErrorAxiosError401.error,
|
|
478
|
+
},
|
|
479
|
+
context: mfeErrorAxiosError401.context,
|
|
480
|
+
title: 'MFE request failed with status code 401 logged through the ti-assist console wrapper',
|
|
481
|
+
service: 'dispatch-pro-console',
|
|
482
|
+
version: '0.0.0-master.8e05d88',
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
event: {
|
|
486
|
+
type: 'error',
|
|
487
|
+
error: hostErrorStringNoStack.error,
|
|
488
|
+
},
|
|
489
|
+
context: hostErrorStringNoStack.context,
|
|
490
|
+
title: 'host logs a string with no error stack through the ti-assist console wrapper',
|
|
491
|
+
service: 'ti-assist',
|
|
492
|
+
version: '0.0.0-master.4f470d3',
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
event: { type: 'action' },
|
|
496
|
+
context: mfeActionCustom.context,
|
|
497
|
+
title: 'MFE adds a custom action',
|
|
498
|
+
service: 'global-search-bar',
|
|
499
|
+
version: '0.0.0-HEAD.c8fa2a6',
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
event: { type: 'view', view: mfeManualView.view },
|
|
503
|
+
context: mfeManualView.context,
|
|
504
|
+
title: 'MFE starts a manual view',
|
|
505
|
+
service: 'task-hub',
|
|
506
|
+
version: '1.4.0',
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
event: { type: 'long_task', long_task: mfeLongAnimationFrame.long_task },
|
|
510
|
+
title: 'long animation frame whose longest script is the MFE',
|
|
511
|
+
service: 'task-hub',
|
|
512
|
+
version: '1.4.0',
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
event: { type: 'long_task', long_task: hostLongAnimationFrame.long_task },
|
|
516
|
+
title: 'long animation frame whose longest script is the host',
|
|
517
|
+
service: undefined,
|
|
518
|
+
version: undefined,
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
event: { type: 'long_task', long_task: legacyLongTask.long_task },
|
|
522
|
+
title: 'legacy long task',
|
|
523
|
+
service: undefined,
|
|
524
|
+
version: undefined,
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
event: { type: 'long_task', long_task: mfeLongAnimationFrameWithoutDurations.long_task },
|
|
528
|
+
title: 'long animation frame whose scripts have no duration',
|
|
529
|
+
service: 'task-hub',
|
|
530
|
+
version: '1.4.0',
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
event: { type: 'long_task', long_task: longAnimationFrameWithoutScripts.long_task },
|
|
534
|
+
title: 'long animation frame with no scripts',
|
|
535
|
+
service: undefined,
|
|
536
|
+
version: undefined,
|
|
537
|
+
},
|
|
177
538
|
];
|
package/src/__mocks__/index.ts
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const mfeHost = (name: string, version: string): HTMLElement => {
|
|
2
|
+
const element = document.createElement(`${name}-abc123`);
|
|
3
|
+
element.setAttribute('data-mfe-name', name);
|
|
4
|
+
element.setAttribute('data-mfe-version', version);
|
|
5
|
+
element.attachShadow({ mode: 'open' });
|
|
6
|
+
return element;
|
|
7
|
+
};
|
|
@@ -4,6 +4,7 @@ import { buildAllowedTracingUrls } from '../build-allowed-tracing-urls';
|
|
|
4
4
|
import { buildBeforeSend } from '../build-before-send';
|
|
5
5
|
import { createImpl } from '../create-impl';
|
|
6
6
|
import { installDdRumGuard } from '../dd-rum-guard';
|
|
7
|
+
import { elementServiceRecorder } from '../element-service-recorder';
|
|
7
8
|
import { DATADOG_RUM_FOR_DEV, installDevConsole, isForceEnabled } from '../runtime-override';
|
|
8
9
|
import type { SharedImpl } from '../shared-impl';
|
|
9
10
|
import type { ApplicationConfig, InitRumOptions, State } from '../types';
|
|
@@ -12,6 +13,7 @@ jest.mock('@datadog/browser-rum');
|
|
|
12
13
|
jest.mock('../build-before-send');
|
|
13
14
|
jest.mock('../build-allowed-tracing-urls');
|
|
14
15
|
jest.mock('../dd-rum-guard');
|
|
16
|
+
jest.mock('../element-service-recorder');
|
|
15
17
|
jest.mock('../runtime-override', () => ({
|
|
16
18
|
...jest.requireActual('../runtime-override'),
|
|
17
19
|
isForceEnabled: jest.fn(),
|
|
@@ -167,6 +169,12 @@ describe(`[datadog-rum] ${createImpl.name}`, () => {
|
|
|
167
169
|
expect(installDdRumGuard).toHaveBeenCalledWith(datadogRum);
|
|
168
170
|
});
|
|
169
171
|
|
|
172
|
+
test('installs the element service recorder', () => {
|
|
173
|
+
subject();
|
|
174
|
+
|
|
175
|
+
expect(elementServiceRecorder.install).toHaveBeenCalled();
|
|
176
|
+
});
|
|
177
|
+
|
|
170
178
|
describe('when already called', () => {
|
|
171
179
|
beforeEach(() => {
|
|
172
180
|
subject();
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { mfeHost } from '../__mocks__';
|
|
2
|
+
import { createElementServiceRecorder } from '../element-service-recorder';
|
|
3
|
+
|
|
4
|
+
describe('[datadog-rum] createElementServiceRecorder', () => {
|
|
5
|
+
const version = '1.2.3';
|
|
6
|
+
|
|
7
|
+
const dispatchPointerUp = (target: HTMLElement) => {
|
|
8
|
+
const event = new MouseEvent('pointerup', { bubbles: true, composed: true });
|
|
9
|
+
target.dispatchEvent(event);
|
|
10
|
+
return event;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let recorder: ReturnType<typeof createElementServiceRecorder>;
|
|
14
|
+
let host: HTMLElement;
|
|
15
|
+
let button: HTMLElement;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
jest.clearAllMocks();
|
|
19
|
+
recorder = createElementServiceRecorder();
|
|
20
|
+
host = document.body.appendChild(mfeHost('servicetitan-task-hub', version));
|
|
21
|
+
button = host.shadowRoot!.appendChild(document.createElement('button'));
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
jest.restoreAllMocks();
|
|
26
|
+
document.body.innerHTML = '';
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('serviceFor', () => {
|
|
30
|
+
let event: Event;
|
|
31
|
+
|
|
32
|
+
beforeEach(() => (event = dispatchPointerUp(button)));
|
|
33
|
+
|
|
34
|
+
const subject = () => recorder.serviceFor(event);
|
|
35
|
+
|
|
36
|
+
test('returns the service of the retargeted target', () => {
|
|
37
|
+
expect(subject()).toEqual({ service: 'task-hub', version });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('with a target that is not an element', () => {
|
|
41
|
+
beforeEach(() => (event = { target: window } as unknown as Event));
|
|
42
|
+
|
|
43
|
+
test('returns undefined', () => {
|
|
44
|
+
expect(subject()).toBeUndefined();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('when the recorder is installed', () => {
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
jest.spyOn(window, 'addEventListener');
|
|
51
|
+
recorder.install();
|
|
52
|
+
event = dispatchPointerUp(button);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
afterEach(() => {
|
|
56
|
+
for (const args of jest.mocked(window.addEventListener).mock.calls) {
|
|
57
|
+
window.removeEventListener(...args);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('returns the service resolved at dispatch', () => {
|
|
62
|
+
expect(subject()).toEqual({ service: 'task-hub', version });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('when the MFE unmounts before enrichment', () => {
|
|
66
|
+
beforeEach(() => host.remove());
|
|
67
|
+
|
|
68
|
+
test('returns the service resolved at dispatch', () => {
|
|
69
|
+
expect(subject()).toEqual({ service: 'task-hub', version });
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe('with a target outside any MFE', () => {
|
|
74
|
+
let outside: HTMLElement;
|
|
75
|
+
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
outside = document.body.appendChild(document.createElement('div'));
|
|
78
|
+
event = dispatchPointerUp(outside);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('returns undefined', () => {
|
|
82
|
+
expect(subject()).toBeUndefined();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('when the target later moves into an MFE', () => {
|
|
86
|
+
beforeEach(() => host.appendChild(outside));
|
|
87
|
+
|
|
88
|
+
test('returns undefined', () => {
|
|
89
|
+
expect(subject()).toBeUndefined();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('install', () => {
|
|
97
|
+
beforeEach(() => jest.spyOn(window, 'addEventListener').mockImplementation(() => {}));
|
|
98
|
+
|
|
99
|
+
const subject = () => recorder.install();
|
|
100
|
+
|
|
101
|
+
test('adds a pointerup capture listener', () => {
|
|
102
|
+
subject();
|
|
103
|
+
|
|
104
|
+
expect(window.addEventListener).toHaveBeenCalledWith(
|
|
105
|
+
'pointerup',
|
|
106
|
+
expect.any(Function),
|
|
107
|
+
{
|
|
108
|
+
capture: true,
|
|
109
|
+
passive: true,
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('when already installed', () => {
|
|
115
|
+
beforeEach(() => {
|
|
116
|
+
subject();
|
|
117
|
+
jest.mocked(window.addEventListener).mockClear();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('adds no listener', () => {
|
|
121
|
+
subject();
|
|
122
|
+
|
|
123
|
+
expect(window.addEventListener).not.toHaveBeenCalled();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|