Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 5a376da

Browse files
debugger hack
1 parent 599858b commit 5a376da

File tree

6 files changed

+80
-69
lines changed

6 files changed

+80
-69
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
var enums = require('../../utils/enums');
2121
var murmurhash = require('murmurhash');
22-
var sprintf = require('sprintf-js').sprintf;
22+
var sprintf = require('../../utils/sprintf');
2323

2424
var ERROR_MESSAGES = enums.ERROR_MESSAGES;
2525
var HASH_SEED = 1;
@@ -53,7 +53,7 @@ module.exports = {
5353
if (groupId) {
5454
var group = bucketerParams.groupIdMap[groupId];
5555
if (!group) {
56-
throw new Error(sprintf(ERROR_MESSAGES.INVALID_GROUP_ID, MODULE_NAME, groupId));
56+
throw new Error(sprintf(ERROR_MESSAGES.INVALID_GROUP_ID, MODULE_NAME, groupId).message);
5757
}
5858
if (group.policy === RANDOM_POLICY) {
5959
var bucketedExperimentId = module.exports.bucketUserIntoExperiment(group,
@@ -63,40 +63,40 @@ module.exports = {
6363

6464
// Return if user is not bucketed into any experiment
6565
if (bucketedExperimentId === null) {
66-
var notbucketedInAnyExperimentLogMessage = sprintf(LOG_MESSAGES.USER_NOT_IN_ANY_EXPERIMENT, MODULE_NAME, bucketerParams.userId, groupId);
66+
var notbucketedInAnyExperimentLogMessage = sprintf(LOG_MESSAGES.USER_NOT_IN_ANY_EXPERIMENT, MODULE_NAME, {useId: bucketerParams.userId, groupId});
6767
bucketerParams.logger.log(LOG_LEVEL.INFO, notbucketedInAnyExperimentLogMessage);
6868
return null;
6969
}
7070

7171
// Return if user is bucketed into a different experiment than the one specified
7272
if (bucketedExperimentId !== bucketerParams.experimentId) {
73-
var notBucketedIntoExperimentOfGroupLogMessage = sprintf(LOG_MESSAGES.USER_NOT_BUCKETED_INTO_EXPERIMENT_IN_GROUP, MODULE_NAME, bucketerParams.userId, bucketerParams.experimentKey, groupId);
73+
var notBucketedIntoExperimentOfGroupLogMessage = sprintf(LOG_MESSAGES.USER_NOT_BUCKETED_INTO_EXPERIMENT_IN_GROUP, MODULE_NAME, {userId: bucketerParams.userId, experimentKey: bucketerParams.experimentKey, groupId});
7474
bucketerParams.logger.log(LOG_LEVEL.INFO, notBucketedIntoExperimentOfGroupLogMessage);
7575
return null;
7676
}
7777

7878
// Continue bucketing if user is bucketed into specified experiment
79-
var bucketedIntoExperimentOfGroupLogMessage = sprintf(LOG_MESSAGES.USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP, MODULE_NAME, bucketerParams.userId, bucketerParams.experimentKey, groupId);
79+
var bucketedIntoExperimentOfGroupLogMessage = sprintf(LOG_MESSAGES.USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP, MODULE_NAME, {userId: bucketerParams.userId, experimentKey: bucketerParams.experimentKey, groupId});
8080
bucketerParams.logger.log(LOG_LEVEL.INFO, bucketedIntoExperimentOfGroupLogMessage);
8181
}
8282
}
83-
var bucketingId = sprintf('%s%s', bucketerParams.bucketingId, bucketerParams.experimentId);
83+
var bucketingId = sprintf('%s%s', bucketerParams.bucketingId, bucketerParams.experimentId).message;
8484
var bucketValue = module.exports._generateBucketValue(bucketingId);
8585

86-
var bucketedUserLogMessage = sprintf(LOG_MESSAGES.USER_ASSIGNED_TO_VARIATION_BUCKET, MODULE_NAME, bucketValue, bucketerParams.userId);
86+
var bucketedUserLogMessage = sprintf(LOG_MESSAGES.USER_ASSIGNED_TO_VARIATION_BUCKET, MODULE_NAME, {bucketValue, userId: bucketerParams.userId});
8787
bucketerParams.logger.log(LOG_LEVEL.DEBUG, bucketedUserLogMessage);
8888

8989
var entityId = module.exports._findBucket(bucketValue, bucketerParams.trafficAllocationConfig);
9090
if (entityId === null) {
91-
var userHasNoVariationLogMessage = sprintf(LOG_MESSAGES.USER_HAS_NO_VARIATION, MODULE_NAME, bucketerParams.userId, bucketerParams.experimentKey);
91+
var userHasNoVariationLogMessage = sprintf(LOG_MESSAGES.USER_HAS_NO_VARIATION, MODULE_NAME, {userId: bucketerParams.userId, experimentKey: bucketerParams.experimentKey});
9292
bucketerParams.logger.log(LOG_LEVEL.DEBUG, userHasNoVariationLogMessage);
9393
} else if (entityId === '' || !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;
9797
} else {
9898
var variationKey = bucketerParams.variationIdMap[entityId].key;
99-
var userInVariationLogMessage = sprintf(LOG_MESSAGES.USER_HAS_VARIATION, MODULE_NAME, bucketerParams.userId, variationKey, bucketerParams.experimentKey);
99+
var userInVariationLogMessage = sprintf(LOG_MESSAGES.USER_HAS_VARIATION, MODULE_NAME, {userId: bucketerParams.userId, variationKey, experimentKey: bucketerParams.experimentKey});
100100
bucketerParams.logger.log(LOG_LEVEL.INFO, userInVariationLogMessage);
101101
}
102102

@@ -112,9 +112,9 @@ module.exports = {
112112
* @return {string} ID of experiment if user is bucketed into experiment within the group, null otherwise
113113
*/
114114
bucketUserIntoExperiment: function(group, bucketingId, userId, logger) {
115-
var bucketingKey = sprintf('%s%s', bucketingId, group.id);
115+
var bucketingKey = sprintf('%s%s', bucketingId, group.id).message;
116116
var bucketValue = module.exports._generateBucketValue(bucketingKey);
117-
logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_ASSIGNED_TO_EXPERIMENT_BUCKET, MODULE_NAME, bucketValue, userId));
117+
logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_ASSIGNED_TO_EXPERIMENT_BUCKET, MODULE_NAME, {bucketValue, userId}));
118118
var trafficAllocationConfig = group.trafficAllocation;
119119
var bucketedExperimentId = module.exports._findBucket(bucketValue, trafficAllocationConfig);
120120
return bucketedExperimentId;
@@ -151,7 +151,7 @@ module.exports = {
151151
var ratio = hashValue / MAX_HASH_VALUE;
152152
return parseInt(ratio * MAX_TRAFFIC_VALUE, 10);
153153
} catch (ex) {
154-
throw new Error(sprintf(ERROR_MESSAGES.INVALID_BUCKETING_ID, MODULE_NAME, bucketingKey, ex.message));
154+
throw new Error(sprintf(ERROR_MESSAGES.INVALID_BUCKETING_ID, MODULE_NAME, {bucketingKey, error: ex.message}).message);
155155
}
156156
},
157157
};

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var enums = require('../../utils/enums');
2020
var fns = require('../../utils/fns');
2121
var projectConfig = require('../project_config');
2222

