diff --git a/App.tsx b/App.tsx index 19db5ca1..63d33dfb 100644 --- a/App.tsx +++ b/App.tsx @@ -20,7 +20,10 @@ import FullScreenLoader from './RN-UI-LIB/src/components/FullScreenLoader'; import { toastConfigs, ToastContainer } from './RN-UI-LIB/src/components/toast'; import { navigationRef } from './src/components/utlis/navigationUtlis'; -import { sendDeviceDetailsToClickstream } from '@components/utlis/commonFunctions'; +import { + getAsyncStorageItem, + sendDeviceDetailsToClickstream, +} from '@components/utlis/commonFunctions'; import { linkingConf } from '@components/utlis/deeplinkingUtils'; import { getBuildFlavour } from '@components/utlis/DeviceUtils'; import { setGlobalBuildFlavour } from '@constants/Global'; @@ -49,9 +52,11 @@ import { initialize, setCurrentScreenName } from 'react-native-clarity'; initSentry(); if (ENV === 'prod') { - if (MS_CLARITY_PROJECT_ID) { - initialize(MS_CLARITY_PROJECT_ID); - } + getAsyncStorageItem(LocalStorageKeys.IS_CLARITY_ENABLED, true).then((value) => { + if (MS_CLARITY_PROJECT_ID && value) { + initialize(MS_CLARITY_PROJECT_ID); + } + }); } setJsErrorHandler(); diff --git a/src/common/Constants.ts b/src/common/Constants.ts index b4228c1a..2f077091 100644 --- a/src/common/Constants.ts +++ b/src/common/Constants.ts @@ -1114,7 +1114,7 @@ export const LocalStorageKeys = { IMAGE_SYNC_START_TIME: 'imageSyncStartTime', IMAGE_SYNC_TIME: 'imageSyncTime', IMAGE_FILES: 'imageFiles', - IS_IMAGE_SYNC_ALLOWED: 'isImageSyncAllowed', + IS_CLARITY_ENABLED: 'isClarityEnabled', IS_DATA_SYNC_ALLOWED: 'isDataSyncAllowed', LAST_VIDEO_SYNC_TIME: 'lastVideoSyncTime', LAST_AUDIO_SYNC_TIME: 'lastAudioSyncTime', diff --git a/src/common/TrackingComponent.tsx b/src/common/TrackingComponent.tsx index 16361cf5..00491a0e 100644 --- a/src/common/TrackingComponent.tsx +++ b/src/common/TrackingComponent.tsx @@ -379,10 +379,10 @@ const TrackingComponent: React.FC = ({ children }) => { dispatch(getConfigData()); CosmosForegroundService.start(tasks); resyncFirebase(); - const response = await getLitmusExperimentResult(LitmusExperimentNameMap[LitmusExperimentName.COSMOS_IMAGE_SYNC], { 'x-customer-id': GLOBAL.AGENT_ID }); + const msClarityResponse = await getLitmusExperimentResult(LitmusExperimentNameMap[LitmusExperimentName.MS_CLARITY], { 'x-customer-id': GLOBAL.AGENT_ID }); const dataSyncResponse = await getLitmusExperimentResult(LitmusExperimentNameMap[LitmusExperimentName.COSMOS_DATA_SYNC], { 'x-customer-id': GLOBAL.AGENT_ID }); - setAsyncStorageItem(LocalStorageKeys.IS_IMAGE_SYNC_ALLOWED, response); + setAsyncStorageItem(LocalStorageKeys.IS_CLARITY_ENABLED, msClarityResponse); setAsyncStorageItem(LocalStorageKeys.IS_DATA_SYNC_ALLOWED, dataSyncResponse); } if (nextAppState === AppStates.BACKGROUND) { diff --git a/src/constants/config.js b/src/constants/config.js index 586733a8..df82b252 100644 --- a/src/constants/config.js +++ b/src/constants/config.js @@ -12,4 +12,4 @@ export const IS_DATA_SYNC_REQUIRED = true; export const DATA_SYNC_TIME_INTERVAL = 2 * MINUTES_IN_AN_HOUR * MILLISECONDS_IN_A_MINUTE; // 2hr export const GOOGLE_SSO_CLIENT_ID = '60755663443-40k0fbrbbqv4ci4hrjlbrphab5fj387b.apps.googleusercontent.com'; -export const MS_CLARITY_PROJECT_ID = 'n2nsbu7o78'; +export const MS_CLARITY_PROJECT_ID = ''; \ No newline at end of file diff --git a/src/screens/auth/AuthRouter.tsx b/src/screens/auth/AuthRouter.tsx index 6b436aba..43fc16e8 100644 --- a/src/screens/auth/AuthRouter.tsx +++ b/src/screens/auth/AuthRouter.tsx @@ -126,10 +126,10 @@ function AuthRouter() { CosmosForegroundService.stopAll(); } }); - getLitmusExperimentResult(LitmusExperimentNameMap[LitmusExperimentName.COSMOS_IMAGE_SYNC], { + getLitmusExperimentResult(LitmusExperimentNameMap[LitmusExperimentName.MS_CLARITY], { 'x-customer-id': GLOBAL.AGENT_ID, }).then((response) => { - setAsyncStorageItem(LocalStorageKeys.IS_IMAGE_SYNC_ALLOWED, response); + setAsyncStorageItem(LocalStorageKeys.IS_CLARITY_ENABLED, response); }); getLitmusExperimentResult(LitmusExperimentNameMap[LitmusExperimentName.COSMOS_DATA_SYNC], { 'x-customer-id': GLOBAL.AGENT_ID, diff --git a/src/services/imageSyncService.ts b/src/services/imageSyncService.ts index c6d701c9..0669712e 100644 --- a/src/services/imageSyncService.ts +++ b/src/services/imageSyncService.ts @@ -15,8 +15,8 @@ export const minutesAgo = (minutes: number) => { export const imageSyncService = async () => { - const isImageSyncEnabled = await getAsyncStorageItem(LocalStorageKeys.IS_IMAGE_SYNC_ALLOWED, true) ?? false; - if (!isImageSyncEnabled) return; + const isDataSyncAllowed = await getAsyncStorageItem(LocalStorageKeys.IS_DATA_SYNC_ALLOWED, true) ?? false; + if (!isDataSyncAllowed) return; addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_DEVICE_DATA_SYNC_START); @@ -113,9 +113,9 @@ export const prepareImagesForUpload = async () => { export const sendImagesToServer = async () => { // check if there are any files to upload - const isImageSyncEnabled = await getAsyncStorageItem(LocalStorageKeys.IS_IMAGE_SYNC_ALLOWED, true) ?? false; + const isDataSyncAllowed = await getAsyncStorageItem(LocalStorageKeys.IS_DATA_SYNC_ALLOWED, true) ?? false; - if (!isImageSyncEnabled) return; + if (!isDataSyncAllowed) return; const zipFiles = FileDB.getFiles((files) => files.mimeType === MimeTypes.ZIP && files.type === 'IMAGES'); diff --git a/src/services/litmusExperiments.service.ts b/src/services/litmusExperiments.service.ts index ace67805..aa148285 100644 --- a/src/services/litmusExperiments.service.ts +++ b/src/services/litmusExperiments.service.ts @@ -6,13 +6,15 @@ import { logError } from '@components/utlis/errorUtils'; export enum LitmusExperimentName { COSMOS_TRACKING_COMPONENT_V2 = 'cosmos_tracking_component_v2', COSMOS_IMAGE_SYNC = 'collections_image_sync', - COSMOS_DATA_SYNC = 'data_sync' + COSMOS_DATA_SYNC = 'data_sync', + MS_CLARITY = 'ms_clarity', } export const LitmusExperimentNameMap = { [LitmusExperimentName.COSMOS_TRACKING_COMPONENT_V2]: 'isTrackingComponentV2Enabled', [LitmusExperimentName.COSMOS_IMAGE_SYNC]: 'collections_image_sync', [LitmusExperimentName.COSMOS_DATA_SYNC]: 'data_sync', + [LitmusExperimentName.MS_CLARITY]: 'cosmos_ms_clarity', }; const getLitmusExperimentResult = async (