diff --git a/frontend/src/common.js b/frontend/src/common.js index ecee7102..851eef19 100644 --- a/frontend/src/common.js +++ b/frontend/src/common.js @@ -3,7 +3,7 @@ window.Raven.config(window.dsn).install(); window.dsn = undefined; const testPilotGA = require('testpilot-ga'); -const {gcmCompliant, sendEvent} = require('./utils'); +const { gcmCompliant, sendEvent } = require('./utils'); window.analytics = new testPilotGA({ an: 'Firefox Send', ds: 'web', @@ -11,20 +11,24 @@ window.analytics = new testPilotGA({ }); const isSender = !location.pathname.includes('/download'); +const ec = isSender ? 'sender' : 'recipient'; +const ua = navigator.userAgent.toLowerCase(); gcmCompliant().catch(err => { - sendEvent(isSender ? 'sender' : 'recipient', 'unsupported', { + sendEvent(ec, 'unsupported', { cd6: err }).then(() => { location.replace('/unsupported/gcm'); }); }); -if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1 && - parseInt(navigator.userAgent.toLowerCase().match(/firefox\/*([^\n\r]*)\./)[1]) <= 49) { - sendEvent(isSender ? 'sender' : 'recipient', 'unsupported', { - cd6: new Error('Firefox is outdated.') - }).then(() => { - location.replace('/unsupported/outdated'); - }); -} \ No newline at end of file +if ( + ua.indexOf('firefox') > -1 && + parseInt(ua.match(/firefox\/*([^\n\r]*)\./)[1], 10) <= 49 +) { + sendEvent(ec, 'unsupported', { + cd6: new Error('Firefox is outdated.') + }).then(() => { + location.replace('/unsupported/outdated'); + }); +} diff --git a/test/frontend/driver.js b/test/frontend/driver.js index 13ca26e1..a9630333 100644 --- a/test/frontend/driver.js +++ b/test/frontend/driver.js @@ -2,9 +2,7 @@ const webdriver = require('selenium-webdriver'); const path = require('path'); const until = webdriver.until; -const driver = new webdriver.Builder() - .forBrowser('firefox') - .build(); +const driver = new webdriver.Builder().forBrowser('firefox').build(); driver.get(path.join('file:///', __dirname, '/frontend.test.html')); driver.wait(until.titleIs('Mocha Tests')); @@ -15,8 +13,10 @@ driver.getTitle().then(title => { if (title === '0') { console.log('Frontend tests have passed.'); } else { - throw new Error('Frontend tests are failing. ' + - 'Please open the frontend.test.html file in a browser.'); + throw new Error( + 'Frontend tests are failing. ' + + 'Please open the frontend.test.html file in a browser.' + ); } - }) -}) \ No newline at end of file + }); +});