@@ -27,7 +27,7 @@ export class Dedupe implements Integration {
27
27
if ( self ) {
28
28
// Juuust in case something goes wrong
29
29
try {
30
- if ( self . _shouldDropEvent ( currentEvent , self . _previousEvent ) ) {
30
+ if ( _shouldDropEvent ( currentEvent , self . _previousEvent ) ) {
31
31
logger . warn ( `Event dropped due to being a duplicate of previously captured event.` ) ;
32
32
return null ;
33
33
}
@@ -40,164 +40,164 @@ export class Dedupe implements Integration {
40
40
return currentEvent ;
41
41
} ) ;
42
42
}
43
+ }
43
44
44
- /** JSDoc */
45
- private _shouldDropEvent ( currentEvent : Event , previousEvent ?: Event ) : boolean {
46
- if ( ! previousEvent ) {
47
- return false ;
48
- }
49
-
50
- if ( this . _isSameMessageEvent ( currentEvent , previousEvent ) ) {
51
- return true ;
52
- }
53
-
54
- if ( this . _isSameExceptionEvent ( currentEvent , previousEvent ) ) {
55
- return true ;
56
- }
57
-
45
+ /** JSDoc */
46
+ function _shouldDropEvent ( currentEvent : Event , previousEvent ?: Event ) : boolean {
47
+ if ( ! previousEvent ) {
58
48
return false ;
59
49
}
60
50
61
- /** JSDoc */
62
- private _isSameMessageEvent ( currentEvent : Event , previousEvent : Event ) : boolean {
63
- const currentMessage = currentEvent . message ;
64
- const previousMessage = previousEvent . message ;
51
+ if ( _isSameMessageEvent ( currentEvent , previousEvent ) ) {
52
+ return true ;
53
+ }
65
54
66
- // If neither event has a message property, they were both exceptions, so bail out
67
- if ( ! currentMessage && ! previousMessage ) {
68
- return false ;
69
- }
55
+ if ( _isSameExceptionEvent ( currentEvent , previousEvent ) ) {
56
+ return true ;
57
+ }
70
58
71
- // If only one event has a stacktrace, but not the other one, they are not the same
72
- if ( ( currentMessage && ! previousMessage ) || ( ! currentMessage && previousMessage ) ) {
73
- return false ;
74
- }
59
+ return false ;
60
+ }
75
61
76
- if ( currentMessage !== previousMessage ) {
77
- return false ;
78
- }
62
+ /** JSDoc */
63
+ function _isSameMessageEvent ( currentEvent : Event , previousEvent : Event ) : boolean {
64
+ const currentMessage = currentEvent . message ;
65
+ const previousMessage = previousEvent . message ;
79
66
80
- if ( ! this . _isSameFingerprint ( currentEvent , previousEvent ) ) {
81
- return false ;
82
- }
67
+ // If neither event has a message property, they were both exceptions, so bail out
68
+ if ( ! currentMessage && ! previousMessage ) {
69
+ return false ;
70
+ }
83
71
84
- if ( ! this . _isSameStacktrace ( currentEvent , previousEvent ) ) {
85
- return false ;
86
- }
72
+ // If only one event has a stacktrace, but not the other one, they are not the same
73
+ if ( ( currentMessage && ! previousMessage ) || ( ! currentMessage && previousMessage ) ) {
74
+ return false ;
75
+ }
87
76
88
- return true ;
77
+ if ( currentMessage !== previousMessage ) {
78
+ return false ;
89
79
}
90
80
91
- /** JSDoc */
92
- private _getFramesFromEvent ( event : Event ) : StackFrame [ ] | undefined {
93
- const exception = event . exception ;
81
+ if ( ! _isSameFingerprint ( currentEvent , previousEvent ) ) {
82
+ return false ;
83
+ }
94
84
95
- if ( exception ) {
96
- try {
97
- // @ts -ignore Object could be undefined
98
- return exception . values [ 0 ] . stacktrace . frames ;
99
- } catch ( _oO ) {
100
- return undefined ;
101
- }
102
- } else if ( event . stacktrace ) {
103
- return event . stacktrace . frames ;
104
- }
105
- return undefined ;
85
+ if ( ! _isSameStacktrace ( currentEvent , previousEvent ) ) {
86
+ return false ;
106
87
}
107
88
108
- /** JSDoc */
109
- private _isSameStacktrace ( currentEvent : Event , previousEvent : Event ) : boolean {
110
- let currentFrames = this . _getFramesFromEvent ( currentEvent ) ;
111
- let previousFrames = this . _getFramesFromEvent ( previousEvent ) ;
89
+ return true ;
90
+ }
112
91
113
- // If neither event has a stacktrace, they are assumed to be the same
114
- if ( ! currentFrames && ! previousFrames ) {
115
- return true ;
116
- }
92
+ /** JSDoc */
93
+ function _isSameExceptionEvent ( currentEvent : Event , previousEvent : Event ) : boolean {
94
+ const previousException = _getExceptionFromEvent ( previousEvent ) ;
95
+ const currentException = _getExceptionFromEvent ( currentEvent ) ;
117
96
118
- // If only one event has a stacktrace, but not the other one, they are not the same
119
- if ( ( currentFrames && ! previousFrames ) || ( ! currentFrames && previousFrames ) ) {
120
- return false ;
121
- }
97
+ if ( ! previousException || ! currentException ) {
98
+ return false ;
99
+ }
122
100
123
- currentFrames = currentFrames as StackFrame [ ] ;
124
- previousFrames = previousFrames as StackFrame [ ] ;
101
+ if ( previousException . type !== currentException . type || previousException . value !== currentException . value ) {
102
+ return false ;
103
+ }
125
104
126
- // If number of frames differ, they are not the same
127
- if ( previousFrames . length !== currentFrames . length ) {
128
- return false ;
129
- }
105
+ if ( ! _isSameFingerprint ( currentEvent , previousEvent ) ) {
106
+ return false ;
107
+ }
130
108
131
- // Otherwise, compare the two
132
- for ( let i = 0 ; i < previousFrames . length ; i ++ ) {
133
- const frameA = previousFrames [ i ] ;
134
- const frameB = currentFrames [ i ] ;
135
-
136
- if (
137
- frameA . filename !== frameB . filename ||
138
- frameA . lineno !== frameB . lineno ||
139
- frameA . colno !== frameB . colno ||
140
- frameA . function !== frameB . function
141
- ) {
142
- return false ;
143
- }
144
- }
109
+ if ( ! _isSameStacktrace ( currentEvent , previousEvent ) ) {
110
+ return false ;
111
+ }
112
+
113
+ return true ;
114
+ }
115
+
116
+ /** JSDoc */
117
+ function _isSameStacktrace ( currentEvent : Event , previousEvent : Event ) : boolean {
118
+ let currentFrames = _getFramesFromEvent ( currentEvent ) ;
119
+ let previousFrames = _getFramesFromEvent ( previousEvent ) ;
145
120
121
+ // If neither event has a stacktrace, they are assumed to be the same
122
+ if ( ! currentFrames && ! previousFrames ) {
146
123
return true ;
147
124
}
148
125
149
- /** JSDoc */
150
- private _getExceptionFromEvent ( event : Event ) : Exception | undefined {
151
- return event . exception && event . exception . values && event . exception . values [ 0 ] ;
126
+ // If only one event has a stacktrace, but not the other one, they are not the same
127
+ if ( ( currentFrames && ! previousFrames ) || ( ! currentFrames && previousFrames ) ) {
128
+ return false ;
152
129
}
153
130
154
- /** JSDoc */
155
- private _isSameExceptionEvent ( currentEvent : Event , previousEvent : Event ) : boolean {
156
- const previousException = this . _getExceptionFromEvent ( previousEvent ) ;
157
- const currentException = this . _getExceptionFromEvent ( currentEvent ) ;
131
+ currentFrames = currentFrames as StackFrame [ ] ;
132
+ previousFrames = previousFrames as StackFrame [ ] ;
158
133
159
- if ( ! previousException || ! currentException ) {
160
- return false ;
161
- }
134
+ // If number of frames differ, they are not the same
135
+ if ( previousFrames . length !== currentFrames . length ) {
136
+ return false ;
137
+ }
162
138
163
- if ( previousException . type !== currentException . type || previousException . value !== currentException . value ) {
139
+ // Otherwise, compare the two
140
+ for ( let i = 0 ; i < previousFrames . length ; i ++ ) {
141
+ const frameA = previousFrames [ i ] ;
142
+ const frameB = currentFrames [ i ] ;
143
+
144
+ if (
145
+ frameA . filename !== frameB . filename ||
146
+ frameA . lineno !== frameB . lineno ||
147
+ frameA . colno !== frameB . colno ||
148
+ frameA . function !== frameB . function
149
+ ) {
164
150
return false ;
165
151
}
152
+ }
166
153
167
- if ( ! this . _isSameFingerprint ( currentEvent , previousEvent ) ) {
168
- return false ;
169
- }
154
+ return true ;
155
+ }
170
156
171
- if ( ! this . _isSameStacktrace ( currentEvent , previousEvent ) ) {
172
- return false ;
173
- }
157
+ /** JSDoc */
158
+ function _isSameFingerprint ( currentEvent : Event , previousEvent : Event ) : boolean {
159
+ let currentFingerprint = currentEvent . fingerprint ;
160
+ let previousFingerprint = previousEvent . fingerprint ;
174
161
162
+ // If neither event has a fingerprint, they are assumed to be the same
163
+ if ( ! currentFingerprint && ! previousFingerprint ) {
175
164
return true ;
176
165
}
177
166
178
- /** JSDoc */
179
- private _isSameFingerprint ( currentEvent : Event , previousEvent : Event ) : boolean {
180
- let currentFingerprint = currentEvent . fingerprint ;
181
- let previousFingerprint = previousEvent . fingerprint ;
167
+ // If only one event has a fingerprint, but not the other one, they are not the same
168
+ if ( ( currentFingerprint && ! previousFingerprint ) || ( ! currentFingerprint && previousFingerprint ) ) {
169
+ return false ;
170
+ }
171
+
172
+ currentFingerprint = currentFingerprint as string [ ] ;
173
+ previousFingerprint = previousFingerprint as string [ ] ;
182
174
183
- // If neither event has a fingerprint, they are assumed to be the same
184
- if ( ! currentFingerprint && ! previousFingerprint ) {
185
- return true ;
186
- }
175
+ // Otherwise, compare the two
176
+ try {
177
+ return ! ! ( currentFingerprint . join ( '' ) === previousFingerprint . join ( '' ) ) ;
178
+ } catch ( _oO ) {
179
+ return false ;
180
+ }
181
+ }
187
182
188
- // If only one event has a fingerprint, but not the other one, they are not the same
189
- if ( ( currentFingerprint && ! previousFingerprint ) || ( ! currentFingerprint && previousFingerprint ) ) {
190
- return false ;
191
- }
183
+ /** JSDoc */
184
+ function _getExceptionFromEvent ( event : Event ) : Exception | undefined {
185
+ return event . exception && event . exception . values && event . exception . values [ 0 ] ;
186
+ }
192
187
193
- currentFingerprint = currentFingerprint as string [ ] ;
194
- previousFingerprint = previousFingerprint as string [ ] ;
188
+ /** JSDoc */
189
+ function _getFramesFromEvent ( event : Event ) : StackFrame [ ] | undefined {
190
+ const exception = event . exception ;
195
191
196
- // Otherwise, compare the two
192
+ if ( exception ) {
197
193
try {
198
- return ! ! ( currentFingerprint . join ( '' ) === previousFingerprint . join ( '' ) ) ;
194
+ // @ts -ignore Object could be undefined
195
+ return exception . values [ 0 ] . stacktrace . frames ;
199
196
} catch ( _oO ) {
200
- return false ;
197
+ return undefined ;
201
198
}
199
+ } else if ( event . stacktrace ) {
200
+ return event . stacktrace . frames ;
202
201
}
202
+ return undefined ;
203
203
}
0 commit comments