diff --git a/.env.example b/.env.example index d884526f76df..127b7147230c 100644 --- a/.env.example +++ b/.env.example @@ -10,3 +10,4 @@ USE_NGROK=false USE_WEB_PROXY=false USE_WDYR=false CAPTURE_METRICS=false +ONYX_METRICS=false diff --git a/src/CONFIG.js b/src/CONFIG.js index 2b6a840690b6..dcbf3d8ea4fe 100644 --- a/src/CONFIG.js +++ b/src/CONFIG.js @@ -61,4 +61,5 @@ export default { UNREAD: '/favicon-unread.png', }, CAPTURE_METRICS: lodashGet(Config, 'CAPTURE_METRICS', false), + ONYX_METRICS: lodashGet(Config, 'ONYX_METRICS', false), }; diff --git a/src/components/OnyxProvider.js b/src/components/OnyxProvider.js index 504e5c6f320b..0c20ce2cdc66 100644 --- a/src/components/OnyxProvider.js +++ b/src/components/OnyxProvider.js @@ -7,13 +7,13 @@ import ComposeProviders from './ComposeProviders'; import CONST from '../CONST'; import Log from '../libs/Log'; import listenToStorageEvents from '../libs/listenToStorageEvents'; -import canCapturePerformanceMetrics from '../libs/canCapturePerformanceMetrics'; +import {canCaptureOnyxMetrics} from '../libs/canCaptureMetrics'; // Initialize the store when the app loads for the first time Onyx.init({ keys: ONYXKEYS, safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], - captureMetrics: canCapturePerformanceMetrics(), + captureMetrics: canCaptureOnyxMetrics(), initialKeyStates: { // Clear any loading and error messages so they do not appear on app startup diff --git a/src/libs/Performance.js b/src/libs/Performance.js index c70d98d0bba2..3d0cacdd8c83 100644 --- a/src/libs/Performance.js +++ b/src/libs/Performance.js @@ -3,7 +3,7 @@ import lodashTransform from 'lodash/transform'; import React, {Profiler, forwardRef} from 'react'; import {Alert} from 'react-native'; -import canCapturePerformanceMetrics from './canCapturePerformanceMetrics'; +import {canCapturePerformanceMetrics} from './canCaptureMetrics'; import getComponentDisplayName from './getComponentDisplayName'; import CONST from '../CONST'; diff --git a/src/libs/canCaptureMetrics/index.js b/src/libs/canCaptureMetrics/index.js new file mode 100644 index 000000000000..420dd2898aee --- /dev/null +++ b/src/libs/canCaptureMetrics/index.js @@ -0,0 +1,6 @@ +import CONFIG from '../../CONFIG'; + +// We don't capture performance metrics on web as there are enough tools available +export const canCapturePerformanceMetrics = () => false; + +export const canCaptureOnyxMetrics = () => Boolean(CONFIG.ONYX_METRICS); diff --git a/src/libs/canCaptureMetrics/index.native.js b/src/libs/canCaptureMetrics/index.native.js new file mode 100644 index 000000000000..30c839b1b231 --- /dev/null +++ b/src/libs/canCaptureMetrics/index.native.js @@ -0,0 +1,15 @@ +import CONFIG from '../../CONFIG'; + +/** + * Is capturing performance stats enabled. + * + * @returns {Boolean} + */ +export const canCapturePerformanceMetrics = () => Boolean(CONFIG.CAPTURE_METRICS); + +/** + * Is capturing Onyx stats enabled. + * + * @returns {Boolean} + */ +export const canCaptureOnyxMetrics = () => Boolean(CONFIG.ONYX_METRICS); diff --git a/src/libs/canCapturePerformanceMetrics/index.js b/src/libs/canCapturePerformanceMetrics/index.js deleted file mode 100644 index 1dc112f46dec..000000000000 --- a/src/libs/canCapturePerformanceMetrics/index.js +++ /dev/null @@ -1,2 +0,0 @@ -// We don't capture performance metrics on web as there are enough tools available -export default () => false; diff --git a/src/libs/canCapturePerformanceMetrics/index.native.js b/src/libs/canCapturePerformanceMetrics/index.native.js deleted file mode 100644 index a324c28a607c..000000000000 --- a/src/libs/canCapturePerformanceMetrics/index.native.js +++ /dev/null @@ -1,10 +0,0 @@ -import CONFIG from '../../CONFIG'; - -/** - * Enables capturing performance stats. - * - * @returns {Boolean} - */ -export default function canCapturePerformanceMetrics() { - return Boolean(CONFIG.CAPTURE_METRICS); -}