analytics-ruby 2.0.6 → 2.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78f87f89a21de0f30bcec88b62edc739f637b148
4
- data.tar.gz: f05b8214e846b4399a698a0a5e30840529d247ed
3
+ metadata.gz: 1c32a838a458467589a5ac12e6ef9324d324ac32
4
+ data.tar.gz: f6d4c491a12271e49a567649d87f630939bda14e
5
5
  SHA512:
6
- metadata.gz: b24cb50f53eb596c86de960516af9e19edec63c4f0268c0f242e7bb1c2910450702fc84c6095fe8de8af4c22bc7460170c33db673c4b30f5f6d9c29575312cbb
7
- data.tar.gz: 64e1ff1189e5edca8d8d0ea697b6e1cc69d2676e09fff1cddbf65b9aea852c0e2bd5c7d80a1973672a1f82de54ba4c3ef997ac0fedfe7a4c74548120797e8e27
6
+ metadata.gz: 69a369b48f8f11f7fe1674fe09809189fb42272f1d0462c55af916869d083d033988628d10f0220d262a7f0107f97bf8546625146ad6430996a4223ecd2f1981
7
+ data.tar.gz: 1f6d0c9a728827100d5ee3c8f9a9968647d12f94f8cdb304c1c02e7f7b2f17fe1a7993e8284863c5a807e4add1d4b293e0d07a3d83923b7258ccc332b46f01e4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- analytics-ruby (2.0.5)
4
+ analytics-ruby (2.0.6)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/History.md CHANGED
@@ -1,3 +1,7 @@
1
+ 2.0.7 / 2014-08-27
2
+ ==================
3
+ * fix: include optional options hash in calls
4
+
1
5
  2.0.6 / 2014-08-12
2
6
  ==================
3
7
  * fix: category param on #page and #screen
@@ -11,17 +11,17 @@ module Segment
11
11
 
12
12
  # public: Creates a new client
13
13
  #
14
- # options - Hash
14
+ # attrs - Hash
15
15
  # :write_key - String of your project's write_key
16
16
  # :max_queue_size - Fixnum of the max calls to remain queued (optional)
17
17
  # :on_error - Proc which handles error calls from the API
18
- def initialize options = {}
19
- symbolize_keys! options
18
+ def initialize attrs = {}
19
+ symbolize_keys! attrs
20
20
 
21
21
  @queue = Queue.new
22
- @write_key = options[:write_key]
23
- @max_queue_size = options[:max_queue_size] || Defaults::Queue::MAX_SIZE
24
- @options = options
22
+ @write_key = attrs[:write_key]
23
+ @max_queue_size = attrs[:max_queue_size] || Defaults::Queue::MAX_SIZE
24
+ @options = attrs
25
25
  @worker_mutex = Mutex.new
26
26
  @worker = Worker.new @queue, @write_key, @options
27
27
 
@@ -43,20 +43,23 @@ module Segment
43
43
 
44
44
  # public: Tracks an event
45
45
  #
46
- # options - Hash
47
- # :event - String of event name.
48
- # :user_id - String of the user id.
49
- # :properties - Hash of event properties. (optional)
50
- # :timestamp - Time of when the event occurred. (optional)
51
- # :context - Hash of context. (optional)
52
- def track options
53
- symbolize_keys! options
54
- check_user_id! options
55
-
56
- event = options[:event]
57
- properties = options[:properties] || {}
58
- timestamp = options[:timestamp] || Time.new
59
- context = options[:context] || {}
46
+ # attrs - Hash
47
+ # :anonymous_id - String of the user's id when you don't know who they are yet. (optional but you must provide either an anonymous_id or user_id. See: https://segment.io/docs/tracking - api/track/#user - id)
48
+ # :context - Hash of context. (optional)
49
+ # :event - String of event name.
50
+ # :integrations - Hash specifying what integrations this event goes to. (optional)
51
+ # :options - Hash specifying options such as user traits. (optional)
52
+ # :properties - Hash of event properties. (optional)
53
+ # :timestamp - Time of when the event occurred. (optional)
54
+ # :user_id - String of the user id.
55
+ def track attrs
56
+ symbolize_keys! attrs
57
+ check_user_id! attrs
58
+
59
+ event = attrs[:event]
60
+ properties = attrs[:properties] || {}
61
+ timestamp = attrs[:timestamp] || Time.new
62
+ context = attrs[:context] || {}
60
63
 