23-
var sprintf = require('sprintf-js').sprintf;
23+
var sprintf = require('../../utils/sprintf');
2424

2525
var MODULE_NAME = 'DECISION_SERVICE';
2626
var ERROR_MESSAGES = enums.ERROR_MESSAGES;
@@ -83,7 +83,7 @@ DecisionService.prototype.getVariation = function(experimentKey, userId, attribu
8383
var experimentBucketMap = this.__resolveExperimentBucketMap(userId, attributes);
8484
variation = this.__getStoredVariation(experiment, userId, experimentBucketMap);
8585
if (!!variation) {
86-
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.RETURNING_STORED_VARIATION, MODULE_NAME, variation.key, experimentKey, userId));
86+
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.RETURNING_STORED_VARIATION, MODULE_NAME, {variationKey: variation.key, experimentKey, userId}));
8787
return variation.key;
8888
}
8989

@@ -126,7 +126,7 @@ DecisionService.prototype.__resolveExperimentBucketMap = function(userId, attrib
126126
*/
127127
DecisionService.prototype.__checkIfExperimentIsActive = function(experimentKey, userId) {
128128
if (!projectConfig.isActive(this.configObj, experimentKey)) {
129-
var experimentNotRunningLogMessage = sprintf(LOG_MESSAGES.EXPERIMENT_NOT_RUNNING, MODULE_NAME, experimentKey);
129+
var experimentNotRunningLogMessage = sprintf(LOG_MESSAGES.EXPERIMENT_NOT_RUNNING, MODULE_NAME, {experimentKey});
130130
this.logger.log(LOG_LEVEL.INFO, experimentNotRunningLogMessage);
131131
return false;
132132
}
@@ -144,11 +144,11 @@ DecisionService.prototype.__getWhitelistedVariation = function(experiment, userI
144144
if (!fns.isEmpty(experiment.forcedVariations) && experiment.forcedVariations.hasOwnProperty(userId)) {
145145
var forcedVariationKey = experiment.forcedVariations[userId];
146146
if (experiment.variationKeyMap.hasOwnProperty(forcedVariationKey)) {
147-
var forcedBucketingSucceededMessageLog = sprintf(LOG_MESSAGES.USER_FORCED_IN_VARIATION, MODULE_NAME, userId, forcedVariationKey);
147+
var forcedBucketingSucceededMessageLog = sprintf(LOG_MESSAGES.USER_FORCED_IN_VARIATION, MODULE_NAME, {userId, forcedVariationKey});
148148
this.logger.log(LOG_LEVEL.INFO, forcedBucketingSucceededMessageLog);
149149
return experiment.variationKeyMap[forcedVariationKey];
150150
} else {
151-
var forcedBucketingFailedMessageLog = sprintf(LOG_MESSAGES.FORCED_BUCKETING_FAILED, MODULE_NAME, forcedVariationKey, userId);
151+
var forcedBucketingFailedMessageLog = sprintf(LOG_MESSAGES.FORCED_BUCKETING_FAILED, MODULE_NAME, {forcedVariationKey, userId});
152152
this.logger.log(LOG_LEVEL.ERROR, forcedBucketingFailedMessageLog);
153153
return null;
154154
}
@@ -168,7 +168,7 @@ DecisionService.prototype.__checkIfUserIsInAudience = function(experimentKey, us
168168
var experimentAudienceConditions = projectConfig.getExperimentAudienceConditions(this.configObj, experimentKey);
169169
var audiencesById = projectConfig.getAudiencesById(this.configObj);
170170
if (!audienceEvaluator.evaluate(experimentAudienceConditions, audiencesById, attributes)) {
171-
var userDoesNotMeetConditionsLogMessage = sprintf(LOG_MESSAGES.USER_NOT_IN_EXPERIMENT, MODULE_NAME, userId, experimentKey);
171+
var userDoesNotMeetConditionsLogMessage = sprintf(LOG_MESSAGES.USER_NOT_IN_EXPERIMENT, MODULE_NAME, {userId, experimentKey});
172172
this.logger.log(LOG_LEVEL.INFO, userDoesNotMeetConditionsLogMessage);
173173
return false;
174174
}
@@ -211,7 +211,7 @@ DecisionService.prototype.__getStoredVariation = function(experiment, userId, ex
211211
if (this.configObj.variationIdMap.hasOwnProperty(variationId)) {
212212
return this.configObj.variationIdMap[decision.variation_id];
213213
} else {
214-
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.SAVED_VARIATION_NOT_FOUND, MODULE_NAME, userId, variationId, experiment.key));
214+
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.SAVED_VARIATION_NOT_FOUND, MODULE_NAME, {userId, variationId, experimentKey: experiment.key}));
215215
}
216216
}
217217

@@ -236,7 +236,7 @@ DecisionService.prototype.__getUserProfile = function(userId) {
236236
try {
237237
return this.userProfileService.lookup(userId);
238238
} catch (ex) {
239-
this.logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.USER_PROFILE_LOOKUP_ERROR, MODULE_NAME, userId, ex.message));
239+
this.logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.USER_PROFILE_LOOKUP_ERROR, MODULE_NAME, {userId, error: ex.message}));
240240
}
241241
};
242242

