@@ -70,21 +70,19 @@ def initialize_ab_panel!(options = {})
7070 # Example:
7171 #
7272 # def show
73- # track_action '[visits] Course', { :course => : id }
73+ # track_action '[visits] Course', { :course_id => @course. id }
7474 # end
7575 #
7676 # This will track the event with the given name on CoursesController#show
77- # and assign an options hash:
78- #
79- # { 'course_id' => @course.id }
77+ # with the passed in attributes.
8078 def track_action ( name , properties = { } )
8179 AbPanel . add_funnel ( properties . delete ( :funnel ) )
8280
8381 options = {
8482 distinct_id : distinct_id ,
8583 ip : request . remote_ip ,
8684 time : Time . now . utc ,
87- }
85+ } . merge ( properties )
8886
8987 AbPanel . funnels . each do |funnel |
9088 options [ "funnel_#{ funnel } " ] = true
@@ -94,22 +92,8 @@ def track_action(name, properties = {})
9492 options [ exp ] = AbPanel . conditions . send ( exp ) . condition rescue nil
9593 end
9694
97- properties . each do |key , val |
98- if respond_to? ( key )
99- inst = send ( key )
100- elsif instance_variable_defined? ( "@#{ key } " )
101- inst = instance_variable_get ( "@#{ key } " )
102- else
103- options [ key ] = val
104- next
105- end
106-
107- val = *val
108-
109- val . each do |m |
110- options [ "#{ key } _#{ m } " ] = inst . send ( m )
111- end
112- end
95+ options . merge! ( ab_panel_options )
96+ AbPanel . set_env ( :properties , options )
11397
11498 AbPanel . identify ( distinct_id )
11599 AbPanel . track ( name , options . merge ( ab_panel_options ) )
0 commit comments