diff --git a/ProtectedRouter.tsx b/ProtectedRouter.tsx index f458cad9..0ad50384 100644 --- a/ProtectedRouter.tsx +++ b/ProtectedRouter.tsx @@ -17,6 +17,9 @@ import { RootState } from './src/store/store'; import Profile from './src/screens/Profile'; import interactionsHandler from './src/screens/caseDetails/interactionsHandler'; import useFirestoreUpdates from './src/hooks/useFirestoreUpdates'; +import crashlytics from '@react-native-firebase/crashlytics'; +import { RouteProp } from '@react-navigation/native'; +import { GenericType } from './src/common/GenericTypes'; const Stack = createNativeStackNavigator(); @@ -39,6 +42,12 @@ const ProtectedRouter = () => { getUniqueId().then(id => dispatch(setDeviceId(id))); } + const getScreenFocusListenerObj = ({route}: {route: RouteProp}) => ({ + focus: () => { + crashlytics().log(JSON.stringify(route)); + } + }); + return ( {isLoggedIn ? ( @@ -49,6 +58,7 @@ const ProtectedRouter = () => { options={{ header: () => null, }} + listeners={getScreenFocusListenerObj} /> { header: () => null, animation: 'slide_from_right' }} + listeners={getScreenFocusListenerObj} /> { options={{ header: () => null, }} + listeners={getScreenFocusListenerObj} /> {_map(RealTemplate.widget, key => ( { header: () => null, animation: 'slide_from_right' }} + listeners={getScreenFocusListenerObj} /> ))} { header: () => null, animation: 'slide_from_bottom' }} + listeners={getScreenFocusListenerObj} /> ) : ( @@ -93,6 +107,7 @@ const ProtectedRouter = () => { options={{ header: () => null, }} + listeners={getScreenFocusListenerObj} /> { options={{ header: () => null, }} + listeners={getScreenFocusListenerObj} /> )} diff --git a/android/app/build.gradle b/android/app/build.gradle index 19e69ad0..d5b63239 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,5 +1,6 @@ apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' +apply plugin: "com.google.firebase.crashlytics" import com.android.build.OutputFile import org.apache.tools.ant.taskdefs.condition.Os diff --git a/android/build.gradle b/android/build.gradle index 85099672..9042623d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -26,6 +26,7 @@ buildscript { // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.google.gms:google-services:4.3.14' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2' } } diff --git a/firebase.json b/firebase.json new file mode 100644 index 00000000..f57d786b --- /dev/null +++ b/firebase.json @@ -0,0 +1,5 @@ +{ + "react-native": { + "crashlytics_debug_enabled": true + } + } \ No newline at end of file diff --git a/package.json b/package.json index d88c0a45..23652e85 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "dependencies": { "@react-native-async-storage/async-storage": "1.17.11", "@react-native-firebase/app": "16.4.6", + "@react-native-firebase/crashlytics": "16.5.0", "@react-native-firebase/database": "16.4.6", "@react-native-firebase/firestore": "16.5.0", "@react-navigation/native": "6.0.16", diff --git a/src/common/GenericTypes.ts b/src/common/GenericTypes.ts new file mode 100644 index 00000000..b3501f5f --- /dev/null +++ b/src/common/GenericTypes.ts @@ -0,0 +1,7 @@ +export type GenericType = any; + +export type GenericObject = { + [key: string]: any; +}; + +export type GenericFunctionArgs = (...args: any[]) => void; diff --git a/src/components/utlis/firebaseUtils.ts b/src/components/utlis/firebaseUtils.ts new file mode 100644 index 00000000..85fea083 --- /dev/null +++ b/src/components/utlis/firebaseUtils.ts @@ -0,0 +1,16 @@ +import crashlytics from '@react-native-firebase/crashlytics'; +import { IUserSlice } from '../../reducer/userSlice'; + +export const initCrashlytics = async (userState: IUserSlice) => { + if (!userState) return; + + await Promise.all([ + crashlytics().setUserId(userState.user?.emailId as string), + crashlytics().setAttributes({ + deviceId: userState.deviceId, + phoneNumber: userState.user?.phoneNumber as string, + emailId: userState.user?.emailId as string, + sessionToken: userState.sessionDetails?.sessionToken as string + }), + ]); +} \ No newline at end of file diff --git a/src/reducer/userSlice.ts b/src/reducer/userSlice.ts index 9433ef82..e4023ed5 100644 --- a/src/reducer/userSlice.ts +++ b/src/reducer/userSlice.ts @@ -23,7 +23,7 @@ export interface IUser { user: IUserDetails | null; } -interface IUserSlice extends IUser { +export interface IUserSlice extends IUser { isLoggedIn: boolean; deviceId: string; } diff --git a/src/screens/allCases/index.tsx b/src/screens/allCases/index.tsx index 5e50d36d..4c01f294 100644 --- a/src/screens/allCases/index.tsx +++ b/src/screens/allCases/index.tsx @@ -30,7 +30,9 @@ import AllCases from './AllCases'; import ComplatedCase from './ComplatedCase'; import {CaseStatuses} from './interface'; import RealJson from '../../data/RealTemplateData.json'; -import {updateTemplateData} from '../../reducer/caseReducre'; +import { updateTemplateData } from '../../reducer/caseReducre'; +import { RootState } from '../../store/store'; +import { initCrashlytics } from '../../components/utlis/firebaseUtils'; import Lottie from '../../../RN-UI-LIB/src/components/lottie/Lottie'; import Button from '../../../RN-UI-LIB/src/components/Button'; @@ -60,6 +62,7 @@ const LogoActions = () => { }; const AllCasesMain = () => { + const { casesList, newlyPinnedCases, @@ -67,6 +70,11 @@ const AllCasesMain = () => { caseDetails, isOnboarded, } = useAppSelector(state => state.allCases); + + const userState = useAppSelector( + (state: RootState) => state.user, + ); + const completed = casesList.filter(caseData => { const detail = caseDetails[caseData.caseReferenceId]; const {caseStatus} = detail; @@ -104,7 +112,9 @@ const AllCasesMain = () => { const handleProfileIconPress = () => { navigateToScreen('Profile'); }; + useEffect(() => { + initCrashlytics(userState); dispatch(updateTemplateData(RealJson)); }, []); diff --git a/yarn.lock b/yarn.lock index fd6df3b4..b7fd9280 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1387,6 +1387,14 @@ opencollective-postinstall "^2.0.1" superstruct "^0.6.2" +"@react-native-firebase/crashlytics@^16.5.0": + version "16.5.0" + resolved "https://registry.yarnpkg.com/@react-native-firebase/crashlytics/-/crashlytics-16.5.0.tgz#5c3e22c1bfdccd0157aad78571298d489e4d871d" + integrity sha512-wCZyF3OHi6PSQ0LH2YT0ewDYsEpMCKwTuIe27unBaE+ikIKJhIYY38+A2K4xUDwj9Gnpd52QE0eSfWS0BxfeNQ== + dependencies: + "@expo/config-plugins" "^5.0.4" + stacktrace-js "^2.0.0" + "@react-native-firebase/database@16.4.6": version "16.4.6" resolved "https://registry.yarnpkg.com/@react-native-firebase/database/-/database-16.4.6.tgz#261a041e79ca5f1cf4bd827def073e634659fd11" @@ -1469,6 +1477,48 @@ redux-thunk "^2.4.2" reselect "^4.1.7" +"@sentry/browser@^7.28.1": + version "7.28.1" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.28.1.tgz#c8086e26079809aa401a05d9b4a6e4df63a9c965" + integrity sha512-N8j93IcrWKWorfJ5D+RSKVAvcR4S5tIcZ/HvFPMrQWnfVa/jtJcrKThdjZYteA0wjmPiy8/D3KA8nB91yulBPA== + dependencies: + "@sentry/core" "7.28.1" + "@sentry/replay" "7.28.1" + "@sentry/types" "7.28.1" + "@sentry/utils" "7.28.1" + tslib "^1.9.3" + +"@sentry/core@7.28.1": + version "7.28.1" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.28.1.tgz#c712ce17469b18b01606108817be24a99ed2116e" + integrity sha512-7wvnuvn/mrAfcugWoCG/3pqDIrUgH5t+HisMJMGw0h9Tc33KqrmqMDCQVvjlrr2pWrw/vuUCFdm8CbUHJ832oQ== + dependencies: + "@sentry/types" "7.28.1" + "@sentry/utils" "7.28.1" + tslib "^1.9.3" + +"@sentry/replay@7.28.1": + version "7.28.1" + resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.28.1.tgz#fbdd377923e082423b95e3f128cb9af9451aca70" + integrity sha512-Os0PzMjKlwtHwzTU0kfVzGzsi4Vaj3g2arCl4Qnr3b6kYTb9WOFZo/n/v56ss7Z+nZG3K8W5PisoD4MRsRJRig== + dependencies: + "@sentry/core" "7.28.1" + "@sentry/types" "7.28.1" + "@sentry/utils" "7.28.1" + +"@sentry/types@7.28.1": + version "7.28.1" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.28.1.tgz#9018b4c152b475de9bedd267237393d3c9b1253d" + integrity sha512-DvSplMVrVEmOzR2M161V5+B8Up3vR71xMqJOpWTzE9TqtFJRGPtqT/5OBsNJJw1+/j2ssMcnKwbEo9Q2EGeS6g== + +"@sentry/utils@7.28.1": + version "7.28.1" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.28.1.tgz#0a7b6aa4b09e91e4d1aded2a8c8dbaf818cee96e" + integrity sha512-75/jzLUO9HH09iC9TslNimGbxOP3jgn89P+q7uR+rp2fJfRExHVeKJZQdK0Ij4/SmE7TJ3Uh2r154N0INZEx1g== + dependencies: + "@sentry/types" "7.28.1" + tslib "^1.9.3" + "@sideway/address@^4.1.3": version "4.1.4" resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0" @@ -7030,6 +7080,11 @@ source-map-url@^0.4.0: resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.1.tgz#0af66605a745a5a2f91cf1bbf8a7afbc283dec56" integrity sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw== +source-map@0.5.6: + version "0.5.6" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" + integrity sha512-MjZkVp0NHr5+TPihLcadqnlVoGIoWo4IBHptutGh9wI3ttUYvCG26HkSuDi+K6lsZ25syXJXcctwgyVCt//xqA== + source-map@^0.5.0, source-map@^0.5.6: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -7088,6 +7143,13 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== +stack-generator@^2.0.5: + version "2.0.10" + resolved "https://registry.yarnpkg.com/stack-generator/-/stack-generator-2.0.10.tgz#8ae171e985ed62287d4f1ed55a1633b3fb53bb4d" + integrity sha512-mwnua/hkqM6pF4k8SnmZ2zfETsRUpWXREfA/goT8SLCV4iOFa4bzOX2nDipWAZFPTjLvQB82f5yaodMVhK0yJQ== + dependencies: + stackframe "^1.3.4" + stack-utils@^2.0.2: version "2.0.6" resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" @@ -7100,6 +7162,23 @@ stackframe@^1.3.4: resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.3.4.tgz#b881a004c8c149a5e8efef37d51b16e412943310" integrity sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw== +stacktrace-gps@^3.0.4: + version "3.1.2" + resolved "https://registry.yarnpkg.com/stacktrace-gps/-/stacktrace-gps-3.1.2.tgz#0c40b24a9b119b20da4525c398795338966a2fb0" + integrity sha512-GcUgbO4Jsqqg6RxfyTHFiPxdPqF+3LFmQhm7MgCuYQOYuWyqxo5pwRPz5d/u6/WYJdEnWfK4r+jGbyD8TSggXQ== + dependencies: + source-map "0.5.6" + stackframe "^1.3.4" + +stacktrace-js@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/stacktrace-js/-/stacktrace-js-2.0.2.tgz#4ca93ea9f494752d55709a081d400fdaebee897b" + integrity sha512-Je5vBeY4S1r/RnLydLl0TBTi3F2qdfWmYsGvtfZgEI+SCprPppaIhQf5nGcal4gI4cGpCV/duLcAzT1np6sQqg== + dependencies: + error-stack-parser "^2.0.6" + stack-generator "^2.0.5" + stacktrace-gps "^3.0.4" + stacktrace-parser@^0.1.3: version "0.1.10" resolved "https://registry.yarnpkg.com/stacktrace-parser/-/stacktrace-parser-0.1.10.tgz#29fb0cae4e0d0b85155879402857a1639eb6051a" @@ -7423,7 +7502,7 @@ tsconfig-paths@^3.14.1: minimist "^1.2.6" strip-bom "^3.0.0" -tslib@^1.8.1: +tslib@^1.8.1, tslib@^1.9.3: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==