8000 fix: log error message when user allocated to vacated space in group … · optimizely/javascript-sdk@7077fb3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7077fb3

Browse files
fayyazarshadmjc1283
authored andcommitted
fix: log error message when user allocated to vacated space in group or experiment (#366)
Summary: When a user is allocated to space in a group that used to be occupied by an experiment, but is now unallocated, the JS SDK logs an error message. This is not an error, so it shouldn't log an error message.
1 parent 4845e50 commit 7077fb3

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

packages/optimizely-sdk/lib/core/bucketer/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ module.exports = {
8787
bucketerParams.logger.log(LOG_LEVEL.DEBUG, bucketedUserLogMessage);
8888

8989
var entityId = module.exports._findBucket(bucketValue, bucketerParams.trafficAllocationConfig);
90-
if (entityId === null) {
90+
if (!entityId) {
9191
var userHasNoVariationLogMessage = sprintf(LOG_MESSAGES.USER_HAS_NO_VARIATION, MODULE_NAME, bucketerParams.userId, bucketerParams.experimentKey);
9292
bucketerParams.logger.log(LOG_LEVEL.DEBUG, userHasNoVariationLogMessage);
93-
} else if (entityId === '' || !bucketerParams.variationIdMap.hasOwnProperty(entityId)) {
93+
} else if (!bucketerParams.variationIdMap.hasOwnProperty(entityId)) {
9494
var invalidVariationIdLogMessage = sprintf(LOG_MESSAGES.INVALID_VARIATION_ID, MODULE_NAME);
9595
bucketerParams.logger.log(LOG_LEVEL.WARNING, invalidVariationIdLogMessage);
9696
return null;

packages/optimizely-sdk/lib/core/bucketer/index.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ describe('lib/core/bucketer', function() {
258258
it('should return null', function() {
259259
var bucketerParamsTest1 = cloneDeep(bucketerParams);
260260
bucketerParamsTest1.userId = 'ppid1';
261-
expect(bucketer.bucket(bucketerParamsTest1)).to.equal(null);
261+
expect(bucketer.bucket(bucketerParamsTest1)).to.equal('');
262262
});
263263
});
264264

packages/optimizely-sdk/lib/core/decision_service/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ DecisionService.prototype._getVariationForFeatureExperiment = function(configObj
349349

350350
DecisionService.prototype._getExperimentInGroup = function(configObj, group, userId) {
351351
var experimentId = bucketer.bucketUserIntoExperiment(group, userId, userId, this.logger);
352-
if (experimentId !== null) {
352+
if (experimentId) {
353353
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP, MODULE_NAME, userId, experimentId, group.id));
354354
var experiment = projectConfig.getExperimentFromId(configObj, experimentId, this.logger);
355355
if (experiment) {

0 commit comments

Comments
 (0)
0