Skip to content

Commit

Permalink
update logs as per python
Browse files Browse the repository at this point in the history
  • Loading branch information
fayyazarshad committed Jul 8, 2020
1 parent c290049 commit fcf75fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
33 changes: 13 additions & 20 deletions packages/optimizely-sdk/lib/core/decision_service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
};

/**
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion packages/optimizely-sdk/lib/utils/enums/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down

0 comments on commit fcf75fb

Please sign in to comment.