just pick the headers we need
This commit is contained in:
committed by
Carl-Gerhard Lindesvärd
parent
e4eb697b47
commit
adc8b90450
@@ -2,17 +2,14 @@ import type { GeoLocation } from '@/utils/parseIp';
|
|||||||
import { getClientIp, parseIp } from '@/utils/parseIp';
|
import { getClientIp, parseIp } from '@/utils/parseIp';
|
||||||
import { parseUserAgent } from '@/utils/parseUserAgent';
|
import { parseUserAgent } from '@/utils/parseUserAgent';
|
||||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||||
import { assocPath, pathOr } from 'ramda';
|
import { assocPath, pathOr, pick } from 'ramda';
|
||||||
|
|
||||||
import { generateDeviceId } from '@openpanel/common';
|
import { generateDeviceId } from '@openpanel/common';
|
||||||
import {
|
import {
|
||||||
ch,
|
|
||||||
createProfileAlias,
|
createProfileAlias,
|
||||||
formatClickhouseDate,
|
|
||||||
getProfileById,
|
getProfileById,
|
||||||
getProfileId,
|
getProfileId,
|
||||||
getSalts,
|
getSalts,
|
||||||
TABLE_NAMES,
|
|
||||||
upsertProfile,
|
upsertProfile,
|
||||||
} from '@openpanel/db';
|
} from '@openpanel/db';
|
||||||
import { eventsQueue } from '@openpanel/queue';
|
import { eventsQueue } from '@openpanel/queue';
|
||||||
@@ -26,7 +23,17 @@ import type {
|
|||||||
} from '@openpanel/sdk';
|
} from '@openpanel/sdk';
|
||||||
|
|
||||||
export function getStringHeaders(headers: FastifyRequest['headers']) {
|
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]) => ({
|
||||||
...acc,
|
...acc,
|
||||||
[key]: value ? String(value) : undefined,
|
[key]: value ? String(value) : undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user