saucy-kiss 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.1.2
2
+
3
+ Tell Snogmetrics to use the :array output strategy in test env,
4
+ so tests aren't littered with console.log statements.
5
+
1
6
  0.1.1
2
7
 
3
8
  Fixed a bug.
data/Gemfile CHANGED
@@ -2,6 +2,8 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
+ gem "snogmetrics", :git => "git://github.com/jasonm/snogmetrics"
6
+
5
7
  group :development, :test do
6
8
  gem "rspec", "~> 2.3.0"
7
9
  end
data/README.rdoc CHANGED
@@ -79,6 +79,13 @@ Add a filter to each request in ApplicationController:
79
79
 
80
80
  include Saucy::Kiss::ControllerFilters
81
81
 
82
+ Emit KISSmetrics javascript into your view (note the %== or equivalent #html_safe):
83
+
84
+ <%== km.js! %>
85
+
86
+ The KISSmetrics javascript is asynchronous, so it's safe to load at the top of
87
+ your page.
88
+
82
89
  Note: Saucy::Kiss will automatically instantiate the Snogmetrics gem like this:
83
90
 
84
91
  api_key = Saucy::Kiss::API_KEYS[Rails.env]
@@ -62,7 +62,18 @@ module Saucy
62
62
  private
63
63
 
64
64
  def javascript_client(data)
65
- Snogmetrics::KissmetricsApi.new(@api_key, data[:request].session, Rails.env.development?)
65
+ Snogmetrics::KissmetricsApi.new(@api_key, data[:request].session, snogmetrics_output_strategy)
66
+ end
67
+
68
+ def snogmetrics_output_strategy
69
+ case Rails.env.to_s
70
+ when 'development'
71
+ :console_log
72
+ when 'test'
73
+ :array
74
+ else
75
+ :live
76
+ end
66
77
  end
67
78
 
68
79
  def http_client
@@ -18,19 +18,52 @@ describe Saucy::Kiss::Observer do
18
18
  Kissmetrics::HttpClient.stub(:new).and_return(http_client)
19
19
  end
20
20
 
21
- it "tells Snogmetrics to use console.log in development" do
22
- with_rails_env(:development) do
21
+ context "setting the Snogmetrics output strategy" do
22
+ it "tells Snogmetrics to use console.log in development" do
23
+ with_rails_env(:development) do
24
+ Snogmetrics::KissmetricsApi.should_receive(:new).
25
+ with(anything(), anything(), :console_log)
26
+
27
+ subject.plan_viewed(:request => request, :plan => small_plan)
28
+ end
29
+ end
30
+
31
+ it "tells Snogmetrics to append to _kmq in test" do
32
+ with_rails_env(:test) do
33
+ Snogmetrics::KissmetricsApi.should_receive(:new).
34
+ with(anything(), anything(), :array)
35
+
36
+ subject.plan_viewed(:request => request, :plan => small_plan)
37
+ end
38
+ end
39
+
40
+ it "tells Snogmetrics to send to KISSmetrics in production" do
41
+ with_rails_env(:production) do
42
+ Snogmetrics::KissmetricsApi.should_receive(:new).
43
+ with(anything(), anything(), :live)
44
+
45
+ subject.plan_viewed(:request => request, :plan => small_plan)
46
+ end
47
+ end
48
+ end
49
+
50
+ context "Snogmetrics configuration" do
51
+ it "tells Snogmetrics to use the correct API key" do
23
52
  Snogmetrics::KissmetricsApi.should_receive(:new).
24
- with(anything(), anything(), true)
53
+ with('abc123', anything(), anything())
54
+
55
+ subject.plan_viewed(:request => request, :plan => small_plan)
56
+ end
57
+
58
+ it "tells Snogmetrics to use the session" do
59
+ Snogmetrics::KissmetricsApi.should_receive(:new).
60
+ with(anything(), session, anything())
25
61
 
26
62
  subject.plan_viewed(:request => request, :plan => small_plan)
27
63
  end
28
64
  end
29
65
 
30
66
  it "records a Viewed Plan event through the KISSmetrics JS API for #plan_viewed" do
31
- Snogmetrics::KissmetricsApi.should_receive(:new).
32
- with('abc123', session, false)
33
-
34
67
  javascript_client.should_receive(:record).
35
68
  with('Viewed Plan', { 'Plan Name' => 'Small', 'Plan Price' => 10, 'Is Trial Plan?' => false })
36
69
 
@@ -38,9 +71,6 @@ describe Saucy::Kiss::Observer do
38
71
  end
39
72
 
40
73
  it "records a Signed Up event through the KISSmetrics JS API for #account_created" do
41
- Snogmetrics::KissmetricsApi.should_receive(:new).
42
- with('abc123', session, false)
43
-
44
74
  javascript_client.should_receive(:record).
45
75
  with('Signed Up', { 'Plan Name' => 'Small', 'Plan Price' => 10, 'Is Trial Plan?' => false })
46
76
 
@@ -48,9 +78,6 @@ describe Saucy::Kiss::Observer do
48
78
  end
49
79
 
50
80
  it "records an Upgraded event through the KISSmetrics JS API for #plan_upgraded" do
51
- Snogmetrics::KissmetricsApi.should_receive(:new).
52
- with('abc123', session, false)
53
-
54
81
  javascript_client.should_receive(:record).
55
82
  with('Upgraded', { 'Previous Plan Name' => 'Small', 'Plan Name' => 'Large', 'Plan Price' => 20, 'Is Trial Plan?' => false })
56
83
 
@@ -58,9 +85,6 @@ describe Saucy::Kiss::Observer do
58
85
  end
59
86
 
60
87
  it "records a Downgraded event through the KISSmetrics JS API for #plan_downgraded" do
61
- Snogmetrics::KissmetricsApi.should_receive(:new).
62
- with('abc123', session, false)
63
-
64
88
  javascript_client.should_receive(:record).
65
89
  with('Downgraded', { 'Previous Plan Name' => 'Large', 'Plan Name' => 'Small', 'Plan Price' => 10, 'Is Trial Plan?' => false })
66
90
 
@@ -80,9 +104,6 @@ describe Saucy::Kiss::Observer do
80
104
  end
81
105
 
82
106
  it "records a Canceled event through the KISSmetrics JS API for #canceled" do
83
- Snogmetrics::KissmetricsApi.should_receive(:new).
84
- with('abc123', session, false)
85
-
86
107
  javascript_client.should_receive(:record).
87
108
  with('Canceled', { 'Plan Name' => 'Small', 'Plan Price' => 10, 'Is Trial Plan?' => false })
88
109
 
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saucy-kiss
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
5
+ version: 0.1.2
11
6
  platform: ruby
12
7
  authors:
13
8
  - Jason Morrison
@@ -27,11 +22,6 @@ dependencies:
27
22
  requirements:
28
23
  - - ~>
29
24
  - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 2
33
- - 3
34
- - 0
35
25
  version: 2.3.0
36
26
  type: :development
37
27
  version_requirements: *id001
@@ -43,11 +33,6 @@ dependencies:
43
33
  requirements:
44
34
  - - ~>
45
35
  - !ruby/object:Gem::Version
46
- hash: 7
47
- segments:
48
- - 0
49
- - 6
50
- - 0
51
36
  version: 0.6.0
52
37
  type: :development
53
38
  version_requirements: *id002
@@ -59,11 +44,6 @@ dependencies:
59
44
  requirements:
60
45
  - - ">="
61
46
  - !ruby/object:Gem::Version
62
- hash: 23
63
- segments:
64
- - 1
65
- - 0
66
- - 0
67
47
  version: 1.0.0
68
48
  type: :development
69
49
  version_requirements: *id003
@@ -75,11 +55,6 @@ dependencies:
75
55
  requirements:
76
56
  - - ~>
77
57
  - !ruby/object:Gem::Version
78
- hash: 11
79
- segments:
80
- - 1
81
- - 6
82
- - 2
83
58
  version: 1.6.2
84
59
  type: :development
85
60
  version_requirements: *id004
@@ -91,9 +66,6 @@ dependencies:
91
66
  requirements:
92
67
  - - ">="
93
68
  - !ruby/object:Gem::Version
94
- hash: 3
95
- segments:
96
- - 0
97
69
  version: "0"
98
70
  type: :development
99
71
  version_requirements: *id005
@@ -105,10 +77,6 @@ dependencies:
105
77
  requirements:
106
78
  - - ~>
107
79
  - !ruby/object:Gem::Version
108
- hash: 7
109
- segments:
110
- - 3
111
- - 0
112
80
  version: "3.0"
113
81
  type: :development
114
82
  version_requirements: *id006
@@ -120,46 +88,20 @@ dependencies:
120
88
  requirements:
121
89
  - - ~>
122
90
  - !ruby/object:Gem::Version
123
- hash: 21
124
- segments:
125
- - 1
126
- - 0
127
- - 1
128
91
  version: 1.0.1
129
92
  type: :runtime
130
93
  version_requirements: *id007
131
- - !ruby/object:Gem::Dependency
132
- name: snogmetrics
133
- prerelease: false
134
- requirement: &id008 !ruby/object:Gem::Requirement
135
- none: false
136
- requirements:
137
- - - ~>
138
- - !ruby/object:Gem::Version
139
- hash: 21
140
- segments:
141
- - 0
142
- - 1
143
- - 7
144
- version: 0.1.7
145
- type: :runtime
146
- version_requirements: *id008
147
94
  - !ruby/object:Gem::Dependency
148
95
  name: saucy
149
96
  prerelease: false
150
- requirement: &id009 !ruby/object:Gem::Requirement
97
+ requirement: &id008 !ruby/object:Gem::Requirement
151
98
  none: false
152
99
  requirements:
153
100
  - - ~>
154
101
  - !ruby/object:Gem::Version
155
- hash: 59
156
- segments:
157
- - 0
158
- - 9
159
- - 0
160
102
  version: 0.9.0
161
103
  type: :runtime
162
- version_requirements: *id009
104
+ version_requirements: *id008
163
105
  description: Record Saucy SaaS events to KISSmetrics
164
106
  email: jason.p.morrison@gmail.com
165
107
  executables: []
@@ -196,18 +138,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
138
  requirements:
197
139
  - - ">="
198
140
  - !ruby/object:Gem::Version
199
- hash: 3
200
- segments:
201
- - 0
202
141
  version: "0"
203
142
  required_rubygems_version: !ruby/object:Gem::Requirement
204
143
  none: false
205
144
  requirements:
206
145
  - - ">="
207
146
  - !ruby/object:Gem::Version
208
- hash: 3
209
- segments:
210
- - 0
211
147
  version: "0"
212
148
  requirements: []
213
149