Module: VWO::Common::ImpressionUtils
- Includes:
- CONSTANTS, Enums, FunctionUtils, UUIDUtils
- Included in:
- VWO
- Defined in:
- lib/vwo/common/impression_utils.rb
Constant Summary
Constants included from UUIDUtils
Constants included from CONSTANTS
CONSTANTS::API_VERSION, CONSTANTS::HTTPS_PROTOCOL, CONSTANTS::HTTP_PROTOCOL, CONSTANTS::LIBRARY_PATH, CONSTANTS::MAX_TRAFFIC_PERCENT, CONSTANTS::MAX_TRAFFIC_VALUE, CONSTANTS::PLATFORM, CONSTANTS::SDK_VERSION, CONSTANTS::SEED_VALUE, CONSTANTS::STATUS_RUNNING, CONSTANTS::URL_NAMESPACE
Instance Method Summary collapse
-
#build_event(settings_file, campaign_id, variation_id, user_id, goal_id = nil, revenue = nil) ⇒ Object
Trigger the goal by sending it to server.
Methods included from UUIDUtils
#generate, #generator_for, parse, uuid_v5
Methods included from FunctionUtils
#get_current_unix_timestamp, #get_random_number
Instance Method Details
#build_event(settings_file, campaign_id, variation_id, user_id, goal_id = nil, revenue = nil) ⇒ Object
Trigger the goal by sending it to server
@param :settings_file Settings file object @param :campaign_id Campaign identifier @param :variation_id Variation identifier @param :user_id User identifier @param :goal_id Goal identifier, if building track impression @param[String|Float|Integer|nil) :revenue Number value, in any representation, if building track impression
@return None if campaign ID or variation ID is invalid,
Else Properties(dict)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/vwo/common/impression_utils.rb', line 31 def build_event(settings_file, campaign_id, variation_id, user_id, goal_id = nil, revenue = nil) 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'] properties = { account_id: account_id, experiment_id: campaign_id, ap: PLATFORM, uId: CGI.escape(user_id.encode('utf-8')), combination: variation_id, random: get_random_number, sId: , u: generator_for(user_id, account_id) } # Version and SDK constants sdk_version = Gem.loaded_specs['vwo_sdk'] ? Gem.loaded_specs['vwo_sdk'].version : VWO::SDK_VERSION properties['sdk'] = 'ruby' properties['sdk-v'] = sdk_version url = HTTPS_PROTOCOL + ENDPOINTS::BASE_URL logger = VWO::CustomLogger.get_instance if is_track_user_api properties['ed'] = JSON.generate(p: 'server') properties['url'] = "#{url}#{ENDPOINTS::TRACK_USER}" logger.log( LogLevelEnum::DEBUG, format( LogMessageEnum::DebugMessages::IMPRESSION_FOR_TRACK_USER, file: FileNameEnum::ImpressionUtil, properties: JSON.generate(properties) ) ) else properties['url'] = url + ENDPOINTS::TRACK_GOAL properties['goal_id'] = goal_id properties['r'] = revenue if revenue logger.log( LogLevelEnum::DEBUG, format( LogMessageEnum::DebugMessages::IMPRESSION_FOR_TRACK_GOAL, file: FileNameEnum::ImpressionUtil, properties: JSON.generate(properties) ) ) end properties end |