@@ -263,9 +263,9 @@ DecisionService.prototype.__saveUserProfile = function(experiment, variation, us
263263
experiment_bucket_map: newBucketMap,
264264
});
265265

266-
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.SAVED_VARIATION, MODULE_NAME, variation.key, experiment.key, userId));
266+
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.SAVED_VARIATION, MODULE_NAME, {variationKey: variation.key, experimentKey: experiment.key, userId}));
267267
} catch (ex) {
268-
this.logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.USER_PROFILE_SAVE_ERROR, MODULE_NAME, userId, ex.message));
268+
this.logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.USER_PROFILE_SAVE_ERROR, MODULE_NAME, {userId, error: ex.message}));
269269
}
270270
};
271271

@@ -286,19 +286,19 @@ DecisionService.prototype.__saveUserProfile = function(experiment, variation, us
286286
DecisionService.prototype.getVariationForFeature = function(feature, userId, attributes) {
287287
var experimentDecision = this._getVariationForFeatureExperiment(feature, userId, attributes);
288288
if (experimentDecision.variation !== null) {
289-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_IN_FEATURE_EXPERIMENT, MODULE_NAME, userId, experimentDecision.variation.key, experimentDecision.experiment.key, feature.key));
289+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_IN_FEATURE_EXPERIMENT, MODULE_NAME, {userId, variationKey: experimentDecision.variation.key, experimentKey: experimentDecision.experiment.key, featureKey: feature.key}));
290290
return experimentDecision;
291291
}
292292

