♻️ Upgrade to next-auth v5 (#1558)

This commit is contained in:
Luke Vella 2025-02-12 12:51:04 +07:00 committed by GitHub
parent 17d386d905
commit 4b26dc50b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 765 additions and 628 deletions

View file

@ -1,4 +1,5 @@
import { waitUntil } from "@vercel/functions";
import type { NextRequest } from "next/server";
import { PostHog } from "posthog-node";
function PostHogClient() {
@ -14,10 +15,14 @@ function PostHogClient() {
export const posthog = PostHogClient();
export function posthogApiHandler() {
try {
waitUntil(Promise.all([posthog?.shutdown()]));
} catch (error) {
console.error("Failed to flush PostHog events:", error);
}
export function withPosthog(handler: (req: NextRequest) => Promise<Response>) {
return async (req: NextRequest) => {
const res = await handler(req);
try {
waitUntil(Promise.all([posthog?.shutdown()]));
} catch (error) {
console.error("Failed to flush PostHog events:", error);
}
return res;
};
}