Skip to content

feat: add 3ds exemption analytics #3072

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

Merged
merged 19 commits into from
Jun 11, 2025
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
12 changes: 12 additions & 0 deletions src/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,18 @@ let useGetURL = () => {
| #Profile => `analytics/v1/profile/metrics/sankey`
}

| _ => ""
}
| ANALYTICS_SCA_EXEMPTION_SANKEY =>
switch methodType {
| Post =>
switch analyticsEntity {
| #Tenant
| #Organization => `analytics/v1/org/metrics/auth_events/sankey`
| #Merchant => `analytics/v1/merchant/metrics/auth_events/sankey`
| #Profile => `analytics/v1/profile/metrics/auth_events/sankey`
}

| _ => ""
}
/* PAYOUTS ROUTING */
Expand Down
1 change: 1 addition & 0 deletions src/APIUtils/APIUtilsTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type entityName =
| API_EVENT_LOGS
| ANALYTICS_PAYMENTS_V2
| ANALYTICS_SANKEY
| ANALYTICS_SCA_EXEMPTION_SANKEY
| HYPERSENSE
| SIMULATE_INTELLIGENT_ROUTING
| INTELLIGENT_ROUTING_RECORDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ open InsightsTypes
open RetryStrategiesAnalyticsUtils

module RetryUpliftCard = {
open RetryStrategiesAnalyticsTypes
open LogicUtils
@react.component
let make = (
~title: string,
~rate: float,
~changeValue: float,
~changeDirection: statisticsDirection,
~recovered: array<recoveredType>,
~recovered: array<RetryStrategiesAnalyticsTypes.recoveredType>,
) => {
let getLegendBg = declineType => {
switch declineType {
Expand Down Expand Up @@ -54,7 +53,9 @@ module RetryUpliftCard = {
<span className={`w-3 h-3 ${getLegendBg(recoveredType.declineType)} rounded-[4px]`} />
<div className="flex gap-2">
<span className="font-medium">
{(recoveredType.declineType: declineTypes :> string)->snakeToTitle->React.string}
{(recoveredType.declineType: RetryStrategiesAnalyticsTypes.declineTypes :> string)
->snakeToTitle
->React.string}
</span>
<span className="text-gray-500">
{`| ${recoveredType.value->valueFormatter(Rate)}`->React.string}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Graphs/SankyGraph/SankeyGraphTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ type nodeDataLabels = {
type node = {
id: string,
dataLabels: nodeDataLabels,
offset?: int,
column?: int,
}
type style = {
fontWeight: fontWeight,
Expand Down
9 changes: 8 additions & 1 deletion src/container/InsightsAnalyticsContainer.res
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ let make = () => {
let applySampleDateFilters = async isSampleDateEnabled => {
try {
setScreenState(_ => Loading)
let values = InsightsUtils.getSampleDateRange(~useSampleDates=isSampleDateEnabled)
let sampleDateRange: HSwitchRemoteFilter.filterBody = {
start_time: "2024-09-04T00:00:00.000Z",
end_time: "2024-10-03T00:00:00.000Z",
}
let values = InsightsUtils.getSampleDateRange(
~useSampleDates=isSampleDateEnabled,
~sampleDateRange,
)
values->Dict.set(sampleDataKey, isSampleDateEnabled->getStringFromBool)
let _ = await updateFilterAsync(~delay=1000, values)
setScreenState(_ => Success)
Expand Down
4 changes: 4 additions & 0 deletions src/screens/NewAnalytics/InsightsTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type metrics = [
| #challenge_success_count
| #authentication_funnel
| #authentication_error_message
| #authentication_exemption_approved_count
| #authentication_exemption_requested_count
]
type granularity = [
| #G_ONEDAY
Expand All @@ -70,6 +72,7 @@ type moduleEntity = {
requestBodyConfig: requestBodyConfig,
title: string,
domain: domain,
description?: string,
}

type getObjects<'data> = {
Expand All @@ -78,6 +81,7 @@ type getObjects<'data> = {
yKey: string,
comparison?: DateRangeUtils.comparison,
currency?: string,
title?: string,
}

type chartEntity<'t, 'chartOption, 'data> = {
Expand Down
6 changes: 1 addition & 5 deletions src/screens/NewAnalytics/InsightsUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,8 @@ let fillMissingDataPoints = (
dataPoints->Dict.valuesToArray
}

let getSampleDateRange = (~useSampleDates) => {
let getSampleDateRange = (~useSampleDates, ~sampleDateRange) => {
let defaultDateRange: filterBody = getDateFilteredObject(~range=7)
let sampleDateRange: filterBody = {
start_time: "2024-09-04T00:00:00.000Z",
end_time: "2024-10-03T00:00:00.000Z",
}
let dates = useSampleDates ? sampleDateRange : defaultDateRange
let comparison = useSampleDates ? (EnableComparison :> string) : (DisableComparison :> string)
let (compareStart, compareEnd) = getComparisionTimePeriod(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
open InsightsTypes
open InsightsHelper
open ExemptionGraphsUtils
open ExemptionGraphsTypes
open InsightsUtils
open NewAuthenticationAnalyticsEntity

module TableModule = {
open LogicUtils
@react.component
let make = (~data, ~className="") => {
let (offset, setOffset) = React.useState(_ => 0)
let defaultSort: Table.sortedObject = {
key: "",
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 mt-7"

let paymentsProcessed =
data
->Array.map(item => {
item->getDictFromJsonObject->tableItemToObjMapper
})
->Array.map(Nullable.make)

let cols = [
Authentication_Connector,
Authentication_Success_Rate,
Exemption_Approval_Rate,
Exemption_Request_Rate,
User_Drop_Off_Rate,
]

<div className>
<div className="flex flex-1 flex-col my-5">
<div className="relative">
<div
className="absolute font-bold text-xl bg-white w-full text-black text-opacity-75 dark:bg-jp-gray-950 dark:text-white dark:text-opacity-75">
{React.string("Authentication Summary")}
</div>
<LoadedTable
visibleColumns=cols
title="Authentication Summary"
hideTitle=true
actualData={paymentsProcessed}
entity=authSummaryTableEntity
resultsPerPage=10
totalResults={paymentsProcessed->Array.length}
offset
setOffset
defaultSort
currrentFetchCount={paymentsProcessed->Array.length}
tableLocalFilter=false
tableheadingClass=tableBorderClass
tableBorderClass
ignoreHeaderBg=true
showSerialNumber=true
tableDataBorderClass=tableBorderClass
isAnalyticsModule=true
/>
</div>
</div>
</div>
}
}

@react.component
let make = (~entity: moduleEntity) => {
open LogicUtils
open APIUtils
let getURL = useGetURL()
let updateDetails = useUpdateMethod()
let fetchApi = AuthHooks.useApiFetcher()
let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Loading)
let {filterValueJson} = React.useContext(FilterContext.filterContext)

let (authenticationSummaryTableData, setAuthenticationSummaryTableData) = React.useState(_ => [])
let startTimeVal = filterValueJson->getString("startTime", "")
let endTimeVal = filterValueJson->getString("endTime", "")
let compareToStartTime = filterValueJson->getString("compareToStartTime", "")
let compareToEndTime = filterValueJson->getString("compareToEndTime", "")
let comparison =
filterValueJson
->getString("comparison", "")
->DateRangeUtils.comparisonMapprer
let currency = filterValueJson->getString((#currency: filters :> string), "")
let featureFlag = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let defaulGranularity = getDefaultGranularity(
~startTime=startTimeVal,
~endTime=endTimeVal,
~granularity=featureFlag.granularity,
)
let (granularity, setGranularity) = React.useState(_ => defaulGranularity)

React.useEffect(() => {
if startTimeVal->isNonEmptyString && endTimeVal->isNonEmptyString {
setGranularity(_ => defaulGranularity)
}
None
}, (startTimeVal, endTimeVal))

let isSampleDataEnabled =
filterValueJson->getStringFromDictAsBool(NewAuthenticationAnalyticsUtils.sampleDataKey, false)
let getPaymentsProcessed = async () => {
setScreenState(_ => PageLoaderWrapper.Loading)
try {
let url = getURL(
~entityName=V1(ANALYTICS_AUTHENTICATION_V2),
~methodType=Post,
~id=Some((entity.domain: domain :> string)),
)
let primaryResponse = if isSampleDataEnabled {
let paymentsUrl = `${GlobalVars.getHostUrl}/test-data/analytics/payments.json`
let res = await fetchApi(
paymentsUrl,
~method_=Get,
~xFeatureRoute=false,
~forceCookies=false,
)
let paymentsResponse = await res->(res => res->Fetch.Response.json)
paymentsResponse
->getDictFromJsonObject
->getJsonObjectFromDict("authenticationSummaryTableData")
} else {
let primaryBody = InsightsUtils.requestBody(
~startTime=startTimeVal,
~endTime=endTimeVal,
~delta=entity.requestBodyConfig.delta,
~metrics=entity.requestBodyConfig.metrics,
~groupByNames=Some(["authentication_connector"]),
~filter=Some(getUpdatedFilterValueJson(filterValueJson)->JSON.Encode.object),
)
await updateDetails(url, primaryBody, Post)
}
let primaryData =
primaryResponse
->getDictFromJsonObject
->getArrayFromDict("queryData", [])
->modifyQueryData
->sortQueryDataByDate
setAuthenticationSummaryTableData(_ => primaryData)
setScreenState(_ => PageLoaderWrapper.Success)
} catch {
| _ => setScreenState(_ => PageLoaderWrapper.Custom)
}
}
React.useEffect(() => {
if startTimeVal->isNonEmptyString && endTimeVal->isNonEmptyString {
getPaymentsProcessed()->ignore
}
None
}, (
startTimeVal,
endTimeVal,
compareToStartTime,
compareToEndTime,
comparison,
granularity.value,
currency,
isSampleDataEnabled,
))

<PageLoaderWrapper
screenState customLoader={<Shimmer layoutId=entity.title />} customUI={<NoData />}>
<TableModule data={authenticationSummaryTableData} />
</PageLoaderWrapper>
}
Loading
Loading