From db65e3639884ea599fc6c22413a4f320171ce88f Mon Sep 17 00:00:00 2001 From: Sagar Naik Date: Tue, 28 Nov 2023 13:51:24 +0530 Subject: [PATCH 1/3] added smart retries and count --- .../HyperSwitch/Analytics/AnalyticsTypes.res | 4 ++ .../PaymentsAnalytics/PaymentAnalytics.res | 11 +-- .../PaymentAnalyticsEntity.res | 67 ++++++++++++++++++- 3 files changed, 71 insertions(+), 11 deletions(-) diff --git a/src/screens/HyperSwitch/Analytics/AnalyticsTypes.res b/src/screens/HyperSwitch/Analytics/AnalyticsTypes.res index f76b0ca46..e82c96a03 100644 --- a/src/screens/HyperSwitch/Analytics/AnalyticsTypes.res +++ b/src/screens/HyperSwitch/Analytics/AnalyticsTypes.res @@ -155,6 +155,8 @@ type paymentsSingleState = { payment_success_rate: float, payment_count: int, payment_success_count: int, + retries_count: int, + retries_amount_processe: float, payment_processed_amount: float, payment_avg_ticket_size: float, } @@ -162,6 +164,8 @@ type paymentsSingleState = { type paymentsSingleStateSeries = { payment_success_rate: float, payment_count: int, + retries_count: int, + retries_amount_processe: float, payment_success_count: int, time_series: string, payment_processed_amount: float, diff --git a/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalytics.res b/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalytics.res index 1746560a4..ef8be373d 100644 --- a/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalytics.res +++ b/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalytics.res @@ -14,16 +14,7 @@ let make = () => { try { let infoUrl = getURL(~entityName=ANALYTICS_PAYMENTS, ~methodType=Get, ~id=Some(domain), ()) let infoDetails = await fetchDetails(infoUrl) - setMetrics(_ => - infoDetails - ->getDictFromJsonObject - ->getArrayFromDict("metrics", []) - ->Js.Array2.filter(item => { - let dict = item->LogicUtils.getDictFromJsonObject - dict->Js.Dict.get("name")->Belt.Option.getWithDefault(""->Js.Json.string) != - "retries_count"->Js.Json.string - }) - ) + setMetrics(_ => infoDetails->getDictFromJsonObject->getArrayFromDict("metrics", [])) setDimensions(_ => infoDetails->getDictFromJsonObject->getArrayFromDict("dimensions", [])) setScreenState(_ => PageLoaderWrapper.Success) } catch { diff --git a/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res b/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res index 75f3ec6c6..0529e64ec 100644 --- a/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res +++ b/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res @@ -225,6 +225,8 @@ let paymentTableEntity = EntityType.makeEntity( let singleStateInitialValue = { payment_success_rate: 0.0, payment_count: 0, + retries_count: 0, + retries_amount_processe: 0.0, payment_success_count: 0, payment_processed_amount: 0.0, payment_avg_ticket_size: 0.0, @@ -233,6 +235,8 @@ let singleStateInitialValue = { let singleStateSeriesInitialValue = { payment_success_rate: 0.0, payment_count: 0, + retries_count: 0, + retries_amount_processe: 0.0, payment_success_count: 0, time_series: "", payment_processed_amount: 0.0, @@ -249,6 +253,8 @@ let singleStateItemToObjMapper = json => { payment_success_count: dict->getInt("payment_success_count", 0), payment_processed_amount: dict->getFloat("payment_processed_amount", 0.0), payment_avg_ticket_size: dict->getFloat("avg_ticket_size", 0.0), + retries_count: dict->getInt("retries_count", 0), + retries_amount_processe: dict->getFloat("retries_amount_processed", 0.0), }) ->Belt.Option.getWithDefault({ singleStateInitialValue @@ -266,6 +272,8 @@ let singleStateSeriesItemToObjMapper = json => { time_series: dict->getString("time_bucket", ""), payment_processed_amount: dict->getFloat("payment_processed_amount", 0.0)->setPrecision(), payment_avg_ticket_size: dict->getFloat("avg_ticket_size", 0.0)->setPrecision(), + retries_count: dict->getInt("retries_count", 0), + retries_amount_processe: dict->getFloat("retries_amount_processed", 0.0), }) ->getWithDefault({ singleStateSeriesInitialValue @@ -289,11 +297,21 @@ type colT = | SuccessCount | ProcessedAmount | AvgTicketSize + | RetriesCount + | RetriesAmountProcessed let defaultColumns: array> = [ { sectionName: "", - columns: [SuccessRate, Count, SuccessCount, ProcessedAmount, AvgTicketSize], + columns: [ + SuccessRate, + Count, + SuccessCount, + ProcessedAmount, + AvgTicketSize, + RetriesCount, + RetriesAmountProcessed, + ], }, ] @@ -346,6 +364,18 @@ let constructData = ( ob.payment_avg_ticket_size /. 100.00, )) ->Js.Array2.sortInPlaceWith(compareLogic) + | "retries_count" => + singlestatTimeseriesData->Js.Array2.map(ob => ( + ob.time_series->DateTimeUtils.parseAsFloat, + ob.retries_count->Belt.Int.toFloat, + )) + | "retries_amount_processed" => + singlestatTimeseriesData + ->Js.Array2.map(ob => ( + ob.time_series->DateTimeUtils.parseAsFloat, + ob.retries_amount_processe /. 100.00, + )) + ->Js.Array2.sortInPlaceWith(compareLogic) | _ => [] } } @@ -448,6 +478,41 @@ let getStatData = ( statType: "Volume", showDelta: false, } + | RetriesCount => { + title: "Smart Retries made", + tooltipText: "Total number of retries that were attempted after a failed payment attempt", + deltaTooltipComponent: AnalyticsUtils.singlestatDeltaTooltipFormat( + singleStatData.retries_count->Belt.Int.toFloat, + deltaTimestampData.currentSr, + ), + value: singleStatData.retries_count->Belt.Int.toFloat, + delta: { + singleStatData.retries_count->Belt.Int.toFloat + }, + data: constructData("retries_count", timeSeriesData), + statType: "Volume", + showDelta: false, + } + | RetriesAmountProcessed => { + title: `Smart retries savings`, + tooltipText: "Total number of retries that were attempted after a failed payment attempt", + deltaTooltipComponent: AnalyticsUtils.singlestatDeltaTooltipFormat( + singleStatData.retries_amount_processe /. 100.00, + deltaTimestampData.currentSr, + ), + value: singleStatData.retries_amount_processe /. 100.00, + delta: { + Js.Float.fromString( + Js.Float.toFixedWithPrecision( + singleStatData.retries_amount_processe /. 100.00, + ~digits=2, + ), + ) + }, + data: constructData("retries_amount_processe", timeSeriesData), + statType: "Amount", + showDelta: false, + } } } From dfc382ba329cc154f7ad1c103ffea12534450933 Mon Sep 17 00:00:00 2001 From: Sagar Naik Date: Tue, 28 Nov 2023 14:03:41 +0530 Subject: [PATCH 2/3] added connector successrate --- .../HyperSwitch/Analytics/AnalyticsTypes.res | 2 ++ .../PaymentAnalyticsEntity.res | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/screens/HyperSwitch/Analytics/AnalyticsTypes.res b/src/screens/HyperSwitch/Analytics/AnalyticsTypes.res index e82c96a03..6fb6a0403 100644 --- a/src/screens/HyperSwitch/Analytics/AnalyticsTypes.res +++ b/src/screens/HyperSwitch/Analytics/AnalyticsTypes.res @@ -157,6 +157,7 @@ type paymentsSingleState = { payment_success_count: int, retries_count: int, retries_amount_processe: float, + connector_success_rate: float, payment_processed_amount: float, payment_avg_ticket_size: float, } @@ -166,6 +167,7 @@ type paymentsSingleStateSeries = { payment_count: int, retries_count: int, retries_amount_processe: float, + connector_success_rate: float, payment_success_count: int, time_series: string, payment_processed_amount: float, diff --git a/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res b/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res index 0529e64ec..c988184c3 100644 --- a/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res +++ b/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res @@ -228,6 +228,7 @@ let singleStateInitialValue = { retries_count: 0, retries_amount_processe: 0.0, payment_success_count: 0, + connector_success_rate: 0.0, payment_processed_amount: 0.0, payment_avg_ticket_size: 0.0, } @@ -240,6 +241,7 @@ let singleStateSeriesInitialValue = { payment_success_count: 0, time_series: "", payment_processed_amount: 0.0, + connector_success_rate: 0.0, payment_avg_ticket_size: 0.0, } @@ -255,6 +257,7 @@ let singleStateItemToObjMapper = json => { payment_avg_ticket_size: dict->getFloat("avg_ticket_size", 0.0), retries_count: dict->getInt("retries_count", 0), retries_amount_processe: dict->getFloat("retries_amount_processed", 0.0), + connector_success_rate: dict->getFloat("connector_success_rate", 0.0), }) ->Belt.Option.getWithDefault({ singleStateInitialValue @@ -274,6 +277,7 @@ let singleStateSeriesItemToObjMapper = json => { payment_avg_ticket_size: dict->getFloat("avg_ticket_size", 0.0)->setPrecision(), retries_count: dict->getInt("retries_count", 0), retries_amount_processe: dict->getFloat("retries_amount_processed", 0.0), + connector_success_rate: dict->getFloat("connector_success_rate", 0.0), }) ->getWithDefault({ singleStateSeriesInitialValue @@ -299,6 +303,7 @@ type colT = | AvgTicketSize | RetriesCount | RetriesAmountProcessed + | ConnectorSuccessRate let defaultColumns: array> = [ { @@ -311,6 +316,7 @@ let defaultColumns: array> = [ AvgTicketSize, RetriesCount, RetriesAmountProcessed, + ConnectorSuccessRate, ], }, ] @@ -376,6 +382,10 @@ let constructData = ( ob.retries_amount_processe /. 100.00, )) ->Js.Array2.sortInPlaceWith(compareLogic) + | "connector_success_rate" => + singlestatTimeseriesData + ->Js.Array2.map(ob => (ob.time_series->DateTimeUtils.parseAsFloat, ob.connector_success_rate)) + ->Js.Array2.sortInPlaceWith(compareLogic) | _ => [] } } @@ -513,6 +523,21 @@ let getStatData = ( statType: "Amount", showDelta: false, } + | ConnectorSuccessRate => { + title: "Payment success rate", + tooltipText: "Total successful payments processed out of all user confirmed payments", + deltaTooltipComponent: AnalyticsUtils.singlestatDeltaTooltipFormat( + singleStatData.connector_success_rate, + deltaTimestampData.currentSr, + ), + value: singleStatData.connector_success_rate, + delta: { + singleStatData.connector_success_rate + }, + data: constructData("connector_success_rate", timeSeriesData), + statType: "Rate", + showDelta: false, + } } } From a3c6c3e4d69c5f70a6ef3b91c37996b4c127dbc3 Mon Sep 17 00:00:00 2001 From: Sagar Naik Date: Tue, 28 Nov 2023 15:34:21 +0530 Subject: [PATCH 3/3] description modification --- .../Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res b/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res index c988184c3..2bc68686f 100644 --- a/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res +++ b/src/screens/HyperSwitch/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res @@ -505,7 +505,7 @@ let getStatData = ( } | RetriesAmountProcessed => { title: `Smart retries savings`, - tooltipText: "Total number of retries that were attempted after a failed payment attempt", + tooltipText: "Total savings in amount terms from retrying failed payments again through a second processor", deltaTooltipComponent: AnalyticsUtils.singlestatDeltaTooltipFormat( singleStatData.retries_amount_processe /. 100.00, deltaTimestampData.currentSr,