Skip to content
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
2 changes: 2 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,8 @@ const CONST = {
TIMING: {
GET_ORDERED_REPORT_IDS: 'get_ordered_report_ids',
CALCULATE_MOST_RECENT_LAST_MODIFIED_ACTION: 'calc_most_recent_last_modified_action',
OPEN_APP: 'open_app',
SPLASH_SCREEN: 'splash_screen',
OPEN_SEARCH: 'open_search',
OPEN_REPORT: 'open_report',
OPEN_REPORT_FROM_PREVIEW: 'open_report_from_preview',
Expand Down
11 changes: 10 additions & 1 deletion src/SplashScreenStateContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useContext, useMemo, useState} from 'react';
import React, {useContext, useEffect, useMemo, useState} from 'react';
import type {ValueOf} from 'type-fest';
import CONST from './CONST';
import Timing from './libs/actions/Timing';
import type ChildrenProps from './types/utils/ChildrenProps';

type SplashScreenStateContextType = {
Expand All @@ -23,6 +24,14 @@ function SplashScreenStateContextProvider({children}: ChildrenProps) {
[splashScreenState],
);

useEffect(() => {
if (splashScreenState !== 'hidden') {
return;
}

Timing.end(CONST.TIMING.SPLASH_SCREEN);
}, [splashScreenState]);

return <SplashScreenStateContext.Provider value={splashScreenStateContext}>{children}</SplashScreenStateContext.Provider>;
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const isReadyToOpenApp = new Promise<void>((resolve) => {
});

function confirmReadyToOpenApp() {
Timing.end(CONST.TIMING.OPEN_APP);
resolveIsReadyPromise();
}

Expand Down Expand Up @@ -215,7 +216,6 @@ function setSidebarLoaded() {

Onyx.set(ONYXKEYS.IS_SIDEBAR_LOADED, true);
Performance.markEnd(CONST.TIMING.SIDEBAR_LOADED);
Timing.end(CONST.TIMING.SIDEBAR_LOADED);
}

function setAppLoading(isLoading: boolean) {
Expand Down
5 changes: 5 additions & 0 deletions src/pages/Search/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {confirmReadyToOpenApp} from '@libs/actions/App';
import {searchInServer} from '@libs/actions/Report';
import {
approveMoneyRequestOnSearch,
Expand Down Expand Up @@ -90,6 +91,10 @@ function SearchPage({route}: SearchPageProps) {
const [currentSearchResults] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${queryJSON?.hash ?? CONST.DEFAULT_NUMBER_ID}`, {canBeMissing: true});
const [lastNonEmptySearchResults, setLastNonEmptySearchResults] = useState<SearchResults | undefined>(undefined);

useEffect(() => {
confirmReadyToOpenApp();
}, []);

useEffect(() => {
if (!currentSearchResults?.search?.type) {
return;
Expand Down
2 changes: 0 additions & 2 deletions src/pages/home/sidebar/BaseSidebarScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import {isMobile} from '@libs/Browser';
import Performance from '@libs/Performance';
import Timing from '@userActions/Timing';
import CONST from '@src/CONST';
import SidebarLinksData from './SidebarLinksData';

Expand All @@ -21,7 +20,6 @@ function BaseSidebarScreen() {

useEffect(() => {
Performance.markStart(CONST.TIMING.SIDEBAR_LOADED);
Timing.start(CONST.TIMING.SIDEBAR_LOADED);
}, []);

return (
Expand Down
3 changes: 3 additions & 0 deletions src/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import ONYXKEYS from '@src/ONYXKEYS';
import addUtilsToWindow from './addUtilsToWindow';
import initializeLastVisitedPath from './initializeLastVisitedPath';
import platformSetup from './platformSetup';
import telemetry from './telemetry';

export default function () {
telemetry();

/*
* Initialize the Onyx store when the app loads for the first time.
*
Expand Down
17 changes: 17 additions & 0 deletions src/setup/telemetry/index.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {AppState} from 'react-native';
import type {AppStateStatus} from 'react-native';
import Timing from '@userActions/Timing';
import CONST from '@src/CONST';

export default function () {
Timing.start(CONST.TIMING.SPLASH_SCREEN);
Timing.start(CONST.TIMING.OPEN_APP);

AppState.addEventListener('change', (nextState: AppStateStatus) => {
if (nextState !== 'active') {
return;
}

Timing.clearData();
});
}
15 changes: 15 additions & 0 deletions src/setup/telemetry/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Timing from '@userActions/Timing';
import CONST from '@src/CONST';

export default function () {
Timing.start(CONST.TIMING.SPLASH_SCREEN);
Timing.start(CONST.TIMING.OPEN_APP);

document.addEventListener('visibilitychange', () => {
if (!document.hidden) {
return;
}

Timing.clearData();
});
}