From f0059c3aa6c5df43f3507f9fd41e2f12a64af079 Mon Sep 17 00:00:00 2001 From: fayyazarshad Date: Wed, 8 Jul 2020 17:48:13 +0500 Subject: [PATCH] update logs as per python --- .../lib/core/decision_service/index.js | 33 ++++++++----------- .../optimizely-sdk/lib/utils/enums/index.js | 2 +- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/packages/optimizely-sdk/lib/core/decision_service/index.js b/packages/optimizely-sdk/lib/core/decision_service/index.js index 4ab768c77..945148946 100644 --- a/packages/optimizely-sdk/lib/core/decision_service/index.js +++ b/packages/optimizely-sdk/lib/core/decision_service/index.js @@ -92,6 +92,13 @@ DecisionService.prototype.getVariation = function(configObj, experimentKey, user // Perform regular targeting and bucketing if (!this.__checkIfUserIsInAudience(configObj, experimentKey, AUDIENCE_EVALUATION_TYPES.EXPERIMENT, userId, attributes, '')) { + var userDoesNotMeetConditionsLogMessage = sprintf( + LOG_MESSAGES.USER_NOT_IN_EXPERIMENT, + MODULE_NAME, + userId, + experimentKey + ); + this.logger.log(LOG_LEVEL.INFO, userDoesNotMeetConditionsLogMessage); return null; } @@ -220,18 +227,7 @@ DecisionService.prototype.__checkIfUserIsInAudience = function(configObj, experi ) ); - if (!result) { - var userDoesNotMeetConditionsLogMessage = sprintf( - LOG_MESSAGES.USER_NOT_IN_EXPERIMENT, - MODULE_NAME, - userId, - loggingKey || experimentKey - ); - this.logger.log(LOG_LEVEL.INFO, userDoesNotMeetConditionsLogMessage); - return false; - } - - return true; + return result; }; /** @@ -358,14 +354,7 @@ DecisionService.prototype.getVariationForFeature = function(configObj, feature, return experimentDecision; } - var rolloutDecision = this._getVariationForRollout(configObj, feature, userId, attributes); - if (rolloutDecision.variation !== null) { - this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_IN_ROLLOUT, MODULE_NAME, userId, feature.key)); - return rolloutDecision; - } - - this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_NOT_IN_ROLLOUT, MODULE_NAME, userId, feature.key)); - return rolloutDecision; + return this._getVariationForRollout(configObj, feature, userId, attributes); }; DecisionService.prototype._getVariationForFeatureExperiment = function(configObj, feature, userId, attributes) { @@ -505,6 +494,10 @@ DecisionService.prototype._getVariationForRollout = function(configObj, feature, var everyoneElseRule = configObj.experimentKeyMap[rollout.experiments[endIndex].key]; if (this.__checkIfUserIsInAudience(configObj, everyoneElseRule.key, AUDIENCE_EVALUATION_TYPES.RULE, userId, attributes, 'Everyone Else')) { + this.logger.log( + LOG_LEVEL.DEBUG, + sprintf(LOG_MESSAGES.USER_MEETS_CONDITIONS_FOR_TARGETING_RULE, MODULE_NAME, userId, 'Everyone Else') + ); bucketerParams = this.__buildBucketerParams(configObj, everyoneElseRule.key, bucketingId, userId); variationId = bucketer.bucket(bucketerParams); variation = configObj.variationIdMap[variationId]; diff --git a/packages/optimizely-sdk/lib/utils/enums/index.js b/packages/optimizely-sdk/lib/utils/enums/index.js index 4f4b691eb..f31bb9779 100644 --- a/packages/optimizely-sdk/lib/utils/enums/index.js +++ b/packages/optimizely-sdk/lib/utils/enums/index.js @@ -96,7 +96,7 @@ export var LOG_MESSAGES = { SHOULD_NOT_DISPATCH_ACTIVATE: '%s: Experiment %s is not in "Running" state. Not activating user.', SKIPPING_JSON_VALIDATION: '%s: Skipping JSON schema validation.', TRACK_EVENT: '%s: Tracking event %s for user %s.', - USER_ASSIGNED_TO_VARIATION_BUCKET: '%s: Assigned variation bucket %s to user %s.', + USER_ASSIGNED_TO_VARIATION_BUCKET: '%s: Assigned bucket %s to user with bucketing ID %s.', USER_ASSIGNED_TO_EXPERIMENT_BUCKET: '%s: Assigned experiment bucket %s to user %s.', USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP: '%s: User %s is in experiment %s of group %s.', USER_BUCKETED_INTO_TARGETING_RULE: '%s: User %s bucketed into targeting rule %s.',