293-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_NOT_IN_FEATURE_EXPERIMENT, MODULE_NAME, userId, feature.key));
293+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_NOT_IN_FEATURE_EXPERIMENT, MODULE_NAME, {userId, featureKey: feature.key}));
294294

295295
var rolloutDecision = this._getVariationForRollout(feature, userId, attributes);
296296
if (rolloutDecision.variation !== null) {
297-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_IN_ROLLOUT, MODULE_NAME, userId, feature.key));
297+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_IN_ROLLOUT, MODULE_NAME, {userId, featureKey: feature.key}));
298298
return rolloutDecision;
299299
}
300300

301-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_NOT_IN_ROLLOUT, MODULE_NAME, userId, feature.key));
301+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_NOT_IN_ROLLOUT, MODULE_NAME, {userId, featureKey: feature.key}));
302302

303303
return {
304304
experiment: null,
@@ -327,7 +327,7 @@ DecisionService.prototype._getVariationForFeatureExperiment = function(feature,
327327
variationKey = this.getVariation(experiment.key, userId, attributes);
328328
}
329329
} else {
330-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.FEATURE_HAS_NO_EXPERIMENTS, MODULE_NAME, feature.key));
330+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.FEATURE_HAS_NO_EXPERIMENTS, MODULE_NAME, {featureKey: feature.key}));
331331
}
332332

333333
var variation = null;
@@ -344,20 +344,20 @@ DecisionService.prototype._getVariationForFeatureExperiment = function(feature,
344344
DecisionService.prototype._getExperimentInGroup = function(group, userId) {
345345
var experimentId = bucketer.bucketUserIntoExperiment(group, userId, userId, this.logger);
346346
if (experimentId !== null) {
347-
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP, MODULE_NAME, userId, experimentId, group.id));
347+
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.USER_BUCKETED_INTO_EXPERIMENT_IN_GROUP, MODULE_NAME, {userId, experimentId, groupId: group.id}));
348348
var experiment = projectConfig.getExperimentFromId(this.configObj, experimentId, this.logger);
349349
if (experiment) {
350350
return experiment;
351351
}
352352
}
353353

354-
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.USER_NOT_BUCKETED_INTO_ANY_EXPERIMENT_IN_GROUP, MODULE_NAME, userId, group.id));
354+
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.USER_NOT_BUCKETED_INTO_ANY_EXPERIMENT_IN_GROUP, MODULE_NAME, {userId, groupId: group.id}));
355355
return null;
356356
};
357357

358358
DecisionService.prototype._getVariationForRollout = function(feature, userId, attributes) {
359359
if (!feature.rolloutId) {
360-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.NO_ROLLOUT_EXISTS, MODULE_NAME, feature.key));
360+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.NO_ROLLOUT_EXISTS, MODULE_NAME, {featureKey: feature.key}));
361361
return {
362362
experiment: null,
363363
variation: null,
@@ -367,7 +367,7 @@ DecisionService.prototype._getVariationForRollout = function(feature, userId, at
367367

368368
var rollout = this.configObj.rolloutIdMap[feature.rolloutId];
369369
if (!rollout) {
370-
this.logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.INVALID_ROLLOUT_ID, MODULE_NAME, feature.rolloutId, feature.key));
370+
this.logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.INVALID_ROLLOUT_ID, MODULE_NAME, {rolloutId: feature.rolloutId, featureKey: feature.key}));
371371
return {
372372
experiment: null,
373373
variation: null,
@@ -376,7 +376,7 @@ DecisionService.prototype._getVariationForRollout = function(feature, userId, at
376376
}
377377

378378
if (rollout.experiments.length === 0) {
379-
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.ROLLOUT_HAS_NO_EXPERIMENTS, MODULE_NAME, feature.rolloutId));
379+
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.ROLLOUT_HAS_NO_EXPERIMENTS, MODULE_NAME, {rolloutId: feature.rolloutId}));
380380
return {
381381
experiment: null,
382382
variation: null,
@@ -396,23 +396,23 @@ DecisionService.prototype._getVariationForRollout = function(feature, userId, at
396396
experiment = this.configObj.experimentKeyMap[rollout.experiments[index].key];
397397

398398
if (!this.__checkIfUserIsInAudience(experiment.key, userId, attributes)) {
399-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_DOESNT_MEET_CONDITIONS_FOR_TARGETING_RULE, MODULE_NAME, userId, index + 1));
399+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_DOESNT_MEET_CONDITIONS_FOR_TARGETING_RULE, MODULE_NAME, {userId, index: index + 1}));
400400
continue;
401401
}
402402

