diff --git a/src/libs/Firebase/index.native.ts b/src/libs/Firebase/index.native.ts index 75884bed59b6..7215b9ec68ea 100644 --- a/src/libs/Firebase/index.native.ts +++ b/src/libs/Firebase/index.native.ts @@ -2,6 +2,7 @@ import crashlytics from '@react-native-firebase/crashlytics'; import perf from '@react-native-firebase/perf'; import * as Environment from '@libs/Environment/Environment'; +import * as SessionUtils from '@libs/SessionUtils'; import type {Log, StartTrace, StopTrace, TraceMap} from './types'; const traceMap: TraceMap = {}; @@ -16,9 +17,12 @@ const startTrace: StartTrace = (customEventName) => { return; } + const session = SessionUtils.getSession(); + perf() .startTrace(customEventName) .then((trace) => { + trace.putAttribute('accountID', session?.accountID?.toString() ?? 'N/A'); traceMap[customEventName] = { trace, start, diff --git a/src/libs/SessionUtils.ts b/src/libs/SessionUtils.ts index e8854e158b48..88c4f01e17d1 100644 --- a/src/libs/SessionUtils.ts +++ b/src/libs/SessionUtils.ts @@ -1,5 +1,7 @@ import Onyx from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; import ONYXKEYS from '@src/ONYXKEYS'; +import type * as OnyxTypes from '@src/types/onyx'; /** * Determine if the transitioning user is logging in as a new user. @@ -26,12 +28,14 @@ function isLoggingInAsNewUser(transitionURL?: string, sessionEmail?: string): bo } let loggedInDuringSession: boolean | undefined; +let currentSession: OnyxEntry; // To tell if the user logged in during this session we will check the value of session.authToken once when the app's JS inits. When the user logs out // we can reset this flag so that it can be updated again. Onyx.connect({ key: ONYXKEYS.SESSION, callback: (session) => { + currentSession = session; if (loggedInDuringSession) { return; } @@ -53,4 +57,8 @@ function didUserLogInDuringSession() { return !!loggedInDuringSession; } -export {isLoggingInAsNewUser, didUserLogInDuringSession, resetDidUserLogInDuringSession}; +function getSession() { + return currentSession; +} + +export {isLoggingInAsNewUser, didUserLogInDuringSession, resetDidUserLogInDuringSession, getSession};