|  |  | @@ -13,23 +13,22 @@ module Agents | 
            
            
              | 13 | 13 |   | 
            
            
              | 14 | 14 |      description do | 
            
            
              | 15 | 15 |        <<-MD | 
            
            
              | 16 |  | -        The Mixpanel Agent checks for analytics data and returns an event. | 
            
            
              |  | 16 | +        The Mixpanel Agent checks for analytics data and returns how many times that event was triggerd. | 
            
            
              | 17 | 17 |   | 
            
            
              | 18 |  | -        # Ordering Events | 
            
            
              |  | 18 | +        Specify the **API Key** and the **Secret Key** for the mixpanel project that you are querying. If you want to filter events using property, it is necessary to specify the value. The **time** property is an *integer* and the interval can be ```minute```, ```day```, ```month```, ```year```. | 
            
            
              | 19 | 19 |   | 
            
            
              | 20 |  | -        #{description_events_order} | 
            
            
              | 21 |  | - | 
            
            
              | 22 |  | -        In this Agent, the default value for `events_order` is `#{DEFAULT_EVENTS_ORDER.to_json}`. | 
            
            
              | 23 | 20 |        MD | 
            
            
              | 24 | 21 |      end | 
            
            
              | 25 | 22 |   | 
            
            
              | 26 | 23 |      def default_options | 
            
            
              | 27 | 24 |        { | 
            
            
              |  | 25 | +        'api_key' => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", | 
            
            
              |  | 26 | +        'secret_key' => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | 
            
            
              | 28 | 27 |          'event_name' => "Page Visit", | 
            
            
              | 29 |  | -        'property' => "Page", | 
            
            
              | 30 |  | -        'value' => "home", | 
            
            
              | 31 | 28 |          'time' => 24, | 
            
            
              | 32 |  | -        'interval' => 'hour' | 
            
            
              |  | 29 | +        'interval' => 'hour', | 
            
            
              |  | 30 | +        'property' => "Page", | 
            
            
              |  | 31 | +        'value' => "home" | 
            
            
              | 33 | 32 |        } | 
            
            
              | 34 | 33 |      end | 
            
            
              | 35 | 34 |   | 
            
            
            
            
              |  |  | @@ -54,8 +53,10 @@ module Agents | 
            
            
              | 54 | 53 |      def validate_options | 
            
            
              | 55 | 54 |        errors.add(:base, "event_name is required") unless options['event_name'].present? | 
            
            
              | 56 | 55 |   | 
            
            
              | 57 |  | -      unless options['property'].present? && options['value'].present? | 
            
            
              | 58 |  | -        errors.add(:base, "Please provide 'property' and 'value'") | 
            
            
              |  | 56 | +      if options['property'].present? || options['value'].present? | 
            
            
              |  | 57 | +        unless options['property'].present? && options['value'].present? | 
            
            
              |  | 58 | +          errors.add(:base, "Please provide 'property' and 'value'") | 
            
            
              |  | 59 | +        end | 
            
            
              | 59 | 60 |        end | 
            
            
              | 60 | 61 |   | 
            
            
              | 61 | 62 |        validate_web_request_options! | 
            
            
            
            
              |  |  | @@ -81,8 +82,8 @@ module Agents | 
            
            
              | 81 | 82 |   | 
            
            
              | 82 | 83 |      def mixpanel_config | 
            
            
              | 83 | 84 |          { | 
            
            
              | 84 |  | -          api_key: ENV['MIXPANEL_API_KEY'], | 
            
            
              | 85 |  | -          api_secret: ENV['MIXPANEL_SECRET_KEY'] | 
            
            
              |  | 85 | +          api_key: options['api_key'], | 
            
            
              |  | 86 | +          api_secret: options['secret_key'] | 
            
            
              | 86 | 87 |          } | 
            
            
              | 87 | 88 |      end | 
            
            
              | 88 | 89 |   |