|
1 | 1 | import { PostHog } from 'posthog-node' |
2 | 2 |
|
3 | | -import type { AnalyticsEvent } from './constants/analytics-events' |
4 | | - |
5 | 3 | /** |
6 | 4 | * Shared analytics core module. |
7 | 5 | * Provides common interfaces, types, and utilities used by both |
@@ -62,32 +60,6 @@ export function createPostHogClient( |
62 | 60 | return new PostHog(apiKey, options) as AnalyticsClientWithIdentify |
63 | 61 | } |
64 | 62 |
|
65 | | -/** |
66 | | - * Extracts analytics config from client environment variables. |
67 | | - * Returns null if required env vars are missing. |
68 | | - */ |
69 | | -export function getConfigFromEnv(env: { |
70 | | - NEXT_PUBLIC_CB_ENVIRONMENT?: string |
71 | | - NEXT_PUBLIC_POSTHOG_API_KEY?: string |
72 | | - NEXT_PUBLIC_POSTHOG_HOST_URL?: string |
73 | | -}): AnalyticsConfig | null { |
74 | | - const envName = env.NEXT_PUBLIC_CB_ENVIRONMENT as AnalyticsEnvName | undefined |
75 | | - const posthogApiKey = env.NEXT_PUBLIC_POSTHOG_API_KEY |
76 | | - const posthogHostUrl = env.NEXT_PUBLIC_POSTHOG_HOST_URL |
77 | | - |
78 | | - if (!envName) return null |
79 | | - if (!posthogApiKey || !posthogHostUrl) return null |
80 | | - |
81 | | - return { envName, posthogApiKey, posthogHostUrl } |
82 | | -} |
83 | | - |
84 | | -/** |
85 | | - * Checks if the environment is production. |
86 | | - */ |
87 | | -export function isProdEnv(envName: AnalyticsEnvName | undefined): boolean { |
88 | | - return envName === 'prod' |
89 | | -} |
90 | | - |
91 | 63 | /** |
92 | 64 | * Generates a unique anonymous ID for pre-login tracking. |
93 | 65 | * Uses crypto.randomUUID() for uniqueness. |
|
0 commit comments