File tree Expand file tree Collapse file tree 2 files changed +68
-0
lines changed
packages/core/src/app/common/error Expand file tree Collapse file tree 2 files changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,68 @@ describe('SentryErrorLogger', () => {
6565 expect ( clientOptions . sampleRate ) . toBe ( 0.123 ) ;
6666 } ) ;
6767
68+ it ( 'does not log exception event if it relates to convertcart' , ( ) => {
69+ new SentryErrorLogger ( config ) ;
70+
71+ const clientOptions : BrowserOptions = ( init as jest . Mock ) . mock . calls [ 0 ] [ 0 ] ;
72+ /* eslint-disable @typescript-eslint/naming-convention */
73+ const event = {
74+ breadcrumbs : [
75+ {
76+ timestamp : 1667952544.208 ,
77+ category : 'fetch' ,
78+ data : {
79+ method : 'POST' ,
80+ url : 'https://dc4.convertcart.com/event/v3/94892041/123.123' ,
81+ status_code : 200 ,
82+ } ,
83+ type : 'http' ,
84+ } ,
85+ {
86+ timestamp : 1667952544.549 ,
87+ category : 'fetch' ,
88+ data : {
89+ method : 'GET' ,
90+ url : '/api/storefront/checkouts/abcdefg' ,
91+ status_code : 200 ,
92+ } ,
93+ type : 'http' ,
94+ } ,
95+ ] ,
96+ exception : {
97+ values : [
98+ {
99+ type : 'TypeError' ,
100+ value : "Cannot read properties of null (reading 'setAttribute')" ,
101+ stacktrace : {
102+ frames : [
103+ {
104+ filename : 'app:///608-12345.js' ,
105+ function : 'u' ,
106+ in_app : true ,
107+ lineno : 1 ,
108+ colno : 10602 ,
109+ } ,
110+ ] ,
111+ } ,
112+ mechanism : {
113+ type : 'instrument' ,
114+ handled : true ,
115+ data : {
116+ function : 'setInterval' ,
117+ } ,
118+ } ,
119+ } ,
120+ ] ,
121+ } ,
122+ } ;
123+ /* eslint-enable @typescript-eslint/naming-convention */
124+ const hint = { originalException : new Error ( 'Unexpected error' ) } ;
125+
126+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
127+ expect ( clientOptions . beforeSend ! ( event , hint ) ) . toBeNull ( ) ;
128+ } ) ;
129+
68130 it ( 'does not log exception event if it does not contain stacktrace' , ( ) => {
69131 new SentryErrorLogger ( config ) ;
70132
Original file line number Diff line number Diff line change @@ -135,6 +135,12 @@ export default class SentryErrorLogger implements ErrorLogger {
135135 }
136136
137137 private handleBeforeSend : ( event : Event , hint ?: EventHint ) => Event | null = ( event , hint ) => {
138+ if (
139+ event . breadcrumbs ?. filter ( ( breadcrumb ) => breadcrumb . data ?. url . includes ( 'convertcart' ) )
140+ ) {
141+ return null ;
142+ }
143+
138144 if ( event . exception ) {
139145 if (
140146 ! this . shouldReportExceptions (
You can’t perform that action at this time.
0 commit comments