feat(analytics): added client columns in payments analytics (#4658)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Vrishab Srivatsa
2024-05-23 15:28:17 +05:30
committed by GitHub
parent ee276ec2d5
commit 0b415dcca6
18 changed files with 96 additions and 0 deletions

View File

@ -22,6 +22,10 @@ pub struct PaymentFilters {
pub payment_method: Vec<PaymentMethod>,
#[serde(default)]
pub payment_method_type: Vec<PaymentMethodType>,
#[serde(default)]
pub client_source: Vec<String>,
#[serde(default)]
pub client_version: Vec<String>,
}
#[derive(
@ -53,6 +57,8 @@ pub enum PaymentDimensions {
#[strum(serialize = "status")]
#[serde(rename = "status")]
PaymentStatus,
ClientSource,
ClientVersion,
}
#[derive(
@ -141,6 +147,8 @@ pub struct PaymentMetricsBucketIdentifier {
pub auth_type: Option<AuthenticationType>,
pub payment_method: Option<String>,
pub payment_method_type: Option<String>,
pub client_source: Option<String>,
pub client_version: Option<String>,
#[serde(rename = "time_range")]
pub time_bucket: TimeRange,
// Coz FE sucks
@ -150,6 +158,7 @@ pub struct PaymentMetricsBucketIdentifier {
}
impl PaymentMetricsBucketIdentifier {
#[allow(clippy::too_many_arguments)]
pub fn new(
currency: Option<Currency>,
status: Option<AttemptStatus>,
@ -157,6 +166,8 @@ impl PaymentMetricsBucketIdentifier {
auth_type: Option<AuthenticationType>,
payment_method: Option<String>,
payment_method_type: Option<String>,
client_source: Option<String>,
client_version: Option<String>,
normalized_time_range: TimeRange,
) -> Self {
Self {
@ -166,6 +177,8 @@ impl PaymentMetricsBucketIdentifier {
auth_type,
payment_method,
payment_method_type,
client_source,
client_version,
time_bucket: normalized_time_range,
start_time: normalized_time_range.start_time,
}
@ -180,6 +193,8 @@ impl Hash for PaymentMetricsBucketIdentifier {
self.auth_type.map(|i| i.to_string()).hash(state);
self.payment_method.hash(state);
self.payment_method_type.hash(state);
self.client_source.hash(state);
self.client_version.hash(state);
self.time_bucket.hash(state);
}
}