From 65954c7b15e0cd6b9a2bbe8417d5d963537aaa7d Mon Sep 17 00:00:00 2001 From: yashmantri Date: Tue, 21 Nov 2023 19:29:57 +0530 Subject: [PATCH] TP-000 | Code Refcatore + Clickstream Added --- android/app/build.gradle | 4 ++-- package.json | 2 +- src/common/Constants.ts | 5 +++++ src/hooks/useFirestoreUpdates.ts | 21 +++++++++++++++++---- src/screens/allCases/CaseItem.tsx | 30 +++++++++++++++--------------- 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index bad2642e..e9f01d5d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -133,8 +133,8 @@ def reactNativeArchitectures() { return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] } -def VERSION_CODE = 100 -def VERSION_NAME = "2.5.5" +def VERSION_CODE = 103 +def VERSION_NAME = "2.5.8" android { ndkVersion rootProject.ext.ndkVersion diff --git a/package.json b/package.json index 32a41982..c183ae24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "AV_APP", - "version": "2.5.5", + "version": "2.5.8", "private": true, "scripts": { "android:dev": "yarn move:dev && react-native run-android", diff --git a/src/common/Constants.ts b/src/common/Constants.ts index bde39595..59d12291 100644 --- a/src/common/Constants.ts +++ b/src/common/Constants.ts @@ -662,6 +662,11 @@ export const CLICKSTREAM_EVENT_NAMES = { name: 'FA_NEARBY_CASE_CLICKED', description: 'FA_NEARBY_CASE_CLICKED', }, + + FA_SNAPSHOT_LISTENER: { + name: 'FA_SNAPSHOT_LISTENER', + description: 'FA_SNAPSHOT_LISTENER', + }, } as const; export enum MimeType { diff --git a/src/hooks/useFirestoreUpdates.ts b/src/hooks/useFirestoreUpdates.ts index 7f817d12..75b57ac6 100644 --- a/src/hooks/useFirestoreUpdates.ts +++ b/src/hooks/useFirestoreUpdates.ts @@ -8,7 +8,7 @@ import { type RootState } from '../store/store'; import { useAppDispatch, useAppSelector } from '.'; import { setLoading, updateCaseDetailsFirestore } from '../reducer/allCasesSlice'; import { type CaseDetail } from '../screens/caseDetails/interface'; -import { FirestoreUpdateTypes } from '../common/Constants'; +import { CLICKSTREAM_EVENT_NAMES, FirestoreUpdateTypes } from '../common/Constants'; import { toast } from '../../RN-UI-LIB/src/components/toast'; import { updateAvTemplateData, updateCollectionTemplateData } from '../reducer/caseReducer'; import { type ILockData, MY_CASE_ITEM, setLockData, VisitPlanStatus } from '../reducer/userSlice'; @@ -18,6 +18,8 @@ import { ToastMessages } from '../screens/allCases/constants'; import { setForceUninstallData } from '../reducer/metadataSlice'; import { logError } from '../components/utlis/errorUtils'; import { type GenericFunctionArgs } from '../common/GenericTypes'; +import { addClickstreamEvent } from '@services/clickstreamEventService'; +import analytics from '@react-native-firebase/analytics'; export interface CaseUpdates { updateType: string; @@ -201,9 +203,20 @@ const useFirestoreUpdates = () => { const subscribeToDoc = (successCb: GenericFunctionArgs, collectionPath: string) => firestore() .doc(collectionPath) - .onSnapshot(successCb, (err) => { - handleError(err, collectionPath); - }); + .onSnapshot( + async () => { + successCb(); + addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_SNAPSHOT_LISTENER, { + snapshot_path: collectionPath, + }); + await analytics().logEvent('snapshot_listener', { + snapshot_path: collectionPath, + }); + }, + (err) => { + handleError(err, collectionPath); + } + ); const subscribeToCases = () => { let refId = user?.referenceId; diff --git a/src/screens/allCases/CaseItem.tsx b/src/screens/allCases/CaseItem.tsx index c62b960a..e18203f8 100644 --- a/src/screens/allCases/CaseItem.tsx +++ b/src/screens/allCases/CaseItem.tsx @@ -97,10 +97,23 @@ const CaseItem: React.FC = ({ case NEARBY_CASES: { return ( - + - View nearby cases + View nearby cases @@ -130,20 +143,7 @@ const styles = StyleSheet.create({ paddingBottom: 6, paddingHorizontal: 2, }, - nearByCasesContainer: { - ...GenericStyles.row, - ...GenericStyles.alignCenter, - ...GenericStyles.spaceBetween, - ...getShadowStyle(2), - ...GenericStyles.ph12, - ...GenericStyles.pv12, - ...GenericStyles.br8, - ...GenericStyles.mt16, - ...GenericStyles.mb12, - ...GenericStyles.whiteBackground, - }, nearByCasesText: { - ...GenericStyles.pl4, color: COLORS.TEXT.DARK, }, });