analytics-ruby 2.3.0 → 2.3.1

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: 783cffe105e269e46ad1a00c48deef3a8259a909ea0c5840a187cd37ec13f00d
4
- data.tar.gz: d2255cdde8b5ea28ade9b3c4a58459d5488423ad53241d284bf0b3d883e97863
3
+ metadata.gz: cdf8f490d498d4be6df74dc0e07337670f201aecf2197df18a0cd6bad097f0ec
4
+ data.tar.gz: 5f578db1517f5d9d376c0dfc3b19cdfb68afcc84b80d23cc929c8bf4038bfa3c
5
5
  SHA512:
6
- metadata.gz: f81af66cb669884d651cc24972795e72141696b13458786593d82b31f15d5c3589ebf2047e98f1a3d3ec276fc4d7e705436865bd0e349643161bfa7356618b46
7
- data.tar.gz: 7c477ea2e3cfb3fe4c7540d649c33e2efd906690a32841d1a549820a0575818637611e389f47c3644ec0380dab3cfdf9ebf124b095a29066d7962a5322f2d003
6
+ metadata.gz: 6d05d3ba281a5af2d16e883afb17b285c5e5c2ee6500041646c136a412a16fd8f659f848e8f72d1bf86eeaddd9ae61a0565b49d051834d57ca0e9446ef6c8396
7
+ data.tar.gz: b1fb05a4a057fe04dc39ed7234bc07cf2d401e9c5e2ca42eea64e9ff8c58bab879e9f4d42efad31128dcc4d8621e7c534f1f3b6c8f262049b78e4299fc16afe5
@@ -7,6 +7,7 @@ require 'segment/analytics/worker'
7
7
  require 'segment/analytics/transport'
8
8
  require 'segment/analytics/response'
9
9
  require 'segment/analytics/logging'
10
+ require 'segment/analytics/test_queue'
10
11
 
11
12
  module Segment
12
13
  class Analytics
@@ -21,6 +21,7 @@ module Segment
21
21
  symbolize_keys!(opts)
22
22
 
23
23
  @queue = Queue.new
24
+ @test = opts[:test]
24
25
  @write_key = opts[:write_key]
25
26
  @max_queue_size = opts[:max_queue_size] || Defaults::Queue::MAX_SIZE
26
27
  @worker_mutex = Mutex.new
@@ -143,6 +144,14 @@ module Segment
143
144
  @queue.length
144
145
  end
145
146
 
147
+ def test_queue
148
+ unless @test
149
+ raise 'Test queue only available when setting :test to true.'
150
+ end
151
+
152
+ @test_queue ||= TestQueue.new
153
+ end
154
+
146
155
  private
147
156
 
148
157
  # private: Enqueues the action.
@@ -152,6 +161,8 @@ module Segment
152
161
  # add our request id for tracing purposes
153
162
  action[:messageId] ||= uid
154
163
 
164
+ test_queue << action if @test
165
+
155
166
  if @queue.length < @max_queue_size
156
167
  @queue << action
157
168
  ensure_worker_running
@@ -0,0 +1,56 @@
1
+ module Segment
2
+ class Analytics
3
+ class TestQueue
4
+ attr_reader :messages
5
+
6
+ def initialize
7
+ reset!
8
+ end
9
+
10
+ def [](key)
11
+ all[key]
12
+ end
13
+
14
+ def count
15
+ all.count
16
+ end
17
+
18
+ def <<(message)
19
+ all << message
20
+ send(message[:type]) << message
21
+ end
22
+
23
+ def alias
24
+ messages[:alias] ||= []
25
+ end
26
+
27
+ def all
28
+ messages[:all] ||= []
29
+ end
30
+
31
+ def group
32
+ messages[:group] ||= []
33
+ end
34
+
35
+ def identify
36
+ messages[:identify] ||= []
37
+ end
38
+
39
+ def page
40
+ messages[:page] ||= []
41
+ end
42
+
43
+ def screen
44
+ messages[:screen] ||= []
45
+ end
46
+
47
+ def track
48
+ messages[:track] ||= []
49
+ end
50
+
51
+ def reset!
52
+ @messages = {}
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,5 +1,5 @@
1
1
  module Segment
2
2
  class Analytics
3
- VERSION = '2.3.0'
3
+ VERSION = '2.3.1'
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.3.0
4
+ version: 2.3.1
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-03-26 00:00:00.000000000 Z
11
+ date: 2021-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -140,6 +140,7 @@ files:
140
140
  - lib/segment/analytics/logging.rb
141
141
  - lib/segment/analytics/message_batch.rb
142
142
  - lib/segment/analytics/response.rb
143
+ - lib/segment/analytics/test_queue.rb
143
144
  - lib/segment/analytics/transport.rb
144
145
  - lib/segment/analytics/utils.rb
145
146
  - lib/segment/analytics/version.rb