mirror of
https://github.com/Kong/insomnia.git
synced 2026-04-21 22:57:59 -04:00
Track unhandled error counts in GA
This commit is contained in:
@@ -23,6 +23,16 @@ export async function init (accountId) {
|
||||
ipcRenderer.on('analytics-track-event', (_, args) => {
|
||||
trackEvent(...args);
|
||||
});
|
||||
|
||||
if (window) {
|
||||
window.addEventListener('error', e => {
|
||||
trackEvent('Error', 'Uncaught Error');
|
||||
});
|
||||
|
||||
window.addEventListener('unhandledrejection', e => {
|
||||
trackEvent('Error', 'Uncaught Promise');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function trackEvent (...args) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import PromptModal from './prompt-modal';
|
||||
import AlertModal from './alert-modal';
|
||||
|
||||
const modals = {};
|
||||
|
||||
@@ -14,6 +15,10 @@ export function showPrompt (config) {
|
||||
showModal(PromptModal, config);
|
||||
}
|
||||
|
||||
export function showAlert (config) {
|
||||
showModal(AlertModal, config);
|
||||
}
|
||||
|
||||
export function showModal (modalCls, ...args) {
|
||||
return _getModal(modalCls).show(...args);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import * as mime from 'mime-types';
|
||||
import * as path from 'path';
|
||||
import * as render from '../../common/render';
|
||||
import {getKeys} from '../../templating/utils';
|
||||
import {showPrompt} from '../components/modals/index';
|
||||
import {showAlert, showPrompt} from '../components/modals/index';
|
||||
import {exportHar} from '../../common/har';
|
||||
|
||||
const KEY_ENTER = 13;
|
||||
@@ -440,8 +440,18 @@ class App extends PureComponent {
|
||||
} else {
|
||||
await models.response.create(responsePatch, bodyBuffer);
|
||||
}
|
||||
} catch (e) {
|
||||
// It's OK
|
||||
} catch (err) {
|
||||
showAlert({
|
||||
title: 'Unexpected Request Failure',
|
||||
message: (
|
||||
<div>
|
||||
<p>The request failed due to an unhandled error:</p>
|
||||
<code className="wide selectable">
|
||||
<pre>{err.message}</pre>
|
||||
</code>
|
||||
</div>
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
// Unset active response because we just made a new one
|
||||
@@ -473,6 +483,18 @@ class App extends PureComponent {
|
||||
} catch (err) {
|
||||
if (err.type === 'render') {
|
||||
showModal(RequestRenderErrorModal, {request, error: err});
|
||||
} else {
|
||||
showAlert({
|
||||
title: 'Unexpected Request Failure',
|
||||
message: (
|
||||
<div>
|
||||
<p>The request failed due to an unhandled error:</p>
|
||||
<code className="wide selectable">
|
||||
<pre>{err.message}</pre>
|
||||
</code>
|
||||
</div>
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user