lib/vwo/utils/impression.rb
# Creates the impression from the arguments passed
#
# @param[Hash]                        :settings_file          Settings file object
# @param[String]                      :campaign_id            Campaign identifier
# @param[String]                      :variation_id           Variation identifier
# @param[String]                      :user_id                User identifier
# @param[String]                      :sdk_key                SDK Key
# @param[String]                      :goal_id                Goal identifier, if building track impression
# @param[String|Float|Integer|nil)    :revenue                Number value, in any representation, if building track impression
#
# @return[nil|Hash]                                           None if campaign ID or variation ID is invalid,
#                                                             Else Properties(dict)
Creates the impression from the arguments passed
Creates the impression from the arguments passed
def create_impression(settings_file, campaign_id, variation_id, user_id, sdk_key, goal_id = nil, revenue = nil, usage_stats = {})
        return unless valid_number?(campaign_id) && valid_string?(user_id)
        is_track_user_api = true
        is_track_user_api = false unless goal_id.nil?
        account_id = settings_file['accountId']
        impression = {
          account_id: account_id,
          experiment_id: campaign_id,
          ap: PLATFORM,
          combination: variation_id,
          random: get_random_number,
          sId: get_current_unix_timestamp,
          u: generator_for(user_id, account_id),
          env: sdk_key
        }
        sdk_version = Gem.loaded_specs['vwo_sdk'] ? Gem.loaded_specs['vwo_sdk'].version : VWO::SDK_VERSION
        impression['sdk'] = 'ruby'
        impression['sdk-v'] = sdk_version
        impression = usage_stats.merge(impression)
        url = HTTPS_PROTOCOL + ENDPOINTS::BASE_URL
        logger = VWO::Logger.get_instance
        if is_track_user_api
          impression['ed'] = JSON.generate(p: 'server')
          impression['url'] = "#{url}#{ENDPOINTS::TRACK_USER}"
          logger.log(
            LogLevelEnum::DEBUG,
            format(
              LogMessageEnum::DebugMessages::IMPRESSION_FOR_TRACK_USER,
              file: FileNameEnum::ImpressionUtil,
              properties: remove_sensitive_properties(impression)
            )
          )
        else
          impression['url'] = url + ENDPOINTS::TRACK_GOAL
          impression['goal_id'] = goal_id
          impression['r'] = revenue if revenue
          logger.log(
            LogLevelEnum::DEBUG,
            format(
              LogMessageEnum::DebugMessages::IMPRESSION_FOR_TRACK_GOAL,
              file: FileNameEnum::ImpressionUtil,
              properties: remove_sensitive_properties(impression)
            )
          )
        end
        impression
      end
def create_impression ( settings_file , campaign_id , variation_id , user_id , sdk_key , goal_id = nil , revenue = nil , usage_stats = { } ) return unless valid_number? ( campaign_id ) && valid_string? ( user_id ) is_track_user_api = true is_track_user_api = false unless goal_id . nil? account_id = settings_file [ 'accountId' ] impression = { account_id : account_id , experiment_id : campaign_id , ap : PLATFORM , combination : variation_id , random : get_random_number , sId : get_current_unix_timestamp , u : generator_for ( user_id , account_id ) , env : sdk_key } sdk_version = Gem . loaded_specs [ 'vwo_sdk' ] ? Gem . loaded_specs [ 'vwo_sdk' ] . version : VWO :: SDK_VERSION impression [ 'sdk' ] = 'ruby' impression [ 'sdk-v' ] = sdk_version impression = usage_stats . merge ( impression ) url = HTTPS_PROTOCOL + ENDPOINTS :: BASE_URL logger = VWO :: Logger . get_instance if is_track_user_api impression [ 'ed' ] = JSON . generate ( p : 'server' ) impression [ 'url' ] = "#{url}#{ENDPOINTS::TRACK_USER}" logger . log ( LogLevelEnum :: DEBUG , format ( LogMessageEnum :: DebugMessages :: IMPRESSION_FOR_TRACK_USER , file : FileNameEnum :: ImpressionUtil , properties : remove_sensitive_properties ( impression ) ) ) else impression [ 'url' ] = url + ENDPOINTS :: TRACK_GOAL impression [ 'goal_id' ] = goal_id impression [ 'r' ] = revenue if revenue logger . log ( LogLevelEnum :: DEBUG , format ( LogMessageEnum :: DebugMessages :: IMPRESSION_FOR_TRACK_GOAL , file : FileNameEnum :: ImpressionUtil , properties : remove_sensitive_properties ( impression ) ) ) end impression end
Creates the impression from the arguments passed
Creates the impression from the arguments passed
# Version and SDK constants
settings_file
<not_specific>
campaign_id
<not_specific>
variation_id
<not_specific>
user_id
<not_specific>
sdk_key
<not_specific>
goal_id
<not_specific>
revenue
<not_specific>
usage_stats
<not_specific>
param[Hash]
:settings_file Settings file object
: settings_file Settings file object
param[String]
:campaign_id Campaign identifier
: campaign_id Campaign identifier
param[String]
:variation_id Variation identifier
: variation_id Variation identifier
param[String]
:user_id User identifier
: user_id User identifier
param[String]
:sdk_key SDK Key
: sdk_key SDK Key
param[String]
:goal_id Goal identifier, if building track impression
: goal_id Goal identifier if building track impression
param[String|Float|Integer|nil)
:revenue Number value, in any representation, if building track impression
: revenue Number value in any representation if building track impression
return[nil|Hash]
None if campaign ID or variation ID is invalid, Else Properties(dict)
None if campaign ID or variation ID is invalid Else Properties ( dict )