61
64
  check_timestamp! timestamp
62
65
 
@@ -71,10 +74,11 @@ module Segment
71
74
 
72
75
  enqueue({
73
76
  :event => event,
74
- :userId => options[:user_id],
75
- :anonymousId => options[:anonymous_id],
77
+ :userId => attrs[:user_id],
78
+ :anonymousId => attrs[:anonymous_id],
76
79
  :context => context,
77
- :integrations => options[:integrations],
80
+ :options => attrs[:options],
81
+ :integrations => attrs[:integrations],
78
82
  :properties => properties,
79
83
  :timestamp => datetime_in_iso8601(timestamp),
80
84
  :type => 'track'
@@ -83,18 +87,21 @@ module Segment
83
87
 
84
88
  # public: Identifies a user
85
89
  #
86
- # options - Hash
87
- # :user_id - String of the user id
88
- # :traits - Hash of user traits. (optional)
89
- # :timestamp - Time of when the event occurred. (optional)
90
- # :context - Hash of context. (optional)
91
- def identify options
92
- symbolize_keys! options
93
- check_user_id! options
94
-
95
- traits = options[:traits] || {}
96
- timestamp = options[:timestamp] || Time.new
97
- context = options[:context] || {}
90
+ # attrs - Hash
91
+ # :anonymous_id - String of the user's id when you don't know who they are yet. (optional but you must provide either an anonymous_id or user_id. See: https://segment.io/docs/tracking - api/track/#user - id)
92
+ # :context - Hash of context. (optional)
93
+ # :integrations - Hash specifying what integrations this event goes to. (optional)
94
+ # :options - Hash specifying options such as user traits. (optional)
95
+ # :timestamp - Time of when the event occurred. (optional)
96
+ # :traits - Hash of user traits. (optional)
97
+ # :user_id - String of the user id
98
+ def identify attrs
99
+ symbolize_keys! attrs
100
+ check_user_id! attrs
101
+
102
+ traits = attrs[:traits] || {}
103
+ timestamp = attrs[:timestamp] || Time.new
104
+ context = attrs[:context] || {}
98
105
 
99
106
  check_timestamp! timestamp
100
107
 
@@ -104,11 +111,12 @@ module Segment
104
111
  add_context context
105
112
 
106
113
  enqueue({
107
- :userId => options[:user_id],
108
- :anonymousId => options[:anonymous_id],
109
- :integrations => options[:integrations],
114
+ :userId => attrs[:user_id],
115
+ :anonymousId => attrs[:anonymous_id],
116
+ :integrations => attrs[:integrations],
110
117
  :context => context,
111
118
  :traits => traits,
119
+ :options => attrs[:options],
112
120
  :timestamp => datetime_in_iso8601(timestamp),
113
121
  :type => 'identify'
114
122
  })
@@ -116,18 +124,20 @@ module Segment
116
124
 
117
125
  # public: Aliases a user from one id to another
118
126
  #
119
- # options - Hash
120
- # :previous_id - String of the id to alias from
121
- # :user_id - String of the id to alias to
122
- # :timestamp - Time of when the alias occured (optional)
123
- # :context - Hash of context (optional)
124
- def alias(options)
125
- symbolize_keys! options
126
-
127
- from = options[:previous_id]
128
- to = options[:user_id]
129
- timestamp = options[:timestamp] || Time.new
130
- context = options[:context] || {}
127
+ # attrs - Hash
128
+ # :context - Hash of context (optional)
129
+ # :integrations - Hash specifying what integrations this event goes to. (optional)
130
+ # :options - Hash specifying options such as user traits. (optional)
131
+ # :previous_id - String of the id to alias from
132
+ # :timestamp - Time of when the alias occured (optional)
133
+ # :user_id - String of the id to alias to
134
+ def alias(attrs)
135
+ symbolize_keys! attrs
136
+
137
+ from = attrs[:previous_id]
138
+ to = attrs[:user_id]
139
+ timestamp = attrs[:timestamp] || Time.new
140
+ context = attrs[:context] || {}
131
141
 
132
142
  check_presence! from, 'previous_id'
133
143
  check_presence! to, 'user_id'
@@ -137,8 +147,9 @@ module Segment
137
147
  enqueue({
138
148
  :previousId => from,
139
149
  :userId => to,
140
- :integrations => options[:integrations],
150
+ :integrations => attrs[:integrations],
141
151
  :context => context,
152
+ :options => attrs[:options],
142
153
  :timestamp => datetime_in_iso8601(timestamp),
143
154
  :type => 'alias'
144
155
  })
@@ -146,20 +157,22 @@ module Segment
146
157
 
147
158
  # public: Associates a user identity with a group.
148
159
  #
149
- # options - Hash
150
- # :previous_id - String of the id to alias from
151
- # :user_id - String of the id to alias to
152
- # :timestamp - Time of when the alias occured (optional)
153
- # :context - Hash of context (optional)
154
- def group(options)
155
- symbolize_keys! options
156
- check_user_id! options
157
-
158
- group_id = options[:group_id]
159
- user_id = options[:user_id]
160
- traits = options[:traits] || {}
161
- timestamp = options[:timestamp] || Time.new
162
- context = options[:context] || {}
160
+ # attrs - Hash
161
+ # :context - Hash of context (optional)
162
+ # :integrations - Hash specifying what integrations this event goes to. (optional)
163
+ # :options - Hash specifying options such as user traits. (optional)
164
+ # :previous_id - String of the id to alias from
165
+ # :timestamp - Time of when the alias occured (optional)
166
+ # :user_id - String of the id to alias to
167
+ def group(attrs)
168
+ symbolize_keys! attrs
169
+ check_user_id! attrs
170
+
171
+ group_id = attrs[:group_id]
172
+ user_id = attrs[:user_id]
173
+ traits = attrs[:traits] || {}
174
+ timestamp = attrs[:timestamp] || Time.new
175
+ context = attrs[:context] || {}
163
176
 
164
177
  fail ArgumentError, '.traits must be a hash' unless traits.is_a? Hash
165
178
  isoify_dates! traits
@@ -172,7 +185,8 @@ module Segment
172
185
  :groupId => group_id,
173
186
  :userId => user_id,
174
187
  :traits => traits,
175
- :integrations => options[:integrations],
188
+ :integrations => attrs[:integrations],
189
+ :options => attrs[:options],
176
190
  :context => context,
177
191
  :timestamp => datetime_in_iso8601(timestamp),
178
192
  :type => 'group'
@@ -181,21 +195,24 @@ module Segment
181
195
 
182
196
  # public: Records a page view
183
197
  #
184
- # options - Hash
185
- # :user_id - String of the id to alias from
186
- # :name - String name of the page
187
- # :properties - Hash of page properties (optional)
188
- # :category - String of the page category (optional)
189
- # :timestamp - Time of when the pageview occured (optional)
190
- # :context - Hash of context (optional)
191
- def page(options)
192
- symbolize_keys! options
193
- check_user_id! options
194
-
195
- name = options[:name].to_s
196
- properties = options[:properties] || {}
197
- timestamp = options[:timestamp] || Time.new
198
- context = options[:context] || {}
198
+ # attrs - Hash
199
+ # :anonymous_id - String of the user's id when you don't know who they are yet. (optional but you must provide either an anonymous_id or user_id. See: https://segment.io/docs/tracking - api/track/#user - id)
200
+ # :category - String of the page category (optional)
201
+ # :context - Hash of context (optional)
202
+ # :integrations - Hash specifying what integrations this event goes to. (optional)
203
+ # :name - String name of the page
204
+ # :options - Hash specifying options such as user traits. (optional)
205
+ # :properties - Hash of page properties (optional)
206
+ # :timestamp - Time of when the pageview occured (optional)
207
+ # :user_id - String of the id to alias from
208
+ def page(attrs)
209
+ symbolize_keys! attrs
210
+ check_user_id! attrs
211
+
212
+ name = attrs[:name].to_s
213
+ properties = attrs[:properties] || {}
214
+ timestamp = attrs[:timestamp] || Time.new
215
+ context = attrs[:context] || {}
199
216
 
200
217
  fail ArgumentError, '.name must be a string' unless !name.empty?
201
218
  fail ArgumentError, '.properties must be a hash' unless properties.is_a? Hash
@@ -205,12 +222,13 @@ module Segment
205
222
  add_context context
206
223
 
207
224
  enqueue({
208
- :userId => options[:user_id],
209
- :anonymousId => options[:anonymous_id],
225
+ :userId => attrs[:user_id],
226
+ :anonymousId => attrs[:anonymous_id],
210
227
  :name => name,
211
- :category => options[:category],
228
+ :category => attrs[:category],
212
229
  :properties => properties,
213
- :integrations => options[:integrations],
230
+ :integrations => attrs[:integrations],
231
+ :options => attrs[:options],
214
232
  :context => context,
215
233
  :timestamp => datetime_in_iso8601(timestamp),
216
234
  :type => 'page'
@@ -218,21 +236,24 @@ module Segment
218
236
  end
219
237
  # public: Records a screen view (for a mobile app)
220
238
  #
221
- # options - Hash
222
- # :user_id - String of the id to alias from
223
- # :name - String name of the screen
224
- # :category - String screen category (optional)
225
- # :properties - Hash of screen properties (optional)
226
- # :timestamp - Time of when the screen occured (optional)
227
- # :context - Hash of context (optional)
228
- def screen(options)
229
- symbolize_keys! options
230
- check_user_id! options
231
-
232
- name = options[:name].to_s
233
- properties = options[:properties] || {}
234
- timestamp = options[:timestamp] || Time.new
235
- context = options[:context] || {}
239
+ # attrs - Hash
240
+ # :anonymous_id - String of the user's id when you don't know who they are yet. (optional but you must provide either an anonymous_id or user_id. See: https://segment.io/docs/tracking - api/track/#user - id)
241
+ # :category - String screen category (optional)
242
+ # :context - Hash of context (optional)
243
+ # :integrations - Hash specifying what integrations this event goes to. (optional)
244
+ # :name - String name of the screen
245
+ # :options - Hash specifying options such as user traits. (optional)
246
+ # :properties - Hash of screen properties (optional)
247
+ # :timestamp - Time of when the screen occured (optional)
248
+ # :user_id - String of the id to alias from
249
+ def screen(attrs)
250
+ symbolize_keys! attrs
251
+ check_user_id! attrs
252
+
253
+ name = attrs[:name].to_s
254
+ properties = attrs[:properties] || {}
255
+ timestamp = attrs[:timestamp] || Time.new
256
+ context = attrs[:context] || {}
236
257
 
237
258
  fail ArgumentError, '.name must be a string' if name.empty?
238
259
  fail ArgumentError, '.properties must be a hash' unless properties.is_a? Hash
@@ -242,12 +263,13 @@ module Segment
242
263
  add_context context
243
264
 
244
265
  enqueue({
245
- :userId => options[:user_id],
246
- :anonymousId => options[:anonymous_id],
266
+ :userId => attrs[:user_id],
267
+ :anonymousId => attrs[:anonymous_id],
247
268
  :name => name,
248
269
  :properties => properties,
249
- :category => options[:category],
250
- :integrations => options[:integrations],
270
+ :category => attrs[:category],
271
+ :options => attrs[:options],
272
+ :integrations => attrs[:integrations],
251
273
  :context => context,
252
274
  :timestamp => timestamp.iso8601,
253
275
  :type => 'screen'
@@ -317,8 +339,8 @@ module Segment
317
339
  }
318
340
  end
319
341
 
320
- def check_user_id! options
321
- fail ArgumentError, 'Must supply either user_id or anonymous_id' unless options[:user_id] || options[:anonymous_id]
342
+ def check_user_id! attrs
343
+ fail ArgumentError, 'Must supply either user_id or anonymous_id' unless attrs[:user_id] || attrs[:anonymous_id]
322
344
  end
323
345
 
324
346
  def ensure_worker_running
@@ -1,5 +1,5 @@
1
1
  module Segment
2
2
  class Analytics
3
- VERSION = '2.0.6'
3
+ VERSION = '2.0.7'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analytics-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Segment.io
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-12 00:00:00.000000000 Z
11
+ date: 2014-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -133,9 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements: []
135
135
  rubyforge_project:
136
- rubygems_version: 2.2.0
136
+ rubygems_version: 2.2.2
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Segment.io analytics library
140
140
  test_files: []
141
- has_rdoc: