File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,13 +2,14 @@ import { PostHog } from "posthog-node";
22
33let posthog : PostHog | undefined ;
44
5- const getPostHog = ( ) : PostHog => {
5+ const getPostHog = ( ) : PostHog | undefined => {
66 if ( posthog === undefined ) {
77 if (
88 ! process . env . NEXT_PUBLIC_POSTHOG_KEY ||
99 ! process . env . NEXT_PUBLIC_POSTHOG_HOST
1010 ) {
11- throw new Error ( "PostHog environment variables are not set" ) ;
11+ console . error ( "PostHog environment variables are not set" ) ;
12+ return ;
1213 }
1314 posthog = new PostHog ( process . env . NEXT_PUBLIC_POSTHOG_KEY , {
1415 host : process . env . NEXT_PUBLIC_POSTHOG_HOST ,
@@ -52,11 +53,11 @@ export const internalError = ({
5253 }
5354 }
5455 const posthog = getPostHog ( ) ;
55- const result = posthog . captureException ( error , undefined , {
56- ... context ,
57- type : slugType ,
58- } ) ;
59- console . error ( result ) ;
56+ if ( posthog )
57+ posthog . captureException ( error , undefined , {
58+ ... context ,
59+ type : slugType ,
60+ } ) ;
6061 if ( process . env . NODE_ENV === "development" ) console . error ( error ) ;
6162 }
6263} ;
You can’t perform that action at this time.
0 commit comments