mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Throttle Sentry exceptions
This commit is contained in:
parent
35c19ed305
commit
b9fd0a03b0
@ -45,7 +45,6 @@ export async function findResourcesForResourceGroup (resourceGroupId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getResourceById (id) {
|
export async function getResourceById (id) {
|
||||||
// TODO: this query should probably include resourceGroupId as well
|
|
||||||
const rawDocs = await _promisifyCallback(_getDB(TYPE_RESOURCE), 'find', {id});
|
const rawDocs = await _promisifyCallback(_getDB(TYPE_RESOURCE), 'find', {id});
|
||||||
return rawDocs.length >= 1 ? rawDocs[0] : null;
|
return rawDocs.length >= 1 ? rawDocs[0] : null;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
<script src="./external/raven.min.js"></script>
|
<script src="./external/raven.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
// UPDATE HANDLERS
|
// UPDATE HANDLERS
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
const CHECK_FOR_UPDATES_INTERVAL = 1000 * 60 * 60 * 3; // 3 hours
|
const CHECK_FOR_UPDATES_INTERVAL = 1000 * 60 * 60 * 3; // 3 hours
|
||||||
|
|
||||||
@ -36,9 +35,18 @@
|
|||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
// Sentry
|
// Sentry (with rate limiting)
|
||||||
|
(function () {
|
||||||
|
// Send a maximum of n errors per interval
|
||||||
|
const MAX_ERRORS_PER_INTERVAL = 5;
|
||||||
|
const MAX_ERRORS_INTERVAL = 1000 * 60;
|
||||||
|
|
||||||
|
// Variable to keep track of errors per interval
|
||||||
|
let intervalErrorCount = 0;
|
||||||
|
|
||||||
|
// Reset error count after every interval
|
||||||
|
setInterval(() => intervalErrorCount = 0, MAX_ERRORS_INTERVAL);
|
||||||
|
|
||||||
if (process.env.INSOMNIA_ENV !== 'development') {
|
|
||||||
Raven.config('https://786e43ae199c4757a9ea4a48a9abd17d@sentry.io/109702', {
|
Raven.config('https://786e43ae199c4757a9ea4a48a9abd17d@sentry.io/109702', {
|
||||||
logger: 'electron.renderer',
|
logger: 'electron.renderer',
|
||||||
environment: process.env.INSOMNIA_ENV || 'production',
|
environment: process.env.INSOMNIA_ENV || 'production',
|
||||||
@ -50,6 +58,18 @@
|
|||||||
includePaths: [
|
includePaths: [
|
||||||
/^(?!.*raven.min.js$).*$/ // Ignore raven stuff
|
/^(?!.*raven.min.js$).*$/ // Ignore raven stuff
|
||||||
],
|
],
|
||||||
|
shouldSendCallback: function (data) {
|
||||||
|
if (process.env.INSOMNIA_ENV === 'development') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (intervalErrorCount++ > MAX_ERRORS_PER_INTERVAL) {
|
||||||
|
console.log('-- Throttling Sentry Exceptions --');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
dataCallback: function (data) {
|
dataCallback: function (data) {
|
||||||
var normalize = function (filename) {
|
var normalize = function (filename) {
|
||||||
var match = filename.match(/\/(app.asar|build)\/(.*)/);
|
var match = filename.match(/\/(app.asar|build)\/(.*)/);
|
||||||
@ -72,23 +92,20 @@
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
}).install();
|
}).install();
|
||||||
|
})();
|
||||||
console.log('-- Initialized Sentry --');
|
|
||||||
} else {
|
|
||||||
console.log('-- Did not Initialize Sentry --');
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
const {productName, version} = require('./package.json');
|
(function () {
|
||||||
if (process.env.INSOMNIA_ENV === 'development') {
|
const {productName, version} = require('./package.json');
|
||||||
document.title = `${productName} v${version} (DEV)`;
|
if (process.env.INSOMNIA_ENV === 'development') {
|
||||||
} else {
|
document.title = `${productName} v${version} (DEV)`;
|
||||||
document.title = `${productName} v${version}`;
|
} else {
|
||||||
}
|
document.title = `${productName} v${version}`;
|
||||||
|
}
|
||||||
|
})()
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
// HOT RELOADING IN DEV
|
// HOT RELOADING IN DEV
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
const script = document.createElement('script');
|
const script = document.createElement('script');
|
||||||
script.src = (process.env.HOT) ? 'http://localhost:3333/build/bundle.js' : './bundle.js';
|
script.src = (process.env.HOT) ? 'http://localhost:3333/build/bundle.js' : './bundle.js';
|
||||||
@ -98,7 +115,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
// SOME HELPERS
|
// SOME HELPERS
|
||||||
|
|
||||||
document.body.setAttribute('data-platform', process.platform);
|
document.body.setAttribute('data-platform', process.platform);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user