Skip to content

Full Toolkit for Next-Level Domain Analysis

Log User Agent to BigQuery 📜

Felix Wotschofsky46d95a79a600
diff --git a/SETUP.md b/SETUP.md
index d24e7f8..53fa588 100644
--- a/SETUP.md
+++ b/SETUP.md
@@ -66,6 +66,13 @@ Use the following schema for creating the dataset:
"description": null,
"fields": []
},
+ {
+ "name": "userAgent",
+ "mode": "NULLABLE",
+ "type": "STRING",
+ "description": null,
+ "fields": []
+ },
{
"name": "isBot",
"mode": "NULLABLE",
diff --git a/app/lookup/[domain]/layout.tsx b/app/lookup/[domain]/layout.tsx
index ab272f3..22bb7d0 100644
--- a/app/lookup/[domain]/layout.tsx
+++ b/app/lookup/[domain]/layout.tsx
@@ -47,8 +47,8 @@ const LookupLayout: FC<LookupLayoutProps> = ({
}
const ip = getVisitorIp(headers());
- const { isBot } = isUserBot(headers());
- recordLookup({ domain, ip, isBot });
+ const { isBot, userAgent } = isUserBot(headers());
+ recordLookup({ domain, ip, userAgent, isBot });
return (
<>
diff --git a/lib/search.ts b/lib/search.ts
index c355dfa..f45c133 100644
--- a/lib/search.ts
+++ b/lib/search.ts
@@ -5,6 +5,7 @@ import { getBaseDomain } from '@/lib/utils';
type LookupLogPayload = {
domain: string;
ip: string;
+ userAgent: string | null;
isBot: boolean;
};
@@ -25,6 +26,7 @@ export const recordLookup = async (payload: LookupLogPayload) => {
baseDomain,
timestamp: Math.floor(new Date().getTime() / 1000),
ip: payload.ip,
+ userAgent: payload.userAgent,
isBot: payload.isBot,
},
],