lib/vwo/core/variation_decider.rb
# If UserStorageService is provided, save the assigned variation
#
# @param[String]              :user_id            Unique user identifier
# @param[String]              :campaign_key       Unique campaign identifier
# @param[String]              :variation_name     Variation identifier
# @param[String]              :goal_identifier    The unique campaign's goal identifier
# @param[Boolean]             :disable_logs       optional: disable logs if True
# @return[Boolean]                                true if found otherwise false
If UserStorageService is provided, save the assigned variation
If UserStorageService is provided save the assigned variation
def save_user_storage(user_id, campaign_key, campaign_type, variation_name, goal_identifier, disable_logs = false)
        unless @user_storage_service
          @logger.log(
            LogLevelEnum::DEBUG,
            format(LogMessageEnum::DebugMessages::NO_USER_STORAGE_SERVICE_SAVE, file: FILE),
            disable_logs
          )
          return false
        end
        new_campaign_user_mapping = {}
        new_campaign_user_mapping['campaign_key'] = campaign_key
        new_campaign_user_mapping['user_id'] = user_id
        new_campaign_user_mapping['variation_name'] = variation_name
        if !goal_identifier.empty?
          new_campaign_user_mapping['goal_identifier'] = goal_identifier
        end
        @user_storage_service.set(new_campaign_user_mapping)
        @logger.log(
          LogLevelEnum::INFO,
          format(LogMessageEnum::InfoMessages::SAVING_DATA_USER_STORAGE_SERVICE, file: FILE, user_id: user_id),
          disable_logs
        )
        @logger.log(
          LogLevelEnum::INFO,
          format(
            LogMessageEnum::InfoMessages::VARIATION_ALLOCATED,
            file: FILE,
            campaign_key: campaign_key,
            user_id: user_id,
            variation_name: variation_name,
            campaign_type: campaign_type
          ),
          disable_logs
        )
        true
      rescue StandardError
        @logger.log(
          LogLevelEnum::ERROR,
          format(LogMessageEnum::ErrorMessages::SAVE_USER_STORAGE_SERVICE_FAILED, file: FILE, user_id: user_id),
          disable_logs
        )
        false
      end
def save_user_storage ( user_id , campaign_key , campaign_type , variation_name , goal_identifier , disable_logs = false ) unless @user_storage_service @logger . log ( LogLevelEnum :: DEBUG , format ( LogMessageEnum :: DebugMessages :: NO_USER_STORAGE_SERVICE_SAVE , file : FILE ) , disable_logs ) return false end new_campaign_user_mapping = { } new_campaign_user_mapping [ 'campaign_key' ] = campaign_key new_campaign_user_mapping [ 'user_id' ] = user_id new_campaign_user_mapping [ 'variation_name' ] = variation_name if ! goal_identifier . empty? new_campaign_user_mapping [ 'goal_identifier' ] = goal_identifier end @user_storage_service . set ( new_campaign_user_mapping ) @logger . log ( LogLevelEnum :: INFO , format ( LogMessageEnum :: InfoMessages :: SAVING_DATA_USER_STORAGE_SERVICE , file : FILE , user_id : user_id ) , disable_logs ) @logger . log ( LogLevelEnum :: INFO , format ( LogMessageEnum :: InfoMessages :: VARIATION_ALLOCATED , file : FILE , campaign_key : campaign_key , user_id : user_id , variation_name : variation_name , campaign_type : campaign_type ) , disable_logs ) true rescue StandardError @logger . log ( LogLevelEnum :: ERROR , format ( LogMessageEnum :: ErrorMessages :: SAVE_USER_STORAGE_SERVICE_FAILED , file : FILE , user_id : user_id ) , disable_logs ) false end
If UserStorageService is provided, save the assigned variation
If UserStorageService is provided save the assigned variation
user_id
<not_specific>
campaign_key
<not_specific>
campaign_type
<not_specific>
variation_name
<not_specific>
goal_identifier
<not_specific>
disable_logs
<not_specific>
param[String]
:user_id Unique user identifier
: user_id Unique user identifier
param[String]
:campaign_key Unique campaign identifier
: campaign_key Unique campaign identifier
param[String]
:variation_name Variation identifier
: variation_name Variation identifier
param[String]
:goal_identifier The unique campaign's goal identifier
: goal_identifier The unique campaign ' s goal identifier
param[Boolean]
:disable_logs optional: disable logs if True
: disable_logs optional : disable logs if True
return[Boolean]
true if found otherwise false
true if found otherwise false