Skip to content
7 changes: 3 additions & 4 deletions packages/optimizely-sdk/lib/core/decision_service/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright 2017, Optimizely, Inc. and contributors *
* Copyright 2017-2018, Optimizely, Inc. and contributors *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
Expand All @@ -26,7 +26,6 @@ var MODULE_NAME = 'DECISION_SERVICE';
var ERROR_MESSAGES = enums.ERROR_MESSAGES;
var LOG_LEVEL = enums.LOG_LEVEL;
var LOG_MESSAGES = enums.LOG_MESSAGES;
var RESERVED_ATTRIBUTE_KEY_BUCKETING_ID = '$opt_bucketing_id';
var DECISION_SOURCES = enums.DECISION_SOURCES;


Expand Down Expand Up @@ -67,8 +66,8 @@ DecisionService.prototype.getVariation = function(experimentKey, userId, attribu

// If the bucketing ID key is defined in attributes, than use that in place of the userID for the murmur hash key
if (!fns.isEmpty(attributes)) {
if (attributes.hasOwnProperty(RESERVED_ATTRIBUTE_KEY_BUCKETING_ID)) {
bucketingId = attributes[RESERVED_ATTRIBUTE_KEY_BUCKETING_ID];
if (attributes.hasOwnProperty(enums.CONTROL_ATTRIBUTES.BUCKETING_ID)) {
bucketingId = attributes[enums.CONTROL_ATTRIBUTES.BUCKETING_ID];
this.logger.log(LOG_LEVEL.DEBUG, sprintf('Setting the bucketing ID to %s.', bucketingId))
}
}
Expand Down
21 changes: 15 additions & 6 deletions packages/optimizely-sdk/lib/core/event_builder/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2016-2017, Optimizely
* Copyright 2016-2018, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,13 +30,14 @@ var HTTP_VERB = 'POST';
* @param {string} options.clientVersion The version of the client
* @param {Object} options.configObj Object representing project configuration, including datafile information and mappings for quick lookup
* @param {string} options.userId ID for user
* @param {Object} options.Logger logger
* @return {Object} Common params with properties that are used in both conversion and impression events
*/
function getCommonEventParams(options) {
var attributes = options.attributes;
var configObj = options.configObj;
var anonymize_ip = configObj.anonymizeIP;

var botFiltering = configObj.botFiltering;
if (anonymize_ip === null || anonymize_ip === undefined) {
anonymize_ip = false;
}
Expand All @@ -58,17 +59,25 @@ function getCommonEventParams(options) {
};

fns.forOwn(attributes, function(attributeValue, attributeKey){
var attributeId = projectConfig.getAttributeId(options.configObj, attributeKey);
var attributeId = projectConfig.getAttributeId(options.configObj, attributeKey, options.logger);
if (attributeId) {
var feature = {
commonParams.visitors[0].attributes.push({
entity_id: attributeId,
key: attributeKey,
type: CUSTOM_ATTRIBUTE_FEATURE_TYPE,
value: attributes[attributeKey],
};
commonParams.visitors[0].attributes.push(feature);
});
}
});

if (typeof botFiltering === 'boolean') {
commonParams.visitors[0].attributes.push({
entity_id: enums.CONTROL_ATTRIBUTES.BOT_FILTERING,
key: enums.CONTROL_ATTRIBUTES.BOT_FILTERING,
type: CUSTOM_ATTRIBUTE_FEATURE_TYPE,
value: botFiltering,
});
};
return commonParams;
}

Expand Down
Loading