staccato 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.ruby-version +1 -1
- data/.travis.yml +2 -0
- data/CHANGELOG.md +11 -0
- data/README.md +75 -5
- data/lib/staccato.rb +2 -2
- data/lib/staccato/exception.rb +4 -5
- data/lib/staccato/hit.rb +113 -20
- data/lib/staccato/option_set.rb +8 -2
- data/lib/staccato/pageview.rb +3 -3
- data/lib/staccato/timing.rb +9 -1
- data/lib/staccato/tracker.rb +17 -2
- data/lib/staccato/transaction_item.rb +1 -0
- data/lib/staccato/version.rb +1 -1
- data/spec/integration/tracker_spec.rb +19 -0
- data/spec/lib/staccato/exception_spec.rb +21 -0
- data/spec/lib/staccato/hit_spec.rb +30 -0
- metadata +9 -19
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDM3ZjczOTg3NDUzNWUyZmUxMzI5ZWZhMzEwYmVlMjYyMmY4N2M5YQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NGUwOTE4YWIyNWE0ZGRjYjlmMzMxNzlmNzY3ZDJkMzMxMDk5ZjhlMw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTdhMzc1NDQ0M2I1ZThiYTVjYTg5ZjFmZmRlY2NlMTdiNDJmODQxZTQwODU0
|
10
|
+
MTY5MDgyMjg1NjZkNjE2ODdmM2JiNjgxN2ZhY2EwOWVmNGY4NDI4N2Q0OTky
|
11
|
+
YThkMGMyYTM3Y2UxMDQ2OWJlYTFjMTcxMTliYThlZTU2ZTNjY2M=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NGIyZDcxMzVmNzE0NTIwOGQxZjY0MDQyNmEyYjM5NDhjY2EzOTc3MTMyNGJi
|
14
|
+
YmI1YTRiZTZiOTkzOWQwYmNmZDVlZmJkY2NkOTY2Zjc0YTBmMmQ1NTRkNjcw
|
15
|
+
NTdkYmMwNjhjZTcyNjIwMWU3NzU2OTZkMzBjZDdkZjc5ZDlkMzY=
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.3
|
1
|
+
1.9.3
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## Staccato 0.1.0 ##
|
2
|
+
|
3
|
+
* adds support for all global hit options in any hit type
|
4
|
+
* adds default hit options at the tracker level
|
5
|
+
* adds proper handling of boolean values into 1/0
|
6
|
+
* have travis-ci run 2.0, 2.1 rubies
|
7
|
+
|
8
|
+
*Tony Pitale*
|
9
|
+
|
10
|
+
* adds user_ip/user_agent *@medullan*
|
11
|
+
|
1
12
|
## Staccato 0.0.4 ##
|
2
13
|
|
3
14
|
* adds session start/end controls
|
data/README.md
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
# Staccato
|
2
2
|
|
3
|
-
Ruby Google Analytics Measurement
|
3
|
+
Ruby library to track into the official Google Analytics Measurement Protocol
|
4
|
+
|
5
|
+
https://developers.google.com/analytics/devguides/collection/protocol/v1/
|
6
|
+
|
7
|
+
**NOTE:** The Measurement Protocol is part of Universal Analytics, which is currently available in public beta. Data from the measurement protocol will only be processed in Universal Analytics enabled properties.
|
4
8
|
|
5
9
|
[](http://badge.fury.io/rb/staccato)
|
6
10
|
[](https://travis-ci.org/tpitale/staccato)
|
7
11
|
[](https://codeclimate.com/github/tpitale/staccato)
|
8
12
|
|
13
|
+
|
9
14
|
## Installation
|
10
15
|
|
11
16
|
Add this line to your application's Gemfile:
|
@@ -73,18 +78,70 @@ tracker.transaction_item({
|
|
73
78
|
})
|
74
79
|
```
|
75
80
|
|
76
|
-
|
81
|
+
### "Global" Options ###
|
82
|
+
|
83
|
+
Any of the options on the parameters list (https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters) that are accepted on ALL hit types can be set as options on any of the hits.
|
77
84
|
|
78
85
|
```ruby
|
79
|
-
tracker.pageview(path: '/
|
86
|
+
tracker.pageview(path: '/video/1235', flash_version: 'v1.2.3')
|
80
87
|
```
|
81
88
|
|
82
|
-
|
89
|
+
Flash Version is a global option in the example above.
|
90
|
+
|
91
|
+
**Note:** There are a few options that if used will override global options:
|
92
|
+
|
93
|
+
* document_path: overriden by `path` in pageviews
|
94
|
+
* document_hostname: overriden by `hostname` in pageviews
|
95
|
+
* document_title: overriden by `title` in pageviews
|
96
|
+
|
97
|
+
These are holdovers from the original design, where `pageview` is a hit type that can take any/all of the optional parameters. `path`, `hostname`, and `title` are slightly nicer to use on `pageview`.
|
98
|
+
|
99
|
+
The complete list at this time:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
Staccato::Hit::GLOBAL_OPTIONS.keys # =>
|
103
|
+
|
104
|
+
[:anonymize_ip,
|
105
|
+
:queue_time,
|
106
|
+
:cache_buster,
|
107
|
+
:user_id,
|
108
|
+
:user_ip,
|
109
|
+
:user_agent,
|
110
|
+
:referrer,
|
111
|
+
:campaign_name,
|
112
|
+
:campaign_source,
|
113
|
+
:campaign_medium,
|
114
|
+
:campaign_keyword,
|
115
|
+
:campaign_content,
|
116
|
+
:campaign_id,
|
117
|
+
:adwords_id,
|
118
|
+
:display_ads_id,
|
119
|
+
:screen_resolution,
|
120
|
+
:viewport_size,
|
121
|
+
:screen_colors,
|
122
|
+
:user_language,
|
123
|
+
:java_enabled,
|
124
|
+
:flash_version,
|
125
|
+
:document_location,
|
126
|
+
:document_encoding,
|
127
|
+
:document_hostname,
|
128
|
+
:document_path,
|
129
|
+
:document_title,
|
130
|
+
:link_id,
|
131
|
+
:application_name,
|
132
|
+
:application_version,
|
133
|
+
:application_id,
|
134
|
+
:application_installer_id,
|
135
|
+
:experiment_id,
|
136
|
+
:experiment_variant]
|
137
|
+
```
|
138
|
+
|
139
|
+
Boolean options like `anonymize_ip` will be converted from `true`/`false` into `1`/`0` as per the tracking API docs.
|
83
140
|
|
84
141
|
#### Custom Dimensions and Metrics ####
|
85
142
|
|
86
143
|
```ruby
|
87
|
-
hit =
|
144
|
+
hit = Staccato::Pageview.new(tracker, '/sports-page-5')
|
88
145
|
hit.add_custom_dimension(19, 'Sports')
|
89
146
|
hit.add_custom_metric(2, 5)
|
90
147
|
hit.track!
|
@@ -130,6 +187,19 @@ tracker.pageview({
|
|
130
187
|
})
|
131
188
|
```
|
132
189
|
|
190
|
+
## Tracker Hit Defaults ##
|
191
|
+
|
192
|
+
Global parameters can be set as defaults on the tracker, and will be used for all hits (unless overwritten by parameters set directly on a hit).
|
193
|
+
|
194
|
+
The following example creates a tracker with a default hostname. The two pageviews will track the default hostname and the page path passed in.
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
tracker = Staccato.tracker('UA-XXXX-Y', client_id, {document_hostname: 'example.com'})
|
198
|
+
|
199
|
+
tracker.pageview(path: '/videos/123')
|
200
|
+
tracker.pageview(path: '/videos/987')
|
201
|
+
```
|
202
|
+
|
133
203
|
## Google Documentation
|
134
204
|
|
135
205
|
https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
|
data/lib/staccato.rb
CHANGED
@@ -17,11 +17,11 @@ module Staccato
|
|
17
17
|
# @param client_id [String, Integer, nil] a unique id to track the session of
|
18
18
|
# an individual user
|
19
19
|
# @return [Staccato::Tracker] a new tracker is returned
|
20
|
-
def self.tracker(id, client_id = nil)
|
20
|
+
def self.tracker(id, client_id = nil, hit_options = {})
|
21
21
|
if id.nil?
|
22
22
|
Staccato::NoopTracker.new
|
23
23
|
else
|
24
|
-
Staccato::Tracker.new(id, client_id)
|
24
|
+
Staccato::Tracker.new(id, client_id, hit_options)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/lib/staccato/exception.rb
CHANGED
@@ -10,14 +10,13 @@ module Staccato
|
|
10
10
|
|
11
11
|
include Hit
|
12
12
|
|
13
|
-
def initialize(*)
|
14
|
-
super
|
15
|
-
options[:fatal] = 1 if options[:fatal]
|
16
|
-
end
|
17
|
-
|
18
13
|
# exception hit type
|
19
14
|
def type
|
20
15
|
:exception
|
21
16
|
end
|
17
|
+
|
18
|
+
def boolean_fields
|
19
|
+
super << :fatal
|
20
|
+
end
|
22
21
|
end
|
23
22
|
end
|
data/lib/staccato/hit.rb
CHANGED
@@ -2,7 +2,7 @@ module Staccato
|
|
2
2
|
# The `Hit` module enables a class to track the appropriate parameters
|
3
3
|
# to Google Analytics given a defined set of `FIELDS` in a map between
|
4
4
|
# the option name and its specified GA field name
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# @author Tony Pitale
|
7
7
|
module Hit
|
8
8
|
# this module is included into each model hit type
|
@@ -18,12 +18,66 @@ module Staccato
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
GLOBAL_OPTIONS = {
|
22
|
+
anonymize_ip: 'aip', # boolean
|
23
|
+
queue_time: 'qt', # integer
|
24
|
+
cache_buster: 'z',
|
25
|
+
user_id: 'uid', # a known user's id
|
26
|
+
|
27
|
+
# Session, works with session control
|
28
|
+
user_ip: 'uip',
|
29
|
+
user_agent: 'ua',
|
30
|
+
|
31
|
+
# Traffic Sources
|
32
|
+
referrer: 'dr',
|
33
|
+
campaign_name: 'cn',
|
34
|
+
campaign_source: 'cs',
|
35
|
+
campaign_medium: 'cm',
|
36
|
+
campaign_keyword: 'ck',
|
37
|
+
campaign_content: 'cc',
|
38
|
+
campaign_id: 'ci',
|
39
|
+
adwords_id: 'gclid',
|
40
|
+
display_ads_id: 'dclid',
|
41
|
+
|
42
|
+
# System Info
|
43
|
+
screen_resolution: 'sr',
|
44
|
+
viewport_size: 'vp',
|
45
|
+
screen_colors: 'sd',
|
46
|
+
user_language: 'ul',
|
47
|
+
java_enabled: 'je', # boolean
|
48
|
+
flash_version: 'fl',
|
49
|
+
non_interactive: 'ni', # boolean
|
50
|
+
document_location: 'dl',
|
51
|
+
document_encoding: 'de', # duplicate of encoding
|
52
|
+
document_hostname: 'dh', # duplicate of hostname
|
53
|
+
document_path: 'dp', # duplicate of path
|
54
|
+
document_title: 'dt', # duplicate of title
|
55
|
+
screen_name: 'cd', # screen name is not related to custom dimensions
|
56
|
+
link_id: 'linkid',
|
57
|
+
|
58
|
+
# App Tracking
|
59
|
+
application_name: 'an',
|
60
|
+
application_id: 'aid',
|
61
|
+
application_installer_id: 'aiid',
|
62
|
+
application_version: 'av',
|
63
|
+
|
64
|
+
# Content Experiments
|
65
|
+
experiment_id: 'xid',
|
66
|
+
experiment_variant: 'xvar'
|
67
|
+
}
|
68
|
+
|
69
|
+
BOOLEAN_FIELDS = [
|
70
|
+
:non_interactive,
|
71
|
+
:anonymize_ip,
|
72
|
+
:java_enabled
|
73
|
+
]
|
74
|
+
|
21
75
|
# sets up a new hit
|
22
76
|
# @param tracker [Staccato::Tracker] the tracker to collect to
|
23
77
|
# @param options [Hash] options for the specific hit type
|
24
78
|
def initialize(tracker, options = {})
|
25
79
|
self.tracker = tracker
|
26
|
-
self.options = OptionSet.new(options)
|
80
|
+
self.options = OptionSet.new(convert_booleans(options))
|
27
81
|
end
|
28
82
|
|
29
83
|
# return the fields for this hit type
|
@@ -35,6 +89,7 @@ module Staccato
|
|
35
89
|
# collects the parameters from options for this hit type
|
36
90
|
def params
|
37
91
|
base_params.
|
92
|
+
merge(tracker_default_params).
|
38
93
|
merge(global_options_params).
|
39
94
|
merge(hit_params).
|
40
95
|
merge(custom_dimensions).
|
@@ -42,12 +97,6 @@ module Staccato
|
|
42
97
|
reject {|_,v| v.nil?}
|
43
98
|
end
|
44
99
|
|
45
|
-
# is this a non interactive hit
|
46
|
-
# @return [Integer, nil]
|
47
|
-
def non_interactive
|
48
|
-
1 if options[:non_interactive] # defaults to nil
|
49
|
-
end
|
50
|
-
|
51
100
|
def add_custom_dimension(position, value)
|
52
101
|
self.custom_dimensions["cd#{position}"] = value
|
53
102
|
end
|
@@ -85,13 +134,41 @@ module Staccato
|
|
85
134
|
Net::HTTP.post_form(uri, params)
|
86
135
|
end
|
87
136
|
|
137
|
+
def convert_booleans(hash)
|
138
|
+
hash.each_pair.with_object({}, &method(:convert_boolean))
|
139
|
+
end
|
140
|
+
|
141
|
+
def convert_boolean((k,v), hash)
|
142
|
+
hash[k] = boolean_field?(k) ? integer_for(v) : v
|
143
|
+
end
|
144
|
+
|
145
|
+
def boolean_fields
|
146
|
+
BOOLEAN_FIELDS
|
147
|
+
end
|
148
|
+
|
149
|
+
def boolean_field?(key)
|
150
|
+
boolean_fields.include?(key)
|
151
|
+
end
|
152
|
+
|
153
|
+
def integer_for(value)
|
154
|
+
case value
|
155
|
+
when Integer
|
156
|
+
value
|
157
|
+
when TrueClass
|
158
|
+
1
|
159
|
+
when FalseClass
|
160
|
+
0
|
161
|
+
when NilClass
|
162
|
+
nil
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
88
166
|
# @private
|
89
167
|
def base_params
|
90
168
|
{
|
91
|
-
'v' => 1,
|
92
|
-
'tid' => tracker.id,
|
93
|
-
'cid' => tracker.client_id,
|
94
|
-
'ni' => non_interactive,
|
169
|
+
'v' => 1, # protocol version
|
170
|
+
'tid' => tracker.id, # tracking/web_property id
|
171
|
+
'cid' => tracker.client_id, # unique client id
|
95
172
|
'sc' => session_control,
|
96
173
|
't' => type.to_s
|
97
174
|
}
|
@@ -99,18 +176,34 @@ module Staccato
|
|
99
176
|
|
100
177
|
# @private
|
101
178
|
def global_options_params
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
179
|
+
Hash[
|
180
|
+
options.map { |k,v|
|
181
|
+
[GLOBAL_OPTIONS[k], v] if global_option?(k)
|
182
|
+
}.compact
|
183
|
+
]
|
184
|
+
end
|
185
|
+
|
186
|
+
# @private
|
187
|
+
def tracker_default_params
|
188
|
+
Hash[
|
189
|
+
tracker.hit_defaults.map { |k,v|
|
190
|
+
[GLOBAL_OPTIONS[k], v] if global_option?(k)
|
191
|
+
}.compact
|
192
|
+
]
|
193
|
+
end
|
194
|
+
|
195
|
+
# @private
|
196
|
+
def global_option?(key)
|
197
|
+
GLOBAL_OPTIONS.keys.include?(key)
|
109
198
|
end
|
110
199
|
|
111
200
|
# @private
|
112
201
|
def hit_params
|
113
|
-
Hash[
|
202
|
+
Hash[
|
203
|
+
fields.map { |field,key|
|
204
|
+
[key, options[field]] unless options[field].nil?
|
205
|
+
}.compact
|
206
|
+
]
|
114
207
|
end
|
115
208
|
end
|
116
209
|
end
|
data/lib/staccato/option_set.rb
CHANGED
@@ -2,9 +2,15 @@ module Staccato
|
|
2
2
|
# Extends OpenStruct with `[]` access method when
|
3
3
|
# the current version of ruby does not include it
|
4
4
|
class OptionSet < OpenStruct
|
5
|
-
|
6
|
-
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
unless OpenStruct.instance_methods.include?(:each)
|
8
|
+
include Enumerable
|
7
9
|
|
10
|
+
def_delegators :@table, :each
|
11
|
+
end
|
12
|
+
|
13
|
+
unless OpenStruct.instance_methods.include?(:[])
|
8
14
|
def_delegators :@table, :[], :[]=
|
9
15
|
end
|
10
16
|
end
|
data/lib/staccato/pageview.rb
CHANGED
@@ -4,9 +4,9 @@ module Staccato
|
|
4
4
|
class Pageview
|
5
5
|
# Pageview field definitions
|
6
6
|
FIELDS = {
|
7
|
-
hostname: 'dh',
|
8
|
-
path: 'dp',
|
9
|
-
title: 'dt'
|
7
|
+
hostname: 'dh', # moved to GLOBAL_OPTIONS
|
8
|
+
path: 'dp', # moved to GLOBAL_OPTIONS
|
9
|
+
title: 'dt' # moved to GLOBAL_OPTIONS
|
10
10
|
}
|
11
11
|
|
12
12
|
include Hit
|
data/lib/staccato/timing.rb
CHANGED
@@ -7,7 +7,15 @@ module Staccato
|
|
7
7
|
category: 'utc',
|
8
8
|
variable: 'utv',
|
9
9
|
label: 'utl',
|
10
|
-
time: 'utt'
|
10
|
+
time: 'utt',
|
11
|
+
|
12
|
+
# more specific timings
|
13
|
+
page_load_time: 'plt',
|
14
|
+
dns_time: 'dns',
|
15
|
+
page_download_time: 'pdt',
|
16
|
+
redirect_response_time: 'rrt',
|
17
|
+
tcp_connect_time: 'tcp',
|
18
|
+
server_response_time: 'srt'
|
11
19
|
}
|
12
20
|
|
13
21
|
include Hit
|
data/lib/staccato/tracker.rb
CHANGED
@@ -4,12 +4,16 @@ module Staccato
|
|
4
4
|
#
|
5
5
|
# @author Tony Pitale
|
6
6
|
class Tracker
|
7
|
+
attr_accessor :hit_defaults
|
8
|
+
|
7
9
|
# sets up a new tracker
|
8
10
|
# @param id [String] the GA tracker id
|
9
11
|
# @param client_id [String, nil] unique value to track user sessions
|
10
|
-
def initialize(id, client_id = nil)
|
12
|
+
def initialize(id, client_id = nil, hit_defaults = {})
|
11
13
|
@id = id
|
12
14
|
@client_id = client_id
|
15
|
+
|
16
|
+
self.hit_defaults = hit_defaults
|
13
17
|
end
|
14
18
|
|
15
19
|
# The tracker id for GA
|
@@ -75,8 +79,15 @@ module Staccato
|
|
75
79
|
# * variable (optional) e.g., 'database'
|
76
80
|
# * label (optional) e.g., 'query'
|
77
81
|
# * time (recommended) the integer time in milliseconds
|
82
|
+
# * page_load_time (optional)
|
83
|
+
# * dns_time (optional)
|
84
|
+
# * page_download_time (optional)
|
85
|
+
# * redirect_response_time (optional)
|
86
|
+
# * tcp_connect_time (optional)
|
87
|
+
# * server_response_time (optional) most useful on the server-side
|
78
88
|
# @param block [#call] if a block is provided, the time it takes to
|
79
|
-
# run will be recorded and set as the `time` value option
|
89
|
+
# run will be recorded and set as the `time` value option, no other
|
90
|
+
# time values will be set.
|
80
91
|
# @return [<Net::HTTPOK] the GA `/collect` endpoint always returns a 200
|
81
92
|
def timing(options = {}, &block)
|
82
93
|
Staccato::Timing.new(self, options).track!(&block)
|
@@ -101,6 +112,10 @@ module Staccato
|
|
101
112
|
# (see Tracker#initialize)
|
102
113
|
def initialize(*); end
|
103
114
|
|
115
|
+
def hit_defaults
|
116
|
+
{}
|
117
|
+
end
|
118
|
+
|
104
119
|
# (see Tracker#id)
|
105
120
|
def id
|
106
121
|
nil
|
data/lib/staccato/version.rb
CHANGED
@@ -215,4 +215,23 @@ describe Staccato::Tracker do
|
|
215
215
|
end
|
216
216
|
end
|
217
217
|
end
|
218
|
+
|
219
|
+
context "with defaults" do
|
220
|
+
before(:each) do
|
221
|
+
tracker.hit_defaults[:document_hostname] = 'mysite.com'
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'tracks page path and default hostname' do
|
225
|
+
tracker.pageview(path: '/foobar')
|
226
|
+
|
227
|
+
Net::HTTP.should have_received(:post_form).with(uri, {
|
228
|
+
'v' => 1,
|
229
|
+
'tid' => 'UA-XXXX-Y',
|
230
|
+
'cid' => '555',
|
231
|
+
't' => 'pageview',
|
232
|
+
'dh' => 'mysite.com',
|
233
|
+
'dp' => '/foobar'
|
234
|
+
})
|
235
|
+
end
|
236
|
+
end
|
218
237
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Staccato::Exception do
|
4
|
+
let(:tracker) { Staccato::NoopTracker.new }
|
5
|
+
|
6
|
+
it 'converts false fatal boolean field values to 0' do
|
7
|
+
expect(Staccato::Exception.new(tracker, fatal: false).params['exf']).to eq(0)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'does not convert fatal field integer values' do
|
11
|
+
expect(Staccato::Exception.new(tracker, fatal: 0).params['exf']).to eq(0)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'converts true fatal boolean field values to 1' do
|
15
|
+
expect(Staccato::Exception.new(tracker, fatal: true).params['exf']).to eq(1)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'rejects nil fatal boolean field values' do
|
19
|
+
expect(Staccato::Exception.new(tracker, fatal: nil).params.has_key?('exf')).to be_false
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class EmptyHit
|
4
|
+
FIELDS = {}
|
5
|
+
|
6
|
+
include Staccato::Hit
|
7
|
+
|
8
|
+
def type; :empty; end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe Staccato::Hit do
|
12
|
+
let(:hit_klass) { EmptyHit }
|
13
|
+
let(:tracker) { Staccato::NoopTracker.new }
|
14
|
+
|
15
|
+
it 'converts false boolean field values to 0' do
|
16
|
+
expect(hit_klass.new(tracker, anonymize_ip: false).params['aip']).to eq(0)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'does not convert integer values in boolean fields' do
|
20
|
+
expect(hit_klass.new(tracker, non_interactive: 0).params['ni']).to eq(0)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'converts true boolean field values to 1' do
|
24
|
+
expect(hit_klass.new(tracker, java_enabled: true).params['je']).to eq(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'rejects nil boolean field values' do
|
28
|
+
expect(hit_klass.new(tracker, non_interactive: nil).params.has_key?('ni')).to be_false
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: staccato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.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-
|
11
|
+
date: 2014-06-05 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
|
@@ -22,7 +20,6 @@ dependencies:
|
|
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
|
@@ -30,7 +27,6 @@ dependencies:
|
|
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
|
@@ -38,7 +34,6 @@ dependencies:
|
|
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
|
@@ -46,7 +41,6 @@ dependencies:
|
|
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
|
@@ -54,7 +48,6 @@ dependencies:
|
|
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
|
@@ -62,7 +55,6 @@ dependencies:
|
|
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
|
@@ -70,7 +62,6 @@ dependencies:
|
|
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
|
@@ -78,7 +69,6 @@ dependencies:
|
|
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
|
@@ -86,7 +76,6 @@ dependencies:
|
|
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
|
@@ -94,7 +83,6 @@ dependencies:
|
|
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
|
@@ -102,7 +90,6 @@ dependencies:
|
|
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
|
@@ -139,6 +126,8 @@ files:
|
|
139
126
|
- spec/integration/tracker_spec.rb
|
140
127
|
- spec/lib/stacatto_spec.rb
|
141
128
|
- spec/lib/staccato/event_spec.rb
|
129
|
+
- spec/lib/staccato/exception_spec.rb
|
130
|
+
- spec/lib/staccato/hit_spec.rb
|
142
131
|
- spec/lib/staccato/pageview_spec.rb
|
143
132
|
- spec/lib/staccato/tracker_spec.rb
|
144
133
|
- spec/spec_helper.rb
|
@@ -146,33 +135,34 @@ files:
|
|
146
135
|
homepage: https://github.com/tpitale/staccato
|
147
136
|
licenses:
|
148
137
|
- MIT
|
138
|
+
metadata: {}
|
149
139
|
post_install_message:
|
150
140
|
rdoc_options: []
|
151
141
|
require_paths:
|
152
142
|
- lib
|
153
143
|
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
144
|
requirements:
|
156
145
|
- - ! '>='
|
157
146
|
- !ruby/object:Gem::Version
|
158
147
|
version: '0'
|
159
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
-
none: false
|
161
149
|
requirements:
|
162
150
|
- - ! '>='
|
163
151
|
- !ruby/object:Gem::Version
|
164
152
|
version: '0'
|
165
153
|
requirements: []
|
166
154
|
rubyforge_project:
|
167
|
-
rubygems_version:
|
155
|
+
rubygems_version: 2.2.1
|
168
156
|
signing_key:
|
169
|
-
specification_version:
|
157
|
+
specification_version: 4
|
170
158
|
summary: Ruby Google Analytics Measurement
|
171
159
|
test_files:
|
172
160
|
- spec/integration/noop_tracker_spec.rb
|
173
161
|
- spec/integration/tracker_spec.rb
|
174
162
|
- spec/lib/stacatto_spec.rb
|
175
163
|
- spec/lib/staccato/event_spec.rb
|
164
|
+
- spec/lib/staccato/exception_spec.rb
|
165
|
+
- spec/lib/staccato/hit_spec.rb
|
176
166
|
- spec/lib/staccato/pageview_spec.rb
|
177
167
|
- spec/lib/staccato/tracker_spec.rb
|
178
168
|
- spec/spec_helper.rb
|