lib/fluent/plugin/out_mixpanel.rb in fluent-plugin-mixpanel-0.0.2 vs lib/fluent/plugin/out_mixpanel.rb in fluent-plugin-mixpanel-0.0.3

- old
+ new

@@ -2,10 +2,11 @@ Fluent::Plugin.register_output('mixpanel', self) config_param :project_token, :string config_param :distinct_id_key, :string config_param :event_key, :string + config_param :ip_key, :string, :default => nil def initialize super require 'mixpanel-ruby' end @@ -13,10 +14,11 @@ def configure(conf) super @project_tokey = conf['project_token'] @distinct_id_key = conf['distinct_id_key'] @event_key = conf['event_key'] + @ip_key = conf['ip_key'] if @project_token.empty? raise Fluent::ConfigError, "'project_token' must be specifed." end @@ -59,9 +61,14 @@ data['event'] = record[@event_key] record.delete(@event_key) else log.warn('no event') return + end + + if !@ip_key.nil? and record[@ip_key] + record['ip'] = record[@ip_key] + record.delete(@ip_key) end record.merge!(time: time.to_i) data['properties'] = record