@@ -27,7 +27,7 @@ export class Dedupe implements Integration {
2727      if  ( self )  { 
2828        // Juuust in case something goes wrong 
2929        try  { 
30-           if  ( self . _shouldDropEvent ( currentEvent ,  self . _previousEvent ) )  { 
30+           if  ( _shouldDropEvent ( currentEvent ,  self . _previousEvent ) )  { 
3131            logger . warn ( `Event dropped due to being a duplicate of previously captured event.` ) ; 
3232            return  null ; 
3333          } 
@@ -40,164 +40,164 @@ export class Dedupe implements Integration {
4040      return  currentEvent ; 
4141    } ) ; 
4242  } 
43+ } 
4344
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 )  { 
5848    return  false ; 
5949  } 
6050
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+   } 
6554
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+   } 
7058
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+ } 
7561
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 ; 
7966
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+   } 
8371
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+   } 
8776
88-     return  true ; 
77+   if  ( currentMessage  !==  previousMessage )  { 
78+     return  false ; 
8979  } 
9080
91-   /** JSDoc */ 
92-   private   _getFramesFromEvent ( event :  Event ) :  StackFrame [ ]   |   undefined   { 
93-      const   exception   =   event . exception ; 
81+   if   ( ! _isSameFingerprint ( currentEvent ,   previousEvent ) )   { 
82+      return   false ; 
83+   } 
9484
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 ; 
10687  } 
10788
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+ } 
11291
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 ) ; 
11796
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+   } 
122100
123-     currentFrames  =  currentFrames  as  StackFrame [ ] ; 
124-     previousFrames  =  previousFrames  as  StackFrame [ ] ; 
101+   if  ( previousException . type  !==  currentException . type  ||  previousException . value  !==  currentException . value )  { 
102+     return  false ; 
103+   } 
125104
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+   } 
130108
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 ) ; 
145120
121+   // If neither event has a stacktrace, they are assumed to be the same 
122+   if  ( ! currentFrames  &&  ! previousFrames )  { 
146123    return  true ; 
147124  } 
148125
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 ; 
152129  } 
153130
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 [ ] ; 
158133
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+   } 
162138
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+     )  { 
164150      return  false ; 
165151    } 
152+   } 
166153
167-     if  ( ! this . _isSameFingerprint ( currentEvent ,  previousEvent ) )  { 
168-       return  false ; 
169-     } 
154+   return  true ; 
155+ } 
170156
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 ; 
174161
162+   // If neither event has a fingerprint, they are assumed to be the same 
163+   if  ( ! currentFingerprint  &&  ! previousFingerprint )  { 
175164    return  true ; 
176165  } 
177166
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 [ ] ; 
182174
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+ } 
187182
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+ } 
192187
193-     currentFingerprint  =  currentFingerprint  as  string [ ] ; 
194-     previousFingerprint  =  previousFingerprint  as  string [ ] ; 
188+ /** JSDoc */ 
189+ function  _getFramesFromEvent ( event : Event ) : StackFrame [ ]  |  undefined  { 
190+   const  exception  =  event . exception ; 
195191
196-      // Otherwise, compare the two 
192+   if   ( exception )   { 
197193    try  { 
198-       return  ! ! ( currentFingerprint . join ( '' )  ===  previousFingerprint . join ( '' ) ) ; 
194+       // @ts -ignore Object could be undefined 
195+       return  exception . values [ 0 ] . stacktrace . frames ; 
199196    }  catch  ( _oO )  { 
200-       return  false ; 
197+       return  undefined ; 
201198    } 
199+   }  else  if  ( event . stacktrace )  { 
200+     return  event . stacktrace . frames ; 
202201  } 
202+   return  undefined ; 
203203} 
0 commit comments