From e13d4832ffa4a7895f65cd427ca5e548673617ba Mon Sep 17 00:00:00 2001 From: Mark Hahnenberg Date: Wed, 22 Mar 2017 18:05:51 -0700 Subject: [PATCH] [client-app] Record file download times Summary: We'd like to get an idea of how long the client app is having to wait when requesting a file. Waiting can cause things like inline image attachments to appear very slow to load. Test Plan: Run locally Reviewers: evan, spang, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D4255 --- .../src/flux/stores/file-download-store.es6 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/client-app/src/flux/stores/file-download-store.es6 b/packages/client-app/src/flux/stores/file-download-store.es6 index 900fc60d0..bd25d7e34 100644 --- a/packages/client-app/src/flux/stores/file-download-store.es6 +++ b/packages/client-app/src/flux/stores/file-download-store.es6 @@ -101,7 +101,15 @@ export class Download { let startRequest = null; + const before = Date.now(); + const onFailed = (err) => { + Actions.recordPerfMetric({ + action: 'file-download-failed', + accountId: this.accountId, + actionTimeMs: Date.now() - before, + maxValue: 10 * 60 * 1000, + }) this.request = null; stream.end(); if (!this.retryWithBackoff || this.attempts >= this.maxAttempts) { @@ -118,6 +126,12 @@ export class Download { }; const onSuccess = () => { + Actions.recordPerfMetric({ + action: 'file-download-succeeded', + accountId: this.accountId, + actionTimeMs: Date.now() - before, + maxValue: 10 * 60 * 1000, + }) this.request = null; stream.end(); this.state = State.Finished;