Skip to content

Commit 8c1ae3d

Browse files
committed
feat(checkout): CHECKOUT-0000 Filter out convertcart-related issues on Sentry
1 parent 53493a1 commit 8c1ae3d

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

packages/core/src/app/common/error/SentryErrorLogger.spec.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff 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

packages/core/src/app/common/error/SentryErrorLogger.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)