javascript: don't report connectivity issues to Sentry

This commit is contained in:
Pierre de La Morinerie 2020-04-15 14:35:39 +00:00
parent 55788990da
commit b2231e98d5
3 changed files with 17 additions and 3 deletions

View file

@ -1,5 +1,6 @@
import Rails from '@rails/ujs';
import AutoUploadController from './auto-upload-controller.js';
import { FAILURE_CONNECTIVITY } from '../../shared/activestorage/file-upload-error';
// Manage multiple concurrent uploads.
//
@ -17,6 +18,11 @@ export default class AutoUploadsControllers {
try {
let controller = new AutoUploadController(input, file);
await controller.start();
} catch (error) {
// Report errors to Sentry (except connectivity issues)
if (error.failureReason != FAILURE_CONNECTIVITY) {
throw error;
}
} finally {
this._decrementInFlightUploads(form);
}

View file

@ -1,5 +1,8 @@
import ProgressBar from './progress-bar';
import { errorFromDirectUploadMessage } from './file-upload-error';
import {
errorFromDirectUploadMessage,
FAILURE_CONNECTIVITY
} from './file-upload-error';
import { fire } from '@utils';
const INITIALIZE_EVENT = 'direct-upload:initialize';
@ -56,7 +59,9 @@ addUploadEventListener(ERROR_EVENT, event => {
ProgressBar.error(id, errorMsg);
let error = errorFromDirectUploadMessage(errorMsg);
fire(document, 'sentry:capture-exception', error);
if (error.failureReason != FAILURE_CONNECTIVITY) {
fire(document, 'sentry:capture-exception', error);
}
});
addUploadEventListener(END_EVENT, ({ detail: { id } }) => {

View file

@ -1,7 +1,10 @@
import { DirectUpload } from '@rails/activestorage';
import { ajax } from '@utils';
import ProgressBar from './progress-bar';
import FileUploadError, { errorFromDirectUploadMessage, ERROR_CODE_ATTACH } from './file-upload-error';
import FileUploadError, {
errorFromDirectUploadMessage,
ERROR_CODE_ATTACH
} from './file-upload-error';
/**
Uploader class is a delegate for DirectUpload instance