From adc8b90450354a1d532ca291c59d6893d83c2577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Wed, 7 Aug 2024 22:59:03 +0200 Subject: [PATCH] just pick the headers we need --- apps/api/src/controllers/track.controller.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/api/src/controllers/track.controller.ts b/apps/api/src/controllers/track.controller.ts index eabedf2b..2d30d611 100644 --- a/apps/api/src/controllers/track.controller.ts +++ b/apps/api/src/controllers/track.controller.ts @@ -2,17 +2,14 @@ import type { GeoLocation } from '@/utils/parseIp'; import { getClientIp, parseIp } from '@/utils/parseIp'; import { parseUserAgent } from '@/utils/parseUserAgent'; import type { FastifyReply, FastifyRequest } from 'fastify'; -import { assocPath, pathOr } from 'ramda'; +import { assocPath, pathOr, pick } from 'ramda'; import { generateDeviceId } from '@openpanel/common'; import { - ch, createProfileAlias, - formatClickhouseDate, getProfileById, getProfileId, getSalts, - TABLE_NAMES, upsertProfile, } from '@openpanel/db'; import { eventsQueue } from '@openpanel/queue'; @@ -26,7 +23,17 @@ import type { } from '@openpanel/sdk'; export function getStringHeaders(headers: FastifyRequest['headers']) { - return Object.entries(headers).reduce( + return Object.entries( + pick( + [ + 'user-agent', + 'openpanel-sdk-name', + 'openpanel-sdk-version', + 'openpanel-client-id', + ], + headers + ) + ).reduce( (acc, [key, value]) => ({ ...acc, [key]: value ? String(value) : undefined,