File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 1- import { env } from '@codebuff/common/env'
21import { PostHog } from 'posthog-node'
32
3+ import { env } from '@codebuff/common/env'
4+
45import type { AnalyticsEvent } from './constants/analytics-events'
56import type { Logger } from '@codebuff/common/types/contracts/logger'
67
@@ -52,11 +53,14 @@ export function trackEvent({
5253 }
5354
5455 if ( ! client ) {
55- logger . warn (
56- { event, userId } ,
57- 'Analytics client not initialized, skipping event tracking' ,
58- )
59- return
56+ initAnalytics ( { logger } )
57+ if ( ! client ) {
58+ logger . warn (
59+ { event, userId } ,
60+ 'Analytics client not initialized, skipping event tracking' ,
61+ )
62+ return
63+ }
6064 }
6165
6266 try {
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ export const clientEnvSchema = z.object({
77 NEXT_PUBLIC_CODEBUFF_APP_URL : z . url ( ) . min ( 1 ) ,
88 NEXT_PUBLIC_CODEBUFF_BACKEND_URL : z . string ( ) . min ( 1 ) ,
99 NEXT_PUBLIC_SUPPORT_EMAIL : z . email ( ) . min ( 1 ) ,
10- NEXT_PUBLIC_POSTHOG_API_KEY : z . string ( ) . optional ( ) . default ( '' ) ,
11- NEXT_PUBLIC_POSTHOG_HOST_URL : z . url ( ) . optional ( ) ,
10+ NEXT_PUBLIC_POSTHOG_API_KEY : z . string ( ) . default ( '' ) ,
11+ NEXT_PUBLIC_POSTHOG_HOST_URL : z . url ( ) ,
1212 NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY : z . string ( ) . min ( 1 ) ,
1313 NEXT_PUBLIC_STRIPE_CUSTOMER_PORTAL : z . url ( ) . min ( 1 ) ,
1414 NEXT_PUBLIC_LINKEDIN_PARTNER_ID : z . string ( ) . optional ( ) ,
You can’t perform that action at this time.
0 commit comments