From 5944b85e670b2d83c69b131c612fdd66961b9bfd Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Wed, 2 Aug 2017 14:13:53 -0700 Subject: [PATCH] filter the hash from error reports --- circle.yml | 1 + frontend/src/common.js | 7 ++++--- package.json | 2 +- server/server.js | 7 +++++-- views/jsconfig.handlebars | 21 +++++++++++++++++---- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/circle.yml b/circle.yml index e25fa992..574e22e4 100644 --- a/circle.yml +++ b/circle.yml @@ -31,6 +31,7 @@ deployment: test: override: + - npm run build:version - npm run lint - npm test - nsp check diff --git a/frontend/src/common.js b/frontend/src/common.js index 851eef19..282bdca1 100644 --- a/frontend/src/common.js +++ b/frontend/src/common.js @@ -1,13 +1,14 @@ window.Raven = require('raven-js'); -window.Raven.config(window.dsn).install(); -window.dsn = undefined; +if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) { + window.Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install(); +} const testPilotGA = require('testpilot-ga'); const { gcmCompliant, sendEvent } = require('./utils'); window.analytics = new testPilotGA({ an: 'Firefox Send', ds: 'web', - tid: window.trackerId + tid: window.GOOGLE_ANALYTICS_ID }); const isSender = !location.pathname.includes('/download'); diff --git a/package.json b/package.json index 3f0da01c..d8e5663e 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,6 @@ "test": "npm-run-all test:*", "test:unit": "mocha test/unit", "test:server": "mocha test/server", - "test:browser": "browserify test/frontend/frontend.bundle.js -o test/frontend/bundle.js -d && node test/frontend/driver.js" + "test--browser": "browserify test/frontend/frontend.bundle.js -o test/frontend/bundle.js -d && node test/frontend/driver.js" } } diff --git a/server/server.js b/server/server.js index 780c18b6..7e3cf06d 100644 --- a/server/server.js +++ b/server/server.js @@ -10,6 +10,7 @@ const storage = require('./storage.js'); const Raven = require('raven'); const crypto = require('crypto'); const fs = require('fs'); +const version = require('../public/version.json'); if (conf.sentry_dsn) { Raven.config(conf.sentry_dsn).install(); @@ -106,8 +107,10 @@ app.get('/legal', (req, res) => { app.get('/jsconfig.js', (req, res) => { res.set('Content-Type', 'application/javascript'); res.render('jsconfig', { - trackerId: conf.analytics_id, - dsn: conf.sentry_id, + googleAnalyticsId: conf.analytics_id, + sentryId: conf.sentry_id, + version: version.version, + commit: version.commit, maxFileSize: conf.max_file_size, expireSeconds: conf.expire_seconds, layout: false diff --git a/views/jsconfig.handlebars b/views/jsconfig.handlebars index 3dbe827c..7a24eb2b 100644 --- a/views/jsconfig.handlebars +++ b/views/jsconfig.handlebars @@ -5,11 +5,24 @@ if (isIE && !isUnsupportedPage) { window.location.replace('/unsupported/ie'); } -{{#if dsn}} -window.dsn = '{{{dsn}}}'; +{{#if sentryId}} +var RAVEN_CONFIG = { + release: '{{{version}}}', + tags: { + commit: '{{{commit}}}' + }, + dataCallback: function (data) { + var hash = window.location.hash; + if (hash) { + return JSON.parse(JSON.stringify(data).replace(new RegExp(hash.slice(1), 'g'), '')); + } + return data; + } +} +var SENTRY_ID = '{{{sentryId}}}'; {{/if}} -{{#if trackerId}} -window.trackerId = '{{{trackerId}}}'; +{{#if googleAnalyticsId}} +var GOOGLE_ANALYTICS_ID = '{{{googleAnalyticsId}}}'; {{/if}} var MAXFILESIZE = {{{maxFileSize}}}; var EXPIRE_SECONDS = {{{expireSeconds}}};