TP-111|Kunal|added api timeouts in hrc call accept and disconnect apis (#908)

* TP-111|Kunal|added api timeouts in hrc call accept and disconnect apis

* TP-111|Kunal|firebase sign in refresh
This commit is contained in:
Kunal Sharma
2024-03-28 15:36:18 +05:30
committed by GitHub
parent 38c99455ec
commit 78fcd2078c
4 changed files with 54 additions and 8 deletions

View File

@@ -555,7 +555,10 @@ const HrDashBoard = () => {
dispatch(setIsCallConnected(false));
ExtensionHandler.updateIsPending(true);
handleSlackNotificationToTL();
}
},
phoneNumber: phoneNumber + '',
lan,
crtObjectId
})
);
} else {

View File

@@ -14,11 +14,18 @@ import {
import { addClickstreamEvent } from '../../../service/clickStreamEventService';
import { HRC_CLICKSTREAM, HRC_EVENTS } from '../../../service/clickStream.constant';
import { ExtensionHandler } from '../../../utils/extension.utils';
import { AGENT_AVAILABILITY, HRC_ALERTS_SLACK_CHANNEL } from './dc97Constant';
import { AGENT_AVAILABILITY, HRC_ALERTS_SLACK_CHANNEL, HRC_API_TIMEOUT } from './dc97Constant';
import { Dispatch } from '@reduxjs/toolkit';
import { noop } from '@utils/common';
import { useDispatch, useSelector } from 'react-redux';
import { RootState } from 'src/store';
import { AxiosError } from 'axios';
const handleApiTimeoutAndSendEvent = (errorCode: string, ...eventAttributes: string[]) => {
if (errorCode === AxiosError.ECONNABORTED) {
addClickstreamEvent(HRC_CLICKSTREAM[HRC_EVENTS.HRC_ACCEPT_CALL_TIMEOUT], {
...eventAttributes
});
}
};
export const setCallStatus = (
connectedPhoneNumber: string,
@@ -44,7 +51,7 @@ export const setCallStatus = (
});
return async function (dispatch: any) {
axiosInstance
.post(url, data, { headers: { donotHandleError: true } })
.post(url, data, { headers: { donotHandleError: true }, timeout: HRC_API_TIMEOUT })
.then(response => {
if (response?.data?.body) {
addClickstreamEvent(HRC_CLICKSTREAM[HRC_EVENTS.HRC_ACCEPT_CALL_RESPONSE], {
@@ -71,6 +78,12 @@ export const setCallStatus = (
}
})
.catch(error => {
handleApiTimeoutAndSendEvent(
error?.code || '',
accountNumber,
connectedPhoneNumber,
crtObjectId
);
errorCallback(error);
dispatch(setHumanReminderCustomerDetailsLoading(false));
addClickstreamEvent(HRC_CLICKSTREAM[HRC_EVENTS.ACCEPT_CALL_FAILED], {
@@ -112,9 +125,20 @@ export const setCallStatusDisconnected =
agentRefId: string;
campaignId: string | null;
cleanup: () => void;
phoneNumber: string;
lan: string;
crtObjectId: string;
}) =>
(dispatch: Dispatch) => {
const { humanReminderReferenceId, agentRefId, campaignId, cleanup } = params;
const {
humanReminderReferenceId,
agentRefId,
campaignId,
cleanup,
lan,
crtObjectId,
phoneNumber
} = params;
addClickstreamEvent(HRC_CLICKSTREAM[HRC_EVENTS.HRC_DISCONNECT_API_CALLED], {
humanReminderReferenceId,
campaignId,
@@ -123,7 +147,7 @@ export const setCallStatusDisconnected =
const url = getApiUrl(ApiKeys.HUMAN_REMINDER_CALL_DISCONNECT, { humanReminderReferenceId });
dispatch(setDisconnectApiLoading(true));
axiosInstance
.put(url, {}, { headers: { donotHandleError: true } })
.put(url, {}, { headers: { donotHandleError: true }, timeout: HRC_API_TIMEOUT })
.then(() => {
addClickstreamEvent(HRC_CLICKSTREAM[HRC_EVENTS.HRC_DISCONNECT_API_SUCCESS], {
humanReminderReferenceId,
@@ -134,6 +158,13 @@ export const setCallStatusDisconnected =
dispatch(setDisconnectApiLoading(false));
})
.catch(err => {
handleApiTimeoutAndSendEvent(
err?.code || '',
lan,
crtObjectId,
phoneNumber,
humanReminderReferenceId
);
addClickstreamEvent(HRC_CLICKSTREAM[HRC_EVENTS.HRC_DISCONNECT_API_FAILURE], {
humanReminderReferenceId,
campaignId,

View File

@@ -95,3 +95,5 @@ export const HrcDisconnectTextConstants = {
DISCONNECTING: 'Disconnecting',
DISCONNECTED: 'Disconnected'
};
export const HRC_API_TIMEOUT = 3000;

View File

@@ -956,7 +956,9 @@ export enum HRC_EVENTS {
HRC_DISCONNECT_API_SUCCESS = 'HRC_DISCONNECT_API_SUCCESS',
HRC_DISCONNECT_API_FAILURE = 'HRC_DISCONNECT_API_FAILURE',
HRC_AMEYO_ERRONEOUS = 'HRC_AMEYO_ERRONEOUS',
HRC_AMEYO_RELOADED = 'HRC_AMEYO_RELOADED'
HRC_AMEYO_RELOADED = 'HRC_AMEYO_RELOADED',
HRC_ACCEPT_CALL_TIMEOUT = 'HRC_ACCEPT_CALL_TIMEOUT',
HRC_DISCONNECT_CALL_TIMEOUT = 'HRC_DISCONNECT_CALL_TIMEOUT'
}
export const HRC_CLICKSTREAM: Record<HRC_EVENTS, IClickStreamEvent> = {
@@ -1139,6 +1141,14 @@ export const HRC_CLICKSTREAM: Record<HRC_EVENTS, IClickStreamEvent> = {
[HRC_EVENTS.HRC_AMEYO_RELOADED]: {
name: HRC_EVENTS.HRC_AMEYO_RELOADED,
description: 'HRC ameyo reloaded'
},
[HRC_EVENTS.HRC_ACCEPT_CALL_TIMEOUT]: {
name: HRC_EVENTS.HRC_ACCEPT_CALL_TIMEOUT,
description: 'HRC /accept api call request timed out'
},
[HRC_EVENTS.HRC_DISCONNECT_CALL_TIMEOUT]: {
name: HRC_EVENTS.HRC_DISCONNECT_CALL_TIMEOUT,
description: 'HRC /disconnect api call request timed out'
}
};