diff --git a/App.tsx b/App.tsx index e81750d5f8..cd72e54c45 100644 --- a/App.tsx +++ b/App.tsx @@ -1,8 +1,9 @@ -import { init } from "@sentry/react-native"; import { Component } from "react"; import codePush from "react-native-code-push"; import { GenericErrorScreen } from "./App/Container/Navi-Insurance"; import { + AnalyticsEventNameConstants, + BASE_SCREEN, BundleState, CODEPUSH_METHOD, EVENT_NAMES, @@ -11,7 +12,6 @@ import { SentryConstants, } from "./App/common/constants"; import { sendAsAnalyticsEvent } from "./App/common/hooks/useAnalyticsEvent"; -import { logToSentry } from "./App/common/hooks/useSentryLogging"; import { CtaData } from "./App/common/interface"; import RnApp from "./App/common/navigator/RnAppCreator"; import { @@ -23,11 +23,6 @@ import { setStringPreference, } from "./App/common/utilities/SharedPreferenceUtils"; -init({ - dsn: SentryConstants.SENTRY_DSN, - environment: SentryConstants.SENTRY_ENVIRONMENT_PRODUCTION, -}); - interface AppState { bundleState: BundleState; } @@ -78,9 +73,14 @@ export default class App extends Component<{}, AppState> { case codePush.SyncStatus.UPDATE_IGNORED: this.setState({ bundleState: BundleState.LOADED }); storeBundleStatus(BundleState.LOADED); - logToSentry( - `Codepush Ignored | Status: ${status} | MethodName: ${CODEPUSH_METHOD}`, - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_CODEPUSH_ERROR, + properties: { + errorType: EVENT_NAMES.CODEPUSH_IGNORED_ERROR, + error: `${status}`, + methodName: `${CODEPUSH_METHOD}`, + }, + }); break; case codePush.SyncStatus.UNKNOWN_ERROR: this.setState({ bundleState: BundleState.ERROR }); @@ -90,9 +90,14 @@ export default class App extends Component<{}, AppState> { [EVENT_PROPERTY_KEYS.STATUS]: EVENT_PROPERTY_VALUES.UNKNOWN_ERROR, }, }); - logToSentry( - `Codepush Failed | Status: ${status} | MethodName: ${CODEPUSH_METHOD}`, - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_CODEPUSH_ERROR, + properties: { + errorType: EVENT_NAMES.CODEPUSH_FAILED_ERROR, + error: `${status}`, + methodName: `${CODEPUSH_METHOD}`, + }, + }); break; default: this.setState({ bundleState: BundleState.LOADED }); @@ -112,9 +117,14 @@ export default class App extends Component<{}, AppState> { const { CtaData } = this.props as any; if (!CtaData) { - logToSentry( - `CtaData is missing or invalid: ${CtaData} | MethodName: getInitialCta`, - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_INVALID_SCREEN_CTA, + properties: { + errorType: EVENT_NAMES.CTA_MISSING_ERROR, + error: `${CtaData}`, + methodName: "getInitialCta", + }, + }); return; } @@ -122,9 +132,14 @@ export default class App extends Component<{}, AppState> { const cta = JSON.parse(CtaData) as CtaData; return cta; } catch (error) { - logToSentry( - `Error parsing CtaData: ${CtaData} | Error: ${error} | MethodName: getInitialCta`, - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_INVALID_SCREEN_CTA, + properties: { + errorType: EVENT_NAMES.CTA_PARSING_ERROR, + error: `${error}`, + methodName: "getInitialCta", + }, + }); return; } }; diff --git a/App/common/constants/AnalyticsEventsConstant.ts b/App/common/constants/AnalyticsEventsConstant.ts index 2a2bc91cf2..4b3432cc16 100644 --- a/App/common/constants/AnalyticsEventsConstant.ts +++ b/App/common/constants/AnalyticsEventsConstant.ts @@ -10,10 +10,18 @@ export const AnalyticsEventNameConstants = { HI_RN_WAITING_PERIOD_PAGE_INIT: "hi_rn_waiting_period_page_init", HI_RN_WAITING_PERIOD_PAGE_ERROR_VIEW: "hi_rn_waiting_period_page_error_view", PATCH_QUOTE_V2: "patch_quote_v2", - HI_INVALID_SCREEN_CTA: "hi_invalid_screen_cta", HI_RN_BENEFIT_INIT: "hi_rn_benefit_init", HI_RN_BENEFIT_ERROR_VIEW: "hi_rn_benefit_error_view", HI_RN_BENEFIT_LOADED_VIEW: "hi_rn_benefit_loaded_view", + + // Sentry Events + HI_INVALID_SCREEN_CTA: "hi_invalid_screen_cta", + HI_RN_CODEPUSH_ERROR: "hi_rn_codepush_error", + HI_RN_NAVIGATION_ERROR: "hi_rn_navigation_error", + HI_RN_PAYLOAD_ERROR: "hi_rn_payload_error", + HI_RN_INVALID_DATA_ERROR: "hi_rn_invalid_data_error", + HI_RN_INVALID_JSON_ERROR: "hi_rn_invalid_json_error", + HI_RN_INVALID_ARITHMETIC_ERROR: "hi_rn_invalid_arithmetic_error", }; export const AnalyticsEventPropertyConstants = { @@ -57,6 +65,19 @@ export const EVENT_NAMES = { CODEPUSH_FETCH_ERROR: "codepush_fetch_error", SCREEN_LOAD_TIME: "react_screen_load_time", INVALID_SCREEN_CTA: "invalid_screen_cta", + CTA_MISSING_ERROR: "cta_missing_error", + CTA_PARSING_ERROR: "cta_parsing_error", + CTA_NAVIGATION_ERROR: "cta_navigation_error", + CODEPUSH_IGNORED_ERROR: "codepush_ignored_error", + CODEPUSH_FAILED_ERROR: "codepush_failed_error", + BASE_ACTION_TYPE_INVALID_ERROR: "base_action_type_invalid_error", + ACTION_PAYLOAD_MISSING_ERROR: "action_payload_missing_error", + API_NO_RESPONSE_ERROR: "api_no_response_error", + KEY_PATH_INVALID_ERROR: "key_path_invalid_error", + ARITHMETIC_ERROR: "arithmetic_error", + SHARED_PREFERENCE_KEY_ERROR: "shared_preference_key_error", + JSON_PARSING_ERROR: "json_parsing_error", + INVALID_TARGET_TYPE_ERROR: "invalid_target_type_error", }; export const EVENT_PROPERTY_KEYS = { diff --git a/App/common/hooks/useSentryLogging.ts b/App/common/hooks/useSentryLogging.ts deleted file mode 100644 index f9651ac0e1..0000000000 --- a/App/common/hooks/useSentryLogging.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { captureException } from "@sentry/react-native"; - -export const logToSentry = (message: string) => { - captureException(new Error(message)); -}; \ No newline at end of file diff --git a/App/common/navigator/NavigationRouter.ts b/App/common/navigator/NavigationRouter.ts index 898a259bc0..5955260e8e 100644 --- a/App/common/navigator/NavigationRouter.ts +++ b/App/common/navigator/NavigationRouter.ts @@ -5,10 +5,14 @@ import { GenericActionPayload, } from "../actions/GenericAction"; import { BASE_SCREEN } from "../constants/ScreenNameConstants"; -import { logToSentry } from "../hooks/useSentryLogging"; -import { BaseNavigator } from "../interface"; +import { sendAsAnalyticsEvent } from "../hooks/useAnalyticsEvent"; +import { BaseNavigator, NavigationType } from "../interface"; import { ScreenActionHandler } from "../screen/ScreenActionHandler"; import WidgetActionHandler from "../widgets/widget-actions/WidgetActionHandler"; +import { + AnalyticsEventNameConstants, + EVENT_NAMES, +} from "../constants/AnalyticsEventsConstant"; export const CtaNavigator: BaseNavigator = { navigate: (navigationRef, ctaData) => { @@ -62,9 +66,14 @@ export const Router = { break; } default: { - logToSentry( - `Invalid baseActionType ${actionPayload.baseActionType} | MethodName: Router.handleAction`, - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_NAVIGATION_ERROR, + properties: { + errorType: EVENT_NAMES.BASE_ACTION_TYPE_INVALID_ERROR, + error: `${actionPayload.baseActionType}`, + methodName: "Router.handleAction", + }, + }); break; } } diff --git a/App/common/screen/BaseScreen.tsx b/App/common/screen/BaseScreen.tsx index 558a7f8df8..d8cda33760 100644 --- a/App/common/screen/BaseScreen.tsx +++ b/App/common/screen/BaseScreen.tsx @@ -6,7 +6,6 @@ import { commonStyles } from "../../Container/Navi-Insurance/Styles"; import { ActionMetaData, GenericActionPayload } from "../actions/GenericAction"; import { sendAsAnalyticsEvent } from "../hooks/useAnalyticsEvent"; import { useBottomSheet } from "../hooks/useBottomSheet"; -import { logToSentry } from "../hooks/useSentryLogging"; import { CtaData } from "../interface"; import { ModalView } from "../interface/modals/ModalView"; import { ScreenData } from "../interface/widgets/screenData/ScreenData"; @@ -26,6 +25,12 @@ import { import { WidgetActionTypes } from "../widgets/widget-actions/WidgetActionTypes"; import { ScreenMapper } from "./screen-mappers/ScreenMapper"; import useScreenLoadTime from "../hooks/useScreenLoadTime"; +import { + AnalyticsEventNameConstants, + BASE_SCREEN, + EVENT_NAMES, + CODEPUSH_METHOD, +} from "../constants"; const BaseScreen: React.FC<{ navigation: any; route: any }> = ({ navigation, @@ -134,9 +139,15 @@ const BaseScreen: React.FC<{ navigation: any; route: any }> = ({ Router.handleAction(updatedActionPayload, navigation); } else { // handle error - logToSentry( - `Action payload is missing or invalid: ${actionPayload} | MethodName: handleActions`, - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_PAYLOAD_ERROR, + properties: { + screenName: BASE_SCREEN, + errorType: EVENT_NAMES.ACTION_PAYLOAD_MISSING_ERROR, + error: `${actionPayload}`, + methodName: "handleActions", + }, + }); } }; diff --git a/App/common/screen/ScreenActionHandler.tsx b/App/common/screen/ScreenActionHandler.tsx index 9ddee892cf..0de2eb0c80 100644 --- a/App/common/screen/ScreenActionHandler.tsx +++ b/App/common/screen/ScreenActionHandler.tsx @@ -8,9 +8,16 @@ import { getWaitingPeriodScreenData, } from "../../Container/Navi-Insurance/network"; import { ActionMetaData, BaseActionTypes } from "../actions/GenericAction"; -import { AnalyticsModuleNameConstant } from "../constants"; -import { sendAsGlobalErrorEvent } from "../hooks/useAnalyticsEvent"; -import { logToSentry } from "../hooks/useSentryLogging"; +import { + AnalyticsEventNameConstants, + AnalyticsModuleNameConstant, + BASE_SCREEN, + EVENT_NAMES, +} from "../constants"; +import { + sendAsAnalyticsEvent, + sendAsGlobalErrorEvent, +} from "../hooks/useAnalyticsEvent"; import { ScreenData } from "../interface/widgets/screenData/ScreenData"; import { getErrorTypeFromStatusCode } from "../utilities/ErrorUtils"; import { ScreenState } from "./BaseScreen"; @@ -79,9 +86,14 @@ export const handleErrorData = ( flowName: string, methodName: string, ) => { - logToSentry( - `No response from api call: ${screenMetaData.actionType} | Error: ${error} | MethodName: handleScreenAction`, - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_DATA_ERROR, + properties: { + errorType: EVENT_NAMES.API_NO_RESPONSE_ERROR, + error: `${error}`, + methodName: "handleScreenAction", + }, + }); const errorEvent: GlobalErrorData = { reason: `${error.message}, axiosError: ${error.axiosCode}`, source: screenMetaData.screenName || "", diff --git a/App/common/screen/screen-mappers/GIScreenMapper.tsx b/App/common/screen/screen-mappers/GIScreenMapper.tsx index 3c2142a274..855e41051a 100644 --- a/App/common/screen/screen-mappers/GIScreenMapper.tsx +++ b/App/common/screen/screen-mappers/GIScreenMapper.tsx @@ -9,18 +9,21 @@ import { } from "../../../Container/Navi-Insurance"; import { GenericActionPayload } from "../../actions/GenericAction"; import { + AnalyticsEventNameConstants, + BASE_SCREEN, BENEFIT_SCREEN, BUY_INSURANCE_SCREEN, COMPARE_PLAN_SCREEN, + EVENT_NAMES, MARKET_BENEFITS_COMPARE_SCREEN, QUOTE_APOLOGY_SCREEN, QUOTE_OFFER_SCREEN, WAITING_PERIOD_SCREEN, } from "../../constants"; -import { logToSentry } from "../../hooks/useSentryLogging"; import { CtaData } from "../../interface"; import { ScreenData } from "../../interface/widgets/screenData/ScreenData"; import { getScreenNameFromCtaData } from "../../utilities/MiscUtils"; +import { sendAsAnalyticsEvent } from "../../hooks/useAnalyticsEvent"; export const GIScreenMapper = { getScreen( @@ -85,9 +88,14 @@ export const GIScreenMapper = { } } } else { - logToSentry( - `CtaData is missing or invalid: ${ctaData} | MethodName: GIScreenMapper.getScreen`, - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_INVALID_SCREEN_CTA, + properties: { + errorType: EVENT_NAMES.CTA_MISSING_ERROR, + error: `${ctaData}`, + methodName: "GIScreenMapper.getScreen", + }, + }); return ; } }, diff --git a/App/common/screen/screen-mappers/ScreenMapper.tsx b/App/common/screen/screen-mappers/ScreenMapper.tsx index fa4775d499..7d943d688d 100644 --- a/App/common/screen/screen-mappers/ScreenMapper.tsx +++ b/App/common/screen/screen-mappers/ScreenMapper.tsx @@ -6,7 +6,12 @@ import { getScreenMapperNameFromCtaData } from "../../utilities/MiscUtils"; import { commonStyles } from "../../../Container/Navi-Insurance/Styles"; import { GIScreenMapper } from "./GIScreenMapper"; import { GI } from "../../constants/NavigationHandlerConstants"; -import { logToSentry } from "../../hooks/useSentryLogging"; +import { + AnalyticsEventNameConstants, + BASE_SCREEN, + EVENT_NAMES, +} from "../../constants"; +import { sendAsAnalyticsEvent } from "../../hooks/useAnalyticsEvent"; export const ScreenMapper = { getScreenMapper( @@ -27,9 +32,14 @@ export const ScreenMapper = { return ; } } else { - logToSentry( - `CtaData is missing or invalid: ${ctaData} | MethodName: ScreenMapper.getScreen` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_INVALID_SCREEN_CTA, + properties: { + errorType: EVENT_NAMES.CTA_MISSING_ERROR, + error: `${ctaData}`, + methodName: "ScreenMapper.getScreen", + }, + }); return ; } }, diff --git a/App/common/utilities/MiscUtils.ts b/App/common/utilities/MiscUtils.ts index e57e50e990..9ad76ebb45 100644 --- a/App/common/utilities/MiscUtils.ts +++ b/App/common/utilities/MiscUtils.ts @@ -1,6 +1,11 @@ import { CtaData } from "../interface"; -import { logToSentry } from "../hooks/useSentryLogging"; import { SPACE_UNICODE } from "../constants/StringConstant"; +import { + AnalyticsEventNameConstants, + BASE_SCREEN, + EVENT_NAMES, +} from "../constants"; +import { sendAsAnalyticsEvent } from "../hooks/useAnalyticsEvent"; export function getScreenNameFromCtaData(ctaData: CtaData): string | undefined { const splitDeeplink = ctaData.url?.split("/"); @@ -8,7 +13,7 @@ export function getScreenNameFromCtaData(ctaData: CtaData): string | undefined { } export function getScreenMapperNameFromCtaData( - ctaData: CtaData + ctaData: CtaData, ): string | undefined { const splitDeeplink = ctaData.url?.split("/"); return splitDeeplink?.at(1); @@ -17,7 +22,7 @@ export function getScreenMapperNameFromCtaData( export function updateValueByKeyPath( obj: T, keyPath?: string, - newValue?: any + newValue?: any, ): void { if (!keyPath || !newValue) { return; @@ -34,9 +39,14 @@ export function updateValueByKeyPath( ) { currentObj = currentObj[key]; } else { - logToSentry( - `Key path not valid: ${keyPath} | Faulty key: ${key} | MethodName: ${arguments.callee.name}` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_DATA_ERROR, + properties: { + errorType: EVENT_NAMES.KEY_PATH_INVALID_ERROR, + error: `${keyPath}`, + methodName: `${arguments.callee.name}`, + }, + }); return; } } @@ -47,9 +57,14 @@ export function updateValueByKeyPath( try { currentObj[lastKey] = newValue; } catch (exception) { - logToSentry( - `Key path not valid: ${keyPath} | Faulty key: ${lastKey} | MethodName: ${arguments.callee.name}` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_DATA_ERROR, + properties: { + errorType: EVENT_NAMES.KEY_PATH_INVALID_ERROR, + error: `${keyPath}`, + methodName: `${arguments.callee.name}`, + }, + }); } } } diff --git a/App/common/utilities/SerializerUtil.ts b/App/common/utilities/SerializerUtil.ts index ad98a4e41f..3346e0e1bf 100644 --- a/App/common/utilities/SerializerUtil.ts +++ b/App/common/utilities/SerializerUtil.ts @@ -1,4 +1,9 @@ -import { logToSentry } from "../hooks/useSentryLogging"; +import { + AnalyticsEventNameConstants, + BASE_SCREEN, + EVENT_NAMES, +} from "../constants"; +import { sendAsAnalyticsEvent } from "../hooks/useAnalyticsEvent"; export function parseValue(value: any, targetType: string): any | null { if (targetType === "string") { @@ -10,34 +15,36 @@ export function parseValue(value: any, targetType: string): any | null { try { return JSON.parse(value); } catch (error) { - logToSentry( - `Error parsing JSON: ${value} | Error: ${error} | MethodName: ${arguments.callee.name}` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_JSON_ERROR, + properties: { + errorType: EVENT_NAMES.JSON_PARSING_ERROR, + error: `${error}`, + methodName: `${arguments.callee.name}`, + }, + }); return null; } } else { - logToSentry( - `Value is not a string; cannot parse as object: ${value} | MethodName: ${arguments.callee.name}` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_JSON_ERROR, + properties: { + errorType: EVENT_NAMES.JSON_PARSING_ERROR, + error: `${value}`, + methodName: `${arguments.callee.name}`, + }, + }); return null; } } else { - logToSentry( - `Invalid targetType: ${targetType} | MethodName: ${arguments.callee.name}` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_JSON_ERROR, + properties: { + errorType: EVENT_NAMES.INVALID_TARGET_TYPE_ERROR, + error: `${targetType}`, + methodName: `${arguments.callee.name}`, + }, + }); return null; } } - -// Usage examples: -// const stringValue: string = '123'; -// const numberValue: number = 456; -// const objectValue: string = '{"key": "value"}'; - -// const parsedString: string = parseValue(stringValue, 'string'); -// const parsedNumber: number = parseValue(numberValue, 'number'); -// const parsedObject: object | null = parseValue(objectValue, 'object'); - -// console.log(parsedString); // "123" -// console.log(parsedNumber); // 456 -// console.log(parsedObject); // { key: 'value' } \ No newline at end of file diff --git a/App/common/utilities/SharedPreferenceUtils.ts b/App/common/utilities/SharedPreferenceUtils.ts index f80167206d..5bdc87974b 100644 --- a/App/common/utilities/SharedPreferenceUtils.ts +++ b/App/common/utilities/SharedPreferenceUtils.ts @@ -1,17 +1,27 @@ -import { logToSentry } from "../hooks/useSentryLogging"; +import { + AnalyticsEventNameConstants, + BASE_SCREEN, + EVENT_NAMES, +} from "../constants"; +import { sendAsAnalyticsEvent } from "../hooks/useAnalyticsEvent"; import { PreferenceManagerConnector } from "../native-module/NativeModules"; export const getStringPreference = async ( key: string, - type: string = "string" + type: string = "string", ) => { try { const data = await PreferenceManagerConnector.get(key, type); return data; } catch (error) { - logToSentry( - `Error getting data for key: ${key}, type: ${type} | Error: ${error} | MethodName: getStringPreference` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_DATA_ERROR, + properties: { + errorType: EVENT_NAMES.SHARED_PREFERENCE_KEY_ERROR, + error: `${error}`, + methodName: "getStringPreference", + }, + }); return null; } }; @@ -24,9 +34,14 @@ export const setStringPreference = (key: string, preferenceData: string) => { const data = PreferenceManagerConnector.setString(key, preferenceData); return data; } catch (error) { - logToSentry( - `Error setting data for key: ${key}, type: ${preferenceData} | Error: ${error} | MethodName: setStringPreference` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_DATA_ERROR, + properties: { + errorType: EVENT_NAMES.SHARED_PREFERENCE_KEY_ERROR, + error: `${error}`, + methodName: "setStringPreference", + }, + }); return null; } }; @@ -39,9 +54,14 @@ export const setIntPreference = (key: string, preferenceData: number) => { const data = PreferenceManagerConnector.setInt(key, preferenceData); return data; } catch (error) { - logToSentry( - `Error setting data for key: ${key}, type: ${preferenceData} | Error: ${error} | MethodName: setStringPreference` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_DATA_ERROR, + properties: { + errorType: EVENT_NAMES.SHARED_PREFERENCE_KEY_ERROR, + error: `${error}`, + methodName: "setIntPreference", + }, + }); return null; } }; @@ -54,9 +74,14 @@ export const setBooleanPreference = (key: string, preferenceData: boolean) => { const data = PreferenceManagerConnector.setBoolean(key, preferenceData); return data; } catch (error) { - logToSentry( - `Error setting data for key: ${key}, type: ${preferenceData} | Error: ${error} | MethodName: setStringPreference` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_DATA_ERROR, + properties: { + errorType: EVENT_NAMES.SHARED_PREFERENCE_KEY_ERROR, + error: `${error}`, + methodName: "setBooleanPreference", + }, + }); return null; } }; @@ -66,9 +91,14 @@ export const getIntPreference = async (key: string, type: string = "int") => { const data = await PreferenceManagerConnector.get(key, type); return data; } catch (error) { - logToSentry( - `Error getting data for key: ${key}, type: ${type} | Error: ${error} | MethodName: getIntPreference` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_DATA_ERROR, + properties: { + errorType: EVENT_NAMES.SHARED_PREFERENCE_KEY_ERROR, + error: `${error}`, + methodName: "getIntPreference", + }, + }); return null; } }; diff --git a/App/common/utilities/SizeUtils.ts b/App/common/utilities/SizeUtils.ts index 793196da21..e1f3b53a0b 100644 --- a/App/common/utilities/SizeUtils.ts +++ b/App/common/utilities/SizeUtils.ts @@ -1,5 +1,10 @@ import { PixelRatio } from "react-native"; -import { logToSentry } from "../hooks/useSentryLogging"; +import { + AnalyticsEventNameConstants, + BASE_SCREEN, + EVENT_NAMES, +} from "../constants"; +import { sendAsAnalyticsEvent } from "../hooks/useAnalyticsEvent"; export const getSizeInPx = (size: number) => { return PixelRatio.getPixelSizeForLayoutSize(size); @@ -7,9 +12,14 @@ export const getSizeInPx = (size: number) => { export const getIndexFromOffset = (offset: number, SIZE: number) => { if (SIZE === 0) { - logToSentry( - `Division by zero, offset: ${offset} | MethodName: getIndexFromOffset` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_ARITHMETIC_ERROR, + properties: { + errorType: EVENT_NAMES.ARITHMETIC_ERROR, + error: `${offset}`, + methodName: "getIndexFromOffset", + }, + }); } return Math.abs(Math.round(offset / SIZE)); }; diff --git a/App/common/widgets/widget-actions/WidgetActionHandler.ts b/App/common/widgets/widget-actions/WidgetActionHandler.ts index e32de2cd1e..174e5e2d7c 100644 --- a/App/common/widgets/widget-actions/WidgetActionHandler.ts +++ b/App/common/widgets/widget-actions/WidgetActionHandler.ts @@ -13,12 +13,12 @@ import { AnalyticsFlowNameConstant, AnalyticsMethodNameConstant, AnalyticsModuleNameConstant, + EVENT_NAMES, } from "../../constants/AnalyticsEventsConstant"; import { sendAsAnalyticsEvent, sendAsGlobalErrorEvent, } from "../../hooks/useAnalyticsEvent"; -import { logToSentry } from "../../hooks/useSentryLogging"; import { AnalyticsEvent, CtaData } from "../../interface"; import { ScreenData } from "../../interface/widgets/screenData/ScreenData"; import { FinalPatchCallRequestBody } from "../../interface/widgets/widgetData/FooterWithCardWidgetData"; @@ -34,6 +34,7 @@ import { getErrorTypeFromStatusCode } from "../../utilities/ErrorUtils"; import { updateValueByKeyPath } from "../../utilities/MiscUtils"; import { parseValue } from "../../utilities/SerializerUtil"; import { WidgetActionTypes } from "./WidgetActionTypes"; +import { BASE_SCREEN } from "../../constants"; const WidgetActionHandler = { handleWidgetAction: ( @@ -278,9 +279,14 @@ const handleErrorData = ( methodName: string, screenData?: ScreenData | null, ) => { - logToSentry( - `No response from api call: ${widgetMetaData.actionType} | Error: ${error} | MethodName: handleWidgetAction}`, - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_RN_INVALID_DATA_ERROR, + properties: { + errorType: EVENT_NAMES.API_NO_RESPONSE_ERROR, + error: `${widgetMetaData.actionType}`, + methodName: "handleWidgetAction", + }, + }); const errorEvent: GlobalErrorData = { reason: `${error.message}, axiosError: ${error.axiosCode}`, source: widgetMetaData.screenName || "", diff --git a/components/widgets/sum-insured-carousel-widget/SumInsuredWidget.tsx b/components/widgets/sum-insured-carousel-widget/SumInsuredWidget.tsx index d3cf418dde..2bc85460cd 100644 --- a/components/widgets/sum-insured-carousel-widget/SumInsuredWidget.tsx +++ b/components/widgets/sum-insured-carousel-widget/SumInsuredWidget.tsx @@ -10,13 +10,14 @@ import { GenericActionPayload } from "../../../App/common/actions/GenericAction" import { AnalyticsEventNameConstants, AnalyticsEventPropertyConstants, + EVENT_NAMES, } from "../../../App/common/constants/AnalyticsEventsConstant"; import { sendAsAnalyticsEvent } from "../../../App/common/hooks/useAnalyticsEvent"; -import { logToSentry } from "../../../App/common/hooks/useSentryLogging"; import { AnalyticsEvent } from "../../../App/common/interface"; import { SumInsuredWidgetData } from "../../../App/common/interface/widgets/widgetData/SumInsuredWidgetData"; import { getIndexFromOffset } from "../../../App/common/utilities/SizeUtils"; import CarouselItem from "./component/CarouselItem"; +import { QUOTE_OFFER_SCREEN } from "../../../App/common/constants"; const SumInsuredWidget = ({ widgetData, @@ -27,7 +28,7 @@ const SumInsuredWidget = ({ widgetData: SumInsuredWidgetData; handleActions: ( value: any | undefined | null, - actionPayloadList: GenericActionPayload | undefined + actionPayloadList: GenericActionPayload | undefined, ) => void; widgetIndex: number; widgetStyle?: ViewStyle; @@ -51,19 +52,21 @@ const SumInsuredWidget = ({ if (widgetData?.carouselListData) { handleActions( widgetData?.carouselListData[index - 1]?.dependentWidgets, - widgetData?.widgetMetaData?.onValueChangeAction + widgetData?.widgetMetaData?.onValueChangeAction, ); } const clickEvent: AnalyticsEvent = { name: AnalyticsEventNameConstants.HI_SI_PILLS_CLICK, properties: { - [AnalyticsEventPropertyConstants.SUM_INSURED] : widgetData?.carouselListData - ?.at(index - 1) - ?.sumInsured?.toString() ?? "", - [AnalyticsEventPropertyConstants.TAG] : widgetData?.widgetMetaData?.recommendItemIndex === index - 1 - ? AnalyticsEventPropertyConstants.RECOMMENDED - : AnalyticsEventPropertyConstants.NOT_RECOMMENDED - } + [AnalyticsEventPropertyConstants.SUM_INSURED]: + widgetData?.carouselListData + ?.at(index - 1) + ?.sumInsured?.toString() ?? "", + [AnalyticsEventPropertyConstants.TAG]: + widgetData?.widgetMetaData?.recommendItemIndex === index - 1 + ? AnalyticsEventPropertyConstants.RECOMMENDED + : AnalyticsEventPropertyConstants.NOT_RECOMMENDED, + }, }; sendAsAnalyticsEvent(clickEvent); } @@ -80,7 +83,7 @@ const SumInsuredWidget = ({ }, []); const onScroll = useAnimatedScrollHandler({ - onScroll: (event) => { + onScroll: event => { x.value = event.contentOffset.x; }, }); @@ -91,16 +94,22 @@ const SumInsuredWidget = ({ widgetData?.widgetMetaData?.onCarouselReleaseActionSequence; if (!actionPayloadList) { - logToSentry( - `Payload not present: ${actionPayloadList} | MethodName: handleActionApiCall` - ); + sendAsAnalyticsEvent({ + name: AnalyticsEventNameConstants.HI_INVALID_SCREEN_CTA, + properties: { + screenName: QUOTE_OFFER_SCREEN, + errorType: EVENT_NAMES.ACTION_PAYLOAD_MISSING_ERROR, + error: `${actionPayloadList}`, + methodName: "handleActionApiCall", + }, + }); return; } // Makes a patch call to update the sumInsured in the backend const updatedActionPayload: GenericActionPayload = { ...actionPayloadList, - metaData: actionPayloadList.metaData?.map((actionPayload) => { + metaData: actionPayloadList.metaData?.map(actionPayload => { return { ...actionPayload, data: { @@ -116,7 +125,7 @@ const SumInsuredWidget = ({ // We can use this debounced function to make api calls on scroll const debouncedHandleActions = useCallback( debounce((index: number) => handleActionApiCall(index), 1000), - [handleActions, handleActionApiCall] + [handleActions, handleActionApiCall], ); const onMomentumScrollEnd = (event: any) => { @@ -124,18 +133,19 @@ const SumInsuredWidget = ({ if (widgetData?.carouselListData) { handleActions( widgetData?.carouselListData[index]?.dependentWidgets, - widgetData?.widgetMetaData?.onValueChangeAction + widgetData?.widgetMetaData?.onValueChangeAction, ); } const clickEvent: AnalyticsEvent = { name: AnalyticsEventNameConstants.HI_SI_PILLS_CLICK, - properties: - { - [AnalyticsEventPropertyConstants.SUM_INSURED] : widgetData?.carouselListData?.at(index)?.sumInsured?.toString() ?? "", - [AnalyticsEventPropertyConstants.TAG] : widgetData?.widgetMetaData?.recommendItemIndex === index - ? AnalyticsEventPropertyConstants.RECOMMENDED - : AnalyticsEventPropertyConstants.NOT_RECOMMENDED, - } + properties: { + [AnalyticsEventPropertyConstants.SUM_INSURED]: + widgetData?.carouselListData?.at(index)?.sumInsured?.toString() ?? "", + [AnalyticsEventPropertyConstants.TAG]: + widgetData?.widgetMetaData?.recommendItemIndex === index + ? AnalyticsEventPropertyConstants.RECOMMENDED + : AnalyticsEventPropertyConstants.NOT_RECOMMENDED, + }, }; sendAsAnalyticsEvent(clickEvent); }; diff --git a/metro.config.js b/metro.config.js index 8deac11918..892433a83f 100644 --- a/metro.config.js +++ b/metro.config.js @@ -1,19 +1,11 @@ const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config"); -const { - createSentryMetroSerializer -} = require("@sentry/react-native/dist/js/tools/sentryMetroSerializer"); - /** * Metro configuration * https://facebook.github.io/metro/docs/configuration * * @type {import('metro-config').MetroConfig} */ -const config = { - serializer: { - customSerializer: createSentryMetroSerializer() - } -}; +const config = {}; -module.exports = mergeConfig(getDefaultConfig(__dirname), config); \ No newline at end of file +module.exports = mergeConfig(getDefaultConfig(__dirname), config); diff --git a/package.json b/package.json index 3f303e5ea1..2c24dc54d1 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "@react-navigation/stack": "^6.3.17", "@react-spring/native": "9.5.5", "@reduxjs/toolkit": "^1.9.5", - "@sentry/react-native": "^5.19.0", "axios": "^1.4.0", "lodash": "^4.17.21", "lottie-react-native": "^5.1.6",