fix: ensure job id is a clean string

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-12-08 20:32:29 +01:00
parent 4e42689115
commit 969c0bc8fe
4 changed files with 27 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
import type { FastifyReply, FastifyRequest } from 'fastify';
import { assocPath, pathOr, pick } from 'ramda';
import { generateId } from '@openpanel/common';
import { generateId, slug } from '@openpanel/common';
import { generateDeviceId, parseUserAgent } from '@openpanel/common/server';
import { getProfileById, getSalts, upsertProfile } from '@openpanel/db';
import { type GeoLocation, getGeoLocation } from '@openpanel/geo';
@@ -254,7 +254,13 @@ async function track({
? `${projectId}:${payload.profileId}`
: `${projectId}:${generateId()}`
: currentDeviceId;
const jobId = [payload.name, timestamp, projectId, currentDeviceId, groupId]
const jobId = [
slug(payload.name),
timestamp,
projectId,
currentDeviceId,
groupId,
]
.filter(Boolean)
.join('-');
await getEventsGroupQueueShard(groupId).add({