Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

just pick the headers we need

Carl-Gerhard Lindesvärdadc8b9045035
diff --git a/apps/api/src/controllers/track.controller.ts b/apps/api/src/controllers/track.controller.ts
index eabedf2b7..2d30d611d 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,