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

fix: Prod x feature deployment #127

Merged
merged 41 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f62b87a
feat: x-feature added for hyperswitch-custom
Dec 22, 2023
f079b96
fix: formatting
Dec 22, 2023
8ae2fce
fix: x-feature
JeevaRamu0104 Dec 22, 2023
a56f7bc
fix: enums
JeevaRamu0104 Dec 22, 2023
1d0d68b
fix: Prod Enum Changes
Dec 22, 2023
2a0ff85
fix: Log removal
Dec 22, 2023
a64ec05
fix: x-feature for None case
Dec 22, 2023
822b34e
fix: handlelogout changes
Dec 22, 2023
628e1f1
Merge branch 'main' into prod-x-feature-deployment
PritishBudhiraja Dec 26, 2023
05ff466
Merge branch 'main' into prod-x-feature-deployment
PritishBudhiraja Dec 26, 2023
37d4cea
Merge branch 'main' into prod-x-feature-deployment
JeevaRamu0104 Jan 3, 2024
c8a1c3e
Merge branch 'main' into prod-x-feature-deployment
JeevaRamu0104 Jan 3, 2024
cae06a5
Merge branch 'main' into prod-x-feature-deployment
JeevaRamu0104 Jan 3, 2024
4d7e58d
Merge branch 'main' into prod-x-feature-deployment
Jan 4, 2024
4dc570c
Merge branch 'main' into prod-x-feature-deployment
JeevaRamu0104 Jan 4, 2024
7e374b3
Merge branch 'main' into prod-x-feature-deployment
JeevaRamu0104 Jan 4, 2024
f838f0d
Merge branch 'main' into prod-x-feature-deployment
Jan 5, 2024
95f9f0f
chore: change data type response for switch merchant
Jan 9, 2024
fb7518d
Merge branch 'main' into switch-merchant-obj-change
Jan 9, 2024
11a28b2
fix: type changes
Jan 9, 2024
9f65bf2
Merge branch 'main' into prod-x-feature-deployment
Jan 9, 2024
b3d6875
Merge branch 'switch-merchant-obj-change' of github.com:juspay/hypers…
Jan 9, 2024
835ef9b
feat: Feature flag for customer_module added
Jan 9, 2024
c639166
Merge branch 'switch-merchant-obj-change' of github.com:juspay/hypers…
Jan 9, 2024
8b2e640
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Jan 10, 2024
d49a9a7
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Jan 23, 2024
330d88e
Merge branch 'main' into prod-x-feature-deployment
Jan 24, 2024
867f305
feat: x-feature addition
Jan 24, 2024
f19bc24
fix: comments addresssed
Jan 24, 2024
53ff0d2
merge branch: synced with main
Riddhiagrawal001 Feb 1, 2024
1b8f259
fix: changes for x-feature
Riddhiagrawal001 Feb 1, 2024
6e03677
Merge branch 'main' into prod-x-feature-deployment
Feb 6, 2024
dc7e3df
chore: enable custom pod deployment
JeevaRamu0104 Sep 10, 2024
b024789
chore: resolve conflict
JeevaRamu0104 Oct 4, 2024
032b7a7
chore: resolve conflict
JeevaRamu0104 Oct 4, 2024
59f36b2
chore: update x feature route
JeevaRamu0104 Oct 4, 2024
0a05330
chore: update x feature route
JeevaRamu0104 Oct 4, 2024
263abe9
chore: update x feature route
JeevaRamu0104 Oct 4, 2024
85a3305
Merge branch 'main' into prod-x-feature-deployment
JeevaRamu0104 Oct 4, 2024
8084233
chore: update x feature route
JeevaRamu0104 Oct 4, 2024
a36e826
Merge branch 'prod-x-feature-deployment' of github.com:juspay/hypersw…
JeevaRamu0104 Oct 4, 2024
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
1 change: 1 addition & 0 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ new_analytics=false
down_time=false
tax_processor=true
transaction_view=false
x_feature_route=false
3 changes: 2 additions & 1 deletion src/components/AdvancedSearchComponent.res
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ let make = (~children, ~setData=?, ~entity: EntityType.entityType<'colType, 't>,
let initialValueJson = JSON.Encode.object(Dict.make())
let showToast = ToastState.useShowToast()
let (showModal, setShowModal) = React.useState(_ => false)
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom

let onSubmit = (values, form: ReactFinalForm.formApi) => {
open Promise

fetchApi(url, ~bodyStr=JSON.stringify(values), ~method_=Post)
fetchApi(url, ~bodyStr=JSON.stringify(values), ~method_=Post, ~xFeatureRoute)
->then(res => res->Fetch.Response.json)
->then(json => {
let jsonData = json->JSON.Decode.object->Option.flatMap(dict => dict->Dict.get("rows"))
Expand Down
3 changes: 2 additions & 1 deletion src/components/AdvancedSearchModal.res
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module AdvanceSearch = {
let fetchApi = AuthHooks.useApiFetcher()
let initialValueJson = JSON.Encode.object(Dict.make())
let showToast = ToastState.useShowToast()
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom

let onSubmit = (values, _) => {
let otherQueries = switch values->JSON.Decode.object {
Expand All @@ -41,7 +42,7 @@ module AdvanceSearch = {
let finalUrl = otherQueries->isNonEmptyString ? `${url}?${otherQueries}` : url

open Promise
fetchApi(finalUrl, ~bodyStr=JSON.stringify(initialValueJson), ~method_=Get)
fetchApi(finalUrl, ~bodyStr=JSON.stringify(initialValueJson), ~method_=Get, ~xFeatureRoute)
->then(res => res->Fetch.Response.json)
->then(json => {
switch JSON.Classify.classify(json) {
Expand Down
4 changes: 4 additions & 0 deletions src/components/DynamicChart.res
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ let makeEntity = (
let useChartFetch = (~setStatusDict) => {
let fetchApi = AuthHooks.useApiFetcher()
let addLogsAroundFetch = AnalyticsLogUtilsHook.useAddLogsAroundFetch()
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom

let fetchChartData = (updatedChartBody: array<fetchDataConfig>, setState) => {
open Promise

Expand All @@ -244,6 +246,7 @@ let useChartFetch = (~setStatusDict) => {
~method_=Post,
~bodyStr=item.body,
~headers=[("QueryType", "Chart")]->Dict.fromArray,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle="Chart Data Api", ~setStatusDict)
->then(json => {
Expand All @@ -258,6 +261,7 @@ let useChartFetch = (~setStatusDict) => {
~method_=Post,
~bodyStr=legendBody,
~headers=[("QueryType", "Chart")]->Dict.fromArray,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle="Chart Data Api", ~setStatusDict)
->then(
Expand Down
4 changes: 4 additions & 0 deletions src/components/DynamicSingleStat.res
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ let make = (
~formaPayload: option<singleStatBodyEntity => string>=?,
) => {
open LogicUtils
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom

let {filterValueJson} = React.useContext(FilterContext.filterContext)
let fetchApi = AuthHooks.useApiFetcher()
let getAllFilter = filterValueJson
Expand Down Expand Up @@ -304,6 +306,7 @@ let make = (
~method_=Post,
~bodyStr=singleStatBody,
~headers=[("QueryType", "SingleStat")]->Dict.fromArray,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle="SingleStat Data Api")
->then(json => resolve((`${urlConfig.prefix->Option.getOr("")}${uri}`, json)))
Expand Down Expand Up @@ -377,6 +380,7 @@ let make = (
~method_=Post,
~bodyStr=singleStatBodyMakerFn(singleStatBodyEntity),
~headers=[("QueryType", "SingleStatTimeseries")]->Dict.fromArray,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle="SingleStatTimeseries Data Api")
->then(
Expand Down
3 changes: 2 additions & 1 deletion src/components/DynamicTable.res
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ let make = (
filterCheck,
filterForRow,
} = entity
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let tableName =
prefixAddition->Option.getOr(false)
? title->(String.replaceRegExp(_, %re("/ /g"), "-"))->String.toLowerCase->Some
Expand Down Expand Up @@ -236,7 +237,7 @@ let make = (
}
let uri = uri ++ getNewUrl(defaultFilters)
setTableDataLoading(_ => true)
fetchApi(uri, ~bodyStr=JSON.stringify(finalJson), ~headers, ~method_=method)
fetchApi(uri, ~bodyStr=JSON.stringify(finalJson), ~headers, ~method_=method, ~xFeatureRoute)
->then(resp => {
let status = resp->Fetch.Response.status
if status >= 300 {
Expand Down
3 changes: 1 addition & 2 deletions src/components/custom-icons/LottieFiles.res
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ let useLottieJson = lottieFileName => {
let uriPrefix = LogicUtils.useUrlPrefix()
let showToast = ToastState.useShowToast()
let prefix = `${Window.Location.origin}${uriPrefix}`

React.useEffect(() => {
switch lottieDict->Dict.get(lottieFileName) {
| Some(val) =>
Expand All @@ -26,7 +25,7 @@ let useLottieJson = lottieFileName => {
}
| None => {
let fetchLottie =
fetchApi(`${prefix}/lottie-files/${lottieFileName}`, ~method_=Get)
fetchApi(`${prefix}/lottie-files/${lottieFileName}`, ~method_=Get, ~xFeatureRoute=false)
->then(res => res->Fetch.Response.json)
->then(json => {
setlottieJson(_ => json)
Expand Down
8 changes: 8 additions & 0 deletions src/context/ChartContext.res
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF
let defaultFilters = [startTimeFilterKey, endTimeFilterKey]

let {allFilterDimension} = chartEntity
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom

let sortingParams = React.useMemo((): option<AnalyticsNewUtils.sortedBasedOn> => {
switch chartEntity {
Expand Down Expand Up @@ -342,6 +343,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF
)->JSON.stringify,
~headers=[("QueryType", "Chart Time Series")]->Dict.fromArray,
~betaEndpointConfig=?betaEndPointConfig,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle=`Chart fetch`)
->then(
Expand Down Expand Up @@ -400,6 +402,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF
)->JSON.stringify,
~headers=[("QueryType", "Chart Legend")]->Dict.fromArray,
~betaEndpointConfig=?betaEndPointConfig,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle=`Chart legend Data`)
->then(text => {
Expand Down Expand Up @@ -467,6 +470,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF
)->JSON.stringify,
~headers=[("QueryType", "Chart Time Series")]->Dict.fromArray,
~betaEndpointConfig=?betaEndPointConfig,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle=`Chart fetch bottomChart`)
->then(
Expand Down Expand Up @@ -522,6 +526,7 @@ let make = (~children, ~chartEntity: DynamicChart.entity, ~chartId="", ~defaultF
)->JSON.stringify,
~headers=[("QueryType", "Chart Legend")]->Dict.fromArray,
~betaEndpointConfig=?betaEndPointConfig,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle=`Chart legend Data`)
->then(text => {
Expand Down Expand Up @@ -579,6 +584,7 @@ module SDKAnalyticsChartContext = {
~segmentValue: option<array<string>>=?,
~differentTimeValues: option<array<AnalyticsUtils.timeRanges>>=?,
) => {
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let parentToken = AuthWrapperUtils.useTokenParent(Original)
let addLogsAroundFetch = AnalyticsLogUtilsHook.useAddLogsAroundFetchNew()
let betaEndPointConfig = React.useContext(BetaEndPointConfigProvider.betaEndPointConfig)
Expand Down Expand Up @@ -810,6 +816,7 @@ module SDKAnalyticsChartContext = {
)->JSON.stringify,
~headers=[("QueryType", "Chart Time Series")]->Dict.fromArray,
~betaEndpointConfig=?betaEndPointConfig,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle=`Chart fetch`)
->then(text => {
Expand Down Expand Up @@ -849,6 +856,7 @@ module SDKAnalyticsChartContext = {
)->JSON.stringify,
~headers=[("QueryType", "Chart Time Series")]->Dict.fromArray,
~betaEndpointConfig=?betaEndPointConfig,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle=`Chart fetch`)
->then(
Expand Down
5 changes: 4 additions & 1 deletion src/context/SingleStatContext.res
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ let make = (
let addLogsAroundFetch = AnalyticsLogUtilsHook.useAddLogsAroundFetchNew()
let betaEndPointConfig = React.useContext(BetaEndPointConfigProvider.betaEndPointConfig)
let fetchApi = AuthHooks.useApiFetcher()

let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let getTopLevelSingleStatFilter = React.useMemo(() => {
getAllFilter
->Dict.toArray
Expand Down Expand Up @@ -259,6 +259,7 @@ let make = (
)->JSON.stringify,
~headers=[("QueryType", "SingleStatHistoric")]->Dict.fromArray,
~betaEndpointConfig=?betaEndPointConfig,
~xFeatureRoute,
)
->addLogsAroundFetch(
~logTitle=`SingleStat histotic data for metrics ${metrics->metrixMapper}`,
Expand Down Expand Up @@ -309,6 +310,7 @@ let make = (
)->JSON.stringify,
~headers=[("QueryType", "SingleStat")]->Dict.fromArray,
~betaEndpointConfig=?betaEndPointConfig,
~xFeatureRoute,
)
->addLogsAroundFetch(~logTitle=`SingleStat data for metrics ${metrics->metrixMapper}`)
->then(
Expand Down Expand Up @@ -358,6 +360,7 @@ let make = (
)->JSON.stringify,
~headers=[("QueryType", "SingleStat Time Series")]->Dict.fromArray,
~betaEndpointConfig=?betaEndPointConfig,
~xFeatureRoute,
)
->addLogsAroundFetch(
~logTitle=`SingleStat Time Series data for metrics ${metrics->metrixMapper}`,
Expand Down
3 changes: 2 additions & 1 deletion src/entryPoints/AuthModule/UserInfo/UserInfoProvider.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ let make = (~children) => {
let (screenState, setScreenState) = React.useState(_ => Loading)
let (userInfo, setUserInfo) = React.useState(_ => UserInfoUtils.defaultValueOfUserInfo)
let fetchApi = AuthHooks.useApiFetcher()
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let getUserInfo = async () => {
open LogicUtils
let url = `${Window.env.apiBaseUrl}/user`
try {
let res = await fetchApi(`${url}`, ~method_=Get)
let res = await fetchApi(`${url}`, ~method_=Get, ~xFeatureRoute)
let response = await res->(res => res->Fetch.Response.json)
let userInfo = response->getDictFromJsonObject->UserInfoUtils.itemMapper
setUserInfo(_ => userInfo)
Expand Down
2 changes: 2 additions & 0 deletions src/entryPoints/FeatureFlagUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type featureFlag = {
downTime: bool,
taxProcessor: bool,
transactionView: bool,
xFeatureRoute: bool,
}

let featureFlagType = (featureFlags: JSON.t) => {
Expand Down Expand Up @@ -77,6 +78,7 @@ let featureFlagType = (featureFlags: JSON.t) => {
downTime: dict->getBool("down_time", false),
taxProcessor: dict->getBool("tax_processor", false),
transactionView: dict->getBool("transaction_view", false),
xFeatureRoute: dict->getBool("x_feature_route", false),
}
typedFeatureFlag
}
30 changes: 22 additions & 8 deletions src/hooks/AuthHooks.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
type contentType = Headers(string) | Unknown
let headersForXFeature = (~uri, ~headers) => {
if uri->String.includes("lottie-files") || uri->String.includes("config/merchant-access") {
headers->Dict.set("Content-Type", `application/json`)
} else {
headers->Dict.set("x-feature", "router-custom")
}
}

let getHeaders = (~uri, ~headers, ~contentType=Headers("application/json"), ~token) => {
let getHeaders = (
~uri,
~headers,
~contentType=Headers("application/json"),
~xFeatureRoute,
~token,
) => {
let isMixpanel = uri->String.includes("mixpanel")

let headerObj = if isMixpanel {
Expand All @@ -9,20 +22,21 @@ let getHeaders = (~uri, ~headers, ~contentType=Headers("application/json"), ~tok
("accept", "application/json"),
]->Dict.fromArray
} else {
let res = switch token {
switch token {
| Some(str) => {
headers->Dict.set("authorization", `Bearer ${str}`)
headers->Dict.set("api-key", `hyperswitch`)

headers
if xFeatureRoute {
headersForXFeature(~headers, ~uri)
}
}
| None => headers
| None => ()
}
switch contentType {
| Headers(headerString) => headers->Dict.set("Content-Type", headerString)
| Unknown => ()
}
res
headers
}
Fetch.HeadersInit.make(headerObj->Identity.dictOfAnyTypeToObj)
}
Expand All @@ -38,7 +52,6 @@ let useApiFetcher = () => {
let {authStatus, setAuthStateToLogout} = React.useContext(AuthInfoProvider.authStatusContext)

let setReqProgress = Recoil.useSetRecoilState(ApiProgressHooks.pendingRequestCount)

React.useCallback(
(
uri,
Expand All @@ -48,6 +61,7 @@ let useApiFetcher = () => {
~method_: Fetch.requestMethod,
~betaEndpointConfig=?,
~contentType=Headers("application/json"),
~xFeatureRoute,
) => {
let token = {
switch authStatus {
Expand Down Expand Up @@ -81,7 +95,7 @@ let useApiFetcher = () => {
~method_,
~body?,
~credentials=SameOrigin,
~headers=getHeaders(~headers, ~uri, ~contentType, ~token),
~headers=getHeaders(~headers, ~uri, ~contentType, ~token, ~xFeatureRoute),
),
)
->catch(
Expand Down
9 changes: 6 additions & 3 deletions src/screens/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -722,13 +722,13 @@ let useHandleLogout = () => {
let {setAuthStateToLogout} = React.useContext(AuthInfoProvider.authStatusContext)
let clearRecoilValue = ClearRecoilValueHook.useClearRecoilValue()
let fetchApi = AuthHooks.useApiFetcher()

let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
() => {
try {
let logoutUrl = getURL(~entityName=USERS, ~methodType=Post, ~userType=#SIGNOUT)
open Promise
let _ =
fetchApi(logoutUrl, ~method_=Post)
fetchApi(logoutUrl, ~method_=Post, ~xFeatureRoute)
->then(Fetch.Response.json)
->then(json => {
json->resolve
Expand Down Expand Up @@ -883,10 +883,11 @@ let useGetMethod = (~showErrorToast=true) => {
},
},
})
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom

async url => {
try {
let res = await fetchApi(url, ~method_=Get)
let res = await fetchApi(url, ~method_=Get, ~xFeatureRoute)
await responseHandler(
~res,
~showErrorToast,
Expand Down Expand Up @@ -927,6 +928,7 @@ let useUpdateMethod = (~showErrorToast=true) => {
},
},
})
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom

async (
url,
Expand All @@ -944,6 +946,7 @@ let useUpdateMethod = (~showErrorToast=true) => {
~bodyFormData,
~headers,
~contentType,
~xFeatureRoute,
)
await responseHandler(
~res,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let make = (
let downloadApplePayCert = () => {
open Promise
let downloadURL = Window.env.applePayCertificateUrl->Option.getOr("")
fetchApi(downloadURL, ~method_=Get)
fetchApi(downloadURL, ~method_=Get, ~xFeatureRoute=featureFlagDetails.xFeatureRoute)
->then(Fetch.Response.blob)
->then(content => {
DownloadUtils.download(
Expand Down
3 changes: 2 additions & 1 deletion src/screens/Hooks/OMPSwitchHooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ let useUserInfo = () => {
let fetchApi = AuthHooks.useApiFetcher()
let {setUserInfoData, userInfo} = React.useContext(UserInfoProvider.defaultContext)
let url = `${Window.env.apiBaseUrl}/user`
let {xFeatureRoute} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom

let getUserInfo = async () => {
try {
let res = await fetchApi(`${url}`, ~method_=Get)
let res = await fetchApi(`${url}`, ~method_=Get, ~xFeatureRoute)
let response = await res->(res => res->Fetch.Response.json)
let userInfo = response->getDictFromJsonObject->UserInfoUtils.itemMapper
setUserInfoData(userInfo)
Expand Down
Loading
Loading