Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(events): Tenant config in API, Connector and Outgoing Web-hook events (#6777)
ShivanshMathurJuspayc620779bbd14
diff --git a/crates/hyperswitch_interfaces/src/events/connector_api_logs.rs b/crates/hyperswitch_interfaces/src/events/connector_api_logs.rsindex 5edd8d68c3..bf9eafe5aa 100644--- a/crates/hyperswitch_interfaces/src/events/connector_api_logs.rs+++ b/crates/hyperswitch_interfaces/src/events/connector_api_logs.rs@@ -9,6 +9,7 @@ use time::OffsetDateTime;/// struct ConnectorEvent#[derive(Debug, Serialize)]pub struct ConnectorEvent {+ tenant_id: common_utils::id_type::TenantId,connector_name: String,flow: String,request: String,@@ -31,6 +32,7 @@ impl ConnectorEvent {/// fn new ConnectorEvent#[allow(clippy::too_many_arguments)]pub fn new(+ tenant_id: common_utils::id_type::TenantId,connector_name: String,flow: &str,request: serde_json::Value,@@ -45,6 +47,7 @@ impl ConnectorEvent {status_code: u16,) -> Self {Self {+ tenant_id,connector_name,flow: flow.rsplit_once("::")diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rsindex 4b9141c649..73d9cfdcae 100644--- a/crates/router/src/core/webhooks/incoming.rs+++ b/crates/router/src/core/webhooks/incoming.rs@@ -99,6 +99,7 @@ pub async fn incoming_webhooks_wrapper<W: types::OutgoingWebhookType>(.attach_printable("Could not convert webhook effect to string")?;let api_event = ApiEvent::new(+ state.tenant.tenant_id.clone(),Some(merchant_account.get_id().clone()),flow,&request_id,diff --git a/crates/router/src/core/webhooks/incoming_v2.rs b/crates/router/src/core/webhooks/incoming_v2.rsindex d331e4d67f..139ae18c17 100644--- a/crates/router/src/core/webhooks/incoming_v2.rs+++ b/crates/router/src/core/webhooks/incoming_v2.rs@@ -91,6 +91,7 @@ pub async fn incoming_webhooks_wrapper<W: types::OutgoingWebhookType>(.attach_printable("Could not convert webhook effect to string")?;let api_event = ApiEvent::new(+ state.tenant.tenant_id.clone(),Some(merchant_account.get_id().clone()),flow,&request_id,diff --git a/crates/router/src/core/webhooks/outgoing.rs b/crates/router/src/core/webhooks/outgoing.rsindex 16d927be26..4bb45327d8 100644--- a/crates/router/src/core/webhooks/outgoing.rs+++ b/crates/router/src/core/webhooks/outgoing.rs@@ -499,6 +499,7 @@ async fn raise_webhooks_analytics_event(});let webhook_event = OutgoingWebhookEvent::new(+ state.tenant.tenant_id.clone(),merchant_id,event_id,event.event_type,diff --git a/crates/router/src/events/api_logs.rs b/crates/router/src/events/api_logs.rsindex 76cbcb958c..419164810c 100644--- a/crates/router/src/events/api_logs.rs+++ b/crates/router/src/events/api_logs.rs@@ -24,6 +24,7 @@ use crate::{#[derive(Clone, Debug, Eq, PartialEq, Serialize)]#[serde(rename_all = "snake_case")]pub struct ApiEvent {+ tenant_id: common_utils::id_type::TenantId,merchant_id: Option<common_utils::id_type::MerchantId>,api_flow: String,created_at_timestamp: i128,@@ -47,6 +48,7 @@ pub struct ApiEvent {impl ApiEvent {#[allow(clippy::too_many_arguments)]pub fn new(+ tenant_id: common_utils::id_type::TenantId,merchant_id: Option<common_utils::id_type::MerchantId>,api_flow: &impl FlowMetric,request_id: &RequestId,@@ -62,6 +64,7 @@ impl ApiEvent {http_method: &http::Method,) -> Self {Self {+ tenant_id,merchant_id,api_flow: api_flow.to_string(),created_at_timestamp: OffsetDateTime::now_utc().unix_timestamp_nanos() / 1_000_000,diff --git a/crates/router/src/events/outgoing_webhook_logs.rs b/crates/router/src/events/outgoing_webhook_logs.rsindex 64126ec76d..b56c473920 100644--- a/crates/router/src/events/outgoing_webhook_logs.rs+++ b/crates/router/src/events/outgoing_webhook_logs.rs@@ -10,6 +10,7 @@ use crate::services::kafka::KafkaMessage;#[derive(Clone, Debug, PartialEq, Serialize)]#[serde(rename_all = "snake_case")]pub struct OutgoingWebhookEvent {+ tenant_id: common_utils::id_type::TenantId,merchant_id: common_utils::id_type::MerchantId,event_id: String,event_type: OutgoingWebhookEventType,@@ -147,6 +148,7 @@ impl OutgoingWebhookEventMetric for OutgoingWebhookContent {impl OutgoingWebhookEvent {#[allow(clippy::too_many_arguments)]pub fn new(+ tenant_id: common_utils::id_type::TenantId,merchant_id: common_utils::id_type::MerchantId,event_id: String,event_type: OutgoingWebhookEventType,@@ -157,6 +159,7 @@ impl OutgoingWebhookEvent {delivery_attempt: Option<WebhookDeliveryAttempt>,) -> Self {Self {+ tenant_id,merchant_id,event_id,event_type,diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rsindex a4c1cac0ac..cfff235856 100644--- a/crates/router/src/services/api.rs+++ b/crates/router/src/services/api.rs@@ -228,6 +228,7 @@ where}).unwrap_or_default();let mut connector_event = ConnectorEvent::new(+ state.tenant.tenant_id.clone(),req.connector.clone(),std::any::type_name::<T>(),masked_request_body,@@ -851,6 +852,7 @@ where};let api_event = ApiEvent::new(+ tenant_id,Some(merchant_id.clone()),flow,&request_id,