understand why bot events not working

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-03-01 09:41:39 +01:00
parent 753df48296
commit 0d5a7a4388

View File

@@ -1,4 +1,5 @@
import { isBot } from '@/bots'; import { isBot } from '@/bots';
import { logInfo } from '@/utils/logger';
import { getClientIp, parseIp } from '@/utils/parseIp'; import { getClientIp, parseIp } from '@/utils/parseIp';
import { getReferrerWithQuery, parseReferrer } from '@/utils/parseReferrer'; import { getReferrerWithQuery, parseReferrer } from '@/utils/parseReferrer';
import { isUserAgentSet, parseUserAgent } from '@/utils/parseUserAgent'; import { isUserAgentSet, parseUserAgent } from '@/utils/parseUserAgent';
@@ -156,11 +157,16 @@ export async function postEvent(
const bot = isBot(ua); const bot = isBot(ua);
if (bot) { if (bot) {
await createBotEvent({ request.log.info({ bot, ua }, 'bot detected 2');
...bot, try {
projectId, await createBotEvent({
createdAt: new Date(body.timestamp), ...bot,
}); projectId,
createdAt: new Date(body.timestamp),
});
} catch (e) {
request.log.error(e, 'bot detected 2 failed');
}
return reply.status(200).send(''); return reply.status(200).send('');
} }