diff --git a/src/CONST.ts b/src/CONST.ts index 4da05d85cfd..1d971e45054 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1308,6 +1308,9 @@ const CONST = { SIDEBAR_LOADED: 'sidebar_loaded', LOAD_SEARCH_OPTIONS: 'load_search_options', SEND_MESSAGE: 'send_message', + APPLY_AIRSHIP_UPDATES: 'apply_airship_updates', + APPLY_PUSHER_UPDATES: 'apply_pusher_updates', + APPLY_HTTPS_UPDATES: 'apply_https_updates', COLD: 'cold', WARM: 'warm', REPORT_ACTION_ITEM_LAYOUT_DEBOUNCE_TIME: 1500, diff --git a/src/libs/actions/OnyxUpdates.ts b/src/libs/actions/OnyxUpdates.ts index 1ba50d08e44..52dfa9dfd74 100644 --- a/src/libs/actions/OnyxUpdates.ts +++ b/src/libs/actions/OnyxUpdates.ts @@ -3,6 +3,7 @@ import Onyx from 'react-native-onyx'; import type {Merge} from 'type-fest'; import Log from '@libs/Log'; import * as SequentialQueue from '@libs/Network/SequentialQueue'; +import Performance from '@libs/Performance'; import PusherUtils from '@libs/PusherUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -26,6 +27,7 @@ let pusherEventsPromise = Promise.resolve(); let airshipEventsPromise = Promise.resolve(); function applyHTTPSOnyxUpdates(request: Request, response: Response) { + Performance.markStart(CONST.TIMING.APPLY_HTTPS_UPDATES); console.debug('[OnyxUpdateManager] Applying https update'); // 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 // the UI. See https://github.com/Expensify/App/issues/12775 for more info. @@ -61,12 +63,15 @@ function applyHTTPSOnyxUpdates(request: Request, response: Response) { return Promise.resolve(); }) .then(() => { + Performance.markEnd(CONST.TIMING.APPLY_HTTPS_UPDATES); console.debug('[OnyxUpdateManager] Done applying HTTPS update'); return Promise.resolve(response); }); } function applyPusherOnyxUpdates(updates: OnyxUpdateEvent[]) { + Performance.markStart(CONST.TIMING.APPLY_PUSHER_UPDATES); + pusherEventsPromise = pusherEventsPromise.then(() => { console.debug('[OnyxUpdateManager] Applying pusher update'); }); @@ -74,6 +79,7 @@ function applyPusherOnyxUpdates(updates: OnyxUpdateEvent[]) { pusherEventsPromise = updates .reduce((promise, update) => promise.then(() => PusherUtils.triggerMultiEventHandler(update.eventType, update.data)), pusherEventsPromise) .then(() => { + Performance.markEnd(CONST.TIMING.APPLY_PUSHER_UPDATES); console.debug('[OnyxUpdateManager] Done applying Pusher update'); }); @@ -81,6 +87,8 @@ function applyPusherOnyxUpdates(updates: OnyxUpdateEvent[]) { } function applyAirshipOnyxUpdates(updates: OnyxUpdateEvent[]) { + Performance.markStart(CONST.TIMING.APPLY_AIRSHIP_UPDATES); + airshipEventsPromise = airshipEventsPromise.then(() => { console.debug('[OnyxUpdateManager] Applying Airship updates'); }); @@ -88,6 +96,7 @@ function applyAirshipOnyxUpdates(updates: OnyxUpdateEvent[]) { airshipEventsPromise = updates .reduce((promise, update) => promise.then(() => Onyx.update(update.data)), airshipEventsPromise) .then(() => { + Performance.markEnd(CONST.TIMING.APPLY_AIRSHIP_UPDATES); console.debug('[OnyxUpdateManager] Done applying Airship updates'); });