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:
Sandeep Kumar
2024-09-03 15:53:04 +05:30
committed by GitHub
parent 98cfc13f53
commit 8ed942c6cd
63 changed files with 2884 additions and 1531 deletions

View File

@ -7,6 +7,7 @@ use api_models::analytics::{
use time::PrimitiveDateTime;
use crate::{
enums::AuthInfo,
query::{Aggregate, GroupByClause, ToSql, Window},
types::{AnalyticsCollection, AnalyticsDataSource, LoadRow, MetricsResult},
};
@ -43,7 +44,7 @@ where
async fn load_metrics(
&self,
dimensions: &[ApiEventDimensions],
merchant_id: &common_utils::id_type::MerchantId,
auth: &AuthInfo,
filters: &ApiEventFilters,
granularity: &Option<Granularity>,
time_range: &TimeRange,
@ -64,7 +65,7 @@ where
async fn load_metrics(
&self,
dimensions: &[ApiEventDimensions],
merchant_id: &common_utils::id_type::MerchantId,
auth: &AuthInfo,
filters: &ApiEventFilters,
granularity: &Option<Granularity>,
time_range: &TimeRange,
@ -73,38 +74,17 @@ where
match self {
Self::Latency => {
MaxLatency
.load_metrics(
dimensions,
merchant_id,
filters,
granularity,
time_range,
pool,
)
.load_metrics(dimensions, auth, filters, granularity, time_range, pool)
.await
}
Self::ApiCount => {
ApiCount
.load_metrics(
dimensions,
merchant_id,
filters,
granularity,
time_range,
pool,
)
.load_metrics(dimensions, auth, filters, granularity, time_range, pool)
.await
}
Self::StatusCodeCount => {
StatusCodeCount
.load_metrics(
dimensions,
merchant_id,
filters,
granularity,
time_range,
pool,
)
.load_metrics(dimensions, auth, filters, granularity, time_range, pool)
.await
}
}