Class: Saucy::Kiss::Observer

Inherits:
Object
  • Object
show all
Defined in:
lib/saucy/kiss/observer.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Observer

Returns a new instance of Observer.



7
8
9
# File 'lib/saucy/kiss/observer.rb', line 7

def initialize(api_key)
  @api_key = api_key
end

Instance Method Details

#account_created(data) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/saucy/kiss/observer.rb', line 23

def (data)
  javascript_client(data).record('Signed Up', {
    'Plan Name' => data[:account].plan.name,
    'Plan Price' => data[:account].plan.price,
    'Is Trial Plan?' => data[:account].plan.trial
  })
end

#activated(data) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/saucy/kiss/observer.rb', line 65

def activated(data)
  plan = data[:account].plan
  http_client.record((data), 'Activated', {
    'Plan Name' => plan.name,
    'Plan Price' => plan.price,
    'Is Trial Plan?'=> plan.trial
  })
end

#billed(data) ⇒ Object



49
50
51
52
53
54
# File 'lib/saucy/kiss/observer.rb', line 49

def billed(data)
  http_client.record((data), 'Billed', {
    'Billing Description' => "Monthly billing for #{data[:account].plan.name} plan",
    'Billing Amount' => data[:account].plan.price
  })
end

#canceled(data) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/saucy/kiss/observer.rb', line 56

def canceled(data)
  plan = data[:account].plan
  javascript_client(data).record('Canceled', {
    'Plan Name' => plan.name,
    'Plan Price' => plan.price,
    'Is Trial Plan?'=> plan.trial
  })
end

#plan_downgraded(data) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/saucy/kiss/observer.rb', line 40

def plan_downgraded(data)
  javascript_client(data).record('Downgraded', {
    'Previous Plan Name' => data[:from_plan].name,
    'Plan Name' => data[:to_plan].name,
    'Plan Price' => data[:to_plan].price,
    'Is Trial Plan?'=> data[:to_plan].trial,
  })
end

#plan_list_viewed(data) ⇒ Object



19
20
21
# File 'lib/saucy/kiss/observer.rb', line 19

def plan_list_viewed(data)
  javascript_client(data).record('Viewed Plan List')
end

#plan_upgraded(data) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/saucy/kiss/observer.rb', line 31

def plan_upgraded(data)
  javascript_client(data).record('Upgraded', {
    'Previous Plan Name' => data[:from_plan].name,
    'Plan Name' => data[:to_plan].name,
    'Plan Price' => data[:to_plan].price,
    'Is Trial Plan?'=> data[:to_plan].trial,
  })
end

#plan_viewed(data) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/saucy/kiss/observer.rb', line 11

def plan_viewed(data)
  javascript_client(data).record('Viewed Plan', {
    'Plan Name' => data[:plan].name,
    'Plan Price' => data[:plan].price,
    'Is Trial Plan?' => data[:plan].trial
  })
end