Skip to content

Commit c1ec572

Browse files
committed
feat(analytics): send first-view email for anonymous viewers with no session
1 parent f3530e7 commit c1ec572

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

  • apps/web/app/api/analytics/track

apps/web/app/api/analytics/track/route.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,23 @@ export async function POST(request: NextRequest) {
192192
]),
193193
);
194194
}
195+
196+
if (!userId && !sessionId) {
197+
yield* Effect.forkDaemon(
198+
Effect.tryPromise(() =>
199+
sendFirstViewEmail({
200+
videoId: body.videoId,
201+
viewerName: "Anonymous Viewer",
202+
isAnonymous: true,
203+
}),
204+
).pipe(
205+
Effect.catchAll((error) => {
206+
console.error("Failed to send first view email:", error);
207+
return Effect.void;
208+
}),
209+
),
210+
);
211+
}
195212
}).pipe(provideOptionalAuth),
196213
);
197214

0 commit comments

Comments
 (0)