From 4f4ee6be28975b3060c955388f0536d2f6cea7ea Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja Date: Mon, 4 Nov 2024 16:02:59 +0530 Subject: [PATCH 1/2] fix: format function refactor for better logs readability (#757) --- src/Utilities/Utils.res | 54 ++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index 7cdbd5a5..1fdb25f1 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -20,8 +20,10 @@ type dateTimeFormat = {resolvedOptions: unit => options} open ErrorUtils +let getJsonFromArrayOfJson = arr => arr->Dict.fromArray->JSON.Encode.object + let messageWindow = (window, ~targetOrigin="*", messageArr) => { - window->postMessage(messageArr->Dict.fromArray->JSON.Encode.object, targetOrigin) + window->postMessage(messageArr->getJsonFromArrayOfJson, targetOrigin) } let messageTopWindow = (~targetOrigin="*", messageArr) => { @@ -317,13 +319,12 @@ let getFailedSubmitResponse = (~errorType, ~message) => { [ ( "error", - [("type", errorType->JSON.Encode.string), ("message", message->JSON.Encode.string)] - ->Dict.fromArray - ->JSON.Encode.object, + [ + ("type", errorType->JSON.Encode.string), + ("message", message->JSON.Encode.string), + ]->getJsonFromArrayOfJson, ), - ] - ->Dict.fromArray - ->JSON.Encode.object + ]->getJsonFromArrayOfJson } let toCamelCase = str => { @@ -385,8 +386,7 @@ let rec transformKeys = (json: JSON.t, to: case) => { } x }) - ->Dict.fromArray - ->JSON.Encode.object + ->getJsonFromArrayOfJson } let getClientCountry = clientTimeZone => { @@ -701,7 +701,7 @@ let handlePostMessageEvents = ( ("elementType", "payment"->JSON.Encode.string), ("complete", complete->JSON.Encode.bool), ("empty", empty->JSON.Encode.bool), - ("value", [("type", paymentType->JSON.Encode.string)]->Dict.fromArray->JSON.Encode.object), + ("value", [("type", paymentType->JSON.Encode.string)]->getJsonFromArrayOfJson), ]) } @@ -877,9 +877,32 @@ let arrayJsonToCamelCase = arr => { item->transformKeys(CamelCase) }) } -let formatException = exc => { - exc->Identity.anyTypeToJson -} + +let formatException = exc => + switch exc { + | Exn.Error(obj) => + let message = Exn.message(obj) + let name = Exn.name(obj) + let stack = Exn.stack(obj) + let fileName = Exn.fileName(obj) + + if ( + message->Option.isSome || + name->Option.isSome || + stack->Option.isSome || + fileName->Option.isSome + ) { + [ + ("message", message->Option.getOr("Unknown Error")->JSON.Encode.string), + ("type", name->Option.getOr("Unknown")->JSON.Encode.string), + ("stack", stack->Option.getOr("Unknown")->JSON.Encode.string), + ("fileName", fileName->Option.getOr("Unknown")->JSON.Encode.string), + ]->getJsonFromArrayOfJson + } else { + exc->Identity.anyTypeToJson + } + | _ => exc->Identity.anyTypeToJson + } let getArrayValFromJsonDict = (dict, key, arrayKey) => { dict @@ -999,8 +1022,7 @@ let mergeTwoFlattenedJsonDicts = (dict1, dict2) => { dict1 ->Dict.toArray ->Array.concat(dict2->Dict.toArray) - ->Dict.fromArray - ->JSON.Encode.object + ->getJsonFromArrayOfJson ->unflattenObject } @@ -1300,8 +1322,6 @@ let getIsWalletElementPaymentType = (paymentType: CardThemeType.mode) => { let getUniqueArray = arr => arr->Array.map(item => (item, ""))->Dict.fromArray->Dict.keysToArray -let getJsonFromArrayOfJson = arr => arr->Dict.fromArray->JSON.Encode.object - let getStateNameFromStateCodeAndCountry = (list: JSON.t, stateCode: string, country: string) => { let options = list From f1e63f1eb9044d91cb6f3a4e4c6ec03a582cc3ec Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 4 Nov 2024 10:34:50 +0000 Subject: [PATCH 2/2] chore(release): 0.98.5 [skip ci] ## [0.98.5](https://github.com/juspay/hyperswitch-web/compare/v0.98.4...v0.98.5) (2024-11-04) ### Bug Fixes * format function refactor for better logs readability ([#757](https://github.com/juspay/hyperswitch-web/issues/757)) ([4f4ee6b](https://github.com/juspay/hyperswitch-web/commit/4f4ee6be28975b3060c955388f0536d2f6cea7ea)) --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2931d316..dec68b12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [0.98.5](https://github.com/juspay/hyperswitch-web/compare/v0.98.4...v0.98.5) (2024-11-04) + + +### Bug Fixes + +* format function refactor for better logs readability ([#757](https://github.com/juspay/hyperswitch-web/issues/757)) ([4f4ee6b](https://github.com/juspay/hyperswitch-web/commit/4f4ee6be28975b3060c955388f0536d2f6cea7ea)) + ## [0.98.4](https://github.com/juspay/hyperswitch-web/compare/v0.98.3...v0.98.4) (2024-10-30) diff --git a/package-lock.json b/package-lock.json index 420aebec..c2ec3289 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "orca-payment-page", - "version": "0.98.4", + "version": "0.98.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "orca-payment-page", - "version": "0.98.4", + "version": "0.98.5", "hasInstallScript": true, "dependencies": { "@glennsl/rescript-fetch": "^0.2.0", diff --git a/package.json b/package.json index a1924ab4..f7491131 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orca-payment-page", - "version": "0.98.4", + "version": "0.98.5", "main": "index.js", "private": true, "dependencies": {