staccato 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe Staccato::Measurement::Checkout do
4
+ let(:uri) {Staccato.tracking_uri}
5
+ let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
+ let(:response) {stub(:body => '', :status => 201)}
7
+
8
+ before(:each) do
9
+ SecureRandom.stubs(:uuid).returns('555')
10
+ Net::HTTP.stubs(:post_form).returns(response)
11
+ end
12
+
13
+ context 'a pageview with a transaction' do
14
+ let(:pageview) {
15
+ tracker.build_pageview({
16
+ path: '/checkout', hostname: 'mystore.com',
17
+ title: 'Complete Your Checkout', product_action: 'checkout'
18
+ })
19
+ }
20
+
21
+ let(:measurment_options) {{
22
+ step: 1,
23
+ step_options: 'Visa'
24
+ }}
25
+
26
+ before(:each) do
27
+ pageview.add_measurement(:checkout, measurment_options)
28
+
29
+ pageview.track!
30
+ end
31
+
32
+ it 'tracks the measurment' do
33
+ Net::HTTP.should have_received(:post_form).with(uri, {
34
+ 'v' => 1,
35
+ 'tid' => 'UA-XXXX-Y',
36
+ 'cid' => '555',
37
+ 't' => 'pageview',
38
+ 'dh' => 'mystore.com',
39
+ 'dp' => '/checkout',
40
+ 'dt' => 'Complete Your Checkout',
41
+ 'pa' => 'checkout',
42
+ 'cos' => 1,
43
+ 'col' => 'Visa'
44
+ })
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe Staccato::Measurement::ProductImpression do
4
+ let(:uri) {Staccato.tracking_uri}
5
+ let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
+ let(:response) {stub(:body => '', :status => 201)}
7
+
8
+ before(:each) do
9
+ SecureRandom.stubs(:uuid).returns('555')
10
+ Net::HTTP.stubs(:post_form).returns(response)
11
+ end
12
+
13
+ context 'a pageview with a transaction' do
14
+ let(:pageview) {
15
+ tracker.build_pageview({
16
+ path: '/home',
17
+ hostname: 'mystore.com',
18
+ title: 'Home Page'
19
+ })
20
+ }
21
+
22
+ let(:measurment_options) {{
23
+ index: 1,
24
+ list_index: 1, # match the impression_list above
25
+ id: 'P12345',
26
+ name: 'T-Shirt',
27
+ category: 'Apparel',
28
+ brand: 'Your Brand',
29
+ variant: 'Purple',
30
+ position: 1,
31
+ price: 14.60
32
+ }}
33
+
34
+ before(:each) do
35
+ pageview.add_measurement(:impression_list, index: 1, name: 'Search Results')
36
+ pageview.add_measurement(:product_impression, measurment_options)
37
+
38
+ pageview.track!
39
+ end
40
+
41
+ it 'tracks the measurment' do
42
+ Net::HTTP.should have_received(:post_form).with(uri, {
43
+ 'v' => 1,
44
+ 'tid' => 'UA-XXXX-Y',
45
+ 'cid' => '555',
46
+ 't' => 'pageview',
47
+ 'dh' => 'mystore.com',
48
+ 'dp' => '/home',
49
+ 'dt' => 'Home Page',
50
+ 'il1nm' => 'Search Results',
51
+ 'il1pr1id' => 'P12345',
52
+ 'il1pr1nm' => 'T-Shirt',
53
+ 'il1pr1br' => 'Your Brand',
54
+ 'il1pr1ca' => 'Apparel',
55
+ 'il1pr1va' => 'Purple',
56
+ 'il1pr1pr' => 14.60,
57
+ 'il1pr1ps' => 1
58
+ })
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe Staccato::Measurement::Product do
4
+ let(:uri) {Staccato.tracking_uri}
5
+ let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
+ let(:response) {stub(:body => '', :status => 201)}
7
+
8
+ before(:each) do
9
+ SecureRandom.stubs(:uuid).returns('555')
10
+ Net::HTTP.stubs(:post_form).returns(response)
11
+ end
12
+
13
+ context 'a pageview with a transaction' do
14
+ let(:event) {
15
+ tracker.build_event({
16
+ category: 'search',
17
+ action: 'click',
18
+ label: 'results',
19
+ product_action: 'click',
20
+ product_action_list: 'Search Results'
21
+ })
22
+ }
23
+
24
+ let(:measurment_options) {{
25
+ index: 1,
26
+ id: 'P12345',
27
+ name: 'T-Shirt',
28
+ category: 'Apparel',
29
+ brand: 'Your Brand',
30
+ variant: 'Purple',
31
+ quantity: 2,
32
+ position: 1,
33
+ price: 14.60,
34
+ coupon_code: 'ILUVTEES'
35
+ }}
36
+
37
+ before(:each) do
38
+ event.add_measurement(:product, measurment_options)
39
+
40
+ event.track!
41
+ end
42
+
43
+ it 'tracks the measurment' do
44
+ Net::HTTP.should have_received(:post_form).with(uri, {
45
+ 'v' => 1,
46
+ 'tid' => 'UA-XXXX-Y',
47
+ 'cid' => '555',
48
+ 't' => 'event',
49
+ 'ec' => 'search',
50
+ 'ea' => 'click',
51
+ 'el' => 'results',
52
+ 'pa' => 'click',
53
+ 'pal' => 'Search Results',
54
+ 'pr1id' => 'P12345',
55
+ 'pr1nm' => 'T-Shirt',
56
+ 'pr1ca' => 'Apparel',
57
+ 'pr1br' => 'Your Brand',
58
+ 'pr1va' => 'Purple',
59
+ 'pr1qt' => 2,
60
+ 'pr1ps' => 1,
61
+ 'pr1pr' => 14.60,
62
+ 'pr1cc' => 'ILUVTEES'
63
+ })
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Staccato::Measurement::Promotion do
4
+ let(:uri) {Staccato.tracking_uri}
5
+ let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
+ let(:response) {stub(:body => '', :status => 201)}
7
+
8
+ before(:each) do
9
+ SecureRandom.stubs(:uuid).returns('555')
10
+ Net::HTTP.stubs(:post_form).returns(response)
11
+ end
12
+
13
+ context 'a pageview with a transaction' do
14
+ let(:pageview) {
15
+ tracker.build_pageview({
16
+ path: '/search', hostname: 'mystore.com',
17
+ title: 'Search Results'
18
+ })
19
+ }
20
+
21
+ let(:measurment_options) {{
22
+ index: 1,
23
+ id: 'PROMO_1234',
24
+ name: 'Summer Sale',
25
+ creative: 'summer_sale_banner',
26
+ position: 'banner_1'
27
+ }}
28
+
29
+ before(:each) do
30
+ pageview.add_measurement(:promotion, measurment_options)
31
+
32
+ pageview.track!
33
+ end
34
+
35
+ it 'tracks the measurment' do
36
+ Net::HTTP.should have_received(:post_form).with(uri, {
37
+ 'v' => 1,
38
+ 'tid' => 'UA-XXXX-Y',
39
+ 'cid' => '555',
40
+ 't' => 'pageview',
41
+ 'dh' => 'mystore.com',
42
+ 'dp' => '/search',
43
+ 'dt' => 'Search Results',
44
+ 'promo1id' => 'PROMO_1234',
45
+ 'promo1nm' => 'Summer Sale',
46
+ 'promo1cr' => 'summer_sale_banner',
47
+ 'promo1ps' => 'banner_1'
48
+ })
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe Staccato::Measurement::Transaction do
4
+ let(:uri) {Staccato.tracking_uri}
5
+ let(:tracker) {Staccato.tracker('UA-XXXX-Y')}
6
+ let(:response) {stub(:body => '', :status => 201)}
7
+
8
+ before(:each) do
9
+ SecureRandom.stubs(:uuid).returns('555')
10
+ Net::HTTP.stubs(:post_form).returns(response)
11
+ end
12
+
13
+ context 'a pageview with a transaction' do
14
+ let(:pageview) {
15
+ tracker.build_pageview({
16
+ path: '/receipt', hostname: 'mystore.com',
17
+ title: 'Your Receipt', product_action: 'purchase'
18
+ })
19
+ }
20
+
21
+ let(:measurment_options) {{
22
+ transaction_id: 'T12345',
23
+ affiliation: 'Your Store',
24
+ revenue: 37.39,
25
+ tax: 2.85,
26
+ shipping: 5.34,
27
+ currency: 'USD',
28
+ coupon_code: 'SUMMERSALE'
29
+ }}
30
+
31
+ before(:each) do
32
+ pageview.add_measurement(:transaction, measurment_options)
33
+
34
+ pageview.track!
35
+ end
36
+
37
+ it 'tracks the measurment' do
38
+ Net::HTTP.should have_received(:post_form).with(uri, {
39
+ 'v' => 1,
40
+ 'tid' => 'UA-XXXX-Y',
41
+ 'cid' => '555',
42
+ 't' => 'pageview',
43
+ 'dh' => 'mystore.com',
44
+ 'dp' => '/receipt',
45
+ 'dt' => 'Your Receipt',
46
+ 'pa' => 'purchase',
47
+ 'ti' => 'T12345',
48
+ 'ta' => 'Your Store',
49
+ 'tr' => 37.39,
50
+ 'ts' => 5.34,
51
+ 'tt' => 2.85,
52
+ 'cu' => 'USD',
53
+ 'tcc' => 'SUMMERSALE'
54
+ })
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Staccato::Measurement do
4
+ it 'looks up the measurement class by key' do
5
+ expect(Staccato::Measurement.lookup(:transaction)).to eq(Staccato::Measurement::Transaction)
6
+ end
7
+ end
metadata CHANGED
@@ -1,110 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staccato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tony Pitale
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-06 00:00:00.000000000 Z
11
+ date: 2015-04-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 3.0.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 3.0.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: mocha
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: bourne
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: simplecov
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  description: Ruby Google Analytics Measurement
@@ -114,19 +101,30 @@ executables: []
114
101
  extensions: []
