fix(events): add logger for incoming webhook payload (#3171)

This commit is contained in:
Prasunna Soppa
2023-12-19 23:50:02 +05:30
committed by GitHub
parent 396a64f3bb
commit cf47a65916

View File

@ -25,8 +25,8 @@ pub async fn receive_incoming_webhook<W: types::OutgoingWebhookType>(
flow.clone(),
state,
&req,
(),
|state, auth, _| {
WebhookBytes(body),
|state, auth, payload| {
webhooks::webhooks_wrapper::<W, Oss>(
&flow,
state.to_owned(),
@ -34,7 +34,7 @@ pub async fn receive_incoming_webhook<W: types::OutgoingWebhookType>(
auth.merchant_account,
auth.key_store,
&connector_id_or_name,
body.clone(),
payload.0,
)
},
&auth::MerchantIdAuth(merchant_id),
@ -42,3 +42,19 @@ pub async fn receive_incoming_webhook<W: types::OutgoingWebhookType>(
))
.await
}
#[derive(Debug)]
struct WebhookBytes(web::Bytes);
impl serde::Serialize for WebhookBytes {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
let payload: serde_json::Value = serde_json::from_slice(&self.0).unwrap_or_default();
payload.serialize(serializer)
}
}
impl common_utils::events::ApiEventMetric for WebhookBytes {
fn get_api_event_type(&self) -> Option<common_utils::events::ApiEventsType> {
Some(common_utils::events::ApiEventsType::Miscellaneous)
}
}