javascript: report upload errors to Sentry
This commit is contained in:
parent
a6d6d72af5
commit
a3057afc22
2 changed files with 10 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
import ProgressBar from './progress-bar';
|
import ProgressBar from './progress-bar';
|
||||||
|
import { fire } from '@utils';
|
||||||
|
|
||||||
const INITIALIZE_EVENT = 'direct-upload:initialize';
|
const INITIALIZE_EVENT = 'direct-upload:initialize';
|
||||||
const START_EVENT = 'direct-upload:start';
|
const START_EVENT = 'direct-upload:start';
|
||||||
|
@ -36,8 +37,9 @@ addUploadEventListener(PROGRESS_EVENT, ({ detail: { id, progress } }) => {
|
||||||
ProgressBar.progress(id, progress);
|
ProgressBar.progress(id, progress);
|
||||||
});
|
});
|
||||||
|
|
||||||
addUploadEventListener(ERROR_EVENT, ({ detail: { id, error } }) => {
|
addUploadEventListener(ERROR_EVENT, event => {
|
||||||
ProgressBar.error(id, error);
|
ProgressBar.error(event.detail.id, event.detail.error);
|
||||||
|
fire(document, 'sentry:capture-exception', new Error(event.detail.error));
|
||||||
});
|
});
|
||||||
|
|
||||||
addUploadEventListener(END_EVENT, ({ detail: { id } }) => {
|
addUploadEventListener(END_EVENT, ({ detail: { id } }) => {
|
||||||
|
|
|
@ -10,4 +10,10 @@ if (enabled && key) {
|
||||||
scope.setUser(user);
|
scope.setUser(user);
|
||||||
scope.setExtra('browser', browser.modern ? 'modern' : 'legacy');
|
scope.setExtra('browser', browser.modern ? 'modern' : 'legacy');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Register a way to explicitely capture messages from a different bundle.
|
||||||
|
addEventListener('sentry:capture-exception', event => {
|
||||||
|
const error = event.detail;
|
||||||
|
Sentry.captureException(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue