[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
This commit is contained in:
Mark Hahnenberg 2017-03-22 18:05:51 -07:00
parent ce17f70f26
commit e13d4832ff

View file

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