From 440c3989b64a79149e24d814e411338397f93167 Mon Sep 17 00:00:00 2001 From: Ryan Bennett Date: Tue, 13 Feb 2024 14:04:19 -0800 Subject: [PATCH] fix logging --- libs/adapters/src/mixpanel/index.ts | 8 +++++--- libs/core/src/ports/index.ts | 5 +---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/libs/adapters/src/mixpanel/index.ts b/libs/adapters/src/mixpanel/index.ts index 02ce33b6cf9..b4bda0805b9 100644 --- a/libs/adapters/src/mixpanel/index.ts +++ b/libs/adapters/src/mixpanel/index.ts @@ -1,6 +1,8 @@ -import { Analytics, AnalyticsOptions } from '@hicommonwealth/core'; +import { Analytics, AnalyticsOptions, logger } from '@hicommonwealth/core'; import MixpanelLib from 'mixpanel'; +const log = logger().getLogger(__filename); + export const MixpanelAnalytics = (): Analytics => { let mixpanelNode; @@ -13,7 +15,7 @@ export const MixpanelAnalytics = (): Analytics => { mixpanelNode = MixpanelLib.init(process.env.MIXPANEL_DEV_TOKEN); } } catch (e) { - console.error('Unable to initialized the backend mixpanel client: ', e); + log.error('Unable to initialized the backend mixpanel client: ', e); } return { @@ -23,7 +25,7 @@ export const MixpanelAnalytics = (): Analytics => { try { mixpanelNode?.track(event, payload); } catch (e) { - console.log(`Failed to track event, ${event.toString()}:`, e.message); + log.error(`Failed to track event, ${event.toString()}:`, e.message); } }, }; diff --git a/libs/core/src/ports/index.ts b/libs/core/src/ports/index.ts index 50e2a01d008..504087b1a48 100644 --- a/libs/core/src/ports/index.ts +++ b/libs/core/src/ports/index.ts @@ -1,4 +1,3 @@ -import { AnalyticsOptions } from '../types'; import { Analytics, Cache, Logger, Stats } from './interfaces'; import { port } from './port'; @@ -92,9 +91,7 @@ export const analytics = port(function analytics(analytics?: Analytics) { analytics || { name: 'in-memory-analytics', dispose: () => Promise.resolve(), - track: (event: string, payload: AnalyticsOptions) => { - console.log(`TRACK [${event}]: ${JSON.stringify(payload)}`); - }, + track: () => {}, } ); });