Skip to content

Commit

Permalink
Merge branch 'main' into small-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Nov 6, 2024
2 parents a7b18ea + 80704c8 commit e32a6a3
Show file tree
Hide file tree
Showing 31 changed files with 57 additions and 54 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- @akash-c-k @ArushKapoorJuspay @PritishBudhiraja @seekshiva

* @PritishBudhiraja @seekshiva @ArushKapoorJuspay
docs/ @akash-c-k
LICENSE @akash-c-k
README.md @akash-c-k
Expand All @@ -17,5 +18,5 @@ webpack.dev.js @ArushKapoorJuspay @PritishBudhiraja @seekshiva
webpack.common.js @ArushKapoorJuspay @PritishBudhiraja @seekshiva

src/ @seekshiva @PritishBudhiraja @ArushKapoorJuspay
src/orca-log-catcher @Sanskar2001
src/hyper-log-catcher @Sanskar2001
cypress-tests/ @seekshiva @Sanskar2001
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## [0.99.5](https://github.com/juspay/hyperswitch-web/compare/v0.99.4...v0.99.5) (2024-11-06)

## [0.99.4](https://github.com/juspay/hyperswitch-web/compare/v0.99.3...v0.99.4) (2024-11-05)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orca-payment-page",
"version": "0.99.4",
"version": "0.99.5",
"main": "index.js",
"private": true,
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/App.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let make = () => {
let paymentMode = CardUtils.getQueryParamsDictforKey(url.search, "componentName")
let paymentType = paymentMode->CardThemeType.getPaymentMode
let (logger, initTimestamp) = React.useMemo0(() => {
(OrcaLogger.make(~source=Elements(paymentType)), Date.now())
(HyperLogger.make(~source=Elements(paymentType)), Date.now())
})
let fullscreenMode = CardUtils.getQueryParamsDictforKey(url.search, "fullscreenType")

Expand Down
4 changes: 2 additions & 2 deletions src/Payments/PaypalSDKHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open Utils
open TaxCalculation

let loadPaypalSDK = (
~loggerState: OrcaLogger.loggerMake,
~loggerState: HyperLogger.loggerMake,
~sdkHandleOneClickConfirmPayment as _,
~buttonStyle,
~iframeId,
Expand Down Expand Up @@ -225,7 +225,7 @@ let loadPaypalSDK = (
}

let loadBraintreePaypalSdk = (
~loggerState: OrcaLogger.loggerMake,
~loggerState: HyperLogger.loggerMake,
~sdkHandleOneClickConfirmPayment,
~token,
~buttonStyle,
Expand Down
2 changes: 1 addition & 1 deletion src/Payments/PlaidSDKIframe.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let make = () => {
let (clientSecret, setClientSecret) = React.useState(_ => "")
let (isForceSync, setIsForceSync) = React.useState(_ => false)
let logger = React.useMemo(() => {
OrcaLogger.make(~source=Elements(Payment), ~clientSecret, ~merchantId=publishableKey)
HyperLogger.make(~source=Elements(Payment), ~clientSecret, ~merchantId=publishableKey)
}, (publishableKey, clientSecret))

React.useEffect0(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/Payments/PreMountLoader.res
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let make = (
false
)
let (sessionTokensResponseSent, setSessionTokensResponseSent) = React.useState(_ => false)
let logger = OrcaLogger.make(
let logger = HyperLogger.make(
~sessionId,
~source=Loader,
~merchantId=publishableKey,
Expand Down
2 changes: 1 addition & 1 deletion src/ThreeDSAuth.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let make = () => {
let threeDsAuthoriseUrl = React.useRef("")
let (expiryTime, setExpiryTime) = React.useState(_ => 600000.0)

let logger = OrcaLogger.make(~source=Elements(Payment))
let logger = HyperLogger.make(~source=Elements(Payment))

let handleFrictionLess = () => {
let ele = Window.querySelector("#threeDsAuthDiv")
Expand Down
2 changes: 1 addition & 1 deletion src/ThreeDSMethod.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
open Utils
@react.component
let make = () => {
let logger = OrcaLogger.make(~source=Elements(Payment))
let logger = HyperLogger.make(~source=Elements(Payment))

let (stateMetadata, setStateMetadata) = React.useState(_ => Dict.make()->JSON.Encode.object)

Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/ApplePayHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ let startApplePaySession = (
~paymentRequest,
~applePaySessionRef,
~applePayPresent,
~logger: OrcaLogger.loggerMake,
~logger: HyperLogger.loggerMake,
~callBackFunc,
~resolvePromise,
~clientSecret,
Expand Down
16 changes: 8 additions & 8 deletions src/Utilities/ErrorUtils.res
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type type_ = Error | Warning
type stringType = Dynamic(string => string) | Static(string)

type error = array<(OrcaLogger.eventName, type_, string)>
type error = array<(HyperLogger.eventName, type_, string)>

open OrcaLogger
open HyperLogger

let errorWarning = [
(
Expand Down Expand Up @@ -107,9 +107,9 @@ let errorWarning = [
]

let manageErrorWarning = (
key: OrcaLogger.eventName,
key: HyperLogger.eventName,
~dynamicStr="",
~logger: OrcaLogger.loggerMake,
~logger: HyperLogger.loggerMake,
) => {
let entry = errorWarning->Array.find(((value, _, _)) => value == key)
switch entry {
Expand All @@ -120,7 +120,7 @@ let manageErrorWarning = (
| Static(string) => string
| Dynamic(fn) => fn(dynamicStr)
}
let logType: OrcaLogger.logType = switch type_ {
let logType: HyperLogger.logType = switch type_ {
| Warning => WARNING
| Error => ERROR
}
Expand Down Expand Up @@ -154,7 +154,7 @@ let unknownPropValueWarning = (
inValidValue,
validValueArr,
dictType,
~logger: OrcaLogger.loggerMake,
~logger: HyperLogger.loggerMake,
) => {
let expectedValues =
validValueArr
Expand All @@ -168,10 +168,10 @@ let unknownPropValueWarning = (
~logger,
)
}
let valueOutRangeWarning = (num: int, dictType, range, ~logger: OrcaLogger.loggerMake) => {
let valueOutRangeWarning = (num: int, dictType, range, ~logger: HyperLogger.loggerMake) => {
manageErrorWarning(
VALUE_OUT_OF_RANGE,
~dynamicStr=`${num->Int.toString} value in ${dictType} Expected value between ${range}`,
~logger: OrcaLogger.loggerMake,
~logger: HyperLogger.loggerMake,
)
}
14 changes: 7 additions & 7 deletions src/Utilities/LoggerUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ let logApi = (
~eventName,
~statusCode="",
~data: JSON.t=Dict.make()->JSON.Encode.object,
~apiLogType: OrcaLogger.apiLogType,
~apiLogType: HyperLogger.apiLogType,
~url="",
~paymentMethod="",
~result: JSON.t=Dict.make()->JSON.Encode.object,
~optLogger: option<OrcaLogger.loggerMake>,
~logType: OrcaLogger.logType=INFO,
~logCategory: OrcaLogger.logCategory=API,
~optLogger: option<HyperLogger.loggerMake>,
~logType: HyperLogger.logType=INFO,
~logCategory: HyperLogger.logCategory=API,
~isPaymentSession: bool=false,
) => {
let (value, internalMetadata) = switch apiLogType {
Expand Down Expand Up @@ -50,17 +50,17 @@ let logApi = (
}
}

let logInputChangeInfo = (text, logger: OrcaLogger.loggerMake) => {
let logInputChangeInfo = (text, logger: HyperLogger.loggerMake) => {
logger.setLogInfo(~value=text, ~eventName=INPUT_FIELD_CHANGED)
}

let handleLogging = (
~optLogger: option<OrcaLogger.loggerMake>,
~optLogger: option<HyperLogger.loggerMake>,
~value,
~internalMetadata="",
~eventName,
~paymentMethod,
~logType: OrcaLogger.logType=INFO,
~logType: HyperLogger.logType=INFO,
) => {
switch optLogger {
| Some(logger) =>
Expand Down
8 changes: 4 additions & 4 deletions src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ let rec intentCall = (

let isCompleteAuthorize = uri->String.includes("/complete_authorize")
let isPostSessionTokens = uri->String.includes("/post_session_tokens")
let (eventName: OrcaLogger.eventName, initEventName: OrcaLogger.eventName) = switch (
let (eventName: HyperLogger.eventName, initEventName: HyperLogger.eventName) = switch (
isConfirm,
isCompleteAuthorize,
isPostSessionTokens,
Expand Down Expand Up @@ -899,7 +899,7 @@ let rec intentCall = (
})
}

let usePaymentSync = (optLogger: option<OrcaLogger.loggerMake>, paymentType: payment) => {
let usePaymentSync = (optLogger: option<HyperLogger.loggerMake>, paymentType: payment) => {
open RecoilAtoms
let paymentMethodList = Recoil.useRecoilValueFromAtom(paymentMethodList)
let keys = Recoil.useRecoilValueFromAtom(keys)
Expand Down Expand Up @@ -1151,7 +1151,7 @@ let usePaymentIntent = (optLogger, paymentType) => {
}
}

let useCompleteAuthorize = (optLogger: option<OrcaLogger.loggerMake>, paymentType: payment) => {
let useCompleteAuthorize = (optLogger: option<HyperLogger.loggerMake>, paymentType: payment) => {
open RecoilAtoms
let paymentMethodList = Recoil.useRecoilValueFromAtom(paymentMethodList)
let keys = Recoil.useRecoilValueFromAtom(keys)
Expand Down Expand Up @@ -1765,7 +1765,7 @@ let callAuthExchange = (
open Promise
open PaymentType
let endpoint = ApiEndpoint.getApiEndPoint()
let logger = OrcaLogger.make(~source=Elements(Payment))
let logger = HyperLogger.make(~source=Elements(Payment))
let uri = `${endpoint}/payment_methods/auth/exchange`
let updatedBody = [
("client_secret", clientSecret->Option.getOr("")->JSON.Encode.string),
Expand Down
4 changes: 2 additions & 2 deletions src/Utilities/PmAuthConnectorUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let pmAuthConnectorToScriptUrlMapper = authConnector => {
let mountAuthConnectorScript = (
~authConnector,
~onScriptLoaded,
~logger: OrcaLogger.loggerMake,
~logger: HyperLogger.loggerMake,
) => {
let authConnector = authConnector->Option.getOr("")
let pmAuthConnectorScriptUrl =
Expand Down Expand Up @@ -47,7 +47,7 @@ let mountAuthConnectorScript = (
let mountAllRequriedAuthConnectorScripts = (
~pmAuthConnectorsArr,
~onScriptLoaded,
~logger: OrcaLogger.loggerMake,
~logger: HyperLogger.loggerMake,
) => {
pmAuthConnectorsArr->Array.forEach(item => {
mountAuthConnectorScript(~authConnector=item, ~onScriptLoaded, ~logger)
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/RecoilAtoms.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let elementOptions = Recoil.atom("elementOptions", ElementType.defaultOptions)
let optionAtom = Recoil.atom("options", PaymentType.defaultOptions)
let sessions = Recoil.atom("sessions", PaymentType.Loading)
let paymentMethodList = Recoil.atom("paymentMethodList", PaymentType.Loading)
let loggerAtom = Recoil.atom("component", OrcaLogger.defaultLoggerConfig)
let loggerAtom = Recoil.atom("component", HyperLogger.defaultLoggerConfig)
let sessionId = Recoil.atom("sessionId", "")
let isConfirmBlocked = Recoil.atom("isConfirmBlocked", false)
let customPodUri = Recoil.atom("customPodUri", "")
Expand Down
6 changes: 3 additions & 3 deletions src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ let handlePostMessageEvents = (
~complete,
~empty,
~paymentType,
~loggerState: OrcaLogger.loggerMake,
~loggerState: HyperLogger.loggerMake,
~savedMethod=false,
) => {
if complete && paymentType !== "" {
Expand Down Expand Up @@ -833,8 +833,8 @@ let getHeaders = (~uri=?, ~token=?, ~headers=Dict.make()) => {
("Content-Type", "application/json"),
("X-Client-Version", Window.version),
("X-Payment-Confirm-Source", "sdk"),
("X-Browser-Name", OrcaLogger.arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others")),
("X-Browser-Version", OrcaLogger.arrayOfNameAndVersion->Array.get(1)->Option.getOr("0")),
("X-Browser-Name", HyperLogger.arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others")),
("X-Browser-Version", HyperLogger.arrayOfNameAndVersion->Array.get(1)->Option.getOr("0")),
("X-Client-Platform", "web"),
]->Dict.fromArray

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ let make = (
~clientSecret,
~sdkSessionId,
~publishableKey,
~logger: option<OrcaLogger.loggerMake>,
~logger: option<HyperLogger.loggerMake>,
~analyticsMetadata,
~customBackendUrl,
) => {
try {
let iframeRef = []
let logger = logger->Option.getOr(OrcaLogger.defaultLoggerConfig)
let logger = logger->Option.getOr(HyperLogger.defaultLoggerConfig)
let savedPaymentElement = Dict.make()
let localOptions = options->JSON.Decode.object->Option.getOr(Dict.make())

Expand Down
4 changes: 2 additions & 2 deletions src/orca-loader/Hyper.res → src/hyper-loader/Hyper.res
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ let handleHyperApplePayMounted = (event: Types.event) => {
let sdkSessionId = dict->getString("sdkSessionId", "")
let analyticsMetadata = dict->getJsonFromDict("analyticsMetadata", JSON.Encode.null)

let logger = OrcaLogger.make(
let logger = HyperLogger.make(
~sessionId=sdkSessionId,
~source=Loader,
~merchantId=publishableKey,
Expand Down Expand Up @@ -155,7 +155,7 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
let sessionID =
analyticsInfoDict->getString("sessionID", "hyp_" ++ Utils.generateRandomString(8))
let sdkTimestamp = analyticsInfoDict->getString("timeStamp", Date.now()->Float.toString)
let logger = OrcaLogger.make(
let logger = HyperLogger.make(
~sessionId=sessionID,
~source=Loader,
~merchantId=publishableKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let loadHyper = (str, option) => {
}

let loadStripe = (str, option) => {
ErrorUtils.manageErrorWarning(DEPRECATED_LOADSTRIPE, ~logger=OrcaLogger.defaultLoggerConfig)
ErrorUtils.manageErrorWarning(DEPRECATED_LOADSTRIPE, ~logger=HyperLogger.defaultLoggerConfig)
loadHyper(str, option)
}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ let make = (
~ephemeralKey,
~sdkSessionId,
~publishableKey,
~logger: option<OrcaLogger.loggerMake>,
~logger: option<HyperLogger.loggerMake>,
~analyticsMetadata,
~customBackendUrl,
) => {
let hyperComponentName = PaymentMethodsManagementElements
try {
let iframeRef = []
let logger = logger->Option.getOr(OrcaLogger.defaultLoggerConfig)
let logger = logger->Option.getOr(HyperLogger.defaultLoggerConfig)
let savedPaymentElement = Dict.make()
let localOptions = options->JSON.Decode.object->Option.getOr(Dict.make())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ let make = (
options,
~clientSecret,
~publishableKey,
~logger: option<OrcaLogger.loggerMake>,
~logger: option<HyperLogger.loggerMake>,
~ephemeralKey,
) => {
let logger = logger->Option.getOr(OrcaLogger.defaultLoggerConfig)
let logger = logger->Option.getOr(HyperLogger.defaultLoggerConfig)
let customPodUri =
options
->JSON.Decode.object
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module ErrorCard = {
let make = (~error: Sentry.ErrorBoundary.fallbackArg, ~level, ~componentName) => {
let beaconApiCall = data => {
if data->Array.length > 0 {
let logData = data->Array.map(OrcaLogger.logFileToObj)->JSON.Encode.array->JSON.stringify
let logData = data->Array.map(HyperLogger.logFileToObj)->JSON.Encode.array->JSON.stringify
Window.Navigator.sendBeacon(GlobalVars.logEndpoint, logData)
}
}
Expand All @@ -142,7 +142,7 @@ module ErrorCard = {

errorDict->Dict.set("componentName", componentName->JSON.Encode.string)

let errorLog: OrcaLogger.logFile = {
let errorLog: HyperLogger.logFile = {
logType: ERROR,
timestamp: Date.now()->Float.toString,
sessionId: "",
Expand All @@ -153,8 +153,8 @@ module ErrorCard = {
category: USER_ERROR,
paymentId: "",
merchantId: "",
browserName: OrcaLogger.arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others"),
browserVersion: OrcaLogger.arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"),
browserName: HyperLogger.arrayOfNameAndVersion->Array.get(0)->Option.getOr("Others"),
browserVersion: HyperLogger.arrayOfNameAndVersion->Array.get(1)->Option.getOr("0"),
platform: Window.Navigator.platform,
userAgent: Window.Navigator.userAgent,
appId: "",
Expand Down
Loading

0 comments on commit e32a6a3

Please sign in to comment.