feat(geo): make geo a package instead of service (#161)

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-06-06 05:56:54 +02:00
committed by GitHub
parent f59bcfba3c
commit 34414e1d3e
24 changed files with 677 additions and 112 deletions

View File

@@ -1,10 +1,11 @@
import { getClientIp, parseIp } from '@/utils/parse-ip';
import { getClientIp } from '@/utils/get-client-ip';
import type { FastifyReply, FastifyRequest } from 'fastify';
import { assocPath, pathOr } from 'ramda';
import { checkDuplicatedEvent, isDuplicatedEvent } from '@/utils/deduplicate';
import { parseUserAgent } from '@openpanel/common/server';
import { getProfileById, upsertProfile } from '@openpanel/db';
import { getGeoLocation } from '@openpanel/geo';
import type {
IncrementProfilePayload,
UpdateProfilePayload,
@@ -24,7 +25,7 @@ export async function updateProfile(
const ip = getClientIp(request)!;
const ua = request.headers['user-agent']!;
const uaInfo = parseUserAgent(ua, properties);
const geo = await parseIp(ip);
const geo = await getGeoLocation(ip);
if (
await checkDuplicatedEvent({