From 9537945322e8661bcb8792eda77e27e97b3b60e9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:20:12 +0530 Subject: [PATCH] chore(CE): add request response log for Stripe (#328) Co-authored-by: TivonB-AI2 <124182151+TivonB-AI2@users.noreply.github.com> --- integrations/Gemfile.lock | 2 +- .../integrations/destination/stripe/client.rb | 16 +++++++--------- .../lib/multiwoven/integrations/rollout.rb | 2 +- .../destination/stripe/client_spec.rb | 12 ++++++++++++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/integrations/Gemfile.lock b/integrations/Gemfile.lock index e6d685ea..7005eb63 100644 --- a/integrations/Gemfile.lock +++ b/integrations/Gemfile.lock @@ -7,7 +7,7 @@ GIT PATH remote: . specs: - multiwoven-integrations (0.8.4) + multiwoven-integrations (0.8.5) activesupport async-websocket aws-sdk-athena diff --git a/integrations/lib/multiwoven/integrations/destination/stripe/client.rb b/integrations/lib/multiwoven/integrations/destination/stripe/client.rb index 8e72c3a8..5dc24bec 100644 --- a/integrations/lib/multiwoven/integrations/destination/stripe/client.rb +++ b/integrations/lib/multiwoven/integrations/destination/stripe/client.rb @@ -52,14 +52,17 @@ def initialize_client(config) end def process_records(records, stream) + log_message_array = [] write_success = 0 write_failure = 0 properties = stream.json_schema[:properties] records.each do |record_object| record = extract_data(record_object, properties) - klass = @client.const_get(stream.name) - klass.send(@action, record) + args = [stream.name, "Id", record] + klass = @client.const_get(stream.name) + response = klass.send(@action, record) write_success += 1 + log_message_array << log_request_response("info", args, response) rescue StandardError => e handle_exception(e, { context: "STRIPE:CRM:WRITE:EXCEPTION", @@ -68,8 +71,9 @@ def process_records(records, stream) sync_run_id: @sync_config.sync_run_id }) write_failure += 1 + log_message_array << log_request_response("error", args, e.message) end - tracking_message(write_success, write_failure) + tracking_message(write_success, write_failure, log_message_array) end def authenticate_client @@ -80,12 +84,6 @@ def load_catalog read_json(CATALOG_SPEC_PATH) end - def tracking_message(success, failure) - Multiwoven::Integrations::Protocol::TrackingMessage.new( - success: success, failed: failure - ).to_multiwoven_message - end - def log_debug(message) Multiwoven::Integrations::Service.logger.debug(message) end diff --git a/integrations/lib/multiwoven/integrations/rollout.rb b/integrations/lib/multiwoven/integrations/rollout.rb index 9518790e..b36e538c 100644 --- a/integrations/lib/multiwoven/integrations/rollout.rb +++ b/integrations/lib/multiwoven/integrations/rollout.rb @@ -2,7 +2,7 @@ module Multiwoven module Integrations - VERSION = "0.8.4" + VERSION = "0.8.5" ENABLED_SOURCES = %w[ Snowflake diff --git a/integrations/spec/multiwoven/integrations/destination/stripe/client_spec.rb b/integrations/spec/multiwoven/integrations/destination/stripe/client_spec.rb index b8591523..8bf82abf 100644 --- a/integrations/spec/multiwoven/integrations/destination/stripe/client_spec.rb +++ b/integrations/spec/multiwoven/integrations/destination/stripe/client_spec.rb @@ -98,6 +98,12 @@ expect(response.tracking.success).to eq(records.size) expect(response.tracking.failed).to eq(0) + log_message = response.tracking.logs.first + expect(log_message).to be_a(Multiwoven::Integrations::Protocol::LogMessage) + expect(log_message.level).to eql("info") + + expect(log_message.message).to include("request") + expect(log_message.message).to include("response") end end @@ -111,6 +117,12 @@ expect(response.tracking.failed).to eq(records.size) expect(response.tracking.success).to eq(0) + log_message = response.tracking.logs.first + expect(log_message).to be_a(Multiwoven::Integrations::Protocol::LogMessage) + expect(log_message.level).to eql("error") + + expect(log_message.message).to include("request") + expect(log_message.message).to include("response") end end end