Use bun
This commit is contained in:
@@ -20,22 +20,9 @@ export default defineEventHandler(async (event) => {
|
||||
},
|
||||
});
|
||||
|
||||
posthog.identifyImmediate({
|
||||
distinctId: String(user!.id),
|
||||
properties: {
|
||||
name: user!.name,
|
||||
country: user!.country,
|
||||
},
|
||||
});
|
||||
|
||||
await db
|
||||
.delete(tables.users)
|
||||
.where(eq(tables.users.id, get(body, "object_id")));
|
||||
|
||||
posthog.captureImmediate({
|
||||
distinctId: get(body, "object_id"),
|
||||
event: "user deleted",
|
||||
});
|
||||
|
||||
sendNoContent(event);
|
||||
});
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { PostHog } from "posthog-node";
|
||||
import { waitUntil } from "@vercel/functions";
|
||||
export default defineNitroPlugin((nitroApp) => {
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
|
||||
const posthog = new PostHog(runtimeConfig.public.posthogPublicKey, {
|
||||
host: runtimeConfig.public.posthogHost,
|
||||
flushAt: 1,
|
||||
flushInterval: 0,
|
||||
});
|
||||
|
||||
nitroApp.hooks.hook("request", (event) => {
|
||||
event.context.posthog = posthog;
|
||||
});
|
||||
|
||||
nitroApp.hooks.hook("beforeResponse", () => {
|
||||
waitUntil(posthog.shutdown());
|
||||
});
|
||||
|
||||
nitroApp.hooks.hook("close", () => {
|
||||
waitUntil(posthog.shutdown());
|
||||
});
|
||||
});
|
||||
|
||||
declare module "h3" {
|
||||
interface H3EventContext {
|
||||
posthog: PostHog;
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,6 @@ export default defineOAuthStravaEventHandler({
|
||||
});
|
||||
}
|
||||
|
||||
const posthog = event.context.posthog;
|
||||
|
||||
const userPayload = {
|
||||
id: auth.user.id,
|
||||
name: `${auth.user.firstname} ${auth.user.lastname}`,
|
||||
@@ -82,19 +80,6 @@ export default defineOAuthStravaEventHandler({
|
||||
user: userPayload,
|
||||
});
|
||||
|
||||
posthog.identifyImmediate({
|
||||
distinctId: String(user!.id),
|
||||
properties: {
|
||||
name: user!.name,
|
||||
country: user!.country,
|
||||
},
|
||||
});
|
||||
|
||||
posthog.captureImmediate({
|
||||
distinctId: String(user!.id),
|
||||
event: "user logged in",
|
||||
});
|
||||
|
||||
sendRedirect(event, "/");
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { PostHog } from "posthog-node";
|
||||
|
||||
let client: PostHog;
|
||||
|
||||
export const usePosthog = () => {
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
|
||||
client =
|
||||
client ??
|
||||
new PostHog(runtimeConfig.public.posthogPublicKey, {
|
||||
host: runtimeConfig.public.posthogHost,
|
||||
defaults: runtimeConfig.public.posthogDefaults,
|
||||
});
|
||||
|
||||
if (process.dev) {
|
||||
client.debug();
|
||||
}
|
||||
|
||||
return client;
|
||||
};
|
||||
Reference in New Issue
Block a user