The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Fixes items not clearing
Ian MacCallumabf012ef484c
diff --git a/apps/web/app/(ee)/api/cron/projects/usage-updates-queue/route.ts b/apps/web/app/(ee)/api/cron/projects/usage-updates-queue/route.tsindex 734b7be25d..f6b72af2ca 100644--- a/apps/web/app/(ee)/api/cron/projects/usage-updates-queue/route.ts+++ b/apps/web/app/(ee)/api/cron/projects/usage-updates-queue/route.ts@@ -39,16 +39,16 @@ const aggregateProjectUsage = (// The entries are a batch of project usage events, each with projectId, timestamp, and possibly linkId.// We want to aggregate by projectId, counting total events (clicks) and tracking first/last timestamps.- for (const [streamId, fields] of Object.entries(entries)) {- const entry = fields as unknown as {- projectId: string;- timestamp: string;- linkId?: string;- };- const projectId = entry.projectId;- const timestamp = Date.parse(entry.timestamp) / 1000;-- lastId = streamId;+ for (const entry of entries) {+ const projectId = entry.data.projectId;++ if (!projectId) {+ continue;+ }++ const timestamp = Date.parse(entry.data.timestamp) / 1000;++ lastId = entry.id;if (aggregatedUsage.has(projectId)) {const existing = aggregatedUsage.get(projectId)!;diff --git a/apps/web/lib/upstash/redis-streams.ts b/apps/web/lib/upstash/redis-streams.tsindex 6c0428bbfc..3005010827 100644--- a/apps/web/lib/upstash/redis-streams.ts+++ b/apps/web/lib/upstash/redis-streams.ts@@ -66,7 +66,7 @@ export class RedisStream {// Delete all entries up to and including the last processed ID// We do this by collecting the IDs we just processed and deleting them// (Assumes entries is the batch we just processed)- const processedEntryIds = Object.keys(entries);+ const processedEntryIds = Object.keys(entriesMap);if (processedEntryIds.length > 0) {// xdel supports deleting multiple IDs at once