Skip to content

Commit 2c04f0d

Browse files
authored
Merge pull request Expensify#67581 from Expensify/arosiclair-log-done-onyx-updates
[No QA] Improve onyx update logging
2 parents dccb6ea + ad6e0f6 commit 2c04f0d

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/libs/Notification/PushNotification/subscribeToPushNotifications.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Onyx.connect({
5252
});
5353

5454
function applyOnyxData({reportID, onyxData, lastUpdateID, previousUpdateID, hasPendingOnyxUpdates = false}: PushNotificationData): Promise<void> {
55-
Log.info(`[PushNotification] Applying onyx data in the ${Visibility.isVisible() ? 'foreground' : 'background'}`, false, {reportID});
55+
Log.info(`[PushNotification] Applying onyx data in the ${Visibility.isVisible() ? 'foreground' : 'background'}`, false, {reportID, lastUpdateID});
5656

5757
const logMissingOnyxDataInfo = (isDataMissing: boolean): boolean => {
5858
if (isDataMissing) {

src/libs/actions/OnyxUpdates.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ let pusherEventsPromise = Promise.resolve();
2626

2727
let airshipEventsPromise = Promise.resolve();
2828

29-
function applyHTTPSOnyxUpdates(request: Request, response: Response) {
29+
function applyHTTPSOnyxUpdates(request: Request, response: Response, lastUpdateID: number) {
3030
Performance.markStart(CONST.TIMING.APPLY_HTTPS_UPDATES);
31-
console.debug('[OnyxUpdateManager] Applying https update');
31+
Log.info('[OnyxUpdateManager] Applying https update', false, {lastUpdateID});
3232
// For most requests we can immediately update Onyx. For write requests we queue the updates and apply them after the sequential queue has flushed to prevent a replay effect in
3333
// the UI. See https://github.com/Expensify/App/issues/12775 for more info.
3434
const updateHandler: (updates: OnyxUpdate[]) => Promise<unknown> = request?.data?.apiRequestType === CONST.API_REQUEST_TYPE.WRITE ? queueOnyxUpdates : Onyx.update;
@@ -64,40 +64,40 @@ function applyHTTPSOnyxUpdates(request: Request, response: Response) {
6464
})
6565
.then(() => {
6666
Performance.markEnd(CONST.TIMING.APPLY_HTTPS_UPDATES);
67-
console.debug('[OnyxUpdateManager] Done applying HTTPS update');
67+
Log.info('[OnyxUpdateManager] Done applying HTTPS update', false, {lastUpdateID});
6868
return Promise.resolve(response);
6969
});
7070
}
7171

72-
function applyPusherOnyxUpdates(updates: OnyxUpdateEvent[]) {
72+
function applyPusherOnyxUpdates(updates: OnyxUpdateEvent[], lastUpdateID: number) {
7373
Performance.markStart(CONST.TIMING.APPLY_PUSHER_UPDATES);
7474

7575
pusherEventsPromise = pusherEventsPromise.then(() => {
76-
console.debug('[OnyxUpdateManager] Applying pusher update');
76+
Log.info('[OnyxUpdateManager] Applying pusher update', false, {lastUpdateID});
7777
});
7878

7979
pusherEventsPromise = updates
8080
.reduce((promise, update) => promise.then(() => PusherUtils.triggerMultiEventHandler(update.eventType, update.data)), pusherEventsPromise)
8181
.then(() => {
8282
Performance.markEnd(CONST.TIMING.APPLY_PUSHER_UPDATES);
83-
console.debug('[OnyxUpdateManager] Done applying Pusher update');
83+
Log.info('[OnyxUpdateManager] Done applying Pusher update', false, {lastUpdateID});
8484
});
8585

8686
return pusherEventsPromise;
8787
}
8888

89-
function applyAirshipOnyxUpdates(updates: OnyxUpdateEvent[]) {
89+
function applyAirshipOnyxUpdates(updates: OnyxUpdateEvent[], lastUpdateID: number) {
9090
Performance.markStart(CONST.TIMING.APPLY_AIRSHIP_UPDATES);
9191

9292
airshipEventsPromise = airshipEventsPromise.then(() => {
93-
console.debug('[OnyxUpdateManager] Applying Airship updates');
93+
Log.info('[OnyxUpdateManager] Applying Airship updates', false, {lastUpdateID});
9494
});
9595

9696
airshipEventsPromise = updates
9797
.reduce((promise, update) => promise.then(() => Onyx.update(update.data)), airshipEventsPromise)
9898
.then(() => {
9999
Performance.markEnd(CONST.TIMING.APPLY_AIRSHIP_UPDATES);
100-
console.debug('[OnyxUpdateManager] Done applying Airship updates');
100+
Log.info('[OnyxUpdateManager] Done applying Airship updates', false, {lastUpdateID});
101101
});
102102

103103
return airshipEventsPromise;
@@ -136,7 +136,7 @@ function apply({lastUpdateID, type, request, response, updates}: OnyxUpdatesFrom
136136

137137
// We use a spread here instead of delete because we don't want to change the response for other middlewares
138138
const {onyxData, ...responseWithoutOnyxData} = response;
139-
return applyHTTPSOnyxUpdates(request, responseWithoutOnyxData);
139+
return applyHTTPSOnyxUpdates(request, responseWithoutOnyxData, Number(lastUpdateID));
140140
}
141141

142142
return Promise.resolve();
@@ -145,13 +145,13 @@ function apply({lastUpdateID, type, request, response, updates}: OnyxUpdatesFrom
145145
Onyx.merge(ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT, Number(lastUpdateID));
146146
}
147147
if (type === CONST.ONYX_UPDATE_TYPES.HTTPS && request && response) {
148-
return applyHTTPSOnyxUpdates(request, response);
148+
return applyHTTPSOnyxUpdates(request, response, Number(lastUpdateID));
149149
}
150150
if (type === CONST.ONYX_UPDATE_TYPES.PUSHER && updates) {
151-
return applyPusherOnyxUpdates(updates);
151+
return applyPusherOnyxUpdates(updates, Number(lastUpdateID));
152152
}
153153
if (type === CONST.ONYX_UPDATE_TYPES.AIRSHIP && updates) {
154-
return applyAirshipOnyxUpdates(updates);
154+
return applyAirshipOnyxUpdates(updates, Number(lastUpdateID));
155155
}
156156
}
157157

src/libs/actions/__mocks__/OnyxUpdates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const apply = jest.fn(({lastUpdateID, request, response}: OnyxUpdatesFromServer)
2424
}
2525

2626
if (request && response) {
27-
return applyHTTPSOnyxUpdates(request, response).then(() => undefined);
27+
return applyHTTPSOnyxUpdates(request, response, Number(lastUpdateID)).then(() => undefined);
2828
}
2929

3030
return Promise.resolve();

0 commit comments

Comments
 (0)