import posthog from 'posthog-js';
import { browser } from '$app/environment';
import { Console, Effect, Exit } from 'effect';
const postHogKeyExit: Exit.Exit<string, Error> = Effect.runSyncExit(
Effect.try({
try: () => import.meta.env.VITE_POSTHOG_KEY,
catch: (error) => new Error(`Missing posthog key. Is VITE_POSTHOG_KEY set? ${error}`)
})
);
export const load = async () => {
if (browser) {
Exit.match(postHogKeyExit, {
onSuccess: (postHogKey) =>
posthog.init(postHogKey, {
api_host: 'https://us.i.posthog.com',
person_profiles: 'always'
}),
onFailure: (error) => Effect.runSync(Console.error(Effect.fail(error)))
});
}
return;
};
import posthog from 'posthog-js';
import { browser } from '$app/environment';
import { Console, Effect, Exit } from 'effect';
const postHogKeyExit: Exit.Exit<string, Error> = Effect.runSyncExit(
Effect.try({
try: () => import.meta.env.VITE_POSTHOG_KEY,
catch: (error) => new Error(`Missing posthog key. Is VITE_POSTHOG_KEY set? ${error}`)
})
);
export const load = async () => {
if (browser) {
Exit.match(postHogKeyExit, {
onSuccess: (postHogKey) =>
posthog.init(postHogKey, {
api_host: 'https://us.i.posthog.com',
person_profiles: 'always'
}),
onFailure: (error) => Effect.runSync(Console.error(Effect.fail(error)))
});
}
return;
};