added sentry

This commit is contained in:
Abhinav Adduri 2017-06-22 14:50:57 -07:00
parent 6d8330992d
commit 50714d35a5
12 changed files with 1065 additions and 961 deletions

View File

@ -2,6 +2,9 @@ const FileReceiver = require('./fileReceiver');
const { notify } = require('./utils'); const { notify } = require('./utils');
const $ = require('jquery'); const $ = require('jquery');
const Raven = window.Raven;
$(document).ready(function() { $(document).ready(function() {
$('#download-progress').hide(); $('#download-progress').hide();
$('#send-file').click(() => { $('#send-file').click(() => {
@ -59,6 +62,10 @@ $(document).ready(function() {
a.download = fname; a.download = fname;
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
})
.catch(err => {
Raven.captureException(err);
return Promise.reject(err);
}); });
}; };

View File

@ -1,6 +1,8 @@
const EventEmitter = require('events'); const EventEmitter = require('events');
const { strToIv } = require('./utils'); const { strToIv } = require('./utils');
const Raven = window.Raven;
class FileReceiver extends EventEmitter { class FileReceiver extends EventEmitter {
constructor() { constructor() {
super(); super();
@ -61,7 +63,8 @@ class FileReceiver extends EventEmitter {
true, true,
['encrypt', 'decrypt'] ['encrypt', 'decrypt']
) )
]).then(([fdata, key]) => { ])
.then(([fdata, key]) => {
const salt = this.salt; const salt = this.salt;
return Promise.all([ return Promise.all([
window.crypto.subtle.decrypt( window.crypto.subtle.decrypt(
@ -76,6 +79,10 @@ class FileReceiver extends EventEmitter {
resolve(fdata.fname); resolve(fdata.fname);
}) })
]); ]);
})
.catch(err => {
Raven.captureException(err);
return Promise.reject(err);
}); });
} }
} }

View File

@ -1,6 +1,8 @@
const EventEmitter = require('events'); const EventEmitter = require('events');
const { ivToStr } = require('./utils'); const { ivToStr } = require('./utils');
const Raven = window.Raven;
class FileSender extends EventEmitter { class FileSender extends EventEmitter {
constructor(file) { constructor(file) {
super(); super();
@ -64,6 +66,10 @@ class FileSender extends EventEmitter {
window.crypto.subtle.exportKey('jwk', secretKey) window.crypto.subtle.exportKey('jwk', secretKey)
]); ]);
}) })
.catch(err => {
Raven.captureException(err)
return Promise.reject(err);
})
.then(([encrypted, keydata]) => { .then(([encrypted, keydata]) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const file = this.file; const file = this.file;
@ -99,6 +105,10 @@ class FileSender extends EventEmitter {
xhr.open('post', '/upload/' + fileId, true); xhr.open('post', '/upload/' + fileId, true);
xhr.send(fd); xhr.send(fd);
}); });
})
.catch(err => {
Raven.captureException(err)
return Promise.reject(err);
}); });
} }
} }

View File

@ -1,2 +1,5 @@
window.Raven = require('raven-js');
window.Raven.config(window.dsn).install();
window.dsn = undefined;
require('./upload'); require('./upload');
require('./download'); require('./download');

View File

@ -2,6 +2,8 @@ const FileSender = require('./fileSender');
const { notify } = require('./utils'); const { notify } = require('./utils');
const $ = require('jquery'); const $ = require('jquery');
const Raven = window.Raven;
$(document).ready(function() { $(document).ready(function() {
// reset copy button // reset copy button
const $copyBtn = $('#copy-btn'); const $copyBtn = $('#copy-btn');
@ -112,6 +114,10 @@ $(document).ready(function() {
).then(() => { ).then(() => {
$(e.target).parents('tr').remove(); $(e.target).parents('tr').remove();
localStorage.removeItem(info.fileId); localStorage.removeItem(info.fileId);
})
.catch(err => {
Raven.captureException(err);
return Promise.reject(err);
}); });
}); });
@ -125,6 +131,10 @@ $(document).ready(function() {
$('#file-list').hide(); $('#file-list').hide();
$('#upload-progress').hide(); $('#upload-progress').hide();
$('#share-link').show(); $('#share-link').show();
})
.catch(err => {
Raven.captureException(err);
return Promise.reject(err);
}); });
function toggleShow() { function toggleShow() {

1938
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@
"jquery": "^3.2.1", "jquery": "^3.2.1",
"mozlog": "^2.1.1", "mozlog": "^2.1.1",
"node-fetch": "^1.7.1", "node-fetch": "^1.7.1",
"raven-js": "^3.16.0",
"redis": "^2.7.1", "redis": "^2.7.1",
"uglify-es": "3.0.19" "uglify-es": "3.0.19"
}, },

View File

@ -27,6 +27,11 @@ const conf = convict({
default: 'UA-101393094-1', default: 'UA-101393094-1',
env: 'GOOGLE_ANALYTICS_ID' env: 'GOOGLE_ANALYTICS_ID'
}, },
sentry_id: {
format: String,
default: 'https://cdf9a4f43a584f759586af8ceb2194f2@sentry.prod.mozaws.net/238',
env: 'P2P_SENTRY_DSN'
},
env: { env: {
format: ['production', 'development', 'test'], format: ['production', 'development', 'test'],
default: 'development', default: 'development',

View File

@ -16,13 +16,10 @@ const log = mozlog('portal.server');
const app = express(); const app = express();
app.engine( app.engine('handlebars', exphbs({
'handlebars',
exphbs({
defaultLayout: 'main', defaultLayout: 'main',
partialsDir: 'views/partials/' partialsDir: 'views/partials/'
}) }));
);
app.set('view engine', 'handlebars'); app.set('view engine', 'handlebars');
app.use(helmet()); app.use(helmet());
@ -30,10 +27,12 @@ app.use(busboy());
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, '../public'))); app.use(express.static(path.join(__dirname, '../public')));
app.get('/', (req, res) => { app.get('/', (req, res) => {
res.render('index', { res.render('index', {
shouldRenderAnalytics: notLocalHost, shouldRenderAnalytics: notLocalHost,
trackerId: conf.analytics_id trackerId: conf.analytics_id,
dsn: conf.sentry_id
}); });
}); });
@ -54,7 +53,8 @@ app.get('/download/:id', (req, res) => {
filename: filename, filename: filename,
filesize: bytes(contentLength), filesize: bytes(contentLength),
shouldRenderAnalytics: notLocalHost, shouldRenderAnalytics: notLocalHost,
trackerId: conf.analytics_id trackerId: conf.analytics_id,
dsn: conf.sentry_id
}); });
}) })
.catch(() => { .catch(() => {

View File

@ -2,6 +2,7 @@
<html> <html>
<head> <head>
<title>Download your file</title> <title>Download your file</title>
{{> sentry dsn=dsn}}
<script src="/bundle.js"></script> <script src="/bundle.js"></script>
<link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css" /> <link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css" />
<link rel="stylesheet" type="text/css" href="/main.css" /> <link rel="stylesheet" type="text/css" href="/main.css" />

View File

@ -2,6 +2,7 @@
<html> <html>
<head> <head>
<title>Firefox Fileshare</title> <title>Firefox Fileshare</title>
{{> sentry dsn=dsn}}
<script src="/bundle.js"></script> <script src="/bundle.js"></script>
<link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css" /> <link rel="stylesheet" href="https://code.cdn.mozilla.net/fonts/fira.css" />
<link rel="stylesheet" type="text/css" href="/main.css" /> <link rel="stylesheet" type="text/css" href="/main.css" />

View File

@ -0,0 +1,3 @@
<script>
window.dsn = '{{{dsn}}}';
</script>