Module: AbPanel

Defined in:
lib/ab_panel.rb,
lib/ab_panel/config.rb,
lib/ab_panel/version.rb,
lib/ab_panel/mixpanel.rb,
lib/ab_panel/javascript.rb,
lib/ab_panel/controller_additions.rb

Defined Under Namespace

Modules: ControllerAdditions, Mixpanel Classes: Config, Javascript

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.add_funnel(funnel) ⇒ Object



73
74
75
# File 'lib/ab_panel.rb', line 73

def add_funnel(funnel)
  funnels.add(funnel) if funnel.present?
end

.conditionsObject



21
22
23
# File 'lib/ab_panel.rb', line 21

def conditions
  @conditions ||= assign_conditions!
end

.conditions=(custom_conditions) ⇒ Object

Set the experiment’s conditions.

This is used to persist conditions from the session.



29
30
31
32
# File 'lib/ab_panel.rb', line 29

def conditions=(custom_conditions)
  return conditions unless custom_conditions
  @conditions = assign_conditions! custom_conditions
end

.envObject



50
51
52
53
54
# File 'lib/ab_panel.rb', line 50

def env
  @env ||= {
    'conditions' => conditions
  }
end

.experimentsObject



34
35
36
# File 'lib/ab_panel.rb', line 34

def experiments
  config.experiments
end

.funnelsObject



65
66
67
# File 'lib/ab_panel.rb', line 65

def funnels
  env['funnels'] ||= Set.new
end

.funnels=(funnels) ⇒ Object



69
70
71
# File 'lib/ab_panel.rb', line 69

def funnels=(funnels)
  env['funnels'] = funnels
end

.identify(distinct_id) ⇒ Object

Identify



17
18
19
# File 'lib/ab_panel.rb', line 17

def identify(distinct_id)
  tracker.identify distinct_id
end

.propertiesObject



46
47
48
# File 'lib/ab_panel.rb', line 46

def properties
  @env[:properties]
end

.reset!Object



56
57
58
59
# File 'lib/ab_panel.rb', line 56

def reset!
  @env = nil
  @conditions = nil
end

.scenarios(experiment) ⇒ Object



38
39
40
# File 'lib/ab_panel.rb', line 38

def scenarios(experiment)
  config.scenarios experiment
end

.set_env(key, value) ⇒ Object



61
62
63
# File 'lib/ab_panel.rb', line 61

def set_env(key, value)
  env[key] = value
end

.track(event_name, properties) ⇒ Object

Track event in Mixpanel backend.



12
13
14
# File 'lib/ab_panel.rb', line 12

def track(event_name, properties)
  tracker.track event_name, properties
end

.weights(experiment) ⇒ Object



42
43
44
# File 'lib/ab_panel.rb', line 42

def weights(experiment)
  config.weights experiment
end