diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8057bd2..b2a25cb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -18,7 +18,7 @@ Metrics/AbcSize: # Offense count: 1 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 223 + Max: 229 # Offense count: 1 Metrics/CyclomaticComplexity: diff --git a/lib/segment/analytics/client.rb b/lib/segment/analytics/client.rb index b216c7a..0475dda 100644 --- a/lib/segment/analytics/client.rb +++ b/lib/segment/analytics/client.rb @@ -1,13 +1,16 @@ require 'thread' require 'time' + +require 'segment/analytics/defaults' +require 'segment/analytics/logging' require 'segment/analytics/utils' require 'segment/analytics/worker' -require 'segment/analytics/defaults' module Segment class Analytics class Client include Segment::Analytics::Utils + include Segment::Analytics::Logging # public: Creates a new client # @@ -314,7 +317,12 @@ def enqueue(action) true else - false # Queue is full + logger.warn( + 'Queue is full, dropping events. The :max_queue_size ' \ + 'configuration parameter can be increased to prevent this from ' \ + 'happening.' + ) + false end end diff --git a/spec/segment/analytics/client_spec.rb b/spec/segment/analytics/client_spec.rb index ebc9a0a..f8a52e3 100644 --- a/spec/segment/analytics/client_spec.rb +++ b/spec/segment/analytics/client_spec.rb @@ -275,6 +275,16 @@ class Analytics end end + it 'returns false if queue is full' do + client.instance_variable_set(:@max_queue_size, 1) + + [:track, :screen, :page, :group, :identify, :alias].each do |s| + expect(client.send(s, data)).to eq(true) + expect(client.send(s, data)).to eq(false) # Queue is full + queue.pop(true) + end + end + it 'converts message id to string' do [:track, :screen, :page, :group, :identify, :alias].each do |s| client.send(s, data)