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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdf8f490d498d4be6df74dc0e07337670f201aecf2197df18a0cd6bad097f0ec
4
- data.tar.gz: 5f578db1517f5d9d376c0dfc3b19cdfb68afcc84b80d23cc929c8bf4038bfa3c
3
+ metadata.gz: cec8be05188f102d0622c0c82771728e855506fb1d1872b6c83a6668515ee667
4
+ data.tar.gz: 8ff1887eac5cdbf44ce702b6cbcf40fdbae60d52e8a4c6adade4637941e0ee04
5
5
  SHA512:
6
- metadata.gz: 6d05d3ba281a5af2d16e883afb17b285c5e5c2ee6500041646c136a412a16fd8f659f848e8f72d1bf86eeaddd9ae61a0565b49d051834d57ca0e9446ef6c8396
7
- data.tar.gz: b1fb05a4a057fe04dc39ed7234bc07cf2d401e9c5e2ca42eea64e9ff8c58bab879e9f4d42efad31128dcc4d8621e7c534f1f3b6c8f262049b78e4299fc16afe5
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: options.writeKey,
47
- on_error: Proc.new { |status, msg| print msg }
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: 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)
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: 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)
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: 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)
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: 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)
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: 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)
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: options.previousId,
98
- user_id: options.userId,
99
- anonymous_id: options.anonymousId,
100
- context: json_hash(options.context),
101
- integrations: json_hash(options.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}"
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'segment'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'segment/analytics/defaults'
2
4
 
3
5
  module Segment
@@ -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
- test_queue << action if @test
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
  module Defaults
@@ -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] || fields[:anonymous_id]
164
- raise ArgumentError, 'Must supply either user_id or anonymous_id'
165
- end
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
- if obj.nil? || (obj.is_a?(String) && obj.empty?)
182
- raise ArgumentError, "#{name} must be given"
183
- end
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 'logger'
2
4
 
3
5
  module Segment
@@ -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
  module Segment
2
4
  class Analytics
3
5
  class Response
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Segment
2
4
  class Analytics
3
5
  class TestQueue
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'segment/analytics/defaults'
2
4
  require 'segment/analytics/utils'
3
5
  require 'segment/analytics/response'
@@ -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.%6N')}#{formatted_offset(time, true, 'Z')}"
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,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Segment
2
4
  class Analytics
3
- VERSION = '2.3.1'
5
+ VERSION = '2.5.0'
4
6
  end
5
7
  end
@@ -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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'segment/analytics/version'
2
4
  require 'segment/analytics/defaults'
3
5
  require 'segment/analytics/utils'
data/lib/segment.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'segment/analytics'
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.3.1
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: 2021-04-13 00:00:00.000000000 Z
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: '10.3'
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: '10.3'
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.1
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.1
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: 4.1.11
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: 4.1.11
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: 0.51.0
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: 0.1.4
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.0.8
153
+ rubygems_version: 3.1.6
168
154
  signing_key:
169
155
  specification_version: 4
170
156
  summary: Segment.io analytics library