403-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_MEETS_CONDITIONS_FOR_TARGETING_RULE, MODULE_NAME, userId, index + 1));
403+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_MEETS_CONDITIONS_FOR_TARGETING_RULE, MODULE_NAME, {userId, index: index + 1}));
404404
bucketerParams = this.__buildBucketerParams(experiment.key, userId, userId);
405405
variationId = bucketer.bucket(bucketerParams);
406406
variation = this.configObj.variationIdMap[variationId];
407407
if (variation) {
408-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_BUCKETED_INTO_TARGETING_RULE, MODULE_NAME, userId, index + 1));
408+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_BUCKETED_INTO_TARGETING_RULE, MODULE_NAME, {userId, index: index + 1}));
409409
return {
410410
experiment: experiment,
411411
variation: variation,
412412
decisionSource: DECISION_SOURCES.ROLLOUT,
413413
};
414414
} else {
415-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_NOT_BUCKETED_INTO_TARGETING_RULE, MODULE_NAME, userId, index + 1));
415+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_NOT_BUCKETED_INTO_TARGETING_RULE, MODULE_NAME, {userId, index: index + 1}));
416416
break;
417417
}
418418
}
@@ -423,14 +423,14 @@ DecisionService.prototype._getVariationForRollout = function(feature, userId, at
423423
variationId = bucketer.bucket(bucketerParams);
424424
variation = this.configObj.variationIdMap[variationId];
425425
if (variation) {
426-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_BUCKETED_INTO_EVERYONE_TARGETING_RULE, MODULE_NAME, userId));
426+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_BUCKETED_INTO_EVERYONE_TARGETING_RULE, MODULE_NAME, {userId}));
427427
return {
428428
experiment: everyoneElseExperiment,
429429
variation: variation,
430430
decisionSource: DECISION_SOURCES.ROLLOUT,
431431
};
432432
} else {
433-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_NOT_BUCKETED_INTO_EVERYONE_TARGETING_RULE, MODULE_NAME, userId));
433+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_NOT_BUCKETED_INTO_EVERYONE_TARGETING_RULE, MODULE_NAME, {userId}));
434434
}
435435
}
436436

@@ -454,7 +454,7 @@ DecisionService.prototype._getBucketingId = function(userId, attributes) {
454454
if ((attributes != null && typeof attributes === 'object') && attributes.hasOwnProperty(enums.CONTROL_ATTRIBUTES.BUCKETING_ID)) {
455455
if (typeof attributes[enums.CONTROL_ATTRIBUTES.BUCKETING_ID] === 'string') {
456456
bucketingId = attributes[enums.CONTROL_ATTRIBUTES.BUCKETING_ID];
457-
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.VALID_BUCKETING_ID, MODULE_NAME, bucketingId));
457+
this.logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.VALID_BUCKETING_ID, MODULE_NAME, {bucketingId}));
458458
} else {
459459
this.logger.log(LOG_LEVEL.WARNING, sprintf(LOG_MESSAGES.BUCKETING_ID_NOT_STRING, MODULE_NAME));
460460
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
var enums = require('../../utils/enums');
1818
var fns = require('../../utils/fns');
19-
var sprintf = require('sprintf-js').sprintf;
19+
var sprintf = require('../../utils/sprintf');
2020

2121
var LOG_LEVEL = enums.LOG_LEVEL;
2222
var LOG_MESSAGES = enums.LOG_MESSAGES;
@@ -165,7 +165,7 @@ NotificationCenter.prototype.sendNotifications = function (notificationType, not
165165
try {
166166
callback(notificationData);
167167
} catch (ex) {
168-
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.NOTIFICATION_LISTENER_EXCEPTION, MODULE_NAME, notificationType, ex.message));
168+
this.logger.log(LOG_LEVEL.ERROR, sprintf(LOG_MESSAGES.NOTIFICATION_LISTENER_EXCEPTION, MODULE_NAME, {notificationType, error: ex.message}));
169169
}
170170
}.bind(this));
171171
} catch (e) {

0 commit comments

Comments
 (0)