Skip to content

Commit

Permalink
Merge branch 'main' into chore/signin-signup-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
racnan authored Nov 28, 2023
2 parents 23c774a + 4ac89db commit 956c84c
Show file tree
Hide file tree
Showing 6 changed files with 27,192 additions and 12 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI

on:
pull_request:

jobs:
build:
name: Build Check
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v4

- name: "Setup node"
uses: actions/setup-node@v4
with:
node-version: 20

- name: "Setup yarn"
run: corepack enable

- name: "Install dependencies"
run: yarn install

- name: "Build"
run: npm run re:build
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ lib/
!.yarn/versions.DS_Store
/public/env-config.js
env-config.js
yarn.lock
# yarn.lock
package-lock.json
user_data.sh
*.pem
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
Loading

0 comments on commit 956c84c

Please sign in to comment.