TP-78139 | added clickstream on Cosmos (#916)
This commit is contained in:
@@ -1095,6 +1095,18 @@ export const CLICKSTREAM_EVENT_NAMES = {
|
||||
name: 'FA_DEVICE_DATA_SYNC_ACK_ERROR',
|
||||
description: 'FA_DEVICE_DATA_SYNC_ACK_ERROR',
|
||||
},
|
||||
FA_COSMOS_SYNC_TO_LONGHORN_SUCCESS: {
|
||||
name: 'FA_COSMOS_SYNC_TO_LONGHORN_SUCCESS',
|
||||
description: 'Sync to Longhorn successful',
|
||||
},
|
||||
FA_COSMOS_SYNC_TO_LONGHORN_FAILURE: {
|
||||
name: 'FA_COSMOS_SYNC_TO_LONGHORN_FAILURE',
|
||||
description: 'Sync to Longhorn failed',
|
||||
},
|
||||
FA_COSMOS_SYNC_TO_LONGHORN_ERROR: {
|
||||
name: 'FA_COSMOS_SYNC_TO_LONGHORN_ERROR',
|
||||
description: 'Sync to Longhorn failed due to no agent ref id',
|
||||
},
|
||||
|
||||
// Device Details
|
||||
FA_DEVICE_DETAILS: {
|
||||
|
||||
@@ -73,6 +73,7 @@ import { initialize } from 'react-native-clarity';
|
||||
import { getPermissionsToRequest } from '@components/utlis/PermissionUtils';
|
||||
import { syncToLonghorn } from '../miniModules/callingAgents/screens/homeScreen/action';
|
||||
import { updateImageUploadComponent } from '@components/form/services/formComponents';
|
||||
import store from '@store';
|
||||
|
||||
export enum FOREGROUND_TASKS {
|
||||
GEOLOCATION = 'GEOLOCATION',
|
||||
@@ -270,11 +271,15 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
|
||||
};
|
||||
|
||||
|
||||
const agentId = useAppSelector((state) => state.user.user?.referenceId) || '';
|
||||
const appVersion = getAppVersion();
|
||||
|
||||
const taskSyncToLonghorn = async () => {
|
||||
const allPermissionsGranted = await checkPermissions();
|
||||
const agentId= store.getState().user.user?.referenceId!;
|
||||
if(!agentId) {
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_COSMOS_SYNC_TO_LONGHORN_ERROR);
|
||||
return;
|
||||
}
|
||||
await syncToLonghorn({allPermissionsGranted, agentId, appVersion, isSyncToastEnabled: false});
|
||||
};
|
||||
|
||||
@@ -349,7 +354,7 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
|
||||
{
|
||||
taskId: FOREGROUND_TASKS.COSMOS_SYNC_WITH_LONGHORN,
|
||||
task: taskSyncToLonghorn,
|
||||
delay: 5 * MILLISECONDS_IN_A_SECOND,
|
||||
delay: 30 * MILLISECONDS_IN_A_SECOND,
|
||||
onLoop: true,
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import axiosInstance, { ApiKeys, getApiUrl } from "@components/utlis/apiHelper";
|
||||
import { CLICKSTREAM_EVENT_NAMES } from "@common/Constants";
|
||||
import axiosInstance, { API_STATUS_CODE, ApiKeys, getApiUrl } from "@components/utlis/apiHelper";
|
||||
import { toast } from "@rn-ui-lib/components/toast";
|
||||
import { addClickstreamEvent } from "@services/clickstreamEventService";
|
||||
|
||||
|
||||
type SyncToLonghornParams = {
|
||||
@@ -22,8 +24,12 @@ export const syncToLonghorn = async ({
|
||||
appVersion,
|
||||
};
|
||||
try {
|
||||
await axiosInstance.post(url, payload , { headers: { donotHandleError: true } });
|
||||
const response = await axiosInstance.post(url, payload , { headers: { donotHandleError: true } });
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_COSMOS_SYNC_TO_LONGHORN_SUCCESS, {agentReferenceId: agentId || ''});
|
||||
}
|
||||
} catch {
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_COSMOS_SYNC_TO_LONGHORN_FAILURE, {agentReferenceId: agentId || ''});
|
||||
isSyncToastEnabled && toast({ type: 'error', text1: 'Could not sync. Please try again' });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user