Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(analytics): separate anon notification and email errors for clearer logging

Richie McIlroy4305c6abc08d
diff --git a/apps/web/app/api/analytics/track/route.ts b/apps/web/app/api/analytics/track/route.ts
index ad32eb2f1..ce6ba757f 100644
--- a/apps/web/app/api/analytics/track/route.ts
+++ b/apps/web/app/api/analytics/track/route.ts
@@ -157,29 +157,36 @@ export async function POST(request: NextRequest) {
city && country ? `${city}, ${country}` : city || country || null;
yield* Effect.forkDaemon(
- Effect.tryPromise(() =>
- Promise.all([
+ Effect.all([
+ 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;
+ }),
+ ),
+ Effect.tryPromise(() =>
sendFirstViewEmail({
videoId: body.videoId,
viewerName: anonName,
isAnonymous: true,
}),
- ]),
- ).pipe(
- Effect.catchAll((error) => {
- console.error(
- "Failed to create anonymous view notification:",
- error,
- );
- return Effect.void;
- }),
- ),
+ ).pipe(
+ Effect.catchAll((error) => {
+ console.error("Failed to send first view email:", error);
+ return Effect.void;
+ }),
+ ),
+ ]),
);
}
}).pipe(provideOptionalAuth),