mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(analytics): refactor and introduce analytics APIs to accommodate OrgLevel, MerchantLevel and ProfileLevel authentication (#5729)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Sampras Lopes <sampras.lopes@juspay.in>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct ConnectorEventsRequest {
|
||||
pub payment_id: String,
|
||||
pub payment_id: common_utils::id_type::PaymentId,
|
||||
pub refund_id: Option<String>,
|
||||
pub dispute_id: Option<String>,
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@ use std::{
|
||||
hash::{Hash, Hasher},
|
||||
};
|
||||
|
||||
use common_utils::id_type;
|
||||
|
||||
use super::{NameDescription, TimeRange};
|
||||
use crate::enums::{Currency, IntentStatus};
|
||||
|
||||
@ -12,6 +14,8 @@ pub struct PaymentIntentFilters {
|
||||
pub status: Vec<IntentStatus>,
|
||||
#[serde(default)]
|
||||
pub currency: Vec<Currency>,
|
||||
#[serde(default)]
|
||||
pub profile_id: Vec<id_type::ProfileId>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
@ -35,6 +39,7 @@ pub enum PaymentIntentDimensions {
|
||||
#[serde(rename = "status")]
|
||||
PaymentIntentStatus,
|
||||
Currency,
|
||||
ProfileId,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
@ -94,6 +99,7 @@ impl From<PaymentIntentDimensions> for NameDescription {
|
||||
pub struct PaymentIntentMetricsBucketIdentifier {
|
||||
pub status: Option<IntentStatus>,
|
||||
pub currency: Option<Currency>,
|
||||
pub profile_id: Option<String>,
|
||||
#[serde(rename = "time_range")]
|
||||
pub time_bucket: TimeRange,
|
||||
#[serde(rename = "time_bucket")]
|
||||
@ -106,11 +112,13 @@ impl PaymentIntentMetricsBucketIdentifier {
|
||||
pub fn new(
|
||||
status: Option<IntentStatus>,
|
||||
currency: Option<Currency>,
|
||||
profile_id: Option<String>,
|
||||
normalized_time_range: TimeRange,
|
||||
) -> Self {
|
||||
Self {
|
||||
status,
|
||||
currency,
|
||||
profile_id,
|
||||
time_bucket: normalized_time_range,
|
||||
start_time: normalized_time_range.start_time,
|
||||
}
|
||||
@ -121,6 +129,7 @@ impl Hash for PaymentIntentMetricsBucketIdentifier {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.status.map(|i| i.to_string()).hash(state);
|
||||
self.currency.hash(state);
|
||||
self.profile_id.hash(state);
|
||||
self.time_bucket.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@ use std::{
|
||||
hash::{Hash, Hasher},
|
||||
};
|
||||
|
||||
use common_utils::id_type;
|
||||
|
||||
use super::{NameDescription, TimeRange};
|
||||
use crate::enums::{
|
||||
AttemptStatus, AuthenticationType, Connector, Currency, PaymentMethod, PaymentMethodType,
|
||||
@ -26,6 +28,8 @@ pub struct PaymentFilters {
|
||||
pub client_source: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub client_version: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub profile_id: Vec<id_type::ProfileId>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
@ -59,6 +63,7 @@ pub enum PaymentDimensions {
|
||||
PaymentStatus,
|
||||
ClientSource,
|
||||
ClientVersion,
|
||||
ProfileId,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
@ -149,6 +154,7 @@ pub struct PaymentMetricsBucketIdentifier {
|
||||
pub payment_method_type: Option<String>,
|
||||
pub client_source: Option<String>,
|
||||
pub client_version: Option<String>,
|
||||
pub profile_id: Option<String>,
|
||||
#[serde(rename = "time_range")]
|
||||
pub time_bucket: TimeRange,
|
||||
// Coz FE sucks
|
||||
@ -168,6 +174,7 @@ impl PaymentMetricsBucketIdentifier {
|
||||
payment_method_type: Option<String>,
|
||||
client_source: Option<String>,
|
||||
client_version: Option<String>,
|
||||
profile_id: Option<String>,
|
||||
normalized_time_range: TimeRange,
|
||||
) -> Self {
|
||||
Self {
|
||||
@ -179,6 +186,7 @@ impl PaymentMetricsBucketIdentifier {
|
||||
payment_method_type,
|
||||
client_source,
|
||||
client_version,
|
||||
profile_id,
|
||||
time_bucket: normalized_time_range,
|
||||
start_time: normalized_time_range.start_time,
|
||||
}
|
||||
@ -195,6 +203,7 @@ impl Hash for PaymentMetricsBucketIdentifier {
|
||||
self.payment_method_type.hash(state);
|
||||
self.client_source.hash(state);
|
||||
self.client_version.hash(state);
|
||||
self.profile_id.hash(state);
|
||||
self.time_bucket.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@ use std::{
|
||||
hash::{Hash, Hasher},
|
||||
};
|
||||
|
||||
use common_utils::id_type;
|
||||
|
||||
use crate::{enums::Currency, refunds::RefundStatus};
|
||||
|
||||
#[derive(
|
||||
@ -39,6 +41,8 @@ pub struct RefundFilters {
|
||||
pub connector: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub refund_type: Vec<RefundType>,
|
||||
#[serde(default)]
|
||||
pub profile_id: Vec<id_type::ProfileId>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
@ -62,6 +66,7 @@ pub enum RefundDimensions {
|
||||
RefundStatus,
|
||||
Connector,
|
||||
RefundType,
|
||||
ProfileId,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
@ -117,6 +122,7 @@ pub struct RefundMetricsBucketIdentifier {
|
||||
pub connector: Option<String>,
|
||||
|
||||
pub refund_type: Option<String>,
|
||||
pub profile_id: Option<String>,
|
||||
#[serde(rename = "time_range")]
|
||||
pub time_bucket: TimeRange,
|
||||
#[serde(rename = "time_bucket")]
|
||||
@ -130,6 +136,7 @@ impl Hash for RefundMetricsBucketIdentifier {
|
||||
self.refund_status.hash(state);
|
||||
self.connector.hash(state);
|
||||
self.refund_type.hash(state);
|
||||
self.profile_id.hash(state);
|
||||
self.time_bucket.hash(state);
|
||||
}
|
||||
}
|
||||
@ -149,6 +156,7 @@ impl RefundMetricsBucketIdentifier {
|
||||
refund_status: Option<String>,
|
||||
connector: Option<String>,
|
||||
refund_type: Option<String>,
|
||||
profile_id: Option<String>,
|
||||
normalized_time_range: TimeRange,
|
||||
) -> Self {
|
||||
Self {
|
||||
@ -156,6 +164,7 @@ impl RefundMetricsBucketIdentifier {
|
||||
refund_status,
|
||||
connector,
|
||||
refund_type,
|
||||
profile_id,
|
||||
time_bucket: normalized_time_range,
|
||||
start_time: normalized_time_range.start_time,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user