Skip to content

Commit b6f9b80

Browse files
committed
fix: dont charge for errors
1 parent 38ee808 commit b6f9b80

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

apps/basket/src/routes/basket.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,6 @@ async function insertError(
171171
userAgent: string,
172172
ip: string
173173
): Promise<void> {
174-
const payload = errorData.payload;
175-
176-
if (FILTERED_ERROR_MESSAGES.has(payload.message)) {
177-
return;
178-
}
179-
180174
let eventId = sanitizeString(
181175
errorData.payload.eventId,
182176
VALIDATION_LIMITS.SHORT_STRING_MAX_LENGTH
@@ -189,6 +183,8 @@ async function insertError(
189183
if (await checkDuplicate(eventId, 'error')) {
190184
return;
191185
}
186+
187+
const payload = errorData.payload;
192188
const now = Date.now();
193189

194190
const { anonymizedIP, country, region } = await getGeo(ip);
@@ -725,7 +721,10 @@ const app = new Elysia()
725721
}
726722

727723
if (eventType === 'error') {
728-
// Check for bots before processing error events
724+
if (FILTERED_ERROR_MESSAGES.has(body.payload?.message)) {
725+
return { status: 'ignored', type: 'error', reason: 'filtered_message' };
726+
}
727+
729728
const botError = await checkForBot(
730729
request,
731730
body,
@@ -978,6 +977,15 @@ const app = new Elysia()
978977
}
979978
}
980979
if (eventType === 'error') {
980+
// Skip filtered error messages as they provide no useful information
981+
if (FILTERED_ERROR_MESSAGES.has(event.payload?.message)) {
982+
return {
983+
status: 'ignored',
984+
type: 'error',
985+
reason: 'filtered_message',
986+
};
987+
}
988+
981989
// Check for bots before processing error events
982990
const botError = await checkForBot(
983991
request,

0 commit comments

Comments
 (0)