Skip to content

Commit

Permalink
bug: [replace all console messages with applicationLogger] (FF-2552) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
leoromanovsky authored Jul 2, 2024
1 parent 86e205c commit 47927fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -58,4 +58,4 @@
"dependencies": {
"@eppo/js-client-sdk-common": "3.3.3"
}
}
}
18 changes: 11 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
AttributeType,
ObfuscatedFlag,
ApiEndpoints,
applicationLogger,
} from '@eppo/js-client-sdk-common';

import { assignmentCacheFactory } from './cache/assignment-cache-factory';
Expand Down Expand Up @@ -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');
}
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -355,21 +356,24 @@ export async function init(config: IClientConfig): Promise<IEppoClient> {
.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
Expand All @@ -378,7 +382,7 @@ export async function init(config: IClientConfig): Promise<IEppoClient> {
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;
});
Expand Down Expand Up @@ -406,7 +410,7 @@ export async function init(config: IClientConfig): Promise<IEppoClient> {
}

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'
Expand Down

0 comments on commit 47927fd

Please sign in to comment.