Implement posthog

This commit is contained in:
2025-07-06 14:02:22 +03:00
parent f7d994d02e
commit 1e099d88ae
13 changed files with 209 additions and 41 deletions

View File

@@ -1,4 +1,4 @@
import { chain, draw, get, isEmpty, omit, pick, tryit } from "radash";
import { chain, draw, get, isEmpty, omit, tryit } from "radash";
import { safeDestr } from "destr";
import { match } from "ts-pattern";
import { User } from "./drizzle";
@@ -191,6 +191,10 @@ export const createActivityContent = async ({
const stravaRequestBody = {
name: responseObject!.title,
description: responseObject!.description,
meta: {
highlight,
tone,
},
};
return [aiError || parseError, stravaRequestBody] as const;

View File

@@ -0,0 +1,20 @@
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;
};