Skip to content

Commit d34f250

Browse files
[FSSDK-10935] log adjustment after merge
1 parent 37f23f9 commit d34f250

File tree

10 files changed

+94
-10
lines changed

10 files changed

+94
-10
lines changed

lib/error_messages.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* Copyright 2024, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
export const BROWSER_ODP_MANAGER_INITIALIZATION_FAILED = '%s: Error initializing Browser ODP Manager.';
218
export const CONDITION_EVALUATOR_ERROR = '%s: Error evaluating audience condition of type %s: %s';
319
export const DATAFILE_AND_SDK_KEY_MISSING =

lib/exception_messages.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* Copyright 2024, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
export const FAILED_TO_DISPATCH_EVENTS = 'Failed to dispatch events'
218
export const FAILED_TO_DISPATCH_EVENTS_WITH_ARG = 'Failed to dispatch events: %s';
319
export const EVENT_PROCESSOR_STOPPED = 'Event processor stopped before it could be started';

lib/log_messages.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* Copyright 2024, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
export const ACTIVATE_USER = '%s: Activating user %s in experiment %s.';
218
export const DISPATCH_CONVERSION_EVENT = '%s: Dispatching conversion event to URL %s with params %s.';
319
export const DISPATCH_IMPRESSION_EVENT = '%s: Dispatching impression event to URL %s with params %s.';

lib/notification_center/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { objectValues } from '../utils/fns';
1818

1919
import {
2020
LOG_LEVEL,
21-
LOG_MESSAGES,
2221
} from '../utils/enums';
2322

2423
import { NOTIFICATION_TYPES } from './type';
@@ -112,7 +111,7 @@ export class DefaultNotificationCenter implements NotificationCenter, Notificati
112111
} catch (ex: any) {
113112
this.logger.log(
114113
LOG_LEVEL.ERROR,
115-
LOG_MESSAGES.NOTIFICATION_LISTENER_EXCEPTION,
114+
NOTIFICATION_LISTENER_EXCEPTION,
116115
MODULE_NAME,
117116
notificationType,
118117
ex.message,

lib/odp/event_manager/odp_event_manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import { BackoffController, Repeater } from '../../utils/repeater/repeater';
2222
import { Producer } from '../../utils/type';
2323
import { runWithRetry } from '../../utils/executor/backoff_retry_runner';
2424
import { isSuccessStatusCode } from '../../utils/http_request_handler/http_util';
25-
import { ERROR_MESSAGES } from '../../utils/enums';
2625
import { ODP_DEFAULT_EVENT_TYPE, ODP_USER_KEY } from '../constant';
26+
import { ODP_NOT_INTEGRATED } from '../../error_messages';
2727

2828
export interface OdpEventManager extends Service {
2929
updateConfig(odpIntegrationConfig: OdpIntegrationConfig): void;
@@ -154,7 +154,7 @@ export class DefaultOdpEventManager extends BaseService implements OdpEventManag
154154
}
155155

156156
if (!this.odpIntegrationConfig?.integrated) {
157-
this.logger?.error(ERROR_MESSAGES.ODP_NOT_INTEGRATED);
157+
this.logger?.error(ODP_NOT_INTEGRATED);
158158
return;
159159
}
160160

lib/odp/segment_manager/odp_segment_manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { ERROR_MESSAGES } from '../../utils/enums';
1817
import { Cache } from '../../utils/cache/cache';
1918
import { OdpSegmentApiManager } from './odp_segment_api_manager';
2019
import { OdpIntegrationConfig } from '../odp_config';
2120
import { OptimizelySegmentOption } from './optimizely_segment_option';
2221
import { ODP_USER_KEY } from '../constant';
2322
import { LoggerFacade } from '../../modules/logging';
23+
import { ODP_CONFIG_NOT_AVAILABLE, ODP_NOT_INTEGRATED } from '../../error_messages';
2424

2525
export interface OdpSegmentManager {
2626
fetchQualifiedSegments(
@@ -61,12 +61,12 @@ export class DefaultOdpSegmentManager implements OdpSegmentManager {
6161
options?: Array<OptimizelySegmentOption>
6262
): Promise<string[] | null> {
6363
if (!this.odpIntegrationConfig) {
64-
this.logger?.warn(ERROR_MESSAGES.ODP_CONFIG_NOT_AVAILABLE);
64+
this.logger?.warn(ODP_CONFIG_NOT_AVAILABLE);
6565
return null;
6666
}
6767

6868
if (!this.odpIntegrationConfig.integrated) {
69-
this.logger?.warn(ERROR_MESSAGES.ODP_NOT_INTEGRATED);
69+
this.logger?.warn(ODP_NOT_INTEGRATED);
7070
return null;
7171
}
7272

lib/optimizely/index.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
import { describe, it, expect, vi } from 'vitest';
1817
import Optimizely from '.';
1918
import { getMockProjectConfigManager } from '../tests/mock/mock_project_config_manager';

lib/optimizely/index.tests.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,43 @@ import { createNotificationCenter } from '../notification_center';
3737
import { createProjectConfig } from '../project_config/project_config';
3838
import { getMockProjectConfigManager } from '../tests/mock/mock_project_config_manager';
3939
import { DECISION_NOTIFICATION_TYPES } from '../notification_center/type';
40+
import {
41+
AUDIENCE_EVALUATION_RESULT_COMBINED,
42+
EVENT_KEY_NOT_FOUND,
43+
EXPERIMENT_NOT_RUNNING,
44+
FEATURE_HAS_NO_EXPERIMENTS,
45+
FORCED_BUCKETING_FAILED,
46+
INVALID_CLIENT_ENGINE,
47+
INVALID_DEFAULT_DECIDE_OPTIONS,
48+
INVALID_OBJECT,
49+
NOT_ACTIVATING_USER,
50+
NOT_TRACKING_USER,
51+
RETURNING_STORED_VARIATION,
52+
USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP,
53+
USER_DOESNT_MEET_CONDITIONS_FOR_TARGETING_RULE,
54+
USER_FORCED_IN_VARIATION,
55+
USER_HAS_FORCED_VARIATION,
56+
USER_HAS_NO_FORCED_VARIATION,
57+
USER_HAS_NO_FORCED_VARIATION_FOR_EXPERIMENT,
58+
USER_HAS_NO_VARIATION,
59+
USER_HAS_VARIATION,
60+
USER_IN_ROLLOUT,
61+
USER_MAPPED_TO_FORCED_VARIATION,
62+
USER_MEETS_CONDITIONS_FOR_TARGETING_RULE,
63+
USER_NOT_BUCKETED_INTO_TARGETING_RULE,
64+
USER_NOT_IN_EXPERIMENT,
65+
VARIATION_REMOVED_FOR_USER,
66+
} from '../log_messages';
67+
import {
68+
EXPERIMENT_KEY_NOT_IN_DATAFILE,
69+
INVALID_ATTRIBUTES,
70+
INVALID_EXPERIMENT_KEY,
71+
INVALID_INPUT_FORMAT,
72+
NO_VARIATION_FOR_EXPERIMENT_KEY,
73+
USER_NOT_IN_FORCED_VARIATION,
74+
} from '../error_messages';
75+
import { FAILED_TO_STOP, ONREADY_TIMEOUT_EXPIRED, PROMISE_SHOULD_NOT_HAVE_RESOLVED } from '../exception_messages';
4076

41-
var ERROR_MESSAGES = enums.ERROR_MESSAGES;
4277
var LOG_LEVEL = enums.LOG_LEVEL;
4378
var DECISION_SOURCES = enums.DECISION_SOURCES;
4479
var DECISION_MESSAGES = enums.DECISION_MESSAGES;

lib/project_config/config_manager_factory.react_native.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import { createPollingProjectConfigManager } from './config_manager_factory.reac
6161
import { BrowserRequestHandler } from '../utils/http_request_handler/browser_request_handler';
6262
import { AsyncStorageCache } from '../utils/cache/async_storage_cache.react_native';
6363
import { getMockSyncCache } from '../tests/mock/mock_cache';
64+
import { MODULE_NOT_FOUND_REACT_NATIVE_ASYNC_STORAGE } from '../exception_messages';
6465

6566
describe('createPollingConfigManager', () => {
6667
const mockGetPollingConfigManager = vi.mocked(getPollingConfigManager);

lib/project_config/polling_datafile_manager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { RequestHandler, AbortableRequest, Headers, Response } from '../utils/ht
2323
import { Repeater } from '../utils/repeater/repeater';
2424
import { Consumer, Fn } from '../utils/type';
2525
import { isSuccessStatusCode } from '../utils/http_request_handler/http_util';
26+
import { DATAFILE_MANAGER_STOPPED, FAILED_TO_FETCH_DATAFILE } from '../exception_messages';
27+
import { DATAFILE_FETCH_REQUEST_FAILED, ERROR_FETCHING_DATAFILE } from '../error_messages';
2628

2729
export class PollingDatafileManager extends BaseService implements DatafileManager {
2830
private requestHandler: RequestHandler;
@@ -96,7 +98,7 @@ export class PollingDatafileManager extends BaseService implements DatafileManag
9698
if (this.isNew() || this.isStarting()) {
9799
this.startPromise.reject(new Error(DATAFILE_MANAGER_STOPPED));
98100
}
99-
101+
// Todo: Replace this with constant
100102
this.logger?.debug('Datafile manager stopped');
101103
this.state = ServiceState.Terminated;
102104
this.repeater.stop();

0 commit comments

Comments
 (0)