Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture navigation logs to build breadcrumbs in Crashlytics #45776

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/libs/Firebase/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable no-unused-vars */
import crashlytics from '@react-native-firebase/crashlytics';
import perf from '@react-native-firebase/perf';
import * as Environment from '@libs/Environment/Environment';
import type {StartTrace, StopTrace, TraceMap} from './types';
import type {Log, StartTrace, StopTrace, TraceMap} from './types';

const traceMap: TraceMap = {};

Expand Down Expand Up @@ -46,7 +47,12 @@ const stopTrace: StopTrace = (customEventName) => {
delete traceMap[customEventName];
};

const log: Log = (action: string) => {
crashlytics().log(action);
};

export default {
startTrace,
stopTrace,
log,
};
4 changes: 3 additions & 1 deletion src/libs/Firebase/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type {StartTrace, StopTrace} from './types';
import type {Log, StartTrace, StopTrace} from './types';

/** Web does not use Firebase for performance tracing */
const startTrace: StartTrace = () => {};
const stopTrace: StopTrace = () => {};
const log: Log = () => {};

export default {
startTrace,
stopTrace,
log,
};
3 changes: 2 additions & 1 deletion src/libs/Firebase/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ type Trace = {
type TraceMap = Record<string, Trace>;
type StartTrace = (customEventName: string) => void;
type StopTrace = (customEventName: string) => void;
type Log = (action: string) => void;

export type {StartTrace, StopTrace, TraceMap};
export type {StartTrace, StopTrace, TraceMap, Log};
4 changes: 4 additions & 0 deletions src/libs/Navigation/NavigationRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useActiveWorkspace from '@hooks/useActiveWorkspace';
import useCurrentReportID from '@hooks/useCurrentReportID';
import useTheme from '@hooks/useTheme';
import useWindowDimensions from '@hooks/useWindowDimensions';
import Firebase from '@libs/Firebase';
import {FSPage} from '@libs/Fullstory';
import hasCompletedGuidedSetupFlowSelector from '@libs/hasCompletedGuidedSetupFlowSelector';
import Log from '@libs/Log';
Expand Down Expand Up @@ -149,6 +150,9 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N
if (!state) {
return;
}
const currentRoute = navigationRef.getCurrentRoute();
Firebase.log(`[NAVIGATION] screen: ${currentRoute?.name}, params: ${JSON.stringify(currentRoute?.params ?? {})}`);

const activeWorkspaceID = getPolicyIDFromState(state as NavigationState<RootStackParamList>);
// Performance optimization to avoid context consumers to delay first render
setTimeout(() => {
Expand Down
Loading