diff --git a/integrations/Gemfile.lock b/integrations/Gemfile.lock index 79d31293..e6d685ea 100644 --- a/integrations/Gemfile.lock +++ b/integrations/Gemfile.lock @@ -7,7 +7,7 @@ GIT PATH remote: . specs: - multiwoven-integrations (0.8.3) + multiwoven-integrations (0.8.4) activesupport async-websocket aws-sdk-athena diff --git a/integrations/lib/multiwoven/integrations/destination/hubspot/client.rb b/integrations/lib/multiwoven/integrations/destination/hubspot/client.rb index 57a2e5e7..68ddfae8 100644 --- a/integrations/lib/multiwoven/integrations/destination/hubspot/client.rb +++ b/integrations/lib/multiwoven/integrations/destination/hubspot/client.rb @@ -55,13 +55,15 @@ def initialize_client(config) end def process_records(records, stream) + log_message_array = [] write_success = 0 write_failure = 0 properties = stream.json_schema.with_indifferent_access[:properties] records.each do |record_object| record = extract_data(record_object, properties) - send_data_to_hubspot(stream.name, record) + request, response = *send_data_to_hubspot(stream.name, record) write_success += 1 + log_message_array << log_request_response("info", request, response) rescue StandardError => e handle_exception(e, { context: "HUBSPOT:CRM:WRITE:EXCEPTION", @@ -70,15 +72,17 @@ 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 send_data_to_hubspot(stream_name, record = {}) args = build_args(@action, stream_name, record) hubspot_stream = @client.crm.send(stream_name) hubspot_data = { simple_public_object_input_for_create: args } - hubspot_stream.basic_api.send(@action, hubspot_data) + response = hubspot_stream.basic_api.send(@action, hubspot_data) + [args, response] end def build_args(action, stream_name, record) @@ -108,12 +112,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 25b5219f..9518790e 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.3" + VERSION = "0.8.4" ENABLED_SOURCES = %w[ Snowflake diff --git a/integrations/spec/multiwoven/integrations/destination/hubspot/client_spec.rb b/integrations/spec/multiwoven/integrations/destination/hubspot/client_spec.rb index 8ce0cf06..a728a384 100644 --- a/integrations/spec/multiwoven/integrations/destination/hubspot/client_spec.rb +++ b/integrations/spec/multiwoven/integrations/destination/hubspot/client_spec.rb @@ -119,6 +119,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 @@ -133,6 +139,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