From 4d092f81b8828adbc386beb9ee50f3c441ecd93e Mon Sep 17 00:00:00 2001 From: TivonB-AI2 <124182151+TivonB-AI2@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:00:22 -0400 Subject: [PATCH] Resolve conflict in cherry-pick of 87c1fa2f2a8e15040c25d2028e51af933ac4f171 and change the commit message --- integrations/Gemfile.lock | 4 ++++ .../destination/salesforce_crm/client.rb | 16 +++++++--------- .../lib/multiwoven/integrations/rollout.rb | 4 ++++ .../destination/salesforce_crm/client_spec.rb | 12 ++++++++++++ 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/integrations/Gemfile.lock b/integrations/Gemfile.lock index e6d685ea..9aff68c8 100644 --- a/integrations/Gemfile.lock +++ b/integrations/Gemfile.lock @@ -7,7 +7,11 @@ GIT PATH remote: . specs: +<<<<<<< HEAD multiwoven-integrations (0.8.4) +======= + multiwoven-integrations (0.8.6) +>>>>>>> 87c1fa2f (chore(CE): add request response log for SalesforceCrm (#344)) activesupport async-websocket aws-sdk-athena diff --git a/integrations/lib/multiwoven/integrations/destination/salesforce_crm/client.rb b/integrations/lib/multiwoven/integrations/destination/salesforce_crm/client.rb index c15558f6..6bdf0914 100644 --- a/integrations/lib/multiwoven/integrations/destination/salesforce_crm/client.rb +++ b/integrations/lib/multiwoven/integrations/destination/salesforce_crm/client.rb @@ -59,13 +59,15 @@ 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) - process_record(stream, record) + request, response = *process_record(stream, record) write_success += 1 + log_message_array << log_request_response("info", request, response) rescue StandardError => e # TODO: add sync_id and sync_run_id to the logs handle_exception(e, { @@ -75,8 +77,9 @@ def process_records(records, stream) sync_run_id: @sync_config.sync_run_id }) write_failure += 1 + log_message_array << log_request_response("error", request, e.message) end - tracking_message(write_success, write_failure) + tracking_message(write_success, write_failure, log_message_array) end def process_record(stream, record) @@ -86,7 +89,8 @@ def process_record(stream, record) def send_data_to_salesforce(stream_name, record = {}) method_name = "#{@action}!" args = build_args(@action, stream_name, record) - @client.send(method_name, *args) + response = @client.send(method_name, *args) + [args, response] end def build_args(action, stream_name, record) @@ -116,12 +120,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..096536e9 100644 --- a/integrations/lib/multiwoven/integrations/rollout.rb +++ b/integrations/lib/multiwoven/integrations/rollout.rb @@ -2,7 +2,11 @@ module Multiwoven module Integrations +<<<<<<< HEAD VERSION = "0.8.4" +======= + VERSION = "0.8.6" +>>>>>>> 87c1fa2f (chore(CE): add request response log for SalesforceCrm (#344)) ENABLED_SOURCES = %w[ Snowflake diff --git a/integrations/spec/multiwoven/integrations/destination/salesforce_crm/client_spec.rb b/integrations/spec/multiwoven/integrations/destination/salesforce_crm/client_spec.rb index d1f0838b..61d136f2 100644 --- a/integrations/spec/multiwoven/integrations/destination/salesforce_crm/client_spec.rb +++ b/integrations/spec/multiwoven/integrations/destination/salesforce_crm/client_spec.rb @@ -103,6 +103,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 @@ -117,6 +123,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