Skip to content

Commit

Permalink
Add ONYX_METRICS to .env and expose checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kidroca committed Aug 23, 2021
1 parent 87dc0fd commit a5e623a
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 15 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ USE_NGROK=false
USE_WEB_PROXY=false
USE_WDYR=false
CAPTURE_METRICS=false
ONYX_METRICS=false
1 change: 1 addition & 0 deletions src/CONFIG.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ export default {
UNREAD: '/favicon-unread.png',
},
CAPTURE_METRICS: lodashGet(Config, 'CAPTURE_METRICS', false),
ONYX_METRICS: lodashGet(Config, 'ONYX_METRICS', false),
};
4 changes: 2 additions & 2 deletions src/components/OnyxProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
6 changes: 6 additions & 0 deletions src/libs/canCaptureMetrics/index.js
Original file line number Diff line number Diff line change
@@ -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);
15 changes: 15 additions & 0 deletions src/libs/canCaptureMetrics/index.native.js
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 0 additions & 2 deletions src/libs/canCapturePerformanceMetrics/index.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/libs/canCapturePerformanceMetrics/index.native.js

This file was deleted.

0 comments on commit a5e623a

Please sign in to comment.