Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix(analytics): shutdown server client
Marc Seitz38636bdb8dfa
diff --git a/lib/analytics/index.ts b/lib/analytics/index.tsindex b59eaad3..a1ca268c 100644--- a/lib/analytics/index.ts+++ b/lib/analytics/index.ts@@ -42,7 +42,7 @@ export function useAnalytics() {export function getAnalyticsServer() {const postHogClient = getPostHogServerClient();- const capture = (+ const capture = async (distinctId: string, // email or user idevent: string,properties?: Record<string, unknown>,@@ -57,6 +57,7 @@ export function getAnalyticsServer() {try {postHogClient.capture({ distinctId, event, properties });+ await postHogClient.shutdownAsync();} catch (e) {log({message: `Failed to record posthog for event: *${event}*`,diff --git a/pages/api/auth/[...nextauth].ts b/pages/api/auth/[...nextauth].tsindex 40663591..c7025bb3 100644--- a/pages/api/auth/[...nextauth].ts+++ b/pages/api/auth/[...nextauth].ts@@ -114,7 +114,7 @@ export const authOptions: NextAuthOptions = {};const analytics = getAnalyticsServer();- analytics.capture(+ await analytics.capture(message.user.email ?? message.user.id,"User Signed Up",);@@ -123,7 +123,7 @@ export const authOptions: NextAuthOptions = {},async signIn(message) {const analytics = getAnalyticsServer();- analytics.capture(+ await analytics.capture(message.user.email ?? message.user.id,"User Signed In",);