From 26ae247d0f30dfe2dcf70939de6e9a6628ca1cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Wed, 24 Jul 2024 18:42:31 +0200 Subject: [PATCH] Avoid registering wrong performance load logs (#8107) --- app/actions/remote/entry/login.ts | 6 ++++++ app/managers/performance_metrics_manager/index.ts | 4 ++++ share_extension/index.tsx | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/app/actions/remote/entry/login.ts b/app/actions/remote/entry/login.ts index 6206e03e3..48b734914 100644 --- a/app/actions/remote/entry/login.ts +++ b/app/actions/remote/entry/login.ts @@ -4,6 +4,7 @@ import {fetchConfigAndLicense} from '@actions/remote/systems'; import DatabaseManager from '@database/manager'; import {getServerCredentials} from '@init/credentials'; +import PerformanceMetricsManager from '@managers/performance_metrics_manager'; import WebsocketManager from '@managers/websocket_manager'; type AfterLoginArgs = { @@ -16,6 +17,11 @@ export async function loginEntry({serverUrl}: AfterLoginArgs): Promise<{error?: return {error: `${serverUrl} database not found`}; } + // There are cases where the target may be reset and a performance metric + // be added after login. This would be done with a wrong value, so we make + // sure we don't do this by skipping the load metric here. + PerformanceMetricsManager.skipLoadMetric(); + try { const clData = await fetchConfigAndLicense(serverUrl, false); if (clData.error) { diff --git a/app/managers/performance_metrics_manager/index.ts b/app/managers/performance_metrics_manager/index.ts index a3369f6a2..f3dcf8298 100644 --- a/app/managers/performance_metrics_manager/index.ts +++ b/app/managers/performance_metrics_manager/index.ts @@ -48,6 +48,10 @@ class PerformanceMetricsManager { this.target = target; } + public skipLoadMetric() { + this.hasRegisteredLoad = true; + } + public finishLoad(location: Target, serverUrl: string) { this.finishLoadWithRetries(location, serverUrl, 0); } diff --git a/share_extension/index.tsx b/share_extension/index.tsx index 47c3ed710..f541d9cb0 100644 --- a/share_extension/index.tsx +++ b/share_extension/index.tsx @@ -11,6 +11,7 @@ import {Appearance, BackHandler} from 'react-native'; import {getDefaultThemeByAppearance} from '@context/theme'; import {DEFAULT_LOCALE, getTranslations} from '@i18n'; import {initialize} from '@init/app'; +import PerformanceMetricsManager from '@managers/performance_metrics_manager'; import {extractStartLink, isValidUrl} from '@utils/url'; import ChannelsScreen from './screens/channels'; @@ -63,6 +64,13 @@ const ShareExtension = () => { return data?.filter((i) => !i.isString) || []; }, [data]); + useEffect(() => { + // Since the share functionality inits the app, the init mark gets set + // at this point. Therefore, any check on load times after this is done + // over the wrong value. + PerformanceMetricsManager.skipLoadMetric(); + }, []); + useEffect(() => { initialize().finally(async () => { const items = await MattermostShare.getSharedData();