insomnia/app/main.html

133 lines
3.6 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-10-27 03:41:30 +00:00
<script>
</script>
2016-03-22 18:20:05 +00:00
</head>
<body>
<div id="root"></div>
2016-10-05 17:13:43 +00:00
<script src="./external/jsonlint.js"></script>
<script src="./external/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 --');
new 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', () => {
showUpdateNotification();
});
setInterval(() => {
ipcRenderer.send('check-for-updates');
}, CHECK_FOR_UPDATES_INTERVAL);
})();
</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;
// Reset error count after every interval
setInterval(() => intervalErrorCount = 0, MAX_ERRORS_INTERVAL);
2016-10-27 03:41:30 +00:00
Raven.config('https://786e43ae199c4757a9ea4a48a9abd17d@sentry.io/109702', {
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) {
var normalize = function (filename) {
var 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') {
document.title = `${productName} v${version} (DEV)`;
} else {
document.title = `${productName} v${version}`;
}
})()
2016-07-21 22:26:51 +00:00
</script>
2016-03-22 18:20:05 +00:00
<script>
// HOT RELOADING IN DEV
2016-03-22 18:20:05 +00:00
(function () {
const script = document.createElement('script');
2016-07-18 20:10:18 +00:00
script.src = (process.env.HOT) ? 'http://localhost:3333/build/bundle.js' : './bundle.js';
2016-03-22 18:20:05 +00:00
document.write(script.outerHTML);
}());
</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>
<!-- 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>
2016-03-22 18:20:05 +00:00
</body>
</html>