Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/hd 112 additional metrics #24

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/screens/HyperSwitch/Analytics/AnalyticsTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,19 @@ type paymentsSingleState = {
payment_success_rate: float,
payment_count: int,
payment_success_count: int,
retries_count: int,
retries_amount_processe: float,
connector_success_rate: float,
payment_processed_amount: float,
payment_avg_ticket_size: float,
}

type paymentsSingleStateSeries = {
payment_success_rate: float,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,23 @@ 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,
connector_success_rate: 0.0,
payment_processed_amount: 0.0,
payment_avg_ticket_size: 0.0,
}

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,
connector_success_rate: 0.0,
payment_avg_ticket_size: 0.0,
}

Expand All @@ -249,6 +255,9 @@ 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),
connector_success_rate: dict->getFloat("connector_success_rate", 0.0),
})
->Belt.Option.getWithDefault({
singleStateInitialValue
Expand All @@ -266,6 +275,9 @@ 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),
connector_success_rate: dict->getFloat("connector_success_rate", 0.0),
})
->getWithDefault({
singleStateSeriesInitialValue
Expand All @@ -289,11 +301,23 @@ type colT =
| SuccessCount
| ProcessedAmount
| AvgTicketSize
| RetriesCount
| RetriesAmountProcessed
| ConnectorSuccessRate

let defaultColumns: array<DynamicSingleStat.columns<colT>> = [
{
sectionName: "",
columns: [SuccessRate, Count, SuccessCount, ProcessedAmount, AvgTicketSize],
columns: [
SuccessRate,
Count,
SuccessCount,
ProcessedAmount,
AvgTicketSize,
RetriesCount,
RetriesAmountProcessed,
ConnectorSuccessRate,
],
},
]

Expand Down Expand Up @@ -346,6 +370,22 @@ 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)
| "connector_success_rate" =>
singlestatTimeseriesData
->Js.Array2.map(ob => (ob.time_series->DateTimeUtils.parseAsFloat, ob.connector_success_rate))
->Js.Array2.sortInPlaceWith(compareLogic)
| _ => []
}
}
Expand Down Expand Up @@ -448,6 +488,56 @@ 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 savings in amount terms from retrying failed payments again through a second processor",
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,
}
| 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,
}
}
}

Expand Down