Avoid registering wrong performance load logs (#8107)

This commit is contained in:
Daniel Espino García 2024-07-24 18:42:31 +02:00 committed by GitHub
parent a3ac7535f1
commit 26ae247d0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 0 deletions

View file

@ -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) {

View file

@ -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);
}

View file

@ -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();