Skip to content

Commit

Permalink
[FSSDK-11090] remove unused log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
raju-opti committed Jan 24, 2025
1 parent 9adc544 commit 23da24b
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 88 deletions.
12 changes: 8 additions & 4 deletions lib/core/decision_service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ import {
import {
SAVED_USER_VARIATION,
SAVED_VARIATION_NOT_FOUND,
USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED,
USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED_BUT_INVALID,
USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED,
USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED_BUT_INVALID,
USER_HAS_NO_FORCED_VARIATION,
USER_MAPPED_TO_FORCED_VARIATION,
USER_HAS_NO_FORCED_VARIATION_FOR_EXPERIMENT,
Expand Down Expand Up @@ -98,6 +94,14 @@ export const IMPROPERLY_FORMATTED_EXPERIMENT = 'Experiment key %s is improperly
export const USER_HAS_FORCED_VARIATION =
'Variation %s is mapped to experiment %s and user %s in the forced variation map.';
export const USER_MEETS_CONDITIONS_FOR_TARGETING_RULE = 'User %s meets conditions for targeting rule %s.';
export const USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED =
'Variation (%s) is mapped to flag (%s), rule (%s) and user (%s) in the forced decision map.';
export const USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED =
'Variation (%s) is mapped to flag (%s) and user (%s) in the forced decision map.';
export const USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED_BUT_INVALID =
'Invalid variation is mapped to flag (%s), rule (%s) and user (%s) in the forced decision map.';
export const USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED_BUT_INVALID =
'Invalid variation is mapped to flag (%s) and user (%s) in the forced decision map.';

export interface DecisionObj {
experiment: Experiment | null;
Expand Down
53 changes: 8 additions & 45 deletions lib/message/error_message.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024, Optimizely
* Copyright 2024-2025, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,14 +14,9 @@
* limitations under the License.
*/
export const NOTIFICATION_LISTENER_EXCEPTION = 'Notification listener for (%s) threw exception: %s';
export const BROWSER_ODP_MANAGER_INITIALIZATION_FAILED = '%s: Error initializing Browser ODP Manager.';
export const CONDITION_EVALUATOR_ERROR = 'Error evaluating audience condition of type %s: %s';
export const DATAFILE_AND_SDK_KEY_MISSING =
'%s: You must provide at least one of sdkKey or datafile. Cannot start Optimizely';
export const EXPERIMENT_KEY_NOT_IN_DATAFILE = 'Experiment key %s is not in datafile.';
export const FEATURE_NOT_IN_DATAFILE = 'Feature key %s is not in datafile.';
export const FETCH_SEGMENTS_FAILED_NETWORK_ERROR = '%s: Audience segments fetch failed. (network error)';
export const FETCH_SEGMENTS_FAILED_DECODE_ERROR = '%s: Audience segments fetch failed. (decode error)';
export const INVALID_ATTRIBUTES = 'Provided attributes are in an invalid format.';
export const INVALID_BUCKETING_ID = 'Unable to generate hash for bucketing ID %s: %s';
export const INVALID_DATAFILE = 'Datafile is invalid - property %s: %s';
Expand All @@ -38,45 +33,18 @@ export const INVALID_GROUP_ID = 'Group ID %s is not in datafile.';
export const INVALID_LOGGER = 'Provided "logger" is in an invalid format.';
export const INVALID_USER_ID = 'Provided user ID is in an invalid format.';
export const INVALID_USER_PROFILE_SERVICE = 'Provided user profile service instance is in an invalid format: %s.';
export const LOCAL_STORAGE_DOES_NOT_EXIST = 'Error accessing window localStorage.';
export const MISSING_INTEGRATION_KEY =
'Integration key missing from datafile. All integrations should include a key.';
export const NO_DATAFILE_SPECIFIED = 'No datafile specified. Cannot start optimizely.';
export const NO_JSON_PROVIDED = 'No JSON object to validate against schema.';
export const NO_EVENT_PROCESSOR = 'No event processor is provided';
export const NO_VARIATION_FOR_EXPERIMENT_KEY = 'No variation key %s defined in datafile for experiment %s.';
export const ODP_CONFIG_NOT_AVAILABLE = '%s: ODP is not integrated to the project.';
export const ODP_CONFIG_NOT_AVAILABLE = 'ODP config is not available.';
export const ODP_EVENT_FAILED = 'ODP event send failed.';
export const ODP_EVENT_MANAGER_IS_NOT_RUNNING = 'ODP event manager is not running.';
export const ODP_EVENTS_SHOULD_HAVE_ATLEAST_ONE_KEY_VALUE = 'ODP events should have at least one key-value pair in identifiers.';
export const ODP_FETCH_QUALIFIED_SEGMENTS_SEGMENTS_MANAGER_MISSING =
'%s: ODP unable to fetch qualified segments (Segments Manager not initialized).';
export const ODP_IDENTIFY_FAILED_EVENT_MANAGER_MISSING =
'%s: ODP identify event %s is not dispatched (Event Manager not instantiated).';
export const ODP_INITIALIZATION_FAILED = '%s: ODP failed to initialize.';
export const ODP_INVALID_DATA = '%s: ODP data is not valid';
export const ODP_EVENT_FAILED_ODP_MANAGER_MISSING = '%s: ODP Event failed to send. (ODP Manager not initialized).';
export const ODP_FETCH_QUALIFIED_SEGMENTS_FAILED_ODP_MANAGER_MISSING =
'%s: ODP failed to Fetch Qualified Segments. (ODP Manager not initialized).';
export const ODP_IDENTIFY_USER_FAILED_ODP_MANAGER_MISSING =
'%s: ODP failed to Identify User. (ODP Manager not initialized).';
export const ODP_IDENTIFY_USER_FAILED_USER_CONTEXT_INITIALIZATION =
'%s: ODP failed to Identify User. (Failed during User Context Initialization).';
export const ODP_MANAGER_UPDATE_SETTINGS_FAILED_EVENT_MANAGER_MISSING =
'%s: ODP Manager failed to update OdpConfig settings for internal event manager. (Event Manager not initialized).';
export const ODP_MANAGER_UPDATE_SETTINGS_FAILED_SEGMENTS_MANAGER_MISSING =
'%s: ODP Manager failed to update OdpConfig settings for internal segments manager. (Segments Manager not initialized).';
export const ODP_NOT_ENABLED = 'ODP is not enabled';
export const ODP_NOT_INTEGRATED = '%s: ODP is not integrated';
export const ODP_SEND_EVENT_FAILED_EVENT_MANAGER_MISSING =
'%s: ODP send event %s was not dispatched (Event Manager not instantiated).';
export const ODP_SEND_EVENT_FAILED_UID_MISSING =
'%s: ODP send event %s was not dispatched (No valid user identifier provided).';
export const ODP_SEND_EVENT_FAILED_VUID_MISSING = '%s: ODP send event %s was not dispatched (Unable to fetch VUID).';
export const ODP_VUID_INITIALIZATION_FAILED = '%s: ODP VUID initialization failed.';
export const ODP_VUID_REGISTRATION_FAILED = '%s: ODP VUID failed to be registered.';
export const ODP_VUID_REGISTRATION_FAILED_EVENT_MANAGER_MISSING =
'%s: ODP register vuid failed. (Event Manager not instantiated).';
export const ODP_EVENT_FAILED_ODP_MANAGER_MISSING = 'ODP Event failed to send. (ODP Manager not available).';
export const ODP_NOT_INTEGRATED = 'ODP is not integrated';
export const UNDEFINED_ATTRIBUTE = 'Provided attribute: %s has an undefined value.';
export const UNRECOGNIZED_ATTRIBUTE =
'Unrecognized attribute %s provided. Pruning before sending event to Optimizely.';
Expand All @@ -86,17 +54,15 @@ export const USER_NOT_IN_FORCED_VARIATION =
export const USER_PROFILE_LOOKUP_ERROR = 'Error while looking up user profile for user ID "%s": %s.';
export const USER_PROFILE_SAVE_ERROR = 'Error while saving user profile for user ID "%s": %s.';
export const VARIABLE_KEY_NOT_IN_DATAFILE =
'%s: Variable with key "%s" associated with feature with key "%s" is not in datafile.';
export const VARIATION_ID_NOT_IN_DATAFILE = '%s: No variation ID %s defined in datafile for experiment %s.';
export const VARIATION_ID_NOT_IN_DATAFILE_NO_EXPERIMENT = 'Variation ID %s is not in the datafile.';
'Variable with key "%s" associated with feature with key "%s" is not in datafile.';
export const VARIATION_ID_NOT_IN_DATAFILE = 'Variation ID %s is not in the datafile.';
export const INVALID_INPUT_FORMAT = 'Provided %s is in an invalid format.';
export const INVALID_DATAFILE_VERSION =
'This version of the JavaScript SDK does not support the given datafile version: %s';
export const INVALID_VARIATION_KEY = 'Provided variation key is in an invalid format.';
export const UNABLE_TO_GET_VUID = 'Unable to get VUID - ODP Manager is not instantiated yet.';
export const ERROR_FETCHING_DATAFILE = 'Error fetching datafile: %s';
export const DATAFILE_FETCH_REQUEST_FAILED = 'Datafile fetch request failed with status: %s';
export const EVENT_DATA_FOUND_TO_BE_INVALID = 'Event data found to be invalid.';
export const EVENT_DATA_INVALID = 'Event data invalid.';
export const EVENT_ACTION_INVALID = 'Event action invalid.';
export const FAILED_TO_SEND_ODP_EVENTS = 'failed to send odp events';
export const UNABLE_TO_GET_VUID_VUID_MANAGER_NOT_AVAILABLE = 'Unable to get VUID - VuidManager is not available'
Expand Down Expand Up @@ -135,13 +101,10 @@ export const SEND_BEACON_FAILED = 'sendBeacon failed';
export const FAILED_TO_DISPATCH_EVENTS = 'Failed to dispatch events'
export const FAILED_TO_DISPATCH_EVENTS_WITH_ARG = 'Failed to dispatch events: %s';
export const EVENT_PROCESSOR_STOPPED = 'Event processor stopped before it could be started';
export const CANNOT_START_WITHOUT_ODP_CONFIG = 'cannot start without ODP config';
export const START_CALLED_WHEN_ODP_IS_NOT_INTEGRATED = 'start() called when ODP is not integrated';
export const ODP_ACTION_IS_NOT_VALID = 'ODP action is not valid (cannot be empty).';
export const ODP_MANAGER_STOPPED_BEFORE_RUNNING = 'odp manager stopped before running';
export const ODP_EVENT_MANAGER_STOPPED = "ODP event manager stopped before it could start";
export const ONREADY_TIMEOUT_EXPIRED = 'onReady timeout expired after %s ms';
export const DATAFILE_MANAGER_FAILED_TO_START = 'Datafile manager failed to start';
export const UNABLE_TO_ATTACH_UNLOAD = 'unable to bind optimizely.close() to page unload event: "%s"';
export const UNABLE_TO_PARSE_AND_SKIPPED_HEADER = 'Unable to parse & skipped header item';

export const messages: string[] = [];
30 changes: 4 additions & 26 deletions lib/message/log_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,24 @@
* limitations under the License.
*/

export const ACTIVATE_USER = '%s: Activating user %s in experiment %s.';
export const DISPATCH_CONVERSION_EVENT = '%s: Dispatching conversion event to URL %s with params %s.';
export const DISPATCH_IMPRESSION_EVENT = '%s: Dispatching impression event to URL %s with params %s.';
export const DEPRECATED_EVENT_VALUE = '%s: Event value is deprecated in %s call.';
export const FEATURE_ENABLED_FOR_USER = 'Feature %s is enabled for user %s.';
export const FEATURE_NOT_ENABLED_FOR_USER = 'Feature %s is not enabled for user %s.';
export const FAILED_TO_PARSE_VALUE = '%s: Failed to parse event value "%s" from event tags.';
export const FAILED_TO_PARSE_VALUE = 'Failed to parse event value "%s" from event tags.';
export const FAILED_TO_PARSE_REVENUE = 'Failed to parse revenue value "%s" from event tags.';
export const INVALID_CLIENT_ENGINE = 'Invalid client engine passed: %s. Defaulting to node-sdk.';
export const INVALID_DEFAULT_DECIDE_OPTIONS = '%s: Provided default decide options is not an array.';
export const INVALID_DEFAULT_DECIDE_OPTIONS = 'Provided default decide options is not an array.';
export const INVALID_DECIDE_OPTIONS = 'Provided decide options is not an array. Using default decide options.';
export const NOT_ACTIVATING_USER = 'Not activating user %s for experiment %s.';
export const ODP_DISABLED = 'ODP Disabled.';
export const ODP_IDENTIFY_FAILED_ODP_DISABLED = '%s: ODP identify event for user %s is not dispatched (ODP disabled).';
export const ODP_IDENTIFY_FAILED_ODP_NOT_INTEGRATED =
'%s: ODP identify event %s is not dispatched (ODP not integrated).';
export const ODP_SEND_EVENT_IDENTIFIER_CONVERSION_FAILED =
'%s: sendOdpEvent failed to parse through and convert fs_user_id aliases';
export const PARSED_REVENUE_VALUE = 'Parsed revenue value "%s" from event tags.';
export const PARSED_NUMERIC_VALUE = 'Parsed event value "%s" from event tags.';
export const SAVED_USER_VARIATION = 'Saved user profile for user "%s".';
export const UPDATED_USER_VARIATION = '%s: Updated variation "%s" of experiment "%s" for user "%s".';
export const SAVED_VARIATION_NOT_FOUND =
'User %s was previously bucketed into variation with ID %s for experiment %s, but no matching variation was found.';
export const SHOULD_NOT_DISPATCH_ACTIVATE = 'Experiment %s is not in "Running" state. Not activating user.';
export const SKIPPING_JSON_VALIDATION = 'Skipping JSON schema validation.';
export const TRACK_EVENT = 'Tracking event %s for user %s.';
export const USER_IN_FEATURE_EXPERIMENT = '%s: User %s is in variation %s of experiment %s on the feature %s.';
export const USER_NOT_BUCKETED_INTO_EVERYONE_TARGETING_RULE =
'%s: User %s not bucketed into everyone targeting rule due to traffic allocation.';
export const USER_NOT_BUCKETED_INTO_ANY_EXPERIMENT_IN_GROUP = '%s: User %s is not in any experiment of group %s.';
export const USER_MAPPED_TO_FORCED_VARIATION =
'Set variation %s for experiment %s and user %s in the forced variation map.';
export const USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED =
'Variation (%s) is mapped to flag (%s), rule (%s) and user (%s) in the forced decision map.';
export const USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED =
'Variation (%s) is mapped to flag (%s) and user (%s) in the forced decision map.';
export const USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED_BUT_INVALID =
'Invalid variation is mapped to flag (%s), rule (%s) and user (%s) in the forced decision map.';
export const USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED_BUT_INVALID =
'Invalid variation is mapped to flag (%s) and user (%s) in the forced decision map.';
export const USER_HAS_NO_FORCED_VARIATION = 'User %s is not in the forced variation map.';
export const USER_RECEIVED_DEFAULT_VARIABLE_VALUE =
'User "%s" is not in any variation or rollout rule. Returning default value for variable "%s" of feature flag "%s".';
Expand All @@ -75,12 +52,13 @@ export const MISSING_ATTRIBUTE_VALUE =
export const UNEXPECTED_TYPE_NULL =
'Audience condition %s evaluated to UNKNOWN because a null value was passed for user attribute "%s".';
export const UPDATED_OPTIMIZELY_CONFIG = 'Updated Optimizely config to revision %s (project id %s)';
export const UNABLE_TO_PARSE_AND_SKIPPED_HEADER = 'Unable to parse & skipped header item';
export const ADDING_AUTHORIZATION_HEADER_WITH_BEARER_TOKEN = 'Adding Authorization header with Bearer Token';
export const MAKING_DATAFILE_REQ_TO_URL_WITH_HEADERS = 'Making datafile request to url %s with headers: %s';
export const RESPONSE_STATUS_CODE = 'Response status code: %s';
export const SAVED_LAST_MODIFIED_HEADER_VALUE_FROM_RESPONSE = 'Saved last modified header value from response: %s';
export const USER_HAS_NO_FORCED_VARIATION_FOR_EXPERIMENT =
'No experiment %s mapped to user %s in the forced variation map.';
export const INVALID_EXPERIMENT_KEY_INFO =
'Experiment key %s is not in datafile. It is either invalid, paused, or archived.';

export const messages: string[] = [];
4 changes: 2 additions & 2 deletions lib/odp/event_manager/odp_event_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { isSuccessStatusCode } from '../../utils/http_request_handler/http_util'
import { ODP_DEFAULT_EVENT_TYPE, ODP_USER_KEY } from '../constant';
import {
EVENT_ACTION_INVALID,
EVENT_DATA_FOUND_TO_BE_INVALID,
EVENT_DATA_INVALID,
FAILED_TO_SEND_ODP_EVENTS,
ODP_EVENT_MANAGER_IS_NOT_RUNNING,
ODP_EVENTS_SHOULD_HAVE_ATLEAST_ONE_KEY_VALUE,
Expand Down Expand Up @@ -179,7 +179,7 @@ export class DefaultOdpEventManager extends BaseService implements OdpEventManag
}

if (!this.isDataValid(event.data)) {
this.logger?.error(EVENT_DATA_FOUND_TO_BE_INVALID);
this.logger?.error(EVENT_DATA_INVALID);
return;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/optimizely/index.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import {
NO_VARIATION_FOR_EXPERIMENT_KEY,
USER_NOT_IN_FORCED_VARIATION,
INSTANCE_CLOSED,
ONREADY_TIMEOUT_EXPIRED,
ONREADY_TIMEOUT,
} from 'error_message';

import {
Expand Down Expand Up @@ -9466,7 +9466,7 @@ describe('lib/optimizely', function() {
return readyPromise.then(() => {
return Promise.reject(new Error('PROMISE_SHOULD_NOT_HAVE_RESOLVED'));
}, (err) => {
assert.equal(err.baseMessage, ONREADY_TIMEOUT_EXPIRED);
assert.equal(err.baseMessage, ONREADY_TIMEOUT);
assert.deepEqual(err.params, [ 500 ]);
});
});
Expand All @@ -9491,7 +9491,7 @@ describe('lib/optimizely', function() {
return readyPromise.then(() => {
return Promise.reject(new Error(PROMISE_SHOULD_NOT_HAVE_RESOLVED));
}, (err) => {
assert.equal(err.baseMessage, ONREADY_TIMEOUT_EXPIRED);
assert.equal(err.baseMessage, ONREADY_TIMEOUT);
assert.deepEqual(err.params, [ 30000 ]);
});
});
Expand Down
4 changes: 2 additions & 2 deletions lib/optimizely/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import { resolvablePromise } from '../utils/promise/resolvablePromise';
import { NOTIFICATION_TYPES, DecisionNotificationType, DECISION_NOTIFICATION_TYPES } from '../notification_center/type';
import {
FEATURE_NOT_IN_DATAFILE,
INVALID_EXPERIMENT_KEY,
INVALID_INPUT_FORMAT,
NO_EVENT_PROCESSOR,
ODP_EVENT_FAILED,
Expand All @@ -88,6 +87,7 @@ import {
INVALID_CLIENT_ENGINE,
INVALID_DECIDE_OPTIONS,
INVALID_DEFAULT_DECIDE_OPTIONS,
INVALID_EXPERIMENT_KEY_INFO,
NOT_ACTIVATING_USER,
SHOULD_NOT_DISPATCH_ACTIVATE,
TRACK_EVENT,
Expand Down Expand Up @@ -452,7 +452,7 @@ export default class Optimizely implements Client {

const experiment = configObj.experimentKeyMap[experimentKey];
if (!experiment || experiment.isRollout) {
this.logger?.debug(INVALID_EXPERIMENT_KEY, experimentKey);
this.logger?.debug(INVALID_EXPERIMENT_KEY_INFO, experimentKey);
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/optimizely_user_context/index.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
USER_HAS_FORCED_DECISION_WITH_NO_RULE_SPECIFIED_BUT_INVALID,
USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED,
USER_HAS_FORCED_DECISION_WITH_RULE_SPECIFIED_BUT_INVALID,
} from 'log_message';
} from '../core/decision_service';

const getMockEventDispatcher = () => {
const dispatcher = {
Expand Down
1 change: 0 additions & 1 deletion lib/project_config/polling_datafile_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export class PollingDatafileManager extends BaseService implements DatafileManag
this.startPromise.reject(new OptimizelyError(DATAFILE_MANAGER_STOPPED));
}

this.logger?.debug(DATAFILE_MANAGER_STOPPED);
this.state = ServiceState.Terminated;
this.repeater.stop();
this.currentRequest?.abort();
Expand Down
4 changes: 2 additions & 2 deletions lib/project_config/project_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
UNEXPECTED_RESERVED_ATTRIBUTE_PREFIX,
UNRECOGNIZED_ATTRIBUTE,
VARIABLE_KEY_NOT_IN_DATAFILE,
VARIATION_ID_NOT_IN_DATAFILE_NO_EXPERIMENT,
VARIATION_ID_NOT_IN_DATAFILE,
} from 'error_message';
import { SKIPPING_JSON_VALIDATION, VALID_DATAFILE } from 'log_message';
import { OptimizelyError } from '../error/optimizly_error';
Expand Down Expand Up @@ -693,7 +693,7 @@ export const getVariableValueForVariation = function(
}

if (!projectConfig.variationVariableUsageMap.hasOwnProperty(variation.id)) {
logger?.error(VARIATION_ID_NOT_IN_DATAFILE_NO_EXPERIMENT, variation.id);
logger?.error(VARIATION_ID_NOT_IN_DATAFILE, variation.id);
return null;
}

Expand Down
3 changes: 1 addition & 2 deletions lib/utils/http_request_handler/request_handler.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import { AbortableRequest, Headers, RequestHandler, Response } from './http';
import { LoggerFacade, LogLevel } from '../../logging/logger';
import { REQUEST_TIMEOUT_MS } from '../enums';
import { REQUEST_ERROR, REQUEST_TIMEOUT } from 'error_message';
import { UNABLE_TO_PARSE_AND_SKIPPED_HEADER } from 'log_message';
import { REQUEST_ERROR, REQUEST_TIMEOUT, UNABLE_TO_PARSE_AND_SKIPPED_HEADER } from 'error_message';
import { OptimizelyError } from '../../error/optimizly_error';

/**
Expand Down

0 comments on commit 23da24b

Please sign in to comment.