115
102
  extra_rdoc_files: []
116
103
  files:
117
- - .gitignore
118
- - .rspec
119
- - .ruby-version
120
- - .travis.yml
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".ruby-version"
107
+ - ".travis.yml"
121
108
  - CHANGELOG.md
122
109
  - Gemfile
123
110
  - LICENSE.txt
124
111
  - README.md
125
112
  - Rakefile
126
113
  - lib/staccato.rb
114
+ - lib/staccato/boolean_helpers.rb
127
115
  - lib/staccato/event.rb
128
116
  - lib/staccato/exception.rb
129
117
  - lib/staccato/hit.rb
118
+ - lib/staccato/measurable.rb
119
+ - lib/staccato/measurement.rb
120
+ - lib/staccato/measurement/checkout.rb
121
+ - lib/staccato/measurement/checkout_option.rb
122
+ - lib/staccato/measurement/impression_list.rb
123
+ - lib/staccato/measurement/product.rb
124
+ - lib/staccato/measurement/product_impression.rb
125
+ - lib/staccato/measurement/promotion.rb
126
+ - lib/staccato/measurement/transaction.rb
127
+ - lib/staccato/null_measurement.rb
130
128
  - lib/staccato/option_set.rb
131
129
  - lib/staccato/pageview.rb
132
130
  - lib/staccato/social.rb
