Skip to content

Commit 38ee808

Browse files
committed
fix: remove script error from errors tracked
1 parent 4c9851a commit 38ee808

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

apps/basket/src/routes/basket.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { detectBot, parseUserAgent } from '../utils/user-agent';
2525
import {
2626
sanitizeString,
2727
VALIDATION_LIMITS,
28+
FILTERED_ERROR_MESSAGES,
2829
validatePayloadSize,
2930
validatePerformanceMetric,
3031
validateSessionId,
@@ -170,6 +171,12 @@ async function insertError(
170171
userAgent: string,
171172
ip: string
172173
): Promise<void> {
174+
const payload = errorData.payload;
175+
176+
if (FILTERED_ERROR_MESSAGES.has(payload.message)) {
177+
return;
178+
}
179+
173180
let eventId = sanitizeString(
174181
errorData.payload.eventId,
175182
VALIDATION_LIMITS.SHORT_STRING_MAX_LENGTH
@@ -182,8 +189,6 @@ async function insertError(
182189
if (await checkDuplicate(eventId, 'error')) {
183190
return;
184191
}
185-
186-
const payload = errorData.payload;
187192
const now = Date.now();
188193

189194
const { anonymizedIP, country, region } = await getGeo(ip);

apps/basket/src/utils/validation.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export const VALIDATION_LIMITS = {
3636
EVENT_ID_MAX_LENGTH: 512,
3737
} as const;
3838

39+
export const FILTERED_ERROR_MESSAGES = new Set([
40+
'Script error.',
41+
'Non-Error promise rejection captured',
42+
'ResizeObserver loop limit exceeded',
43+
'Loading chunk',
44+
'ChunkLoadError',
45+
]);
46+
3947
export const SAFE_HEADERS = new Set([
4048
'user-agent',
4149
'referer',

0 commit comments

Comments
 (0)