@@ -40,26 +40,32 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
40
40
} ;
41
41
42
42
// @ts -ignore replay event type
43
- expect ( handleGlobalEventListener ( replay ) ( replayEvent ) ) . toEqual ( {
43
+ expect ( handleGlobalEventListener ( replay ) ( replayEvent , { } ) ) . toEqual ( {
44
44
type : REPLAY_EVENT_NAME ,
45
45
} ) ;
46
46
} ) ;
47
47
48
48
it ( 'does not delete breadcrumbs from error and transaction events' , ( ) => {
49
49
expect (
50
- handleGlobalEventListener ( replay ) ( {
51
- breadcrumbs : [ { type : 'fakecrumb' } ] ,
52
- } ) ,
50
+ handleGlobalEventListener ( replay ) (
51
+ {
52
+ breadcrumbs : [ { type : 'fakecrumb' } ] ,
53
+ } ,
54
+ { } ,
55
+ ) ,
53
56
) . toEqual (
54
57
expect . objectContaining ( {
55
58
breadcrumbs : [ { type : 'fakecrumb' } ] ,
56
59
} ) ,
57
60
) ;
58
61
expect (
59
- handleGlobalEventListener ( replay ) ( {
60
- type : 'transaction' ,
61
- breadcrumbs : [ { type : 'fakecrumb' } ] ,
62
- } ) ,
62
+ handleGlobalEventListener ( replay ) (
63
+ {
64
+ type : 'transaction' ,
65
+ breadcrumbs : [ { type : 'fakecrumb' } ] ,
66
+ } ,
67
+ { } ,
68
+ ) ,
63
69
) . toEqual (
64
70
expect . objectContaining ( {
65
71
breadcrumbs : [ { type : 'fakecrumb' } ] ,
@@ -76,7 +82,7 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
76
82
tags : expect . not . objectContaining ( { replayId : expect . anything ( ) } ) ,
77
83
} ) ,
78
84
) ;
79
- expect ( handleGlobalEventListener ( replay ) ( error ) ) . toEqual (
85
+ expect ( handleGlobalEventListener ( replay ) ( error , { } ) ) . toEqual (
80
86
expect . objectContaining ( {
81
87
tags : expect . objectContaining ( { replayId : expect . any ( String ) } ) ,
82
88
} ) ,
@@ -102,9 +108,9 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
102
108
103
109
const client = getCurrentHub ( ) . getClient ( ) ! ;
104
110
105
- handleGlobalEventListener ( replay ) ( error1 ) ;
106
- handleGlobalEventListener ( replay ) ( error2 ) ;
107
- handleGlobalEventListener ( replay ) ( error3 ) ;
111
+ handleGlobalEventListener ( replay ) ( error1 , { } ) ;
112
+ handleGlobalEventListener ( replay ) ( error2 , { } ) ;
113
+ handleGlobalEventListener ( replay ) ( error3 , { } ) ;
108
114
109
115
client . recordDroppedEvent ( 'before_send' , 'error' , { event_id : 'err2' } ) ;
110
116
@@ -125,7 +131,7 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
125
131
tags : expect . objectContaining ( { replayId : expect . any ( String ) } ) ,
126
132
} ) ,
127
133
) ;
128
- expect ( handleGlobalEventListener ( replay ) ( error ) ) . toEqual (
134
+ expect ( handleGlobalEventListener ( replay ) ( error , { } ) ) . toEqual (
129
135
expect . objectContaining ( {
130
136
tags : expect . objectContaining ( { replayId : expect . any ( String ) } ) ,
131
137
} ) ,
@@ -166,7 +172,7 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
166
172
event_id : 'ff1616b1e13744c6964281349aecc82a' ,
167
173
} ;
168
174
169
- expect ( handleGlobalEventListener ( replay ) ( errorEvent ) ) . toEqual ( errorEvent ) ;
175
+ expect ( handleGlobalEventListener ( replay ) ( errorEvent , { } ) ) . toEqual ( errorEvent ) ;
170
176
} ) ;
171
177
172
178
it ( 'skips rrweb internal errors' , ( ) => {
@@ -204,7 +210,87 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
204
210
event_id : 'ff1616b1e13744c6964281349aecc82a' ,
205
211
} ;
206
212
207
- expect ( handleGlobalEventListener ( replay ) ( errorEvent ) ) . toEqual ( null ) ;
213
+ expect ( handleGlobalEventListener ( replay ) ( errorEvent , { } ) ) . toEqual ( null ) ;
214
+ } ) ;
215
+
216
+ it ( 'skips exception with __rrweb__ set' , ( ) => {
217
+ const errorEvent : Event = {
218
+ exception : {
219
+ values : [
220
+ {
221
+ type : 'TypeError' ,
222
+ value : "Cannot read properties of undefined (reading 'contains')" ,
223
+ stacktrace : {
224
+ frames : [
225
+ {
226
+ filename : 'scrambled.js' ,
227
+ function : 'MutationBuffer.processMutations' ,
228
+ in_app : true ,
229
+ lineno : 101 ,
230
+ colno : 23 ,
231
+ } ,
232
+ {
233
+ filename : '<anonymous>' ,
234
+ function : 'Array.forEach' ,
235
+ in_app : true ,
236
+ } ,
237
+ ] ,
238
+ } ,
239
+ mechanism : {
240
+ type : 'generic' ,
241
+ handled : true ,
242
+ } ,
243
+ } ,
244
+ ] ,
245
+ } ,
246
+ level : 'error' ,
247
+ event_id : 'ff1616b1e13744c6964281349aecc82a' ,
248
+ } ;
249
+
250
+ const originalException = new window . Error ( 'some exception' ) ;
251
+ // @ts -ignore this could be set by rrweb
252
+ originalException . __rrweb__ = true ;
253
+
254
+ expect ( handleGlobalEventListener ( replay ) ( errorEvent , { originalException } ) ) . toEqual ( null ) ;
255
+ } ) ;
256
+
257
+ it ( 'handles string exceptions' , ( ) => {
258
+ const errorEvent : Event = {
259
+ exception : {
260
+ values : [
261
+ {
262
+ type : 'TypeError' ,
263
+ value : "Cannot read properties of undefined (reading 'contains')" ,
264
+ stacktrace : {
265
+ frames : [
266
+ {
267
+ filename : 'scrambled.js' ,
268
+ function : 'MutationBuffer.processMutations' ,
269
+ in_app : true ,
270
+ lineno : 101 ,
271
+ colno : 23 ,
272
+ } ,
273
+ {
274
+ filename : '<anonymous>' ,
275
+ function : 'Array.forEach' ,
276
+ in_app : true ,
277
+ } ,
278
+ ] ,
279
+ } ,
280
+ mechanism : {
281
+ type : 'generic' ,
282
+ handled : true ,
283
+ } ,
284
+ } ,
285
+ ] ,
286
+ } ,
287
+ level : 'error' ,
288
+ event_id : 'ff1616b1e13744c6964281349aecc82a' ,
289
+ } ;
290
+
291
+ const originalException = 'some string exception' ;
292
+
293
+ expect ( handleGlobalEventListener ( replay ) ( errorEvent , { originalException } ) ) . toEqual ( errorEvent ) ;
208
294
} ) ;
209
295
210
296
it ( 'does not skip rrweb internal errors with _experiments.captureExceptions' , ( ) => {
@@ -244,7 +330,7 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
244
330
245
331
replay . getOptions ( ) . _experiments = { captureExceptions : true } ;
246
332
247
- expect ( handleGlobalEventListener ( replay ) ( errorEvent ) ) . toEqual ( errorEvent ) ;
333
+ expect ( handleGlobalEventListener ( replay ) ( errorEvent , { } ) ) . toEqual ( errorEvent ) ;
248
334
} ) ;
249
335
250
336
it ( 'does not skip non-rrweb errors when no stacktrace exists' , ( ) => {
@@ -268,7 +354,7 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
268
354
event_id : 'ff1616b1e13744c6964281349aecc82a' ,
269
355
} ;
270
356
271
- expect ( handleGlobalEventListener ( replay ) ( errorEvent ) ) . toEqual ( errorEvent ) ;
357
+ expect ( handleGlobalEventListener ( replay ) ( errorEvent , { } ) ) . toEqual ( errorEvent ) ;
272
358
} ) ;
273
359
274
360
it ( 'does not skip non-rrweb errors when no exception' , ( ) => {
@@ -278,6 +364,6 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
278
364
event_id : 'ff1616b1e13744c6964281349aecc82a' ,
279
365
} ;
280
366
281
- expect ( handleGlobalEventListener ( replay ) ( errorEvent ) ) . toEqual ( errorEvent ) ;
367
+ expect ( handleGlobalEventListener ( replay ) ( errorEvent , { } ) ) . toEqual ( errorEvent ) ;
282
368
} ) ;
283
369
} ) ;
0 commit comments