Skip to content

Commit

Permalink
Redifined bugsnag reporting at login & uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
shyambhongle committed Mar 20, 2024
1 parent 70cf9a8 commit 8b229ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/actions/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ export const auth0Login = (dispatch: any, inventoryDispatch: any) => {
// if any error is found then deletes the user and clear the user app state
deleteUser();
clearUserDetails()(dispatch);
bugsnag.notify(err);
} else {
dbLog.info({
logType: LogTypes.USER,
message: 'User cancelled auth0 login',
logStack: JSON.stringify(err),
});
}
bugsnag.notify(err);
reject(err);
});
});
Expand Down Expand Up @@ -163,7 +163,6 @@ export const auth0Logout = async (userDispatch = null) => {
logStack: JSON.stringify(err),
});
resolve(false);
bugsnag.notify(err);
} else {
dbLog.info({
logType: LogTypes.USER,
Expand All @@ -172,6 +171,7 @@ export const auth0Logout = async (userDispatch = null) => {
});
resolve(false);
}
bugsnag.notify(err);
});
});
};
Expand Down Expand Up @@ -293,6 +293,7 @@ export const getUserDetailsFromServer = (userDispatch: any) => {
.catch(async err => {
// calls this function to check for the error code and either logout the user or ask to signup
await checkErrorCode(err, userDispatch);
bugsnag.notify(err);
console.error(
'Error at /actions/user/getUserDetailsFromServer: GET - /app/profile,',
err.response,
Expand Down Expand Up @@ -337,6 +338,7 @@ export const SignupService = (payload: any, dispatch: any) => {
}
})
.catch(err => {
bugsnag.notify(err);
console.error(
`Error at /actions/user/SignupService: POST - /app/profile, ${JSON.stringify(
err.response,
Expand Down Expand Up @@ -377,6 +379,7 @@ export const getAllProjects = () => {
}
})
.catch(err => {
bugsnag.notify(err);
console.error(
'Error at /actions/user/getAllProjects: GET - /app/profile/projects,',
err.response ? err.response : err,
Expand Down
2 changes: 2 additions & 0 deletions app/components/Common/Syncing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import dbLog from '../../../repositories/logs';
import { LogTypes } from '../../../utils/constants';
import { useNetInfo } from '@react-native-community/netinfo';
import AlertModal from '../AlertModal';
import { bugsnag } from '../../../utils';

interface ISyncingProps {
uploadCount: number;
Expand Down Expand Up @@ -70,6 +71,7 @@ export default function Syncing({
const onPressUploadNow = () => {
if (netInfo.isConnected && netInfo.isInternetReachable) {
uploadInventoryData(dispatch, userDispatch).catch(err => {
bugsnag.notify(err);
dbLog.error({
logType: LogTypes.INVENTORY,
message: 'Failed to upload Inventories',
Expand Down
2 changes: 2 additions & 0 deletions app/components/MainScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import BottomBar from './BottomBar';
import LoginButton from './LoginButton';
import MainMap from './MainMap';
import ProjectAndSiteSelector from './ProjectAndSiteSelector';
import { bugsnag } from '../../utils';

const IS_ANDROID = Platform.OS === 'android';

Expand Down Expand Up @@ -216,6 +217,7 @@ export default function MainScreen() {
fetchInventoryCount();
})
.catch(err => {
bugsnag.notify(err);
if (err?.response?.status === 303) {
navigation.navigate('SignUp');
} else if (
Expand Down
2 changes: 2 additions & 0 deletions app/components/TreeInventory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
} from '../Common';
import VerifyEmailAlert from '../Common/EmailAlert';
import { setInventoryId } from '../../actions/inventory';
import { bugsnag } from '../../utils';

const isAndroid = Platform.OS === 'android';

Expand Down Expand Up @@ -156,6 +157,7 @@ const TreeInventory = () => {
// handleBackPress();
})
.catch(err => {
bugsnag.notify(err);
if (err?.response?.status === 303) {
navigation.navigate('SignUp');
} else if (err?.message === 'blocked') {
Expand Down

0 comments on commit 8b229ac

Please sign in to comment.