packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, attributeKey, logger) {
    var attribute = projectConfig.attributeKeyMap[attributeKey];
    var hasReservedPrefix = attributeKey.indexOf(RESERVED_ATTRIBUTE_PREFIX) === 0;
    if (attribute) {
      if (hasReservedPrefix) {
        logger.log(LOG_LEVEL.WARN,
                   sprintf('Attribute %s unexpectedly has reserved prefix %s; using attribute ID instead of reserved attribute name.', attributeKey, RESERVED_ATTRIBUTE_PREFIX));
      }
      return attribute.id;
    } else if (hasReservedPrefix) {
      return attributeKey;
    }

    logger.log(LOG_LEVEL.DEBUG, sprintf(ERROR_MESSAGES.UNRECOGNIZED_ATTRIBUTE, MODULE_NAME, attributeKey));
    return null;
  }
function(projectConfig, attributeKey, logger) {
    var attribute = projectConfig.attributeKeyMap[attributeKey];
    var hasReservedPrefix = attributeKey.indexOf(RESERVED_ATTRIBUTE_PREFIX) === 0;
    if (attribute) {
      if (hasReservedPrefix) {
        logger.log(LOG_LEVEL.WARN,
                   sprintf('Attribute %s unexpectedly has reserved prefix %s; using attribute ID instead of reserved attribute name.', attributeKey, RESERVED_ATTRIBUTE_PREFIX));
      }
      return attribute.id;
    } else if (hasReservedPrefix) {
      return attributeKey;
    }

    logger.log(LOG_LEVEL.DEBUG, sprintf(ERROR_MESSAGES.UNRECOGNIZED_ATTRIBUTE, MODULE_NAME, attributeKey));
    return null;
  }
function ( projectConfig , attributeKey , logger ) { var attribute = projectConfig . attributeKeyMap [ attributeKey ] ; var hasReservedPrefix = attributeKey . indexOf ( RESERVED_ATTRIBUTE_PREFIX ) === 0 ; if ( attribute ) { if ( hasReservedPrefix ) { logger . log ( LOG_LEVEL . WARN , sprintf ( 'Attribute %s unexpectedly has reserved prefix %s; using attribute ID instead of reserved attribute name.' , attributeKey , RESERVED_ATTRIBUTE_PREFIX ) ) ; } return attribute . id ; } else if ( hasReservedPrefix ) { return attributeKey ; } logger . log ( LOG_LEVEL . DEBUG , sprintf ( ERROR_MESSAGES . UNRECOGNIZED_ATTRIBUTE , MODULE_NAME , attributeKey ) ) ; return null ; }
Get attribute ID for the provided attribute key
@param  {Object}      projectConfig Object representing project configuration
@param  {string}      attributeKey  Attribute key for which ID is to be determined
@param  {Object}      logger
@return {string|null} Attribute ID corresponding to the provided attribute key. Attribute key if it is a reserved attribute.
Get attribute ID for the provided attribute key