1
1
import type { Event } from '@sentry/types' ;
2
2
import { createStackParser , GLOBAL_OBJ } from '@sentry/utils' ;
3
3
4
- import { applyDebugMetadata } from '../../src/utils/prepareEvent' ;
4
+ import { applyDebugIds , applyDebugMeta } from '../../src/utils/prepareEvent' ;
5
5
6
- describe ( 'applyDebugMetadata ' , ( ) => {
6
+ describe ( 'applyDebugIds ' , ( ) => {
7
7
afterEach ( ( ) => {
8
8
GLOBAL_OBJ . _sentryDebugIds = undefined ;
9
9
} ) ;
10
10
11
- it ( ' should put debug source map images in debug_meta field' , ( ) => {
11
+ it ( " should put debug IDs into an event's stack frames" , ( ) => {
12
12
GLOBAL_OBJ . _sentryDebugIds = {
13
13
'filename1.js\nfilename1.js' : 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa' ,
14
14
'filename2.js\nfilename2.js' : 'bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbb' ,
@@ -34,35 +34,74 @@ describe('applyDebugMetadata', () => {
34
34
} ,
35
35
} ;
36
36
37
- applyDebugMetadata ( event , stackParser ) ;
37
+ applyDebugIds ( event , stackParser ) ;
38
38
39
- expect ( event . debug_meta ?. images ) . toContainEqual ( {
40
- type : 'sourcemap' ,
41
- code_file : 'filename1.js' ,
39
+ expect ( event . exception ?. values ?. [ 0 ] . stacktrace ?. frames ) . toContainEqual ( {
40
+ filename : 'filename1.js' ,
42
41
debug_id : 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa' ,
43
42
} ) ;
44
43
45
- expect ( event . debug_meta ?. images ) . toContainEqual ( {
46
- type : 'sourcemap' ,
47
- code_file : 'filename2.js' ,
44
+ expect ( event . exception ?. values ?. [ 0 ] . stacktrace ?. frames ) . toContainEqual ( {
45
+ filename : 'filename2.js' ,
48
46
debug_id : 'bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbb' ,
49
47
} ) ;
50
48
51
49
// expect not to contain an image for the stack frame that doesn't have a corresponding debug id
52
- expect ( event . debug_meta ?. images ) . not . toContainEqual (
50
+ expect ( event . exception ?. values ?. [ 0 ] . stacktrace ?. frames ) . not . toContainEqual (
53
51
expect . objectContaining ( {
54
- type : 'sourcemap ' ,
55
- code_file : 'filename3.js' ,
52
+ filename3 : 'filename3.js ' ,
53
+ debug_id : expect . any ( String ) ,
56
54
} ) ,
57
55
) ;
58
56
59
57
// expect not to contain an image for the debug id mapping that isn't contained in the stack trace
60
- expect ( event . debug_meta ?. images ) . not . toContainEqual (
58
+ expect ( event . exception ?. values ?. [ 0 ] . stacktrace ?. frames ) . not . toContainEqual (
61
59
expect . objectContaining ( {
62
- type : 'sourcemap' ,
63
- code_file : 'filename4.js' ,
60
+ filename3 : 'filename4.js' ,
64
61
debug_id : 'cccccccc-cccc-4ccc-cccc-cccccccccc' ,
65
62
} ) ,
66
63
) ;
67
64
} ) ;
68
65
} ) ;
66
+
67
+ describe ( 'applyDebugMeta' , ( ) => {
68
+ it ( "should move the debug IDs inside an event's stack frame into the debug_meta field" , ( ) => {
69
+ const event : Event = {
70
+ exception : {
71
+ values : [
72
+ {
73
+ stacktrace : {
74
+ frames : [
75
+ { filename : 'filename1.js' , debug_id : 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa' } ,
76
+ { filename : 'filename2.js' , debug_id : 'bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbb' } ,
77
+ { filename : 'filename1.js' , debug_id : 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa' } ,
78
+ { filename : 'filename3.js' } ,
79
+ ] ,
80
+ } ,
81
+ } ,
82
+ ] ,
83
+ } ,
84
+ } ;
85
+
86
+ applyDebugMeta ( event ) ;
87
+
88
+ expect ( event . exception ?. values ?. [ 0 ] . stacktrace ?. frames ) . toEqual ( [
89
+ { filename : 'filename1.js' } ,
90
+ { filename : 'filename2.js' } ,
91
+ { filename : 'filename1.js' } ,
92
+ { filename : 'filename3.js' } ,
93
+ ] ) ;
94
+
95
+ expect ( event . debug_meta ?. images ) . toContainEqual ( {
96
+ type : 'sourcemap' ,
97
+ code_file : 'filename1.js' ,
98
+ debug_id : 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa' ,
99
+ } ) ;
100
+
101
+ expect ( event . debug_meta ?. images ) . toContainEqual ( {
102
+ type : 'sourcemap' ,
103
+ code_file : 'filename2.js' ,
104
+ debug_id : 'bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbb' ,
105
+ } ) ;
106
+ } ) ;
107
+ } ) ;
0 commit comments