diff --git a/src/libs/Firebase/index.js b/src/libs/Firebase/index.js deleted file mode 100644 index a8c7a34f869f..000000000000 --- a/src/libs/Firebase/index.js +++ /dev/null @@ -1,6 +0,0 @@ -/** Web does not use Firebase for performance tracing */ - -export default { - startTrace() {}, - stopTrace() {}, -}; diff --git a/src/libs/Firebase/index.native.js b/src/libs/Firebase/index.native.ts similarity index 71% rename from src/libs/Firebase/index.native.js rename to src/libs/Firebase/index.native.ts index 0fc452a523ec..2014e2b8bd3e 100644 --- a/src/libs/Firebase/index.native.js +++ b/src/libs/Firebase/index.native.ts @@ -1,15 +1,11 @@ /* eslint-disable no-unused-vars */ import perf from '@react-native-firebase/perf'; -import lodashGet from 'lodash/get'; import * as Environment from '../Environment/Environment'; -import Log from '../Log'; +import {StartTrace, StopTrace, TraceMap} from './types'; -const traceMap = {}; +const traceMap: TraceMap = {}; -/** - * @param {String} customEventName - */ -function startTrace(customEventName) { +const startTrace: StartTrace = (customEventName) => { const start = global.performance.now(); if (Environment.isDevelopment()) { return; @@ -27,18 +23,16 @@ function startTrace(customEventName) { start, }; }); -} +}; -/** - * @param {String} customEventName - */ -function stopTrace(customEventName) { - const stop = global.performance.now(); +const stopTrace: StopTrace = (customEventName) => { + // Uncomment to inspect logs on release builds + // const stop = global.performance.now(); if (Environment.isDevelopment()) { return; } - const trace = lodashGet(traceMap, [customEventName, 'trace']); + const trace = traceMap[customEventName].trace; if (!trace) { return; } @@ -50,7 +44,7 @@ function stopTrace(customEventName) { // Log.info(`sidebar_loaded: ${stop - start} ms`, true); delete traceMap[customEventName]; -} +}; export default { startTrace, diff --git a/src/libs/Firebase/index.ts b/src/libs/Firebase/index.ts new file mode 100644 index 000000000000..3048cf1d9bd8 --- /dev/null +++ b/src/libs/Firebase/index.ts @@ -0,0 +1,10 @@ +import {StartTrace, StopTrace} from './types'; + +/** Web does not use Firebase for performance tracing */ +const startTrace: StartTrace = () => {}; +const stopTrace: StopTrace = () => {}; + +export default { + startTrace, + stopTrace, +}; diff --git a/src/libs/Firebase/types.ts b/src/libs/Firebase/types.ts new file mode 100644 index 000000000000..3822f7072a7f --- /dev/null +++ b/src/libs/Firebase/types.ts @@ -0,0 +1,11 @@ +import {FirebasePerformanceTypes} from '@react-native-firebase/perf'; + +type Trace = { + trace: FirebasePerformanceTypes.Trace; + start: number; +}; +type TraceMap = Record; +type StartTrace = (customEventName: string) => void; +type StopTrace = (customEventName: string) => void; + +export type {StartTrace, StopTrace, TraceMap};