class VWO::EventDispatcher
Constants
- EXCLUDE_KEYS
Public Class Methods
new(is_development_mode = false)
click to toggle source
Initialize the dispatcher with logger
@param [Boolean] : To specify whether the request
to our server should be made or not.
# File lib/vwo/event_dispatcher.rb, line 19 def initialize(is_development_mode = false) @logger = CustomLogger.get_instance @is_development_mode = is_development_mode end
Public Instance Methods
dispatch(properties)
click to toggle source
Dispatch the event being represented in the properties object.
@param :properties Object holding information about
the request to be dispatched to the VWO backend.
# File lib/vwo/event_dispatcher.rb, line 30 def dispatch(properties) return true if @is_development_mode modified_properties = properties.reject do |key, _value| EXCLUDE_KEYS.include?(key) end resp = VWO::Common::Requests.get(properties['url'], modified_properties) if resp.code == '200' @logger.log( LogLevelEnum::INFO, format( LogMessageEnum::InfoMessages::IMPRESSION_SUCCESS, file: FileNameEnum::EventDispatcher, end_point: properties[:url], campaign_id: properties[:experiment_id], user_id: properties[:uId], account_id: properties[:account_id], variation_id: properties[:combination] ) ) return true else @logger.log( LogLevelEnum::ERROR, format(LogMessageEnum::ErrorMessages::IMPRESSION_FAILED, file: FileNameEnum.EventDispatcher, end_point: properties['url']) ) return false end rescue StandardError @logger.log( LogLevelEnum::ERROR, format(LogMessageEnum::ErrorMessages::IMPRESSION_FAILED, file: FileNameEnum::EventDispatcher, end_point: properties['url']) ) false end