import { components } from "./_generated/api";
import { PostHog } from "@samhoque/convex-posthog";
const posthog = new PostHog(components.posthog, {
apiKey: process.env.POSTHOG_API_KEY,
});
export const signupUser = mutation({
args: { userId: v.string(), email: v.string() },
handler: async (ctx, args) => {
// Your business logic here
await ctx.db.insert("users", args);
// Track the event
await posthog.trackUserEvent(ctx, {
userId: args.userId,
event: "user_signed_up",
properties: { email: args.email }
});
return { success: true };
},
});
import { components } from "./_generated/api";
import { PostHog } from "@samhoque/convex-posthog";
const posthog = new PostHog(components.posthog, {
apiKey: process.env.POSTHOG_API_KEY,
});
export const signupUser = mutation({
args: { userId: v.string(), email: v.string() },
handler: async (ctx, args) => {
// Your business logic here
await ctx.db.insert("users", args);
// Track the event
await posthog.trackUserEvent(ctx, {
userId: args.userId,
event: "user_signed_up",
properties: { email: args.email }
});
return { success: true };
},
});