snogmetrics 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +47 -0
- data/README.mdown +4 -0
- data/lib/snogmetrics.rb +12 -1
- data/snogmetrics.gemspec +5 -4
- data/spec/snogmetrics_spec.rb +29 -0
- metadata +10 -4
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
BlueCloth (1.0.1)
|
5
|
+
actionmailer (2.3.5)
|
6
|
+
actionpack (= 2.3.5)
|
7
|
+
actionpack (2.3.5)
|
8
|
+
activesupport (= 2.3.5)
|
9
|
+
rack (~> 1.0.0)
|
10
|
+
activerecord (2.3.5)
|
11
|
+
activesupport (= 2.3.5)
|
12
|
+
activeresource (2.3.5)
|
13
|
+
activesupport (= 2.3.5)
|
14
|
+
activesupport (2.3.5)
|
15
|
+
gemcutter (0.6.1)
|
16
|
+
git (1.2.5)
|
17
|
+
jeweler (1.4.0)
|
18
|
+
gemcutter (>= 0.1.0)
|
19
|
+
git (>= 1.2.5)
|
20
|
+
rubyforge (>= 2.0.0)
|
21
|
+
json_pure (1.4.6)
|
22
|
+
rack (1.0.1)
|
23
|
+
rails (2.3.5)
|
24
|
+
actionmailer (= 2.3.5)
|
25
|
+
actionpack (= 2.3.5)
|
26
|
+
activerecord (= 2.3.5)
|
27
|
+
activeresource (= 2.3.5)
|
28
|
+
activesupport (= 2.3.5)
|
29
|
+
rake (>= 0.8.3)
|
30
|
+
rake (0.8.7)
|
31
|
+
rcov (0.9.8)
|
32
|
+
rspec (1.3.0)
|
33
|
+
rubyforge (2.0.4)
|
34
|
+
json_pure (>= 1.1.7)
|
35
|
+
yard (0.6.0)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
BlueCloth
|
42
|
+
jeweler
|
43
|
+
rails (= 2.3.5)
|
44
|
+
rake
|
45
|
+
rcov
|
46
|
+
rspec (>= 1.3.0)
|
47
|
+
yard
|
data/README.mdown
CHANGED
@@ -29,6 +29,10 @@ Yes it does.
|
|
29
29
|
|
30
30
|
Just do it. You need to make sure that the `_kmq` array exists, though. SNOGmetrics will define it where you place `<%= km.js! %>`, but that is usually at the bottom of the page (with the async API you could probably put it at the top if you wanted to), so if you want to add things to `_kmq` before that you need to define it yourself. Just add `var _kmq = _kmq || []` and you're set.
|
31
31
|
|
32
|
+
## What about A/B testing
|
33
|
+
|
34
|
+
SNOGmetrics implements #set, which is equivalent to `_kmq.push(["set", ...])`, the preferred way of recording which version a user saw in an A/B test. SNOGmetrics does not support the `KM.ab` function, because that's something you want to do in JavaScript only.
|
35
|
+
|
32
36
|
## Anything else I should know?
|
33
37
|
|
34
38
|
Yes, SNOGmetrics will _not_ output the KISSmetrics API code unless `RAILS_ENV` is `production`. Instead it will output code that logs all calls to the console (if `console` is defined).
|
data/lib/snogmetrics.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# the default implementation outputs the real API only when
|
15
15
|
# `Rails.env.production?` is true.
|
16
16
|
module Snogmetrics
|
17
|
-
VERSION = '0.1.
|
17
|
+
VERSION = '0.1.4'
|
18
18
|
|
19
19
|
# Returns an instance of KissmetricsApi, which is an interface to the
|
20
20
|
# KISSmetrics API. It has the methods #record and #identify, which work just
|
@@ -68,6 +68,17 @@ private
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
# The equivalent of the `KM.trackClick` method of the JavaScript API. The first
|
72
|
+
# argument should be a selector (a tag id or class name). Furthermore you can
|
73
|
+
# pass either an event name, an event name and a hash of properties, or only
|
74
|
+
# a hash of properties.
|
75
|
+
def trackClick(selector, *args)
|
76
|
+
raise 'Not enough arguments' if args.size == 0
|
77
|
+
raise 'Too many arguments' if args.size > 2
|
78
|
+
|
79
|
+
queue << ['trackClick', selector, *args]
|
80
|
+
end
|
81
|
+
|
71
82
|
# Register which variant the user saw in an A/B test.
|
72
83
|
def set(experiment, variant)
|
73
84
|
queue << ['set', experiment, variant]
|
data/snogmetrics.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{snogmetrics}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Theo"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-02}
|
13
13
|
s.description = %q{SNOGmetrics gives you the best of both worlds: access to KISSmetrics' JavaScript API through Ruby}
|
14
14
|
s.email = %q{theo@iconara.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
".gitignore",
|
22
22
|
"CHANGELOG.mdown",
|
23
23
|
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
24
25
|
"LICENSE",
|
25
26
|
"README.mdown",
|
26
27
|
"Rakefile",
|
@@ -60,7 +61,7 @@ Gem::Specification.new do |s|
|
|
60
61
|
s.homepage = %q{http://github.com/iconara/snogmetrics}
|
61
62
|
s.rdoc_options = ["--charset=UTF-8"]
|
62
63
|
s.require_paths = ["lib"]
|
63
|
-
s.rubygems_version = %q{1.3.
|
64
|
+
s.rubygems_version = %q{1.3.7}
|
64
65
|
s.summary = %q{SNOGmetrics is a KISSmetrics helper for Rails}
|
65
66
|
s.test_files = [
|
66
67
|
"spec/snogmetrics_spec.rb",
|
@@ -71,7 +72,7 @@ Gem::Specification.new do |s|
|
|
71
72
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
72
73
|
s.specification_version = 3
|
73
74
|
|
74
|
-
if Gem::Version.new(Gem::
|
75
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
75
76
|
else
|
76
77
|
end
|
77
78
|
else
|
data/spec/snogmetrics_spec.rb
CHANGED
@@ -58,6 +58,35 @@ describe Snogmetrics do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
describe '#trackClick' do
|
62
|
+
it 'will output code that pushes an event with the specified name and properties' do
|
63
|
+
@context.km.trackClick('tagid', 'hello world', :foo => 'bar')
|
64
|
+
@context.km.js.should include('_kmq.push(["trackClick","tagid","hello world",{"foo":"bar"}]);')
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'will output code that pushes an event with name only' do
|
68
|
+
@context.km.trackClick('tagid', 'foo')
|
69
|
+
@context.km.js.should include('_kmq.push(["trackClick","tagid","foo"]);')
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'will output code that pushes an event with properties only' do
|
73
|
+
@context.km.trackClick('tagid', {:foo => 'bar', :plink => :plonk})
|
74
|
+
@context.km.js.should match(%r#_kmq.push\(\["trackClick","tagid",\{(?:"foo":"bar","plink":"plonk"|"plink":"plonk","foo":"bar")\}\]\)#)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'complains if called without arguments' do
|
78
|
+
running { @context.km.trackClick }.should raise_error
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'complains if called with selector only' do
|
82
|
+
running { @context.km.trackClick('tagid') }.should raise_error
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'complains if called with more than three arguments' do
|
86
|
+
running { @context.km.trackClick('tagid', 'hello world', {:foo => 'bar'}, '12') }.should raise_error
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
61
90
|
describe '#identify' do
|
62
91
|
it 'will output code that pushes an identify call with the provided identity' do
|
63
92
|
@context.km.identify('Phil')
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snogmetrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Theo
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-09-02 00:00:00 +02:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
@@ -32,6 +33,7 @@ files:
|
|
32
33
|
- .gitignore
|
33
34
|
- CHANGELOG.mdown
|
34
35
|
- Gemfile
|
36
|
+
- Gemfile.lock
|
35
37
|
- LICENSE
|
36
38
|
- README.mdown
|
37
39
|
- Rakefile
|
@@ -77,23 +79,27 @@ rdoc_options:
|
|
77
79
|
require_paths:
|
78
80
|
- lib
|
79
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
80
83
|
requirements:
|
81
84
|
- - ">="
|
82
85
|
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
83
87
|
segments:
|
84
88
|
- 0
|
85
89
|
version: "0"
|
86
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
87
92
|
requirements:
|
88
93
|
- - ">="
|
89
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
90
96
|
segments:
|
91
97
|
- 0
|
92
98
|
version: "0"
|
93
99
|
requirements: []
|
94
100
|
|
95
101
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.3.
|
102
|
+
rubygems_version: 1.3.7
|
97
103
|
signing_key:
|
98
104
|
specification_version: 3
|
99
105
|
summary: SNOGmetrics is a KISSmetrics helper for Rails
|