NTP-7595 | replace sentry event with clickStream (#13285)
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user