make the site mostly work when cookies (localStorage) are disabled

This commit is contained in:
Danny Coates 2017-08-09 18:16:10 -07:00
parent 493bf8dc89
commit 09faedf059
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
4 changed files with 47 additions and 10 deletions

View file

@ -1,6 +1,13 @@
const testPilotGA = require('testpilot-ga/src/TestPilotGA');
const Storage = require('./storage');
const storage = new Storage(localStorage);
const storage = new Storage();
let hasLocalStorage = false;
try {
hasLocalStorage = !!localStorage;
} catch (e) {
// don't care
}
const analytics = new testPilotGA({
an: 'Firefox Send',
@ -18,7 +25,10 @@ document.addEventListener('DOMContentLoaded', function() {
});
function sendEvent() {
return analytics.sendEvent.apply(analytics, arguments).catch(() => 0);
return (
hasLocalStorage &&
analytics.sendEvent.apply(analytics, arguments).catch(() => 0)
);
}
function urlToMetric(url) {