NTP-8444 | NAP Phase 2 | OE for GI (#13693)
Co-authored-by: shrihari-raju_navi <shrihari.raju@navi.com> Co-authored-by: Kshitij Pramod Ghongadi <kshitij.pramod@navi.com>
This commit is contained in:
@@ -24,6 +24,7 @@ export const getBenefitPageData = async (
|
||||
setScreenData: Dispatch<SetStateAction<ScreenData | null>>,
|
||||
) => {
|
||||
const url = "benefits/v2";
|
||||
const startTime = Date.now();
|
||||
const cacheKey = buildUrlWithParams(url, screenMetaData.data);
|
||||
const cachePromise = getScreenDataFromCache(cacheKey);
|
||||
const apiPromise = get<ApiResponse<CtaData>>(
|
||||
@@ -60,6 +61,7 @@ export const getBenefitPageData = async (
|
||||
screenMetaData,
|
||||
AnalyticsFlowNameConstant.GI_RN_BENEFIT,
|
||||
AnalyticsMethodNameConstant.FETCH_BENEFIT_LIST,
|
||||
startTime,
|
||||
);
|
||||
isScreenLoaded = true;
|
||||
} else {
|
||||
|
||||
@@ -22,6 +22,7 @@ export const getMarketBenefitComparePageData = async (
|
||||
setScreenData: Dispatch<SetStateAction<ScreenData | null>>,
|
||||
) => {
|
||||
const url = "market-benefit-compare";
|
||||
const startTime = Date.now();
|
||||
const cachePromise = getScreenDataFromCache(url);
|
||||
const apiPromise = get<ApiResponse<CtaData>>(
|
||||
url,
|
||||
@@ -56,6 +57,7 @@ export const getMarketBenefitComparePageData = async (
|
||||
screenMetaData,
|
||||
AnalyticsFlowNameConstant.GI_RN_BENEFIT_COMPARE,
|
||||
AnalyticsMethodNameConstant.MARKET_BENEFIT_COMPARE_LIST,
|
||||
startTime,
|
||||
);
|
||||
isScreenLoaded = true;
|
||||
} else {
|
||||
|
||||
@@ -37,6 +37,7 @@ export const createQuote = async (
|
||||
"X-Target": GI.toLocaleUpperCase(),
|
||||
},
|
||||
};
|
||||
const startTime = Date.now();
|
||||
return post<ApiResponse<CtaData>>(url, screenMetaData.data, requestConfig)
|
||||
.then(response => {
|
||||
if (response) {
|
||||
@@ -66,6 +67,7 @@ export const createQuote = async (
|
||||
screenMetaData,
|
||||
AnalyticsFlowNameConstant.GI_RN_QUOTE,
|
||||
AnalyticsMethodNameConstant.FETCH_QUOTE_V4,
|
||||
startTime,
|
||||
);
|
||||
});
|
||||
};
|
||||
@@ -88,6 +90,7 @@ export const getQuotePageData = async (
|
||||
},
|
||||
};
|
||||
const url = `v3/quotes/${quoteId}`;
|
||||
const startTime = Date.now();
|
||||
return get<ApiResponse<CtaData>>(url, requestConfig, screenMetaData.data)
|
||||
.then(response => {
|
||||
handleResponseData(setScreenData, response);
|
||||
@@ -99,6 +102,7 @@ export const getQuotePageData = async (
|
||||
screenMetaData,
|
||||
AnalyticsFlowNameConstant.GI_RN_QUOTE,
|
||||
AnalyticsMethodNameConstant.FETCH_INSURANCE_QUOTE_PAGE_FROM_BACKEND,
|
||||
startTime,
|
||||
);
|
||||
});
|
||||
};
|
||||
@@ -119,6 +123,7 @@ export const fetchComparisonPlanList = async (
|
||||
screenMetaData: ActionMetaData,
|
||||
setScreenData: Dispatch<SetStateAction<ScreenData | null>>,
|
||||
) => {
|
||||
const startTime = Date.now();
|
||||
return post<ApiResponse<CtaData>>(
|
||||
"quotes/compare-plans",
|
||||
screenMetaData.data,
|
||||
@@ -138,6 +143,7 @@ export const fetchComparisonPlanList = async (
|
||||
screenMetaData,
|
||||
AnalyticsFlowNameConstant.GI_RN_QUOTE,
|
||||
AnalyticsMethodNameConstant.COMPARE_PLAN_LIST,
|
||||
startTime,
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@ export const getWaitingPeriodScreenData = async (
|
||||
setScreenData: Dispatch<SetStateAction<ScreenData | null>>,
|
||||
) => {
|
||||
const url = "waiting-period";
|
||||
const startTime = Date.now();
|
||||
const cachePromise = getScreenDataFromCache(url);
|
||||
const apiPromise = get<ApiResponse<CtaData>>(
|
||||
url,
|
||||
@@ -56,6 +57,7 @@ export const getWaitingPeriodScreenData = async (
|
||||
screenMetaData,
|
||||
AnalyticsFlowNameConstant.GI_WAITING_PERIOD,
|
||||
AnalyticsMethodNameConstant.WAITING_PERIOD_SCREEN,
|
||||
startTime,
|
||||
);
|
||||
isScreenLoaded = true;
|
||||
} else {
|
||||
|
||||
@@ -34,7 +34,7 @@ export enum BundleState {
|
||||
}
|
||||
|
||||
export const CODEPUSH_METHOD = "onCodepushStatusChange";
|
||||
export const ERROR_TITLE = "Something went wrong";
|
||||
export const ERROR_TITLE = "Something went wrong!";
|
||||
export const ERROR_INTERNET_TITLE = "No internet connection!";
|
||||
export const ERROR_SUBTITLE = "Please try again after some time";
|
||||
export const ERROR_INTERNET_SUBTITLE =
|
||||
|
||||
@@ -71,6 +71,9 @@ export const sendAsGlobalErrorEvent = (event: GlobalErrorData) => {
|
||||
extras = null,
|
||||
journeySource = null,
|
||||
isAppDowntimeEvent = null,
|
||||
errorCode = null,
|
||||
errorTitle = null,
|
||||
latency = null,
|
||||
} = event;
|
||||
|
||||
const updatedSource = moduleName + "_" + REACT_NATIVE + "_" + source;
|
||||
@@ -88,6 +91,9 @@ export const sendAsGlobalErrorEvent = (event: GlobalErrorData) => {
|
||||
extras,
|
||||
journeySource,
|
||||
isAppDowntimeEvent,
|
||||
errorCode,
|
||||
errorTitle,
|
||||
latency,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
interface GlobalErrorData {
|
||||
reason?: string | null;
|
||||
source?: string | null;
|
||||
moduleName: string;
|
||||
globalErrorType: string;
|
||||
statusCode?: number | null;
|
||||
networkType?: string | null;
|
||||
flowName?: string | null;
|
||||
methodName?: string | null;
|
||||
vendorName?: string | null;
|
||||
extras?: Map<string, string> | null;
|
||||
journeySource?: string | null;
|
||||
isAppDowntimeEvent?: boolean | null;
|
||||
}
|
||||
reason?: string | null;
|
||||
source?: string | null;
|
||||
moduleName: string;
|
||||
globalErrorType: string;
|
||||
statusCode?: number | null;
|
||||
networkType?: string | null;
|
||||
flowName?: string | null;
|
||||
methodName?: string | null;
|
||||
vendorName?: string | null;
|
||||
extras?: Map<string, string> | null;
|
||||
journeySource?: string | null;
|
||||
isAppDowntimeEvent?: boolean | null;
|
||||
latency?: number | null;
|
||||
errorCode?: string | null;
|
||||
errorTitle?: string | null;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@ import {
|
||||
sendAsGlobalErrorEvent,
|
||||
} from "../hooks/useAnalyticsEvent";
|
||||
import { ScreenData } from "../interface/widgets/screenData/ScreenData";
|
||||
import { getErrorTypeFromStatusCode } from "../utilities/ErrorUtils";
|
||||
import {
|
||||
getErrorTitleFromError,
|
||||
getErrorTypeFromStatusCode,
|
||||
} from "../utilities/ErrorUtils";
|
||||
import { ScreenState } from "./BaseScreen";
|
||||
import { ScreenActionTypes } from "./ScreenActionTypes";
|
||||
|
||||
@@ -79,6 +82,7 @@ export const handleErrorData = (
|
||||
screenMetaData: ActionMetaData,
|
||||
flowName: string,
|
||||
methodName: string,
|
||||
startTime: number,
|
||||
) => {
|
||||
sendAsAnalyticsEvent({
|
||||
name: AnalyticsEventNameConstants.HI_RN_INVALID_DATA_ERROR,
|
||||
@@ -88,6 +92,7 @@ export const handleErrorData = (
|
||||
methodName: "handleScreenAction",
|
||||
},
|
||||
});
|
||||
const latency = Date.now() - startTime;
|
||||
const errorEvent: GlobalErrorData = {
|
||||
reason: `${error.message}, axiosError: ${error.axiosCode}`,
|
||||
source: screenMetaData.screenName || "",
|
||||
@@ -97,6 +102,9 @@ export const handleErrorData = (
|
||||
methodName: methodName,
|
||||
globalErrorType: getErrorTypeFromStatusCode(error.statusCode || -1),
|
||||
isAppDowntimeEvent: false,
|
||||
errorCode: error.axiosCode,
|
||||
errorTitle: getErrorTitleFromError(error.statusCode || -1),
|
||||
latency: latency,
|
||||
};
|
||||
sendAsGlobalErrorEvent(errorEvent);
|
||||
const updatedScreenData: ScreenData = {
|
||||
|
||||
@@ -19,6 +19,16 @@ export const getErrorTypeFromStatusCode = (statusCode: number) => {
|
||||
return AnalyticsGlobalErrorTypeConstant.GLOBAL_INTERNAL_ERRORS;
|
||||
};
|
||||
|
||||
export const getErrorTitleFromError = (statusCode: number) => {
|
||||
const statusCodeforInternetIssues = [20, 21, 23, 24];
|
||||
|
||||
if (statusCodeforInternetIssues.includes(statusCode)) {
|
||||
return ERROR_INTERNET_TITLE;
|
||||
}
|
||||
|
||||
return ERROR_TITLE;
|
||||
};
|
||||
|
||||
export const getErrorResponseFromStatusCode = (
|
||||
statusCode?: number,
|
||||
): ErrorResponse => {
|
||||
|
||||
Reference in New Issue
Block a user