module AbPanel
Constants
- VERSION
Public Class Methods
add_funnel(funnel)
click to toggle source
# File lib/ab_panel.rb, line 83 def add_funnel(funnel) funnels.add(funnel) if funnel.present? end
conditions()
click to toggle source
# File lib/ab_panel.rb, line 21 def conditions Thread.current[:ab_panel_conditions] ||= assign_conditions! end
conditions=(custom_conditions)
click to toggle source
Set the experiment's conditions.
This is used to persist conditions from the session.
# File lib/ab_panel.rb, line 39 def conditions=(custom_conditions) return conditions unless custom_conditions Thread.current[:ab_panel_conditions] = assign_conditions! custom_conditions end
env()
click to toggle source
# File lib/ab_panel.rb, line 60 def env Thread.current[:ab_panel_env] ||= { 'conditions' => conditions } end
environment()
click to toggle source
# File lib/ab_panel.rb, line 87 def environment props = { distinct_id: self.env["distinct_id"] } props.merge!(self.properties) if self.properties self.funnels.each { |f| props["funnel_#{f}"] = true } self.experiments.each { |exp| props[exp] = self.conditions.send(exp).condition } props end
experiments()
click to toggle source
# File lib/ab_panel.rb, line 44 def experiments config.experiments end
funnels()
click to toggle source
# File lib/ab_panel.rb, line 75 def funnels env[:funnels] ||= Set.new end
funnels=(funnels)
click to toggle source
# File lib/ab_panel.rb, line 79 def funnels=(funnels) env[:funnels] = funnels end
identify(distinct_id)
click to toggle source
Identify
# File lib/ab_panel.rb, line 17 def identify(distinct_id) tracker.identify distinct_id end
properties()
click to toggle source
# File lib/ab_panel.rb, line 56 def properties env[:properties] end
reset!()
click to toggle source
# File lib/ab_panel.rb, line 66 def reset! Thread.current[:ab_panel_env] = nil Thread.current[:ab_panel_conditions] = nil end
scenarios(experiment)
click to toggle source
# File lib/ab_panel.rb, line 48 def scenarios(experiment) config.scenarios experiment end
serialized_conditions()
click to toggle source
# File lib/ab_panel.rb, line 25 def serialized_conditions cs = {} conditions.each_pair do |key, value| cs[key] = value.marshal_dump end cs.to_json end
set_env(key, value)
click to toggle source
# File lib/ab_panel.rb, line 71 def set_env(key, value) env[key] = value end
track(event_name, properties)
click to toggle source
Track event in Mixpanel
backend.
# File lib/ab_panel.rb, line 12 def track(event_name, properties) tracker.track event_name, properties end
weights(experiment)
click to toggle source
# File lib/ab_panel.rb, line 52 def weights(experiment) config.weights experiment end
Public Instance Methods
config()
click to toggle source
# File lib/ab_panel.rb, line 138 def config @config ||= Config.new end
tracker()
click to toggle source
# File lib/ab_panel.rb, line 134 def tracker Mixpanel::Tracker.new end