diff --git a/libs/adapters/src/mixpanel/index.ts b/libs/adapters/src/mixpanel/index.ts index df2f056254a..baa3720ff05 100644 --- a/libs/adapters/src/mixpanel/index.ts +++ b/libs/adapters/src/mixpanel/index.ts @@ -16,10 +16,7 @@ export const MixpanelAnalytics = (): Analytics => { mixpanelNode = MixpanelLib.init(config.ANALYTICS.MIXPANEL_DEV_TOKEN!); } } catch (e) { - log.error( - 'Unable to initialized the backend mixpanel client: ', - e as Error, - ); + log.error('Unable to initialize the backend mixpanel: ', e as Error); } return { @@ -29,7 +26,10 @@ export const MixpanelAnalytics = (): Analytics => { try { mixpanelNode?.track(event, payload); } catch (e) { - log.error(`Failed to track event, ${event.toString()}:`, e as Error); + log.error( + `Failed to track backend mixpanel event, ${event.toString()}:`, + e as Error, + ); } }, }; diff --git a/packages/commonwealth/shared/analytics/client-track.ts b/packages/commonwealth/shared/analytics/client-track.ts index 4da0fb2f359..b65aa6ede7d 100644 --- a/packages/commonwealth/shared/analytics/client-track.ts +++ b/packages/commonwealth/shared/analytics/client-track.ts @@ -4,14 +4,16 @@ import { AnalyticsPayload, BaseMixpanelPayload, providers } from './types'; // WARN: Using process.env to avoid webpack failures try { if (process.env.APP_ENV === 'production') { - mixpanel.init(process.env.MIXPANEL_PROD_TOKEN, { debug: true }); - } else if (process.env.APP_ENV === 'development') { - // NOTE: Only works if NODE_ENV defined in .env - // Make sure that is set to development if you want to use backend Mixpanel locally. - mixpanel.init(process.env.MIXPANEL_DEV_TOKEN, { debug: true }); + mixpanel.init(process.env.MIXPANEL_PROD_TOKEN, { + debug: true, + }); + } else if (process.env.APP_ENV === 'local') { + mixpanel.init(process.env.MIXPANEL_DEV_TOKEN, { + debug: true, + }); } } catch (e) { - console.log('Unable to initialized the backend mixpanel client: ', e); + console.log('Unable to initialize the frontend mixpanel: ', e); } // ----- Client Side Mixpanel Library Utils ------ // @@ -20,7 +22,10 @@ export function mixpanelBrowserTrack(data: T) { try { mixpanel.track(event, payload); } catch (e) { - console.log(`Failed to track event, ${event.toString()}:`, e.message); + console.log( + `Failed to track frontend mixpanel event, ${event.toString()}:`, + e.message, + ); } }