From 47927fdef4ec75a4f901f581d1b42d3b74ba54e1 Mon Sep 17 00:00:00 2001 From: Leo Romanovsky Date: Mon, 1 Jul 2024 18:13:51 -0700 Subject: [PATCH] bug: [replace all console messages with applicationLogger] (FF-2552) (#91) --- package.json | 4 ++-- src/index.ts | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index c310bec..6f508f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eppo/js-client-sdk", - "version": "3.2.1", + "version": "3.2.2", "description": "Eppo SDK for client-side JavaScript applications", "main": "dist/index.js", "files": [ @@ -58,4 +58,4 @@ "dependencies": { "@eppo/js-client-sdk-common": "3.3.3" } -} +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 0b08881..fa595d4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,7 @@ import { AttributeType, ObfuscatedFlag, ApiEndpoints, + applicationLogger, } from '@eppo/js-client-sdk-common'; import { assignmentCacheFactory } from './cache/assignment-cache-factory'; @@ -213,7 +214,7 @@ export class EppoJSClient extends EppoClient { private static getAssignmentInitializationCheck() { if (!EppoJSClient.initialized) { - console.warn('Eppo SDK assignment requested before init() completed'); + applicationLogger.warn('Eppo SDK assignment requested before init() completed'); } } } @@ -268,7 +269,7 @@ export function offlineInit(config: IClientConfigSync): IEppoClient { }); EppoJSClient.instance.useCustomAssignmentCache(assignmentCache); } catch (error) { - console.warn( + applicationLogger.warn( 'Eppo SDK encountered an error initializing, assignment calls will return the default value and not be logged', ); if (throwOnFailedInitialization) { @@ -355,21 +356,24 @@ export async function init(config: IClientConfig): Promise { .then(async () => { if (!configurationStore.getKeys().length) { // Consider empty configuration stores invalid - console.warn('Eppo SDK cached configuration is empty'); + applicationLogger.warn('Eppo SDK cached configuration is empty'); initFromConfigStoreError = new Error('Configuration store was empty'); return ''; } const cacheIsExpired = await configurationStore.isExpired(); if (cacheIsExpired && !config.useExpiredCache) { - console.warn('Eppo SDK set not to use expired cached configuration'); + applicationLogger.warn('Eppo SDK set not to use expired cached configuration'); initFromConfigStoreError = new Error('Configuration store was expired'); return ''; } return 'config store'; }) .catch((e) => { - console.warn('Eppo SDK encountered an error initializing from the configuration store', e); + applicationLogger.warn( + 'Eppo SDK encountered an error initializing from the configuration store', + e, + ); initFromConfigStoreError = e; }); const attemptInitFromFetch = instance @@ -378,7 +382,7 @@ export async function init(config: IClientConfig): Promise { return 'fetch'; }) .catch((e) => { - console.warn('Eppo SDK encountered an error initializing from fetching', e); + applicationLogger.warn('Eppo SDK encountered an error initializing from fetching', e); // eslint-disable-next-line @typescript-eslint/no-unused-vars initFromFetchError = e; }); @@ -406,7 +410,7 @@ export async function init(config: IClientConfig): Promise { } if (initializationError) { - console.warn( + applicationLogger.warn( 'Eppo SDK was unable to initialize with a configuration, assignment calls will return the default value and not be logged' + (config.pollAfterFailedInitialization ? ' until an experiment configuration is successfully retrieved'