Skip to content

Commit

Permalink
Merge pull request #293 from Multiwoven/chore/add-request-response-lo…
Browse files Browse the repository at this point in the history
…g-klaviyo

chore(CE): add request response log for Klaviyo
  • Loading branch information
TivonB-AI2 authored Aug 12, 2024
2 parents aa9caaf + 366a686 commit 5845ac4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion integrations/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GIT
PATH
remote: .
specs:
multiwoven-integrations (0.7.8)
multiwoven-integrations (0.7.9)
activesupport
async-websocket
aws-sdk-athena
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ def write(sync_config, records, _action = "destination_insert")

request_method = sync_config.stream.request_method

log_message_array = []
write_success = 0
write_failure = 0
records.each do |record|
# pre process payload
# Add hardcode values into payload
record["data"] ||= {}
record["data"]["type"] = sync_config.stream.name
args = [request_method, url, record]

response = Multiwoven::Integrations::Core::HttpClient.request(
url,
Expand All @@ -57,6 +59,7 @@ def write(sync_config, records, _action = "destination_insert")
else
write_failure += 1
end
log_message_array << log_request_response("info", args, response)
rescue StandardError => e
handle_exception(e, {
context: "KLAVIYO:RECORD:WRITE:FAILURE",
Expand All @@ -65,12 +68,9 @@ def write(sync_config, records, _action = "destination_insert")
sync_run_id: sync_config.sync_run_id
})
write_failure += 1
log_message_array << log_request_response("error", args, e.message)
end
tracker = Multiwoven::Integrations::Protocol::TrackingMessage.new(
success: write_success,
failed: write_failure
)
tracker.to_multiwoven_message
tracking_message(write_success, write_failure, log_message_array)
rescue StandardError => e
# TODO: Handle rate limiting seperately
handle_exception(e, {
Expand Down
2 changes: 1 addition & 1 deletion integrations/lib/multiwoven/integrations/rollout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Multiwoven
module Integrations
VERSION = "0.7.8"
VERSION = "0.7.9"

ENABLED_SOURCES = %w[
Snowflake
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@

expect(tracker.success).to eq(records.count)
expect(tracker.failed).to eq(0)
log_message = message.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

Expand All @@ -208,6 +214,12 @@
tracker = message.tracking
expect(tracker.failed).to eq(records.count)
expect(tracker.success).to eq(0)
log_message = message.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

it "returns log message" do
Expand Down

0 comments on commit 5845ac4

Please sign in to comment.