mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
feat(analytics): Add metrics, filters and APIs for Analytics v2 Dashboard - Payments Page (#5870)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Sampras Lopes <Sampras.lopes@juspay.in> Co-authored-by: Sampras Lopes <lsampras@pm.me>
This commit is contained in:
@ -33,6 +33,14 @@ pub struct PaymentFilters {
|
||||
pub card_network: Vec<CardNetwork>,
|
||||
#[serde(default)]
|
||||
pub profile_id: Vec<id_type::ProfileId>,
|
||||
#[serde(default)]
|
||||
pub merchant_id: Vec<id_type::MerchantId>,
|
||||
#[serde(default)]
|
||||
pub card_last_4: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub card_issuer: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub error_reason: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
@ -68,6 +76,12 @@ pub enum PaymentDimensions {
|
||||
ClientVersion,
|
||||
ProfileId,
|
||||
CardNetwork,
|
||||
MerchantId,
|
||||
#[strum(serialize = "card_last_4")]
|
||||
#[serde(rename = "card_last_4")]
|
||||
CardLast4,
|
||||
CardIssuer,
|
||||
ErrorReason,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
@ -92,6 +106,15 @@ pub enum PaymentMetrics {
|
||||
AvgTicketSize,
|
||||
RetriesCount,
|
||||
ConnectorSuccessRate,
|
||||
SessionizedPaymentSuccessRate,
|
||||
SessionizedPaymentCount,
|
||||
SessionizedPaymentSuccessCount,
|
||||
SessionizedPaymentProcessedAmount,
|
||||
SessionizedAvgTicketSize,
|
||||
SessionizedRetriesCount,
|
||||
SessionizedConnectorSuccessRate,
|
||||
PaymentsDistribution,
|
||||
FailureReasons,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, serde::Serialize)]
|
||||
@ -159,6 +182,11 @@ pub struct PaymentMetricsBucketIdentifier {
|
||||
pub client_source: Option<String>,
|
||||
pub client_version: Option<String>,
|
||||
pub profile_id: Option<String>,
|
||||
pub card_network: Option<String>,
|
||||
pub merchant_id: Option<String>,
|
||||
pub card_last_4: Option<String>,
|
||||
pub card_issuer: Option<String>,
|
||||
pub error_reason: Option<String>,
|
||||
#[serde(rename = "time_range")]
|
||||
pub time_bucket: TimeRange,
|
||||
// Coz FE sucks
|
||||
@ -179,6 +207,11 @@ impl PaymentMetricsBucketIdentifier {
|
||||
client_source: Option<String>,
|
||||
client_version: Option<String>,
|
||||
profile_id: Option<String>,
|
||||
card_network: Option<String>,
|
||||
merchant_id: Option<String>,
|
||||
card_last_4: Option<String>,
|
||||
card_issuer: Option<String>,
|
||||
error_reason: Option<String>,
|
||||
normalized_time_range: TimeRange,
|
||||
) -> Self {
|
||||
Self {
|
||||
@ -191,6 +224,11 @@ impl PaymentMetricsBucketIdentifier {
|
||||
client_source,
|
||||
client_version,
|
||||
profile_id,
|
||||
card_network,
|
||||
merchant_id,
|
||||
card_last_4,
|
||||
card_issuer,
|
||||
error_reason,
|
||||
time_bucket: normalized_time_range,
|
||||
start_time: normalized_time_range.start_time,
|
||||
}
|
||||
@ -208,6 +246,11 @@ impl Hash for PaymentMetricsBucketIdentifier {
|
||||
self.client_source.hash(state);
|
||||
self.client_version.hash(state);
|
||||
self.profile_id.hash(state);
|
||||
self.card_network.hash(state);
|
||||
self.merchant_id.hash(state);
|
||||
self.card_last_4.hash(state);
|
||||
self.card_issuer.hash(state);
|
||||
self.error_reason.hash(state);
|
||||
self.time_bucket.hash(state);
|
||||
}
|
||||
}
|
||||
@ -228,11 +271,20 @@ pub struct PaymentMetricsBucketValue {
|
||||
pub payment_count: Option<u64>,
|
||||
pub payment_success_count: Option<u64>,
|
||||
pub payment_processed_amount: Option<u64>,
|
||||
pub payment_processed_count: Option<u64>,
|
||||
pub payment_processed_amount_without_smart_retries: Option<u64>,
|
||||
pub payment_processed_count_without_smart_retries: Option<u64>,
|
||||
pub avg_ticket_size: Option<f64>,
|
||||
pub payment_error_message: Option<Vec<ErrorResult>>,
|
||||
pub retries_count: Option<u64>,
|
||||
pub retries_amount_processed: Option<u64>,
|
||||
pub connector_success_rate: Option<f64>,
|
||||
pub payments_success_rate_distribution: Option<f64>,
|
||||
pub payments_success_rate_distribution_without_smart_retries: Option<f64>,
|
||||
pub payments_failure_rate_distribution: Option<f64>,
|
||||
pub payments_failure_rate_distribution_without_smart_retries: Option<f64>,
|
||||
pub failure_reason_count: Option<u64>,
|
||||
pub failure_reason_count_without_smart_retries: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
|
||||
Reference in New Issue
Block a user