2017-08-03 21:07:22 +00:00
|
|
|
const testPilotGA = require('testpilot-ga');
|
|
|
|
const Raven = require('raven-js');
|
|
|
|
|
2017-08-02 21:13:53 +00:00
|
|
|
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) {
|
2017-08-03 21:07:22 +00:00
|
|
|
Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install();
|
2017-08-02 21:13:53 +00:00
|
|
|
}
|
2017-07-19 23:16:46 +00:00
|
|
|
|
2017-08-03 21:07:22 +00:00
|
|
|
const analytics = new testPilotGA({
|
2017-07-19 23:16:46 +00:00
|
|
|
an: 'Firefox Send',
|
|
|
|
ds: 'web',
|
2017-08-02 21:13:53 +00:00
|
|
|
tid: window.GOOGLE_ANALYTICS_ID
|
2017-07-27 17:01:39 +00:00
|
|
|
});
|
|
|
|
|
2017-08-05 16:40:57 +00:00
|
|
|
function sendEvent() {
|
|
|
|
return analytics.sendEvent
|
|
|
|
.apply(analytics, arguments)
|
|
|
|
.catch(() => 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function findMetric(href) {
|
|
|
|
switch (href) {
|
|
|
|
case 'https://www.mozilla.org/':
|
|
|
|
return 'mozilla';
|
|
|
|
case 'https://www.mozilla.org/about/legal':
|
|
|
|
return 'legal';
|
|
|
|
case 'https://testpilot.firefox.com/about':
|
|
|
|
return 'about';
|
|
|
|
case 'https://testpilot.firefox.com/privacy':
|
|
|
|
return 'privacy';
|
|
|
|
case 'https://testpilot.firefox.com/terms':
|
|
|
|
return 'terms';
|
|
|
|
case 'https://www.mozilla.org/privacy/websites/#cookies':
|
|
|
|
return 'cookies';
|
|
|
|
case 'https://github.com/mozilla/send':
|
|
|
|
return 'github';
|
|
|
|
case 'https://twitter.com/FxTestPilot':
|
|
|
|
return 'twitter';
|
|
|
|
case 'https://www.mozilla.org/firefox/new/?scene=2':
|
|
|
|
return 'download-firefox';
|
|
|
|
default:
|
|
|
|
return 'other';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-31 15:32:55 +00:00
|
|
|
const ua = navigator.userAgent.toLowerCase();
|
|
|
|
if (
|
|
|
|
ua.indexOf('firefox') > -1 &&
|
|
|
|
parseInt(ua.match(/firefox\/*([^\n\r]*)\./)[1], 10) <= 49
|
|
|
|
) {
|
2017-08-03 21:07:22 +00:00
|
|
|
const isSender = !location.pathname.includes('/download');
|
|
|
|
const ec = isSender ? 'sender' : 'recipient';
|
2017-07-31 15:32:55 +00:00
|
|
|
sendEvent(ec, 'unsupported', {
|
|
|
|
cd6: new Error('Firefox is outdated.')
|
|
|
|
}).then(() => {
|
|
|
|
location.replace('/unsupported/outdated');
|
|
|
|
});
|
|
|
|
}
|
2017-08-03 21:07:22 +00:00
|
|
|
|
2017-08-05 16:40:57 +00:00
|
|
|
module.exports = {
|
|
|
|
Raven,
|
|
|
|
sendEvent,
|
|
|
|
findMetric
|
|
|
|
}
|