From fc44a6a650cdbc001f40148662527909911437aa Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 00:26:30 +0000 Subject: [PATCH 1/3] chore(version): 2024.10.25.0 --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a02d3249d..4c030976f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [conven - - - +## 2024.10.25.0 + +### Bug Fixes + +- Auto retry bug ([#1639](https://github.com/juspay/hyperswitch-control-center/pull/1639)) ([`46f4de6`](https://github.com/juspay/hyperswitch-control-center/commit/46f4de64f0c68e587a62c876b56e94a5e25ec26d)) +- Merchant account credentials not shown in profile view ([#1626](https://github.com/juspay/hyperswitch-control-center/pull/1626)) ([`9108801`](https://github.com/juspay/hyperswitch-control-center/commit/9108801555d2e3e03908dbe33f4a52ce9c0503a3)) + +### Miscellaneous Tasks + +- TwoFa restriction after multiple failed attempts before login ([#1594](https://github.com/juspay/hyperswitch-control-center/pull/1594)) ([`9ff488b`](https://github.com/juspay/hyperswitch-control-center/commit/9ff488b8edc99af45fc8f77ab1f56e6cef34a838)) +- Add merchant specific config ([#1643](https://github.com/juspay/hyperswitch-control-center/pull/1643)) ([`aac4ada`](https://github.com/juspay/hyperswitch-control-center/commit/aac4adabf17e96ef7d02fe91048fca8b668030a8)) + +**Full Changelog:** [`2024.10.24.0...2024.10.25.0`](https://github.com/juspay/hyperswitch-control-center/compare/2024.10.24.0...2024.10.25.0) + +- - - + ## 2024.10.24.0 ### Testing From d910c1e649ac7ae78f5d7cf02a20769abb5e17eb Mon Sep 17 00:00:00 2001 From: Riddhiagrawal001 <50551695+Riddhiagrawal001@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:52:42 +0530 Subject: [PATCH 2/3] fix: changes to enable card-network (#1655) Co-authored-by: Pritish Budhiraja --- src/screens/Order/OrderUIUtils.res | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/screens/Order/OrderUIUtils.res b/src/screens/Order/OrderUIUtils.res index 721e36154..51bd76bb4 100644 --- a/src/screens/Order/OrderUIUtils.res +++ b/src/screens/Order/OrderUIUtils.res @@ -274,11 +274,7 @@ let initialFilters = (json, filtervalues) => { let connectorFilter = filtervalues->getArrayFromDict("connector", [])->getStrArrayFromJsonArray - // TODO: Remove the card-network delete once card-network issue is fixed - let filterDict = - json - ->getDictFromJsonObject - ->DictionaryUtils.deleteKeys(["card_network"]) + let filterDict = json->getDictFromJsonObject let filterArr = filterDict->itemToObjMapper let arr = filterDict->Dict.keysToArray From e166495d24fd6088423b4e9e8062d2524bd3202c Mon Sep 17 00:00:00 2001 From: Sagar naik Date: Mon, 28 Oct 2024 15:30:18 +0530 Subject: [PATCH 3/3] feat: Smart retry analytics (#1642) Co-authored-by: Jeeva Ramachandran Co-authored-by: Jeeva Ramachandran <120017870+JeevaRamu0104@users.noreply.github.com> --- .../NewAnalyticsContainerUtils.res | 6 ++- .../NewAnalytics/NewAnalyticsHelper.res | 41 ++++++++++++++ .../NewAnalytics/NewAnalyticsTypes.res | 4 ++ .../FailedPaymentsDistribution.res | 28 +++++++--- .../FailedPaymentsDistributionUtils.res | 23 +++++++- .../PaymentAnalytics/NewPaymentAnalytics.res | 1 + .../NewPaymentAnalyticsEntity.res | 8 +-- .../NewPaymentAnalyticsUtils.res | 17 ++++++ .../PaymentsLifeCycle/PaymentsLifeCycle.res | 19 ++++++- .../PaymentsLifeCycleUtils.res | 10 ++-- .../NewPaymentsOverviewSection.res | 31 ++++++++--- .../NewPaymentsOverviewSectionUtils.res | 14 +++++ .../PaymentsProcessed/PaymentsProcessed.res | 46 +++++++++++++--- .../PaymentsProcessedUtils.res | 53 ++++++++++++++++--- .../PaymentsSuccessRate.res | 44 ++++++++++++--- .../PaymentsSuccessRateUtils.res | 32 ++++++++--- .../SuccessfulPaymentsDistribution.res | 27 +++++++--- .../SuccessfulPaymentsDistributionUtils.res | 23 +++++++- 18 files changed, 372 insertions(+), 55 deletions(-) diff --git a/src/screens/NewAnalytics/NewAnalyticsContainerUtils.res b/src/screens/NewAnalytics/NewAnalyticsContainerUtils.res index 7754ccd11..ac5bc62c5 100644 --- a/src/screens/NewAnalytics/NewAnalyticsContainerUtils.res +++ b/src/screens/NewAnalytics/NewAnalyticsContainerUtils.res @@ -18,7 +18,11 @@ let getPageFromIndex = index => { } } -let (startTimeFilterKey, endTimeFilterKey) = ("startTime", "endTime") +let (startTimeFilterKey, endTimeFilterKey, smartRetryKey) = ( + "startTime", + "endTime", + "is_smart_retry_enabled", +) let initialFixedFilterFields = () => { let newArr = [ diff --git a/src/screens/NewAnalytics/NewAnalyticsHelper.res b/src/screens/NewAnalytics/NewAnalyticsHelper.res index 3b49aab76..beb38ca06 100644 --- a/src/screens/NewAnalytics/NewAnalyticsHelper.res +++ b/src/screens/NewAnalytics/NewAnalyticsHelper.res @@ -221,3 +221,44 @@ module GraphHeader = { } } + +module SmartRetryToggle = { + open LogicUtils + open NewAnalyticsContainerUtils + @react.component + let make = () => { + let {updateExistingKeys, filterValue, filterValueJson} = React.useContext( + FilterContext.filterContext, + ) + let (isEnabled, setIsEnabled) = React.useState(_ => false) + + React.useEffect(() => { + let value = filterValueJson->getString(smartRetryKey, "true")->getBoolFromString(true) + setIsEnabled(_ => value) + None + }, [filterValueJson]) + + let onClick = _ => { + let updatedValue = !isEnabled + let newValue = filterValue->Dict.copy + newValue->Dict.set(smartRetryKey, updatedValue->getStringFromBool) + newValue->updateExistingKeys + } + +
+ +

+ {"Include Payment Retries data: "->React.string} + + {"Your data will consist of all the payment retries that contributed to the success rate"->React.string} + +

+
+ } +} diff --git a/src/screens/NewAnalytics/NewAnalyticsTypes.res b/src/screens/NewAnalytics/NewAnalyticsTypes.res index f9dd5d78b..3f0a7e37b 100644 --- a/src/screens/NewAnalytics/NewAnalyticsTypes.res +++ b/src/screens/NewAnalytics/NewAnalyticsTypes.res @@ -59,3 +59,7 @@ type valueType = | Latency | LatencyMs | No_Type + +type metricType = + | Smart_Retry + | Default diff --git a/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistribution.res b/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistribution.res index f32698871..f1b4ad2b3 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistribution.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistribution.res @@ -3,17 +3,27 @@ open NewAnalyticsHelper open NewPaymentAnalyticsEntity open BarGraphTypes open FailedPaymentsDistributionUtils - +open NewPaymentAnalyticsUtils module TableModule = { @react.component let make = (~data, ~className="", ~selectedTab: string) => { + open LogicUtils + let (offset, setOffset) = React.useState(_ => 0) + let {filterValueJson} = React.useContext(FilterContext.filterContext) + let isSmartRetryEnabled = + filterValueJson + ->getString("is_smart_retry_enabled", "true") + ->getBoolFromString(true) + ->getSmartRetryMetricType let defaultSort: Table.sortedObject = { key: "", order: Table.INC, } let tableBorderClass = "border-2 border-solid border-jp-gray-940 border-collapse border-opacity-30 dark:border-jp-gray-dark_table_border_color dark:border-opacity-30" - let visibleColumns = visibleColumns->Array.concat([selectedTab->getColumn]) + + let defaultCol = isSmartRetryEnbldForFailedPmtDist(isSmartRetryEnabled) + let visibleColumns = [defaultCol]->Array.concat([selectedTab->getColumn]) let tableData = getTableData(data)
@@ -78,15 +88,21 @@ let make = ( let (groupBy, setGroupBy) = React.useState(_ => defaulGroupBy) let startTimeVal = filterValueJson->getString("startTime", "") let endTimeVal = filterValueJson->getString("endTime", "") + let isSmartRetryEnabled = + filterValueJson + ->getString("is_smart_retry_enabled", "true") + ->getBoolFromString(true) + ->getSmartRetryMetricType let getFailedPaymentsDistribution = async () => { try { setScreenState(_ => PageLoaderWrapper.Loading) let url = getURL( - ~entityName=ANALYTICS_PAYMENTS, + ~entityName=isSmartRetryEnabled->getEntityForSmartRetry, ~methodType=Post, ~id=Some((entity.domain: domain :> string)), ) + let metrics = isSmartRetryEnabled->getMetricsForSmartRetry let body = NewAnalyticsUtils.requestBody( ~dimensions=[], @@ -94,7 +110,7 @@ let make = ( ~endTime=endTimeVal, ~delta=entity.requestBodyConfig.delta, ~filters=entity.requestBodyConfig.filters, - ~metrics=entity.requestBodyConfig.metrics, + ~metrics, ~groupByNames=[groupBy.value]->Some, ~customFilter=entity.requestBodyConfig.customFilter, ~applyFilterFor=entity.requestBodyConfig.applyFilterFor, @@ -123,7 +139,7 @@ let make = ( getFailedPaymentsDistribution()->ignore } None - }, [startTimeVal, endTimeVal, groupBy.value]) + }, [startTimeVal, endTimeVal, groupBy.value, (isSmartRetryEnabled :> string)])
@@ -138,7 +154,7 @@ let make = ( entity={chartEntity} object={chartEntity.getObjects( ~data=failedPaymentsDistribution, - ~xKey=Payments_Failure_Rate_Distribution->getStringFromVariant, + ~xKey=Payments_Failure_Rate_Distribution->getKeyForModule(~isSmartRetryEnabled), ~yKey=groupBy.value, )} className="mr-3" diff --git a/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistributionUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistributionUtils.res index f4ea77dc4..65e44f132 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistributionUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/FailedPaymentsDistribution/FailedPaymentsDistributionUtils.res @@ -43,7 +43,6 @@ let failedPaymentsDistributionMapper = ( } open NewAnalyticsTypes -let visibleColumns = [Payments_Failure_Rate_Distribution] let tableItemToObjMapper: Dict.t => failedPaymentsDistributionObject = dict => { { @@ -153,3 +152,25 @@ let defaulGroupBy = { label: "Connector", value: Connector->getStringFromVariant, } + +let getKeyForModule = (field, ~isSmartRetryEnabled) => { + switch (field, isSmartRetryEnabled) { + | (Payments_Failure_Rate_Distribution, Smart_Retry) => Payments_Failure_Rate_Distribution + | (Payments_Failure_Rate_Distribution, Default) | _ => + Payments_Failure_Rate_Distribution_Without_Smart_Retries + }->getStringFromVariant +} + +let isSmartRetryEnbldForFailedPmtDist = isEnabled => { + switch isEnabled { + | Smart_Retry => Payments_Failure_Rate_Distribution + | Default => Payments_Failure_Rate_Distribution_Without_Smart_Retries + } +} + +let getMetricsForSmartRetry = isEnabled => { + switch isEnabled { + | Smart_Retry => [#payments_distribution] + | Default => [#sessionized_payments_distribution] + } +} diff --git a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalytics.res b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalytics.res index 792161264..c3db4f90b 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalytics.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/NewPaymentAnalytics.res @@ -3,6 +3,7 @@ let make = () => { open NewPaymentAnalyticsEntity
+ { } )->asTooltipPointFormatter } + +let getSmartRetryMetricType = isSmartRetryEnabled => { + open NewAnalyticsTypes + switch isSmartRetryEnabled { + | true => Smart_Retry + | false => Default + } +} + +let getEntityForSmartRetry = isEnabled => { + open NewAnalyticsTypes + open APIUtilsTypes + switch isEnabled { + | Smart_Retry => ANALYTICS_PAYMENTS + | Default => ANALYTICS_PAYMENTS_V2 + } +} diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycle.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycle.res index 688342bce..c23970de8 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycle.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycle.res @@ -22,6 +22,8 @@ let make = ( let {filterValueJson} = React.useContext(FilterContext.filterContext) let startTimeVal = filterValueJson->getString("startTime", "") let endTimeVal = filterValueJson->getString("endTime", "") + let isSmartRetryEnabled = filterValueJson->getString("is_smart_retry_enabled", "true") + let getPaymentLieCycleData = async () => { try { let url = getURL(~entityName=ANALYTICS_SANKEY, ~methodType=Post) @@ -61,6 +63,20 @@ let make = ( } None }, (startTimeVal, endTimeVal)) + + let mockDelay = async () => { + if data != JSON.Encode.null->PaymentsLifeCycleUtils.paymentLifeCycleResponseMapper { + setScreenState(_ => Loading) + await HyperSwitchUtils.delay(300) + setScreenState(_ => Success) + } + } + + React.useEffect(() => { + mockDelay()->ignore + None + }, [isSmartRetryEnabled]) +
@@ -68,7 +84,8 @@ let make = ( screenState customLoader={} customUI={}>
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res index 150bd8d15..02242fee4 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsLifeCycle/PaymentsLifeCycleUtils.res @@ -23,11 +23,15 @@ let paymentLifeCycleResponseMapper = (json: JSON.t) => { let paymentsLifeCycleMapper = ( ~data: paymentLifeCycle, - ~xKey as _, + ~xKey, ~yKey as _, ): SankeyGraphTypes.sankeyPayload => { - let success = data.normalSuccess + data.smartRetriedSuccess - let failure = data.normalFailure + data.smartRetriedFailure + let isSmartRetryEnabled = + xKey->getBoolFromString(true)->NewPaymentAnalyticsUtils.getSmartRetryMetricType + let success = + data.normalSuccess + (isSmartRetryEnabled === Smart_Retry ? data.smartRetriedSuccess : 0) + let failure = + data.normalFailure + (isSmartRetryEnabled === Smart_Retry ? data.smartRetriedFailure : 0) let refunded = data.refunded let pending = data.pending // Attempted Pending let cancelled = data.cancelled diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSection.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSection.res index cac25b000..4289043cd 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSection.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSection.res @@ -14,6 +14,11 @@ let make = (~entity: moduleEntity) => { let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading) let startTimeVal = filterValueJson->getString("startTime", "") let endTimeVal = filterValueJson->getString("endTime", "") + let metricType: metricType = + filterValueJson + ->getString("is_smart_retry_enabled", "true") + ->getBoolFromString(true) + ->NewPaymentAnalyticsUtils.getSmartRetryMetricType let getData = async () => { setScreenState(_ => PageLoaderWrapper.Loading) @@ -159,15 +164,29 @@ let make = (~entity: moduleEntity) => { None }, [startTimeVal, endTimeVal]) + let mockDelay = async () => { + if data != []->JSON.Encode.array { + setScreenState(_ => Loading) + await HyperSwitchUtils.delay(300) + setScreenState(_ => Success) + } + } + + React.useEffect(() => { + mockDelay()->ignore + None + }, [metricType]) + }> - // Need to modify
- + getKeyForModule(~metricType)} />
- - - - + getKeyForModule(~metricType)} /> + getKeyForModule(~metricType)} + /> + getKeyForModule(~metricType)} /> + getKeyForModule(~metricType)} />
diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionUtils.res index aac2e2b2d..b18a186dc 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsOverviewSection/NewPaymentsOverviewSectionUtils.res @@ -104,3 +104,17 @@ let getValueFromObj = (data, index, responseKey) => { ->getDictFromJsonObject ->getFloat(responseKey, 0.0) } + +let getKeyForModule = (field, ~metricType) => { + switch (field, metricType) { + | (Total_Smart_Retried_Amount, Smart_Retry) => Total_Smart_Retried_Amount + | (Total_Payment_Processed_Amount, Smart_Retry) => Total_Payment_Processed_Amount + | (Total_Success_Rate, Smart_Retry) => Total_Success_Rate + | (Total_Smart_Retried_Amount, Default) => Total_Smart_Retried_Amount_Without_Smart_Retries + | (Total_Success_Rate, Default) => Total_Success_Rate_Without_Smart_Retries + | (Total_Payment_Processed_Amount, Default) => + Total_Payment_Processed_Amount_Without_Smart_Retries + | (Refund_Processed_Amount, _) => Refund_Processed_Amount + | (Total_Dispute, _) | _ => Total_Dispute + } +} diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res index 99a5445f2..7feb7aecf 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessed.res @@ -3,9 +3,10 @@ open NewAnalyticsHelper open LineGraphTypes open NewPaymentAnalyticsEntity open PaymentsProcessedUtils - +open NewPaymentAnalyticsUtils module TableModule = { open LogicUtils + @react.component let make = (~data, ~className="") => { let (offset, setOffset) = React.useState(_ => 0) @@ -14,12 +15,21 @@ module TableModule = { order: Table.INC, } let tableBorderClass = "border-collapse border border-jp-gray-940 border-solid border-2 border-opacity-30 dark:border-jp-gray-dark_table_border_color dark:border-opacity-30" - + let {filterValueJson} = React.useContext(FilterContext.filterContext) let paymentsProcessed = switch data->getArrayFromJson([])->Array.get(0) { | Some(val) => val->getArrayDataFromJson(tableItemToObjMapper) | _ => [] }->Array.map(Nullable.make) + let isSmartRetryEnabled = + filterValueJson + ->getString("is_smart_retry_enabled", "true") + ->getBoolFromString(true) + ->getSmartRetryMetricType + + let defaultCols = isSmartRetryEnabled->isSmartRetryEnbldForPmtProcessed + let visibleColumns = defaultCols->Array.concat(visibleColumns) +
{ + let {filterValueJson} = React.useContext(FilterContext.filterContext) + let isSmartRetryEnabled = + filterValueJson + ->getString("is_smart_retry_enabled", "true") + ->getBoolFromString(true) + ->getSmartRetryMetricType let primaryValue = getMetaDataValue( ~data, ~index=0, - ~key=selectedMetric.value->getMetaDataMapper, + ~key=selectedMetric.value->getMetaDataMapper(~isSmartRetryEnabled), ) let secondaryValue = getMetaDataValue( ~data, ~index=1, - ~key=selectedMetric.value->getMetaDataMapper, + ~key=selectedMetric.value->getMetaDataMapper(~isSmartRetryEnabled), ) let (value, direction) = calculatePercentageChange(~primaryValue, ~secondaryValue) @@ -127,6 +143,11 @@ let make = ( let (viewType, setViewType) = React.useState(_ => Graph) let startTimeVal = filterValueJson->getString("startTime", "") let endTimeVal = filterValueJson->getString("endTime", "") + let isSmartRetryEnabled = + filterValueJson + ->getString("is_smart_retry_enabled", "true") + ->getBoolFromString(true) + ->getSmartRetryMetricType let getPaymentsProcessed = async () => { setScreenState(_ => PageLoaderWrapper.Loading) @@ -228,6 +249,19 @@ let make = ( None }, [startTimeVal, endTimeVal]) + let mockDelay = async () => { + if paymentsProcessedData != []->JSON.Encode.array { + setScreenState(_ => Loading) + await HyperSwitchUtils.delay(300) + setScreenState(_ => Success) + } + } + + React.useEffect(() => { + mockDelay()->ignore + None + }, [isSmartRetryEnabled]) +
@@ -250,7 +284,7 @@ let make = ( entity={chartEntity} data={chartEntity.getObjects( ~data=paymentsProcessedData, - ~xKey=selectedMetric.value, + ~xKey=selectedMetric.value->getKeyForModule(~isSmartRetryEnabled), ~yKey=Time_Bucket->getStringFromVariant, )} className="mr-3" diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res index 88cff3694..402746206 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsProcessed/PaymentsProcessedUtils.res @@ -16,6 +16,23 @@ let getStringFromVariant = value => { } } +let getVariantValueFromString = value => { + switch value { + | "payment_processed_amount" => Payment_Processed_Amount + | "payment_processed_count" => Payment_Processed_Count + | "payment_processed_amount_without_smart_retries" => + Payment_Processed_Amount_Without_Smart_Retries + | "payment_processed_count_without_smart_retries" => Payment_Processed_Count_Without_Smart_Retries + | "total_payment_processed_amount" => Total_Payment_Processed_Amount + | "total_payment_processed_count" => Total_Payment_Processed_Count + | "total_payment_processed_amount_without_smart_retries" => + Total_Payment_Processed_Amount_Without_Smart_Retries + | "total_payment_processed_count_without_smart_retries" => + Total_Payment_Processed_Count_Without_Smart_Retriess + | "time_bucket" | _ => Time_Bucket + } +} + let paymentsProcessedMapper = ( ~data: JSON.t, ~xKey: string, @@ -57,7 +74,7 @@ let getMetaData = json => ->getValueFromArray(0, JSON.Encode.array([])) ->getDictFromJsonObject -let visibleColumns = [Payment_Processed_Amount, Payment_Processed_Count, Time_Bucket] +let visibleColumns = [Time_Bucket] let tableItemToObjMapper: Dict.t => paymentsProcessedObject = dict => { { @@ -172,12 +189,32 @@ let defaulGranularity = { value: (#G_ONEDAY: granularity :> string), } -let getMetaDataMapper = key => { - switch key { - | "payment_processed_amount" => "total_payment_processed_amount" - | "payment_processed_count" => "total_payment_processed_count" - | "payment_processed_amount_without_smart_retries" => "total_payment_processed_amount_without_smart_retries" - | "payment_processed_count_without_smart_retries" => "total_payment_processed_count_without_smart_retries" - | _ => "" +let getKeyForModule = (key, ~isSmartRetryEnabled) => { + let field = key->getVariantValueFromString + switch (field, isSmartRetryEnabled) { + | (Payment_Processed_Amount, Smart_Retry) => Payment_Processed_Amount + | (Payment_Processed_Count, Smart_Retry) => Payment_Processed_Count + | (Payment_Processed_Amount, Default) => Payment_Processed_Amount_Without_Smart_Retries + | (Payment_Processed_Count, Default) | _ => Payment_Processed_Count_Without_Smart_Retries + }->getStringFromVariant +} + +let getMetaDataMapper = (key, ~isSmartRetryEnabled) => { + let field = key->getVariantValueFromString + switch (field, isSmartRetryEnabled) { + | (Payment_Processed_Amount, Smart_Retry) => Total_Payment_Processed_Amount + | (Payment_Processed_Count, Smart_Retry) => Total_Payment_Processed_Count + | (Payment_Processed_Amount, Default) => Total_Payment_Processed_Amount_Without_Smart_Retries + | (Payment_Processed_Count, Default) | _ => Total_Payment_Processed_Count_Without_Smart_Retriess + }->getStringFromVariant +} + +let isSmartRetryEnbldForPmtProcessed = isEnabled => { + switch isEnabled { + | Smart_Retry => [Payment_Processed_Amount, Payment_Processed_Count] + | Default => [ + Payment_Processed_Amount_Without_Smart_Retries, + Payment_Processed_Count_Without_Smart_Retries, + ] } } diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRate.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRate.res index e832dc68d..2b9e85ca2 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRate.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRate.res @@ -2,21 +2,35 @@ open NewAnalyticsTypes open NewAnalyticsHelper open LineGraphTypes open PaymentsSuccessRateUtils +open NewPaymentAnalyticsUtils module PaymentsSuccessRateHeader = { - open NewPaymentAnalyticsUtils open NewAnalyticsUtils + open LogicUtils @react.component let make = (~data, ~keyValue, ~granularity, ~setGranularity) => { let setGranularity = value => { setGranularity(_ => value) } - - let primaryValue = getMetaDataValue(~data, ~index=0, ~key=keyValue->getMetaDataMapper) - let secondaryValue = getMetaDataValue(~data, ~index=1, ~key=keyValue->getMetaDataMapper) + let {filterValueJson} = React.useContext(FilterContext.filterContext) + let isSmartRetryEnabled = + filterValueJson + ->getString("is_smart_retry_enabled", "true") + ->getBoolFromString(true) + ->getSmartRetryMetricType + + let primaryValue = getMetaDataValue( + ~data, + ~index=0, + ~key=keyValue->getMetaDataMapper(~isSmartRetryEnabled), + ) + let secondaryValue = getMetaDataValue( + ~data, + ~index=1, + ~key=keyValue->getMetaDataMapper(~isSmartRetryEnabled), + ) let (value, direction) = calculatePercentageChange(~primaryValue, ~secondaryValue) -
// will enable it in future
@@ -55,6 +69,11 @@ let make = ( let {filterValueJson} = React.useContext(FilterContext.filterContext) let startTimeVal = filterValueJson->getString("startTime", "") let endTimeVal = filterValueJson->getString("endTime", "") + let isSmartRetryEnabled = + filterValueJson + ->getString("is_smart_retry_enabled", "true") + ->getBoolFromString(true) + ->getSmartRetryMetricType let getPaymentsSuccessRate = async () => { setScreenState(_ => PageLoaderWrapper.Loading) @@ -155,6 +174,19 @@ let make = ( None }, [startTimeVal, endTimeVal]) + let mockDelay = async () => { + if paymentsSuccessRateData != []->JSON.Encode.array { + setScreenState(_ => Loading) + await HyperSwitchUtils.delay(300) + setScreenState(_ => Success) + } + } + + React.useEffect(() => { + mockDelay()->ignore + None + }, [isSmartRetryEnabled]) +
@@ -171,7 +203,7 @@ let make = ( entity={chartEntity} data={chartEntity.getObjects( ~data=paymentsSuccessRateData, - ~xKey=Payments_Success_Rate->getStringFromVariant, + ~xKey=Payments_Success_Rate->getKeyForModule(~isSmartRetryEnabled), ~yKey=Time_Bucket->getStringFromVariant, )} className="mr-3" diff --git a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res index b91663363..c76c0968a 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/PaymentsSuccessRate/PaymentsSuccessRateUtils.res @@ -15,6 +15,19 @@ let getStringFromVariant = value => { } } +let getVariantValueFromString = value => { + switch value { + | "successful_payments" => Successful_Payments + | "successful_payments_without_smart_retries" => Successful_Payments_Without_Smart_Retries + | "total_payments" => Total_Payments + | "payments_success_rate" => Payments_Success_Rate + | "payments_success_rate_without_smart_retries" => Payments_Success_Rate_Without_Smart_Retries + | "total_success_rate" => Total_Success_Rate + | "total_success_rate_without_smart_retries" => Total_Success_Rate_Without_Smart_Retries + | "time_bucket" | _ => Time_Bucket + } +} + let paymentsSuccessRateMapper = ( ~data: JSON.t, ~xKey: string, @@ -55,10 +68,17 @@ let defaulGranularity = { value: (#G_ONEDAY: granularity :> string), } -let getMetaDataMapper = key => { - switch key { - | "payments_success_rate" => "total_success_rate" - | "payments_success_rate_without_smart_retries" => "total_success_rate_without_smart_retries" - | _ => "" - } +let getKeyForModule = (field, ~isSmartRetryEnabled) => { + switch (field, isSmartRetryEnabled) { + | (Payments_Success_Rate, Smart_Retry) => Payments_Success_Rate + | (Payments_Success_Rate, Default) | _ => Payments_Success_Rate_Without_Smart_Retries + }->getStringFromVariant +} + +let getMetaDataMapper = (key, ~isSmartRetryEnabled) => { + let field = key->getVariantValueFromString + switch (field, isSmartRetryEnabled) { + | (Payments_Success_Rate, Smart_Retry) => Total_Success_Rate + | (Payments_Success_Rate, Default) | _ => Total_Success_Rate_Without_Smart_Retries + }->getStringFromVariant } diff --git a/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistribution.res b/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistribution.res index 0c0e67aae..6a68372e1 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistribution.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistribution.res @@ -3,8 +3,9 @@ open NewAnalyticsHelper open NewPaymentAnalyticsEntity open BarGraphTypes open SuccessfulPaymentsDistributionUtils - +open NewPaymentAnalyticsUtils module TableModule = { + open LogicUtils @react.component let make = (~data, ~className="", ~selectedTab: string) => { let (offset, setOffset) = React.useState(_ => 0) @@ -12,8 +13,15 @@ module TableModule = { key: "", order: Table.INC, } + let {filterValueJson} = React.useContext(FilterContext.filterContext) + let isSmartRetryEnabled = + filterValueJson + ->getString("is_smart_retry_enabled", "true") + ->getBoolFromString(true) + ->getSmartRetryMetricType let tableBorderClass = "border-2 border-solid border-jp-gray-940 border-collapse border-opacity-30 dark:border-jp-gray-dark_table_border_color dark:border-opacity-30" - let visibleColumns = visibleColumns->Array.concat([selectedTab->getColumn]) + let defaultCol = isSmartRetryEnabled->isSmartRetryEnbldForSuccessPmtDist + let visibleColumns = [defaultCol]->Array.concat([selectedTab->getColumn]) let tableData = getTableData(data)
@@ -77,23 +85,30 @@ let make = ( let (groupBy, setGroupBy) = React.useState(_ => defaulGroupBy) let startTimeVal = filterValueJson->getString("startTime", "") let endTimeVal = filterValueJson->getString("endTime", "") + let isSmartRetryEnabled = + filterValueJson + ->getString("is_smart_retry_enabled", "true") + ->getBoolFromString(true) + ->getSmartRetryMetricType let getPaymentsDistribution = async () => { setScreenState(_ => PageLoaderWrapper.Loading) try { let url = getURL( - ~entityName=ANALYTICS_PAYMENTS, + ~entityName=isSmartRetryEnabled->getEntityForSmartRetry, ~methodType=Post, ~id=Some((entity.domain: domain :> string)), ) + let metrics = isSmartRetryEnabled->getMetricsForSmartRetry + let body = NewAnalyticsUtils.requestBody( ~dimensions=[], ~startTime=startTimeVal, ~endTime=endTimeVal, ~delta=entity.requestBodyConfig.delta, ~filters=entity.requestBodyConfig.filters, - ~metrics=entity.requestBodyConfig.metrics, + ~metrics, ~groupByNames=[groupBy.value]->Some, ~customFilter=entity.requestBodyConfig.customFilter, ~applyFilterFor=entity.requestBodyConfig.applyFilterFor, @@ -122,7 +137,7 @@ let make = ( getPaymentsDistribution()->ignore } None - }, [startTimeVal, endTimeVal, groupBy.value]) + }, [startTimeVal, endTimeVal, groupBy.value, (isSmartRetryEnabled :> string)])
@@ -137,7 +152,7 @@ let make = ( entity={chartEntity} object={chartEntity.getObjects( ~data=paymentsDistribution, - ~xKey=Payments_Success_Rate_Distribution->getStringFromVariant, + ~xKey=Payments_Success_Rate_Distribution->getKeyForModule(~isSmartRetryEnabled), ~yKey=groupBy.value, )} className="mr-3" diff --git a/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistributionUtils.res b/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistributionUtils.res index 6d39b74ad..c9ac3263d 100644 --- a/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistributionUtils.res +++ b/src/screens/NewAnalytics/PaymentAnalytics/SuccessfulPaymentsDistribution/SuccessfulPaymentsDistributionUtils.res @@ -45,7 +45,6 @@ let successfulPaymentsDistributionMapper = ( } open NewAnalyticsTypes -let visibleColumns = [Payments_Success_Rate_Distribution] let tableItemToObjMapper: Dict.t => successfulPaymentsDistributionObject = dict => { { @@ -154,3 +153,25 @@ let defaulGroupBy = { label: "Connector", value: Connector->getStringFromVariant, } + +let getKeyForModule = (field, ~isSmartRetryEnabled) => { + switch (field, isSmartRetryEnabled) { + | (Payments_Success_Rate_Distribution, Smart_Retry) => Payments_Success_Rate_Distribution + | (Payments_Success_Rate_Distribution, Default) | _ => + Payments_Success_Rate_Distribution_Without_Smart_Retries + }->getStringFromVariant +} + +let isSmartRetryEnbldForSuccessPmtDist = isEnabled => { + switch isEnabled { + | Smart_Retry => Payments_Success_Rate_Distribution + | Default => Payments_Success_Rate_Distribution_Without_Smart_Retries + } +} + +let getMetricsForSmartRetry = isEnabled => { + switch isEnabled { + | Smart_Retry => [#payments_distribution] + | Default => [#sessionized_payments_distribution] + } +}