@@ -32,6 +32,8 @@ import utils from './utils';
3232import type { WithOnyxState } from './withOnyx/types' ;
3333import type { DeferredTask } from './createDeferredTask' ;
3434import createDeferredTask from './createDeferredTask' ;
35+ import * as GlobalSettings from './GlobalSettings' ;
36+ import decorateWithMetrics from './metrics' ;
3537
3638// Method constants
3739const METHOD = {
@@ -1418,6 +1420,51 @@ const OnyxUtils = {
14181420 getEvictionBlocklist,
14191421} ;
14201422
1421- export type { OnyxMethod } ;
1423+ GlobalSettings . addGlobalSettingsChangeListener ( ( { enablePerformanceMetrics} ) => {
1424+ if ( ! enablePerformanceMetrics ) {
1425+ return ;
1426+ }
1427+ // We are reassigning the functions directly so that internal function calls are also decorated
1428+
1429+ // @ts -expect-error Reassign
1430+ initStoreValues = decorateWithMetrics ( initStoreValues , 'OnyxUtils.initStoreValues' ) ;
1431+ // @ts -expect-error Reassign
1432+ maybeFlushBatchUpdates = decorateWithMetrics ( maybeFlushBatchUpdates , 'OnyxUtils.maybeFlushBatchUpdates' ) ;
1433+ // @ts -expect-error Reassign
1434+ batchUpdates = decorateWithMetrics ( batchUpdates , 'OnyxUtils.batchUpdates' ) ;
1435+ // @ts -expect-error Complex type signature
1436+ get = decorateWithMetrics ( get , 'OnyxUtils.get' ) ;
1437+ // @ts -expect-error Reassign
1438+ getAllKeys = decorateWithMetrics ( getAllKeys , 'OnyxUtils.getAllKeys' ) ;
1439+ // @ts -expect-error Reassign
1440+ getCollectionKeys = decorateWithMetrics ( getCollectionKeys , 'OnyxUtils.getCollectionKeys' ) ;
1441+ // @ts -expect-error Reassign
1442+ addAllSafeEvictionKeysToRecentlyAccessedList = decorateWithMetrics ( addAllSafeEvictionKeysToRecentlyAccessedList , 'OnyxUtils.addAllSafeEvictionKeysToRecentlyAccessedList' ) ;
1443+ // @ts -expect-error Reassign
1444+ keysChanged = decorateWithMetrics ( keysChanged , 'OnyxUtils.keysChanged' ) ;
1445+ // @ts -expect-error Reassign
1446+ keyChanged = decorateWithMetrics ( keyChanged , 'OnyxUtils.keyChanged' ) ;
1447+ // @ts -expect-error Reassign
1448+ sendDataToConnection = decorateWithMetrics ( sendDataToConnection , 'OnyxUtils.sendDataToConnection' ) ;
1449+ // @ts -expect-error Reassign
1450+ scheduleSubscriberUpdate = decorateWithMetrics ( scheduleSubscriberUpdate , 'OnyxUtils.scheduleSubscriberUpdate' ) ;
1451+ // @ts -expect-error Reassign
1452+ scheduleNotifyCollectionSubscribers = decorateWithMetrics ( scheduleNotifyCollectionSubscribers , 'OnyxUtils.scheduleNotifyCollectionSubscribers' ) ;
1453+ // @ts -expect-error Reassign
1454+ remove = decorateWithMetrics ( remove , 'OnyxUtils.remove' ) ;
1455+ // @ts -expect-error Reassign
1456+ reportStorageQuota = decorateWithMetrics ( reportStorageQuota , 'OnyxUtils.reportStorageQuota' ) ;
1457+ // @ts -expect-error Complex type signature
1458+ evictStorageAndRetry = decorateWithMetrics ( evictStorageAndRetry , 'OnyxUtils.evictStorageAndRetry' ) ;
1459+ // @ts -expect-error Reassign
1460+ broadcastUpdate = decorateWithMetrics ( broadcastUpdate , 'OnyxUtils.broadcastUpdate' ) ;
1461+ // @ts -expect-error Reassign
1462+ initializeWithDefaultKeyStates = decorateWithMetrics ( initializeWithDefaultKeyStates , 'OnyxUtils.initializeWithDefaultKeyStates' ) ;
1463+ // @ts -expect-error Complex type signature
1464+ multiGet = decorateWithMetrics ( multiGet , 'OnyxUtils.multiGet' ) ;
1465+ // @ts -expect-error Reassign
1466+ subscribeToKey = decorateWithMetrics ( subscribeToKey , 'OnyxUtils.subscribeToKey' ) ;
1467+ } ) ;
14221468
1469+ export type { OnyxMethod } ;
14231470export default OnyxUtils ;
0 commit comments