analytics-ruby 2.4.0 → 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: 51f3f02afed05c9c8461b454e0a3067962a75b8efde0930db0098eebf4a62829
4
- data.tar.gz: e7d486d6c6186535e9a005c4d950e6e29d2dd9937f9b6da625191d786f76846a
3
+ metadata.gz: cec8be05188f102d0622c0c82771728e855506fb1d1872b6c83a6668515ee667
4
+ data.tar.gz: 8ff1887eac5cdbf44ce702b6cbcf40fdbae60d52e8a4c6adade4637941e0ee04
5
5
  SHA512:
6
- metadata.gz: c2ce09d450de65620eb99f9fae86aa5ce57709d53aa4a93c73c2d3db0b173afad532383a50fe4dcb953df72171b731a263ff7308aed79b646a25bc202c555e4d
7
- data.tar.gz: b3625484ebca6117ae79fc42f03a595dff861b8c5ca02a6ef12ea9e933229c1479dad40b4db1d85e61ddf585c7c5a072d68e9cd21ced6b2482db338f45073707
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.4.0'
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'
@@ -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.4.0
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-05-05 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