lib/flagsmith/sdk/analytics_processor.rb in flagsmith-4.0.1 vs lib/flagsmith/sdk/analytics_processor.rb in flagsmith-4.1.0
- old
+ new
@@ -17,18 +17,23 @@
def initialize(data)
@last_flushed = Time.now
@analytics_data = {}
@api_client = data.fetch(:api_client)
@timeout = data.fetch(:timeout, 3)
+ @logger = data.fetch(:logger)
end
# Sends all the collected data to the api asynchronously and resets the timer
def flush
return if @analytics_data.empty?
- @api_client.post(ENDPOINT, @analytics_data.to_json)
+ begin
+ @api_client.post(ENDPOINT, @analytics_data.to_json)
+ @analytics_data = {}
+ rescue StandardError => e
+ @logger.warn "Temporarily unable to access flag analytics endpoint for exception: #{e}"
+ end
- @analytics_data = {}
@last_flushed = Time.now
end
def track_feature(feature_name)
@analytics_data[feature_name] = @analytics_data.fetch(feature_name, 0) + 1