Skip to content

Commit

Permalink
chore: update mixpanel details (#1684)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeevaRamu0104 authored Nov 11, 2024
1 parent b51680c commit aad2309
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
17 changes: 11 additions & 6 deletions src/screens/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ let useHandleLogout = () => {
let sessionExpired = ref(false)

let responseHandler = async (
~url,
~res,
~showToast: ToastState.showToastFn,
~showErrorToast: bool,
Expand All @@ -752,7 +753,7 @@ let responseHandler = async (
~email: string=?,
~description: option<'a>=?,
~section: string=?,
~metadata: Dict.t<'b>=?,
~metadata: JSON.t=?,
) => unit,
) => {
let json = try {
Expand All @@ -764,11 +765,13 @@ let responseHandler = async (
let responseStatus = res->Fetch.Response.status

if responseStatus >= 500 && responseStatus < 600 {
sendEvent(
~eventName="API Error",
~description=Some(responseStatus),
~metadata=json->getDictFromJsonObject,
)
let metaData =
[
("url", url->JSON.Encode.string),
("response", json),
("status", responseStatus->JSON.Encode.int),
]->getJsonFromArrayOfJson
sendEvent(~eventName="API Error", ~description=Some(responseStatus), ~metadata=metaData)
}

switch responseStatus {
Expand Down Expand Up @@ -880,6 +883,7 @@ let useGetMethod = (~showErrorToast=true) => {
try {
let res = await fetchApi(url, ~method_=Get, ~xFeatureRoute)
await responseHandler(
~url,
~res,
~showErrorToast,
~showToast,
Expand Down Expand Up @@ -940,6 +944,7 @@ let useUpdateMethod = (~showErrorToast=true) => {
~xFeatureRoute,
)
await responseHandler(
~url,
~res,
~showErrorToast,
~showToast,
Expand Down
2 changes: 1 addition & 1 deletion src/screens/GenerateReports/DownloadReportModal.res
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let make = (~reportModal, ~setReportModal, ~entityName) => {
endTime: lte,
},
}
let metadata = body->Identity.genericTypeToDictOfJson
let metadata = body->Identity.genericTypeToJson
mixpanelEvent(~eventName="generate_reports_download", ~metadata)
downloadReport(body->Identity.genericTypeToJson)
}
Expand Down
4 changes: 2 additions & 2 deletions src/screens/MixpanelHook.res
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let useSendEvent = () => {
~description,
~event,
~section,
~metadata=Dict.make(),
~metadata=JSON.Encode.null,
) => {
let mixpanel_token = Window.env.mixpanelToken

Expand Down Expand Up @@ -77,7 +77,7 @@ let useSendEvent = () => {
}
}

(~eventName, ~email="", ~description=None, ~section="", ~metadata=Dict.make()) => {
(~eventName, ~email="", ~description=None, ~section="", ~metadata=JSON.Encode.null) => {
let section = section->LogicUtils.isNonEmptyString ? section : getUrlEndpoint()
let eventName = eventName->String.toLowerCase

Expand Down
4 changes: 0 additions & 4 deletions src/utils/HyperSwitchUtils.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
let fetchRequestIdFromAPI = res => {
res->Fetch.Response.headers->Fetch.Headers.get("x-request-id")->Option.getOr("")
}

let getMixpanelRouteName = (pageTitle, url: RescriptReactRouter.url) => {
switch (url.path, url.search) {
| (list{"payments", ""}, _)
Expand Down

0 comments on commit aad2309

Please sign in to comment.