drop.chapril.org-firefoxsend/frontend/src/common.js

36 lines
931 B
JavaScript
Raw Normal View History

2017-06-22 23:50:57 +02:00
window.Raven = require('raven-js');
2017-08-02 23:13:53 +02:00
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',
2017-08-02 23:13:53 +02:00
tid: window.GOOGLE_ANALYTICS_ID
2017-07-27 19:01:39 +02:00
});
2017-07-27 19:15:50 +02:00
const isSender = !location.pathname.includes('/download');
const ec = isSender ? 'sender' : 'recipient';
const ua = navigator.userAgent.toLowerCase();
2017-07-27 19:01:39 +02:00
gcmCompliant().catch(err => {
sendEvent(ec, 'unsupported', {
2017-07-27 19:01:39 +02:00
cd6: err
}).then(() => {
location.replace('/unsupported/gcm');
2017-07-27 19:01:39 +02:00
});
});
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');
});
}