analytics-ruby 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/History.md +4 -0
- data/lib/segment/analytics/client.rb +128 -106
- data/lib/segment/analytics/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c32a838a458467589a5ac12e6ef9324d324ac32
|
4
|
+
data.tar.gz: f6d4c491a12271e49a567649d87f630939bda14e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69a369b48f8f11f7fe1674fe09809189fb42272f1d0462c55af916869d083d033988628d10f0220d262a7f0107f97bf8546625146ad6430996a4223ecd2f1981
|
7
|
+
data.tar.gz: 1f6d0c9a728827100d5ee3c8f9a9968647d12f94f8cdb304c1c02e7f7b2f17fe1a7993e8284863c5a807e4add1d4b293e0d07a3d83923b7258ccc332b46f01e4
|
data/Gemfile.lock
CHANGED
data/History.md
CHANGED
@@ -11,17 +11,17 @@ module Segment
|
|
11
11
|
|
12
12
|
# public: Creates a new client
|
13
13
|
#
|
14
|
-
#
|
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
|
19
|
-
symbolize_keys!
|
18
|
+
def initialize attrs = {}
|
19
|
+
symbolize_keys! attrs
|
20
20
|
|
21
21
|
@queue = Queue.new
|
22
|
-
@write_key =
|
23
|
-
@max_queue_size =
|
24
|
-
@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
|
-
#
|
47
|
-
# :
|
48
|
-
# :
|
49
|
-
# :
|
50
|
-
# :
|
51
|
-
# :
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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 =>
|
75
|
-
:anonymousId =>
|
77
|
+
:userId => attrs[:user_id],
|
78
|
+
:anonymousId => attrs[:anonymous_id],
|
76
79
|
:context => context,
|
77
|
-
:
|
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
|
-
#
|
87
|
-
# :
|
88
|
-
# :
|
89
|
-
# :
|
90
|
-
# :
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
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 =>
|
108
|
-
:anonymousId =>
|
109
|
-
: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
|
-
#
|
120
|
-
# :
|
121
|
-
# :
|
122
|
-
# :
|
123
|
-
# :
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
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 =>
|
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
|
-
#
|
150
|
-
# :
|
151
|
-
# :
|
152
|
-
# :
|
153
|
-
# :
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
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 =>
|
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
|
-
#
|
185
|
-
# :
|
186
|
-
# :
|
187
|
-
# :
|
188
|
-
# :
|
189
|
-
# :
|
190
|
-
# :
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
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 =>
|
209
|
-
:anonymousId =>
|
225
|
+
:userId => attrs[:user_id],
|
226
|
+
:anonymousId => attrs[:anonymous_id],
|
210
227
|
:name => name,
|
211
|
-
:category =>
|
228
|
+
:category => attrs[:category],
|
212
229
|
:properties => properties,
|
213
|
-
: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
|
-
#
|
222
|
-
# :
|
223
|
-
# :
|
224
|
-
# :
|
225
|
-
# :
|
226
|
-
# :
|
227
|
-
# :
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
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 =>
|
246
|
-
:anonymousId =>
|
266
|
+
:userId => attrs[:user_id],
|
267
|
+
:anonymousId => attrs[:anonymous_id],
|
247
268
|
:name => name,
|
248
269
|
:properties => properties,
|
249
|
-
:category =>
|
250
|
-
:
|
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!
|
321
|
-
fail ArgumentError, 'Must supply either user_id or anonymous_id' unless
|
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
|
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.
|
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-
|
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.
|
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:
|