insomnia/app/renderer.html

129 lines
3.5 KiB
HTML
Raw Normal View History

2016-03-22 18:20:05 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
2016-07-21 22:26:51 +00:00
<title>Insomnia</title>
2016-03-22 18:20:05 +00:00
</head>
<body>
<div id="root"></div>
<script>
// HOT RELOADING IN DEV
(function () {
const script = document.createElement('script');
script.src = (process.env.HOT) ? 'http://localhost:3333/bundle.js' : './bundle.js';
document.write(script.outerHTML);
}());
</script>
<script src="static/raven.min.js"></script>
2016-10-11 21:06:25 +00:00
<script>
// UPDATE HANDLERS
(function () {
const CHECK_FOR_UPDATES_INTERVAL = 1000 * 60 * 60 * 3; // 3 hours
function showUpdateNotification () {
console.log('-- Update Available --');
// eslint-disable-next-line no-new
new window.Notification('Insomnia Update Ready', {
body: 'Relaunch the app for it to take effect',
silent: true,
sticky: true
2016-10-11 21:06:25 +00:00
});
}
const {ipcRenderer} = require('electron');
ipcRenderer.on('update-available', () => {
2016-12-06 00:32:24 +00:00
// Give it a few seconds before showing this. Sometimes, when
// you relaunch too soon it doesn't work the first time.
setTimeout(showUpdateNotification, 1000 * 10);
2016-10-11 21:06:25 +00:00
});
function checkForUpdates () {
2016-10-11 21:06:25 +00:00
ipcRenderer.send('check-for-updates');
}
setInterval(checkForUpdates, CHECK_FOR_UPDATES_INTERVAL);
2016-10-11 21:06:25 +00:00
})();
</script>
<script>
2016-10-28 18:42:40 +00:00
// Sentry (with rate limiting)
(function () {
if (process.env.INSOMNIA_ENV === 'development') {
console.log('-- Not initializing Sentry for dev --');
return;
}
2016-10-28 18:42:40 +00:00
// 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;
function resetErrorCount () {
intervalErrorCount = 0;
}
2016-10-28 18:42:40 +00:00
// Reset error count after every interval
setInterval(resetErrorCount, MAX_ERRORS_INTERVAL);
window.Raven.config('https://786e43ae199c4757a9ea4a48a9abd17d@sentry.io/109702', {
2016-10-27 03:41:30 +00:00
logger: 'electron.renderer',
environment: process.env.INSOMNIA_ENV || 'production',
level: 'warning',
2016-09-15 22:45:08 +00:00
release: require('./package.json').version,
ignoreUrls: [
/.*raven\.min\.js.*/
],
includePaths: [
/^(?!.*raven.min.js$).*$/ // Ignore raven stuff
],
2016-10-28 18:42:40 +00:00
shouldSendCallback: function (data) {
if (intervalErrorCount++ > MAX_ERRORS_PER_INTERVAL) {
console.log('-- Throttling Sentry Exceptions --');
return false;
}
return true;
},
dataCallback: function (data) {
2016-11-30 03:55:27 +00:00
const normalize = function (filename) {
const match = filename.match(/\/(app.asar|build)\/(.*)/);
if (match) {
return match[2]; // return everything after ../app.asar/*
} else {
return filename;
}
};
2016-08-17 19:12:13 +00:00
if (!data.exception) {
// Probably a regular console.error, etc
return data;
}
2016-08-25 19:44:51 +00:00
data.exception.values[0].stacktrace.frames.forEach(function (frame) {
frame.filename = normalize(frame.filename);
});
2016-08-17 19:12:13 +00:00
return data;
}
}).install();
2016-10-28 18:42:40 +00:00
})();
</script>
2016-07-21 22:26:51 +00:00
<script>
2016-10-28 18:42:40 +00:00
(function () {
const {productName, version} = require('./package.json');
if (process.env.INSOMNIA_ENV === 'development') {
2017-01-24 00:07:00 +00:00
document.title = `${productName}`;
2016-10-28 18:42:40 +00:00
} else {
document.title = `${productName} v${version}`;
}
})();
2016-07-21 22:26:51 +00:00
</script>
2016-07-07 22:06:18 +00:00
2016-07-18 19:44:46 +00:00
<script>
// SOME HELPERS
document.body.setAttribute('data-platform', process.platform);
2016-07-07 22:06:18 +00:00
</script>
2016-03-22 18:20:05 +00:00
</body>
</html>