Skip to content

Commit

Permalink
Merge pull request #42 from Li357/3.0.1-b6-debug
Browse files Browse the repository at this point in the history
Login issue, additional breadcrumbs for future debug
  • Loading branch information
Li357 authored Jan 14, 2020
2 parents 5e4df1e + 3e74378 commit 1c1bb7d
Show file tree
Hide file tree
Showing 5 changed files with 742 additions and 27 deletions.
4 changes: 4 additions & 0 deletions packages/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ export default class App extends Component<{}, AppComponentState> {
if (newDayScheduleType === dayScheduleType) {
return;
}
client.leaveBreadcrumb(`Updating today's schedule to ${newDayScheduleType}`);
store.dispatch(setDaySchedule(newDayScheduleType));
}
}

private async refreshScheduleIfNeeded() {
// FIXME: Schedule is not refreshed sometimes even in new semester, stuck on 1st finals
client.leaveBreadcrumb('Refreshing schedule and notifications if needed');

const {
Expand All @@ -75,6 +77,7 @@ export default class App extends Component<{}, AppComponentState> {
} = store.getState();
const now = new Date();

client.leaveBreadcrumb(`Now: ${now} 2nd Start: ${semesterTwoStart} 2nd Refreshed: ${refreshedSemesterTwo}`);
if (semesterOneStart === null || semesterTwoStart === null || semesterTwoEnd === null) {
return;
}
Expand All @@ -88,6 +91,7 @@ export default class App extends Component<{}, AppComponentState> {

const shouldRefresh = (isAfter(now, semesterTwoStart) && !refreshedSemesterTwo)
|| (isAfter(now, semesterOneStart) && !refreshedSemesterOne);
client.leaveBreadcrumb(`Should refresh? ${shouldRefresh}`);
if (isScheduleEmpty(schedule) || shouldRefresh) {
client.leaveBreadcrumb('Refreshing semesters one/two');

Expand Down
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"@whs/server": "^3.0.0",
"babel-jest": "^24.8.0",
"bugsnag-sourcemaps": "^1.2.1",
"code-push-cli": "^2.1.9",
"fetch-mock": "^7.3.3",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.55.0",
Expand Down
11 changes: 10 additions & 1 deletion packages/app/src/screens/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,31 @@ export default memo(function Login(props: NavigationScreenProps) {
let updatedDates = dates;
try {
updatedDates = await dispatch(fetchDates());
// tslint:disable-next-line: no-empty
// tslint:disable-next-line: no-empty
} catch (error) {}

try {
const now = new Date();

client.leaveBreadcrumb('Login: Fetching user info');
await dispatch(fetchUserInfo(username, password));

client.leaveBreadcrumb('Login: Registering scheduler');
await registerNotificationScheduler();

client.leaveBreadcrumb('Login: Scheduling notifications');
await scheduleNotifications();

client.leaveBreadcrumb('Set day schedule');
dispatch(setDaySchedule(getScheduleTypeOnDate(now, updatedDates)));
props.navigation.navigate('Dashboard');
} catch (error) {
if (error instanceof LoginError) {
setError(true);
} else {
reportError(error);
// 3.0.1-b6, weird bug prevent login, extra notify to debug
client.notify(error);
}
setLoading(false);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/utils/bugsnag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function serializeState(state: AppState): IMetadata {
}

const config = new Configuration();
config.codeBundleId = '3.0.1-b5';
config.codeBundleId = '3.0.1-b6';
config.notifyReleaseStages = ['production'];
config.registerBeforeSendCallback((report) => {
const state = store.getState();
Expand Down
Loading

0 comments on commit 1c1bb7d

Please sign in to comment.