mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +08:00 
			
		
		
		
	chore(analytics): adding dispute id to api log events (#3450)
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							d6807abba4
						
					
				
				
					commit
					937aea906e
				
			| @ -18,7 +18,8 @@ CREATE TABLE hyperswitch.api_events_queue on cluster '{cluster}' ( | |||||||
|     `created_at` DateTime CODEC(T64, LZ4), |     `created_at` DateTime CODEC(T64, LZ4), | ||||||
|     `latency` Nullable(UInt128), |     `latency` Nullable(UInt128), | ||||||
|     `user_agent` Nullable(String), |     `user_agent` Nullable(String), | ||||||
|     `ip_addr` Nullable(String) |     `ip_addr` Nullable(String), | ||||||
|  |     `dispute_id` Nullable(String) | ||||||
| ) ENGINE = Kafka SETTINGS kafka_broker_list = 'hyper-c1-kafka-brokers.kafka-cluster.svc.cluster.local:9092', | ) ENGINE = Kafka SETTINGS kafka_broker_list = 'hyper-c1-kafka-brokers.kafka-cluster.svc.cluster.local:9092', | ||||||
| kafka_topic_list = 'hyperswitch-api-log-events', | kafka_topic_list = 'hyperswitch-api-log-events', | ||||||
| kafka_group_name = 'hyper-c1', | kafka_group_name = 'hyper-c1', | ||||||
| @ -81,7 +82,8 @@ CREATE TABLE hyperswitch.api_events_dist on cluster '{cluster}' ( | |||||||
|     `created_at` DateTime64(3), |     `created_at` DateTime64(3), | ||||||
|     `latency` Nullable(UInt128), |     `latency` Nullable(UInt128), | ||||||
|     `user_agent` Nullable(String), |     `user_agent` Nullable(String), | ||||||
|     `ip_addr` Nullable(String) |     `ip_addr` Nullable(String), | ||||||
|  |     `dispute_id` Nullable(String) | ||||||
| ) ENGINE = Distributed('{cluster}', 'hyperswitch', 'api_events_clustered', rand()); | ) ENGINE = Distributed('{cluster}', 'hyperswitch', 'api_events_clustered', rand()); | ||||||
|  |  | ||||||
| CREATE MATERIALIZED VIEW hyperswitch.api_events_mv on cluster '{cluster}' TO hyperswitch.api_events_dist ( | CREATE MATERIALIZED VIEW hyperswitch.api_events_mv on cluster '{cluster}' TO hyperswitch.api_events_dist ( | ||||||
| @ -105,7 +107,8 @@ CREATE MATERIALIZED VIEW hyperswitch.api_events_mv on cluster '{cluster}' TO hyp | |||||||
|     `created_at` DateTime64(3), |     `created_at` DateTime64(3), | ||||||
|     `latency` Nullable(UInt128), |     `latency` Nullable(UInt128), | ||||||
|     `user_agent` Nullable(String), |     `user_agent` Nullable(String), | ||||||
|     `ip_addr` Nullable(String) |     `ip_addr` Nullable(String), | ||||||
|  |     `dispute_id` Nullable(String) | ||||||
| ) AS | ) AS | ||||||
| SELECT | SELECT | ||||||
|     merchant_id, |     merchant_id, | ||||||
| @ -158,7 +161,7 @@ WHERE length(_error) > 0 | |||||||
|  |  | ||||||
| ALTER TABLE hyperswitch.api_events_clustered on cluster '{cluster}' ADD COLUMN `url_path` LowCardinality(Nullable(String)); | ALTER TABLE hyperswitch.api_events_clustered on cluster '{cluster}' ADD COLUMN `url_path` LowCardinality(Nullable(String)); | ||||||
| ALTER TABLE hyperswitch.api_events_clustered on cluster '{cluster}' ADD COLUMN `event_type` LowCardinality(Nullable(String)); | ALTER TABLE hyperswitch.api_events_clustered on cluster '{cluster}' ADD COLUMN `event_type` LowCardinality(Nullable(String)); | ||||||
|  | ALTER TABLE hyperswitch.api_events_clustered on cluster '{cluster}' ADD COLUMN `dispute_id` Nullable(String); | ||||||
|  |  | ||||||
| CREATE TABLE hyperswitch.api_audit_log ON CLUSTER '{cluster}' ( | CREATE TABLE hyperswitch.api_audit_log ON CLUSTER '{cluster}' ( | ||||||
|     `merchant_id` LowCardinality(String), |     `merchant_id` LowCardinality(String), | ||||||
| @ -209,7 +212,8 @@ CREATE MATERIALIZED VIEW hyperswitch.api_audit_log_mv ON CLUSTER `{cluster}` TO | |||||||
|     `created_at` DateTime64(3), |     `created_at` DateTime64(3), | ||||||
|     `latency` Nullable(UInt128), |     `latency` Nullable(UInt128), | ||||||
|     `user_agent` Nullable(String), |     `user_agent` Nullable(String), | ||||||
|     `ip_addr` Nullable(String) |     `ip_addr` Nullable(String), | ||||||
|  |     `dispute_id` Nullable(String) | ||||||
| ) AS  | ) AS  | ||||||
| SELECT  | SELECT  | ||||||
|     merchant_id, |     merchant_id, | ||||||
| @ -232,6 +236,7 @@ SELECT | |||||||
|     created_at, |     created_at, | ||||||
|     latency, |     latency, | ||||||
|     user_agent, |     user_agent, | ||||||
|     ip_addr |     ip_addr, | ||||||
|  |     dispute_id | ||||||
| FROM hyperswitch.api_events_queue | FROM hyperswitch.api_events_queue | ||||||
| WHERE length(_error) = 0 | WHERE length(_error) = 0 | ||||||
| @ -23,7 +23,8 @@ CREATE TABLE api_events_queue ( | |||||||
|     `ip_addr` String, |     `ip_addr` String, | ||||||
|     `hs_latency` Nullable(UInt128), |     `hs_latency` Nullable(UInt128), | ||||||
|     `http_method` LowCardinality(String), |     `http_method` LowCardinality(String), | ||||||
|     `url_path` String |     `url_path` String, | ||||||
|  |     `dispute_id` Nullable(String) | ||||||
| ) ENGINE = Kafka SETTINGS kafka_broker_list = 'kafka0:29092', | ) ENGINE = Kafka SETTINGS kafka_broker_list = 'kafka0:29092', | ||||||
| kafka_topic_list = 'hyperswitch-api-log-events', | kafka_topic_list = 'hyperswitch-api-log-events', | ||||||
| kafka_group_name = 'hyper-c1', | kafka_group_name = 'hyper-c1', | ||||||
| @ -57,6 +58,7 @@ CREATE TABLE api_events_dist ( | |||||||
|     `hs_latency` Nullable(UInt128), |     `hs_latency` Nullable(UInt128), | ||||||
|     `http_method` LowCardinality(String), |     `http_method` LowCardinality(String), | ||||||
|     `url_path` String, |     `url_path` String, | ||||||
|  |     `dispute_id` Nullable(String) | ||||||
|     INDEX flowIndex flow_type TYPE bloom_filter GRANULARITY 1, |     INDEX flowIndex flow_type TYPE bloom_filter GRANULARITY 1, | ||||||
|     INDEX apiIndex api_flow TYPE bloom_filter GRANULARITY 1, |     INDEX apiIndex api_flow TYPE bloom_filter GRANULARITY 1, | ||||||
|     INDEX statusIndex status_code TYPE bloom_filter GRANULARITY 1 |     INDEX statusIndex status_code TYPE bloom_filter GRANULARITY 1 | ||||||
| @ -92,7 +94,8 @@ CREATE MATERIALIZED VIEW api_events_mv TO api_events_dist ( | |||||||
|     `ip_addr` String, |     `ip_addr` String, | ||||||
|     `hs_latency` Nullable(UInt128), |     `hs_latency` Nullable(UInt128), | ||||||
|     `http_method` LowCardinality(String), |     `http_method` LowCardinality(String), | ||||||
|     `url_path` String |     `url_path` String, | ||||||
|  |     `dispute_id` Nullable(String) | ||||||
| ) AS | ) AS | ||||||
| SELECT | SELECT | ||||||
|     merchant_id, |     merchant_id, | ||||||
| @ -120,7 +123,8 @@ SELECT | |||||||
|     ip_addr, |     ip_addr, | ||||||
|     hs_latency, |     hs_latency, | ||||||
|     http_method, |     http_method, | ||||||
|     url_path |     url_path, | ||||||
|  |     dispute_id | ||||||
| FROM | FROM | ||||||
|     api_events_queue |     api_events_queue | ||||||
| where length(_error) = 0; | where length(_error) = 0; | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| pub mod connector_onboarding; | pub mod connector_onboarding; | ||||||
| pub mod customer; | pub mod customer; | ||||||
|  | pub mod dispute; | ||||||
| pub mod gsm; | pub mod gsm; | ||||||
| mod locker_migration; | mod locker_migration; | ||||||
| pub mod payment; | pub mod payment; | ||||||
| @ -44,8 +45,6 @@ impl_misc_api_event_type!( | |||||||
|     RetrievePaymentLinkResponse, |     RetrievePaymentLinkResponse, | ||||||
|     MandateListConstraints, |     MandateListConstraints, | ||||||
|     CreateFileResponse, |     CreateFileResponse, | ||||||
|     DisputeResponse, |  | ||||||
|     SubmitEvidenceRequest, |  | ||||||
|     MerchantConnectorResponse, |     MerchantConnectorResponse, | ||||||
|     MerchantConnectorId, |     MerchantConnectorId, | ||||||
|     MandateResponse, |     MandateResponse, | ||||||
|  | |||||||
							
								
								
									
										25
									
								
								crates/api_models/src/events/dispute.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								crates/api_models/src/events/dispute.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | |||||||
|  | use common_utils::events::{ApiEventMetric, ApiEventsType}; | ||||||
|  |  | ||||||
|  | use super::{DisputeResponse, DisputeResponsePaymentsRetrieve, SubmitEvidenceRequest}; | ||||||
|  |  | ||||||
|  | impl ApiEventMetric for SubmitEvidenceRequest { | ||||||
|  |     fn get_api_event_type(&self) -> Option<ApiEventsType> { | ||||||
|  |         Some(ApiEventsType::Dispute { | ||||||
|  |             dispute_id: self.dispute_id.clone(), | ||||||
|  |         }) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | impl ApiEventMetric for DisputeResponsePaymentsRetrieve { | ||||||
|  |     fn get_api_event_type(&self) -> Option<ApiEventsType> { | ||||||
|  |         Some(ApiEventsType::Dispute { | ||||||
|  |             dispute_id: self.dispute_id.clone(), | ||||||
|  |         }) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | impl ApiEventMetric for DisputeResponse { | ||||||
|  |     fn get_api_event_type(&self) -> Option<ApiEventsType> { | ||||||
|  |         Some(ApiEventsType::Dispute { | ||||||
|  |             dispute_id: self.dispute_id.clone(), | ||||||
|  |         }) | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -50,6 +50,9 @@ pub enum ApiEventsType { | |||||||
|     RustLocker, |     RustLocker, | ||||||
|     FraudCheck, |     FraudCheck, | ||||||
|     Recon, |     Recon, | ||||||
|  |     Dispute { | ||||||
|  |         dispute_id: String, | ||||||
|  |     }, | ||||||
| } | } | ||||||
|  |  | ||||||
| impl ApiEventMetric for serde_json::Value {} | impl ApiEventMetric for serde_json::Value {} | ||||||
|  | |||||||
| @ -114,7 +114,6 @@ impl_misc_api_event_type!( | |||||||
|     CreateFileRequest, |     CreateFileRequest, | ||||||
|     FileId, |     FileId, | ||||||
|     AttachEvidenceRequest, |     AttachEvidenceRequest, | ||||||
|     DisputeId, |  | ||||||
|     PaymentLinkFormData, |     PaymentLinkFormData, | ||||||
|     ConfigUpdate |     ConfigUpdate | ||||||
| ); | ); | ||||||
| @ -142,3 +141,11 @@ impl ApiEventMetric for PaymentsRedirectResponseData { | |||||||
|         }) |         }) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | impl ApiEventMetric for DisputeId { | ||||||
|  |     fn get_api_event_type(&self) -> Option<ApiEventsType> { | ||||||
|  |         Some(ApiEventsType::Dispute { | ||||||
|  |             dispute_id: self.dispute_id.clone(), | ||||||
|  |         }) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user