analytics-ruby 2.3.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/analytics +36 -36
- data/lib/analytics-ruby.rb +2 -0
- data/lib/segment/analytics/backoff_policy.rb +2 -0
- data/lib/segment/analytics/client.rb +7 -4
- data/lib/segment/analytics/defaults.rb +2 -0
- data/lib/segment/analytics/field_parser.rb +11 -6
- data/lib/segment/analytics/logging.rb +2 -0
- data/lib/segment/analytics/message_batch.rb +3 -0
- data/lib/segment/analytics/response.rb +2 -0
- data/lib/segment/analytics/test_queue.rb +2 -0
- data/lib/segment/analytics/transport.rb +2 -0
- data/lib/segment/analytics/utils.rb +3 -1
- data/lib/segment/analytics/version.rb +3 -1
- data/lib/segment/analytics/worker.rb +3 -1
- data/lib/segment/analytics.rb +2 -0
- data/lib/segment.rb +2 -0
- metadata +13 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cec8be05188f102d0622c0c82771728e855506fb1d1872b6c83a6668515ee667
|
4
|
+
data.tar.gz: 8ff1887eac5cdbf44ce702b6cbcf40fdbae60d52e8a4c6adade4637941e0ee04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94ea84292a05e8a922f82b59d2eed172202839918a59aa978c2fb00e083fb1620f81b86105b49c20607e318bcb8fe7d7a377e96df91c941a182cf23eddde1514
|
7
|
+
data.tar.gz: add48055b0e80a97bba09e2b3278f0fee2b25b074591150efc079ed244fa8ae5d8c0829b7b22c465b93ea214db4dd4e5d029d2c78053c3a4cebd74c3db88fd8c
|
data/bin/analytics
CHANGED
@@ -43,62 +43,62 @@ command :send do |c|
|
|
43
43
|
|
44
44
|
c.action do |args, options|
|
45
45
|
Analytics = Segment::Analytics.new({
|
46
|
-
write_key
|
47
|
-
on_error
|
46
|
+
:write_key => options.writeKey,
|
47
|
+
:on_error => Proc.new { |status, msg| print msg }
|
48
48
|
})
|
49
49
|
|
50
50
|
case options.type
|
51
51
|
when "track"
|
52
52
|
Analytics.track({
|
53
|
-
user_id
|
54
|
-
event
|
55
|
-
anonymous_id
|
56
|
-
properties
|
57
|
-
context
|
58
|
-
integrations
|
53
|
+
:user_id => options.userId,
|
54
|
+
:event => options.event,
|
55
|
+
:anonymous_id => options.anonymousId,
|
56
|
+
:properties => json_hash(options.properties),
|
57
|
+
:context => json_hash(options.context),
|
58
|
+
:integrations => json_hash(options.integrations)
|
59
59
|
})
|
60
60
|
when "page"
|
61
61
|
Analytics.page({
|
62
|
-
user_id
|
63
|
-
anonymous_id
|
64
|
-
name
|
65
|
-
properties
|
66
|
-
context
|
67
|
-
integrations
|
62
|
+
:user_id => options.userId,
|
63
|
+
:anonymous_id => options.anonymousId,
|
64
|
+
:name => options.name,
|
65
|
+
:properties => json_hash(options.properties),
|
66
|
+
:context => json_hash(options.context),
|
67
|
+
:integrations => json_hash(options.integrations)
|
68
68
|
})
|
69
69
|
when "screen"
|
70
70
|
Analytics.screen({
|
71
|
-
user_id
|
72
|
-
anonymous_id
|
73
|
-
name
|
74
|
-
properties
|
75
|
-
context
|
76
|
-
integrations
|
71
|
+
:user_id => options.userId,
|
72
|
+
:anonymous_id => options.anonymousId,
|
73
|
+
:name => options.name,
|
74
|
+
:properties => json_hash(options.properties),
|
75
|
+
:context => json_hash(options.context),
|
76
|
+
:integrations => json_hash(options.integrations)
|
77
77
|
})
|
78
78
|
when "identify"
|
79
79
|
Analytics.identify({
|
80
|
-
user_id
|
81
|
-
anonymous_id
|
82
|
-
traits
|
83
|
-
context
|
84
|
-
integrations
|
80
|
+
:user_id => options.userId,
|
81
|
+
:anonymous_id => options.anonymousId,
|
82
|
+
:traits => json_hash(options.traits),
|
83
|
+
:context => json_hash(options.context),
|
84
|
+
:integrations => json_hash(options.integrations)
|
85
85
|
})
|
86
86
|
when "group"
|
87
87
|
Analytics.group({
|
88
|
-
user_id
|
89
|
-
anonymous_id
|
90
|
-
group_id
|
91
|
-
traits
|
92
|
-
context
|
93
|
-
integrations
|
88
|
+
:user_id => options.userId,
|
89
|
+
:anonymous_id => options.anonymousId,
|
90
|
+
:group_id => options.groupId,
|
91
|
+
:traits => json_hash(options.traits),
|
92
|
+
:context => json_hash(options.context),
|
93
|
+
:integrations => json_hash(options.integrations)
|
94
94
|
})
|
95
95
|
when "alias"
|
96
96
|
Analytics.alias({
|
97
|
-
previous_id
|
98
|
-
user_id
|
99
|
-
anonymous_id
|
100
|
-
context
|
101
|
-
integrations
|
97
|
+
:previous_id => options.previousId,
|
98
|
+
:user_id => options.userId,
|
99
|
+
:anonymous_id => options.anonymousId,
|
100
|
+
:context => json_hash(options.context),
|
101
|
+
:integrations => json_hash(options.integrations)
|
102
102
|
})
|
103
103
|
else
|
104
104
|
raise "Invalid Message Type #{options.type}"
|
data/lib/analytics-ruby.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'thread'
|
2
4
|
require 'time'
|
3
5
|
|
@@ -161,7 +163,10 @@ module Segment
|
|
161
163
|
# add our request id for tracing purposes
|
162
164
|
action[:messageId] ||= uid
|
163
165
|
|
164
|
-
|
166
|
+
if @test
|
167
|
+
test_queue << action
|
168
|
+
return true
|
169
|
+
end
|
165
170
|
|
166
171
|
if @queue.length < @max_queue_size
|
167
172
|
@queue << action
|
@@ -170,9 +175,7 @@ module Segment
|
|
170
175
|
true
|
171
176
|
else
|
172
177
|
logger.warn(
|
173
|
-
'Queue is full, dropping events. The :max_queue_size '
|
174
|
-
'configuration parameter can be increased to prevent this from ' \
|
175
|
-
'happening.'
|
178
|
+
'Queue is full, dropping events. The :max_queue_size configuration parameter can be increased to prevent this from happening.'
|
176
179
|
)
|
177
180
|
false
|
178
181
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Segment
|
2
4
|
class Analytics
|
3
5
|
# Handles parsing fields according to the Segment Spec
|
@@ -160,9 +162,10 @@ module Segment
|
|
160
162
|
end
|
161
163
|
|
162
164
|
def check_user_id!(fields)
|
163
|
-
unless fields[:user_id]
|
164
|
-
|
165
|
-
|
165
|
+
return unless blank?(fields[:user_id])
|
166
|
+
return unless blank?(fields[:anonymous_id])
|
167
|
+
|
168
|
+
raise ArgumentError, 'Must supply either user_id or anonymous_id'
|
166
169
|
end
|
167
170
|
|
168
171
|
def check_timestamp!(timestamp)
|
@@ -178,9 +181,11 @@ module Segment
|
|
178
181
|
# obj - String|Number that must be non-blank
|
179
182
|
# name - Name of the validated value
|
180
183
|
def check_presence!(obj, name)
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
+
raise ArgumentError, "#{name} must be given" if blank?(obj)
|
185
|
+
end
|
186
|
+
|
187
|
+
def blank?(obj)
|
188
|
+
obj.nil? || (obj.is_a?(String) && obj.empty?)
|
184
189
|
end
|
185
190
|
|
186
191
|
def check_is_hash!(obj, name)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'forwardable'
|
2
4
|
require 'segment/analytics/logging'
|
3
5
|
|
@@ -27,6 +29,7 @@ module Segment
|
|
27
29
|
message_json_size = message_json.bytesize
|
28
30
|
if message_too_big?(message_json_size)
|
29
31
|
logger.error('a message exceeded the maximum allowed size')
|
32
|
+
raise JSONGenerationError, 'Message Exceeded Maximum Allowed Size'
|
30
33
|
else
|
31
34
|
@messages << message
|
32
35
|
@json_size += message_json_size + 1 # One byte for the comma
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'securerandom'
|
2
4
|
|
3
5
|
module Segment
|
@@ -65,7 +67,7 @@ module Segment
|
|
65
67
|
end
|
66
68
|
|
67
69
|
def time_in_iso8601(time)
|
68
|
-
"#{time.strftime('%Y-%m-%dT%H:%M:%S.%
|
70
|
+
"#{time.strftime('%Y-%m-%dT%H:%M:%S.%3N')}#{formatted_offset(time, true, 'Z')}"
|
69
71
|
end
|
70
72
|
|
71
73
|
def date_in_iso8601(date)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'segment/analytics/defaults'
|
2
4
|
require 'segment/analytics/message_batch'
|
3
5
|
require 'segment/analytics/transport'
|
@@ -29,7 +31,7 @@ module Segment
|
|
29
31
|
batch_size = options[:batch_size] || Defaults::MessageBatch::MAX_SIZE
|
30
32
|
@batch = MessageBatch.new(batch_size)
|
31
33
|
@lock = Mutex.new
|
32
|
-
@transport = Transport.new
|
34
|
+
@transport = Transport.new(options)
|
33
35
|
end
|
34
36
|
|
35
37
|
# public: Continuously runs the loop to check for new events
|
data/lib/segment/analytics.rb
CHANGED
data/lib/segment.rb
CHANGED
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.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Segment.io
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,30 +56,30 @@ dependencies:
|
|
56
56
|
name: tzinfo
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.2
|
61
|
+
version: '1.2'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.2
|
68
|
+
version: '1.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 5.2.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 5.2.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: oj
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,28 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 0.51.0
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: codecov
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.1.4
|
103
|
+
version: '1.0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
108
|
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
110
|
+
version: '1.0'
|
125
111
|
description: The Segment.io ruby analytics library
|
126
112
|
email: friends@segment.io
|
127
113
|
executables:
|
@@ -164,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
150
|
- !ruby/object:Gem::Version
|
165
151
|
version: '0'
|
166
152
|
requirements: []
|
167
|
-
rubygems_version: 3.
|
153
|
+
rubygems_version: 3.1.6
|
168
154
|
signing_key:
|
169
155
|
specification_version: 4
|
170
156
|
summary: Segment.io analytics library
|