mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
133 lines
3.5 KiB
HTML
133 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Insomnia</title>
|
|
<script>
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="root"></div>
|
|
<script src="static/jsonlint.js"></script>
|
|
<script src="static/raven.min.js"></script>
|
|
<script>
|
|
// UPDATE HANDLERS
|
|
(function () {
|
|
const CHECK_FOR_UPDATES_INTERVAL = 1000 * 60 * 60 * 3; // 3 hours
|
|
|
|
function showUpdateNotification () {
|
|
console.log('-- Update Available --');
|
|
new Notification('Insomnia Update Ready', {
|
|
body: 'Relaunch the app for it to take effect',
|
|
silent: true,
|
|
sticky: true
|
|
});
|
|
}
|
|
|
|
const {ipcRenderer} = require('electron');
|
|
ipcRenderer.on('update-available', () => {
|
|
showUpdateNotification();
|
|
});
|
|
|
|
setInterval(() => {
|
|
ipcRenderer.send('check-for-updates');
|
|
}, CHECK_FOR_UPDATES_INTERVAL);
|
|
})();
|
|
</script>
|
|
<script>
|
|
// Sentry (with rate limiting)
|
|
(function () {
|
|
if (process.env.INSOMNIA_ENV === 'development') {
|
|
console.log('-- Not initializing Sentry for dev --');
|
|
return;
|
|
}
|
|
// 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);
|
|
|
|
Raven.config('https://786e43ae199c4757a9ea4a48a9abd17d@sentry.io/109702', {
|
|
logger: 'electron.renderer',
|
|
environment: process.env.INSOMNIA_ENV || 'production',
|
|
level: 'warning',
|
|
release: require('./package.json').version,
|
|
ignoreUrls: [
|
|
/.*raven\.min\.js.*/
|
|
],
|
|
includePaths: [
|
|
/^(?!.*raven.min.js$).*$/ // Ignore raven stuff
|
|
],
|
|
shouldSendCallback: function (data) {
|
|
if (intervalErrorCount++ > MAX_ERRORS_PER_INTERVAL) {
|
|
console.log('-- Throttling Sentry Exceptions --');
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
},
|
|
dataCallback: function (data) {
|
|
var normalize = function (filename) {
|
|
var match = filename.match(/\/(app.asar|build)\/(.*)/);
|
|
if (match) {
|
|
return match[2]; // return everything after ../app.asar/*
|
|
} else {
|
|
return filename;
|
|
}
|
|
};
|
|
|
|
if (!data.exception) {
|
|
// Probably a regular console.error, etc
|
|
return data;
|
|
}
|
|
|
|
data.exception.values[0].stacktrace.frames.forEach(function (frame) {
|
|
frame.filename = normalize(frame.filename);
|
|
});
|
|
|
|
return data
|
|
}
|
|
}).install();
|
|
})();
|
|
</script>
|
|
<script>
|
|
(function () {
|
|
const {productName, version} = require('./package.json');
|
|
if (process.env.INSOMNIA_ENV === 'development') {
|
|
document.title = `${productName} v${version} (DEV)`;
|
|
} else {
|
|
document.title = `${productName} v${version}`;
|
|
}
|
|
})()
|
|
</script>
|
|
<script>
|
|
// HOT RELOADING IN DEV
|
|
(function () {
|
|
const script = document.createElement('script');
|
|
script.src = (process.env.HOT) ? 'http://localhost:3333/build/bundle.js' : './bundle.js';
|
|
document.write(script.outerHTML);
|
|
}());
|
|
</script>
|
|
|
|
<script>
|
|
// SOME HELPERS
|
|
document.body.setAttribute('data-platform', process.platform);
|
|
</script>
|
|
|
|
<!-- Other Scripts -->
|
|
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
|
|
<script>
|
|
(function () {
|
|
const key = process.env.INSOMNIA_ENV === 'development' ?
|
|
'pk_test_MbOhGu5jCPvr7Jt4VC6oySdH' :
|
|
'pk_live_lntbVSXY3v1RAytACIQJ5BBH';
|
|
Stripe.setPublishableKey(key);
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|