@@ -135,12 +133,19 @@ files:
135
133
  - lib/staccato/transaction.rb
136
134
  - lib/staccato/transaction_item.rb
137
135
  - lib/staccato/version.rb
136
+ - spec/integration/measurement/checkout_option_spec.rb
137
+ - spec/integration/measurement/checkout_spec.rb
138
+ - spec/integration/measurement/product_impression_spec.rb
139
+ - spec/integration/measurement/product_spec.rb
140
+ - spec/integration/measurement/promotion_spec.rb
141
+ - spec/integration/measurement/transaction_spec.rb
138
142
  - spec/integration/noop_tracker_spec.rb
139
143
  - spec/integration/tracker_spec.rb
140
144
  - spec/lib/stacatto_spec.rb
141
145
  - spec/lib/staccato/event_spec.rb
142
146
  - spec/lib/staccato/exception_spec.rb
143
147
  - spec/lib/staccato/hit_spec.rb
148
+ - spec/lib/staccato/measurement_spec.rb
144
149
  - spec/lib/staccato/pageview_spec.rb
145
150
  - spec/lib/staccato/tracker_spec.rb
146
151
  - spec/spec_helper.rb
@@ -148,35 +153,41 @@ files:
148
153
  homepage: https://github.com/tpitale/staccato
149
154
  licenses:
150
155
  - MIT
156
+ metadata: {}
151
157
  post_install_message:
152
158
  rdoc_options: []
153
159
  require_paths:
154
160
  - lib
155
161
  required_ruby_version: !ruby/object:Gem::Requirement
156
- none: false
157
162
  requirements:
158
- - - ! '>='
163
+ - - ">="
159
164
  - !ruby/object:Gem::Version
160
165
  version: '0'
161
166
  required_rubygems_version: !ruby/object:Gem::Requirement
162
- none: false
163
167
  requirements:
164
- - - ! '>='
168
+ - - ">="
165
169
  - !ruby/object:Gem::Version
166
170
  version: '0'
167
171
  requirements: []
168
172
  rubyforge_project:
169
- rubygems_version: 1.8.29
173
+ rubygems_version: 2.2.2
170
174
  signing_key:
171
- specification_version: 3
175
+ specification_version: 4
172
176
  summary: Ruby Google Analytics Measurement
173
177
  test_files:
178
+ - spec/integration/measurement/checkout_option_spec.rb
179
+ - spec/integration/measurement/checkout_spec.rb
180
+ - spec/integration/measurement/product_impression_spec.rb
181
+ - spec/integration/measurement/product_spec.rb
182
+ - spec/integration/measurement/promotion_spec.rb
183
+ - spec/integration/measurement/transaction_spec.rb
174
184
  - spec/integration/noop_tracker_spec.rb
175
185
  - spec/integration/tracker_spec.rb
176
186
  - spec/lib/stacatto_spec.rb
177
187
  - spec/lib/staccato/event_spec.rb
178
188
  - spec/lib/staccato/exception_spec.rb
179
189
  - spec/lib/staccato/hit_spec.rb
190
+ - spec/lib/staccato/measurement_spec.rb
180
191
  - spec/lib/staccato/pageview_spec.rb
181
192
  - spec/lib/staccato/tracker_spec.rb
182
193
  - spec/spec_helper.rb