mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +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:
@ -330,6 +330,30 @@ impl<'a> FromRow<'a, PgRow> for super::payments::metrics::PaymentMetricRow {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_network: Option<String> = row.try_get("card_network").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let merchant_id: Option<String> = row.try_get("merchant_id").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_last_4: Option<String> = row.try_get("card_last_4").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_issuer: Option<String> = row.try_get("card_issuer").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let error_reason: Option<String> = row.try_get("error_reason").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let first_attempt: Option<bool> = row.try_get("first_attempt").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let total: Option<bigdecimal::BigDecimal> = row.try_get("total").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
@ -355,6 +379,12 @@ impl<'a> FromRow<'a, PgRow> for super::payments::metrics::PaymentMetricRow {
|
||||
client_source,
|
||||
client_version,
|
||||
profile_id,
|
||||
card_network,
|
||||
merchant_id,
|
||||
card_last_4,
|
||||
card_issuer,
|
||||
error_reason,
|
||||
first_attempt,
|
||||
total,
|
||||
count,
|
||||
start_bucket,
|
||||
@ -407,6 +437,26 @@ impl<'a> FromRow<'a, PgRow> for super::payments::distribution::PaymentDistributi
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_network: Option<String> = row.try_get("card_network").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let merchant_id: Option<String> = row.try_get("merchant_id").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_last_4: Option<String> = row.try_get("card_last_4").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_issuer: Option<String> = row.try_get("card_issuer").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let error_reason: Option<String> = row.try_get("error_reason").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let total: Option<bigdecimal::BigDecimal> = row.try_get("total").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
@ -419,6 +469,10 @@ impl<'a> FromRow<'a, PgRow> for super::payments::distribution::PaymentDistributi
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let first_attempt: Option<bool> = row.try_get("first_attempt").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
// Removing millisecond precision to get accurate diffs against clickhouse
|
||||
let start_bucket: Option<PrimitiveDateTime> = row
|
||||
.try_get::<Option<PrimitiveDateTime>, _>("start_bucket")?
|
||||
@ -436,6 +490,12 @@ impl<'a> FromRow<'a, PgRow> for super::payments::distribution::PaymentDistributi
|
||||
client_source,
|
||||
client_version,
|
||||
profile_id,
|
||||
card_network,
|
||||
merchant_id,
|
||||
card_last_4,
|
||||
card_issuer,
|
||||
error_reason,
|
||||
first_attempt,
|
||||
total,
|
||||
count,
|
||||
error_message,
|
||||
@ -493,6 +553,22 @@ impl<'a> FromRow<'a, PgRow> for super::payments::filters::PaymentFilterRow {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let merchant_id: Option<String> = row.try_get("merchant_id").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_last_4: Option<String> = row.try_get("card_last_4").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_issuer: Option<String> = row.try_get("card_issuer").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let error_reason: Option<String> = row.try_get("error_reason").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
Ok(Self {
|
||||
currency,
|
||||
status,
|
||||
@ -504,6 +580,10 @@ impl<'a> FromRow<'a, PgRow> for super::payments::filters::PaymentFilterRow {
|
||||
client_version,
|
||||
profile_id,
|
||||
card_network,
|
||||
merchant_id,
|
||||
card_last_4,
|
||||
card_issuer,
|
||||
error_reason,
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -524,6 +604,45 @@ impl<'a> FromRow<'a, PgRow> for super::payment_intents::metrics::PaymentIntentMe
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let connector: Option<String> = row.try_get("connector").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let authentication_type: Option<DBEnumWrapper<AuthenticationType>> =
|
||||
row.try_get("authentication_type").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let payment_method: Option<String> =
|
||||
row.try_get("payment_method").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let payment_method_type: Option<String> =
|
||||
row.try_get("payment_method_type").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_network: Option<String> = row.try_get("card_network").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let merchant_id: Option<String> = row.try_get("merchant_id").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_last_4: Option<String> = row.try_get("card_last_4").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_issuer: Option<String> = row.try_get("card_issuer").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let error_reason: Option<String> = row.try_get("error_reason").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let total: Option<bigdecimal::BigDecimal> = row.try_get("total").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
@ -532,6 +651,10 @@ impl<'a> FromRow<'a, PgRow> for super::payment_intents::metrics::PaymentIntentMe
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let first_attempt: Option<i64> = row.try_get("first_attempt").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
// Removing millisecond precision to get accurate diffs against clickhouse
|
||||
let start_bucket: Option<PrimitiveDateTime> = row
|
||||
.try_get::<Option<PrimitiveDateTime>, _>("start_bucket")?
|
||||
@ -543,6 +666,16 @@ impl<'a> FromRow<'a, PgRow> for super::payment_intents::metrics::PaymentIntentMe
|
||||
status,
|
||||
currency,
|
||||
profile_id,
|
||||
connector,
|
||||
authentication_type,
|
||||
payment_method,
|
||||
payment_method_type,
|
||||
card_network,
|
||||
merchant_id,
|
||||
card_last_4,
|
||||
card_issuer,
|
||||
error_reason,
|
||||
first_attempt,
|
||||
total,
|
||||
count,
|
||||
start_bucket,
|
||||
@ -567,11 +700,58 @@ impl<'a> FromRow<'a, PgRow> for super::payment_intents::filters::PaymentIntentFi
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
|
||||
let connector: Option<String> = row.try_get("connector").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let authentication_type: Option<DBEnumWrapper<AuthenticationType>> =
|
||||
row.try_get("authentication_type").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let payment_method: Option<String> =
|
||||
row.try_get("payment_method").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let payment_method_type: Option<String> =
|
||||
row.try_get("payment_method_type").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_network: Option<String> = row.try_get("card_network").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let merchant_id: Option<String> = row.try_get("merchant_id").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_last_4: Option<String> = row.try_get("card_last_4").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let card_issuer: Option<String> = row.try_get("card_issuer").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let error_reason: Option<String> = row.try_get("error_reason").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
Ok(Self {
|
||||
status,
|
||||
currency,
|
||||
profile_id,
|
||||
connector,
|
||||
authentication_type,
|
||||
payment_method,
|
||||
payment_method_type,
|
||||
card_network,
|
||||
merchant_id,
|
||||
card_last_4,
|
||||
card_issuer,
|
||||
error_reason,
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -716,7 +896,11 @@ impl ToSql<SqlxClient> for AnalyticsCollection {
|
||||
fn to_sql(&self, _table_engine: &TableEngine) -> error_stack::Result<String, ParsingError> {
|
||||
match self {
|
||||
Self::Payment => Ok("payment_attempt".to_string()),
|
||||
Self::PaymentSessionized => Err(error_stack::report!(ParsingError::UnknownError)
|
||||
.attach_printable("PaymentSessionized table is not implemented for Sqlx"))?,
|
||||
Self::Refund => Ok("refund".to_string()),
|
||||
Self::RefundSessionized => Err(error_stack::report!(ParsingError::UnknownError)
|
||||
.attach_printable("RefundSessionized table is not implemented for Sqlx"))?,
|
||||
Self::SdkEvents => Err(error_stack::report!(ParsingError::UnknownError)
|
||||
.attach_printable("SdkEventsAudit table is not implemented for Sqlx"))?,
|
||||
Self::SdkEventsAnalytics => Err(error_stack::report!(ParsingError::UnknownError)
|
||||
@ -725,6 +909,10 @@ impl ToSql<SqlxClient> for AnalyticsCollection {
|
||||
.attach_printable("ApiEvents table is not implemented for Sqlx"))?,
|
||||
Self::FraudCheck => Ok("fraud_check".to_string()),
|
||||
Self::PaymentIntent => Ok("payment_intent".to_string()),
|
||||
Self::PaymentIntentSessionized => Err(error_stack::report!(
|
||||
ParsingError::UnknownError
|
||||
)
|
||||
.attach_printable("PaymentIntentSessionized table is not implemented for Sqlx"))?,
|
||||
Self::ConnectorEvents => Err(error_stack::report!(ParsingError::UnknownError)
|
||||
.attach_printable("ConnectorEvents table is not implemented for Sqlx"))?,
|
||||
Self::ApiEventsAnalytics => Err(error_stack::report!(ParsingError::UnknownError)
|
||||
|
||||
Reference in New Issue
Block a user