Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

perf(api): fork anon view notification as background daemon

Richie McIlroyd14166690d62
diff --git a/apps/web/app/api/analytics/track/route.ts b/apps/web/app/api/analytics/track/route.ts
index 66f9c82c0..49a3c7677 100644
--- a/apps/web/app/api/analytics/track/route.ts
+++ b/apps/web/app/api/analytics/track/route.ts
@@ -135,25 +135,26 @@ export async function POST(request: NextRequest) {
if (!userId && sessionId) {
const anonName = getAnonymousName(sessionId);
- const locationParts = [city, country].filter(Boolean);
const location =
- locationParts.length > 0 ? locationParts.join(", ") : null;
-
- yield* Effect.tryPromise(() =>
- createAnonymousViewNotification({
- videoId: body.videoId,
- sessionId,
- anonName,
- location,
- }),
- ).pipe(
- Effect.catchAll((error) => {
- console.error(
- "Failed to create anonymous view notification:",
- error,
- );
- return Effect.void;
- }),
+ city && country ? `${city}, ${country}` : city || country || null;
+
+ yield* Effect.forkDaemon(
+ Effect.tryPromise(() =>
+ createAnonymousViewNotification({
+ videoId: body.videoId,
+ sessionId,
+ anonName,
+ location,
+ }),
+ ).pipe(
+ Effect.catchAll((error) => {
+ console.error(
+ "Failed to create anonymous view notification:",
+ error,
+ );
+ return Effect.void;
+ }),
+ ),
);
}
}).pipe(provideOptionalAuth),