From 2cc4b004312759f7d6d2081b1ec88d77dcbfb3ca Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Mon, 7 Jun 2021 15:16:49 -0400 Subject: [PATCH] fix start since launch metric (#5433) --- app/mattermost.js | 4 +--- app/telemetry/index.ts | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/mattermost.js b/app/mattermost.js index 18034fa5a..bc53b35e8 100644 --- a/app/mattermost.js +++ b/app/mattermost.js @@ -76,9 +76,7 @@ const launchApp = (credentials) => { resetToSelectServer(emmProvider.allowOtherServers); } - if (!EphemeralStore.appStarted) { - telemetry.startSinceLaunch(credentials ? 'Launch on Channel Screen' : 'Launch on Server Screen'); - } + telemetry.startSinceLaunch(credentials ? 'Launch on Channel Screen' : 'Launch on Server Screen'); }); EphemeralStore.appStarted = true; diff --git a/app/telemetry/index.ts b/app/telemetry/index.ts index 3502aff43..61708829e 100644 --- a/app/telemetry/index.ts +++ b/app/telemetry/index.ts @@ -19,10 +19,12 @@ export const PERF_MARKERS = { class Telemetry { metrics: PerfMetric[]; currentMetrics: Record; + started: boolean; constructor() { this.metrics = []; this.currentMetrics = {}; + this.started = false; } getMetrics = () => { @@ -62,14 +64,17 @@ class Telemetry { } startSinceLaunch(extra = '') { - getTimeSinceStartup().then((endTime) => { - this.metrics.push({ - extra, - name: PERF_MARKERS.START_SINCE_LAUNCH, - startTime: 0, - endTime, + if (!this.started) { + this.started = true; + getTimeSinceStartup().then((endTime) => { + this.metrics.push({ + extra, + name: PERF_MARKERS.START_SINCE_LAUNCH, + startTime: 0, + endTime, + }); }); - }); + } } remove(names = []) {