final fixes
This commit is contained in:
parent
14f3d837f9
commit
9585850d6d
|
@ -1,5 +1,5 @@
|
||||||
const FileReceiver = require('./fileReceiver');
|
const FileReceiver = require('./fileReceiver');
|
||||||
const { notify, findMetric } = require('./utils');
|
const { notify, findMetric, sendEvent } = require('./utils');
|
||||||
const Storage = require('./storage');
|
const Storage = require('./storage');
|
||||||
const storage = new Storage(localStorage);
|
const storage = new Storage(localStorage);
|
||||||
const $ = require('jquery');
|
const $ = require('jquery');
|
||||||
|
@ -18,8 +18,7 @@ $(document).ready(function() {
|
||||||
if (location.pathname.toString().includes('download')) {
|
if (location.pathname.toString().includes('download')) {
|
||||||
$('.send-new').click(function(target) {
|
$('.send-new').click(function(target) {
|
||||||
target.preventDefault();
|
target.preventDefault();
|
||||||
window.analytics
|
sendEvent('recipient', 'restarted', {
|
||||||
.sendEvent('recipient', 'restarted', {
|
|
||||||
cd2: 'completed'
|
cd2: 'completed'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -32,8 +31,7 @@ $(document).ready(function() {
|
||||||
target.preventDefault();
|
target.preventDefault();
|
||||||
const metric = findMetric(target.currentTarget.href);
|
const metric = findMetric(target.currentTarget.href);
|
||||||
// record exited event by recipient
|
// record exited event by recipient
|
||||||
window.analytics
|
sendEvent('recipient', 'exited', {
|
||||||
.sendEvent('recipient', 'exited', {
|
|
||||||
cd3: metric
|
cd3: metric
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -64,22 +62,17 @@ $(document).ready(function() {
|
||||||
storage.totalDownloads += 1;
|
storage.totalDownloads += 1;
|
||||||
|
|
||||||
const fileReceiver = new FileReceiver();
|
const fileReceiver = new FileReceiver();
|
||||||
|
|
||||||
const unexpiredFiles = storage.numFiles;
|
const unexpiredFiles = storage.numFiles;
|
||||||
let totalUploads = 0;
|
|
||||||
if (storage.has('totalUploads')) {
|
|
||||||
totalUploads = storage.totalUploads;
|
|
||||||
}
|
|
||||||
|
|
||||||
fileReceiver.on('progress', progress => {
|
fileReceiver.on('progress', progress => {
|
||||||
|
|
||||||
window.onunload = function() {
|
window.onunload = function() {
|
||||||
storage.referrer = 'cancelled-download';
|
storage.referrer = 'cancelled-download';
|
||||||
// record download-stopped (cancelled by tab close or reload)
|
// record download-stopped (cancelled by tab close or reload)
|
||||||
window.analytics
|
sendEvent('recipient', 'download-stopped', {
|
||||||
.sendEvent('recipient', 'download-stopped', {
|
|
||||||
cm1: bytelength,
|
cm1: bytelength,
|
||||||
cm5: totalUploads,
|
cm5: storage.totalUploads,
|
||||||
cm6: unexpiredFiles,
|
cm6: unexpiredFiles,
|
||||||
cm7: storage.totalDownloads,
|
cm7: storage.totalDownloads,
|
||||||
cd2: 'cancelled'
|
cd2: 'cancelled'
|
||||||
|
@ -141,11 +134,10 @@ $(document).ready(function() {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
// record download-started by recipient
|
// record download-started by recipient
|
||||||
window.analytics
|
sendEvent('recipient', 'download-started', {
|
||||||
.sendEvent('recipient', 'download-started', {
|
|
||||||
cm1: bytelength,
|
cm1: bytelength,
|
||||||
cm4: timeToExpiry,
|
cm4: timeToExpiry,
|
||||||
cm5: totalUploads,
|
cm5: storage.totalUploads,
|
||||||
cm6: unexpiredFiles,
|
cm6: unexpiredFiles,
|
||||||
cm7: storage.totalDownloads
|
cm7: storage.totalDownloads
|
||||||
});
|
});
|
||||||
|
@ -154,10 +146,9 @@ $(document).ready(function() {
|
||||||
.download()
|
.download()
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
// record download-stopped (errored) by recipient
|
// record download-stopped (errored) by recipient
|
||||||
window.analytics
|
sendEvent('recipient', 'download-stopped', {
|
||||||
.sendEvent('recipient', 'download-stopped', {
|
|
||||||
cm1: bytelength,
|
cm1: bytelength,
|
||||||
cm5: totalUploads,
|
cm5: storage.totalUploads,
|
||||||
cm6: unexpiredFiles,
|
cm6: unexpiredFiles,
|
||||||
cm7: storage.totalDownloads,
|
cm7: storage.totalDownloads,
|
||||||
cd2: 'errored',
|
cd2: 'errored',
|
||||||
|
@ -181,12 +172,11 @@ $(document).ready(function() {
|
||||||
|
|
||||||
storage.referrer = 'completed-download';
|
storage.referrer = 'completed-download';
|
||||||
// record download-stopped (completed) by recipient
|
// record download-stopped (completed) by recipient
|
||||||
window.analytics
|
sendEvent('recipient', 'download-stopped', {
|
||||||
.sendEvent('recipient', 'download-stopped', {
|
|
||||||
cm1: bytelength,
|
cm1: bytelength,
|
||||||
cm2: totalTime,
|
cm2: totalTime,
|
||||||
cm3: downloadSpeed,
|
cm3: downloadSpeed,
|
||||||
cm5: totalUploads,
|
cm5: storage.totalUploads,
|
||||||
cm6: unexpiredFiles,
|
cm6: unexpiredFiles,
|
||||||
cm7: storage.totalDownloads,
|
cm7: storage.totalDownloads,
|
||||||
cd2: 'completed'
|
cd2: 'completed'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const FileSender = require('./fileSender');
|
const FileSender = require('./fileSender');
|
||||||
const { notify, gcmCompliant, findMetric, ONE_DAY_IN_MS } = require('./utils');
|
const { notify, gcmCompliant, findMetric, sendEvent, ONE_DAY_IN_MS } = require('./utils');
|
||||||
const Storage = require('./storage');
|
const Storage = require('./storage');
|
||||||
const storage = new Storage(localStorage);
|
const storage = new Storage(localStorage);
|
||||||
const $ = require('jquery');
|
const $ = require('jquery');
|
||||||
|
@ -25,8 +25,7 @@ $(document).ready(function() {
|
||||||
$('#page-one').attr('hidden', true);
|
$('#page-one').attr('hidden', true);
|
||||||
$('#unsupported-browser').removeAttr('hidden');
|
$('#unsupported-browser').removeAttr('hidden');
|
||||||
// record unsupported event
|
// record unsupported event
|
||||||
window.analytics
|
sendEvent('sender', 'unsupported', {
|
||||||
.sendEvent('sender', 'unsupported', {
|
|
||||||
cd6: err
|
cd6: err
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -37,8 +36,7 @@ $(document).ready(function() {
|
||||||
target.preventDefault();
|
target.preventDefault();
|
||||||
const metric = findMetric(target.currentTarget.href);
|
const metric = findMetric(target.currentTarget.href);
|
||||||
// record exited event by recipient
|
// record exited event by recipient
|
||||||
window.analytics
|
sendEvent('sender', 'exited', {
|
||||||
.sendEvent('sender', 'exited', {
|
|
||||||
cd3: metric
|
cd3: metric
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -49,8 +47,7 @@ $(document).ready(function() {
|
||||||
$('#send-new-completed').click(function(target) {
|
$('#send-new-completed').click(function(target) {
|
||||||
target.preventDefault();
|
target.preventDefault();
|
||||||
// record restarted event
|
// record restarted event
|
||||||
window.analytics
|
sendEvent('sender', 'restarted', {
|
||||||
.sendEvent('sender', 'restarted', {
|
|
||||||
cd2: 'completed'
|
cd2: 'completed'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -62,8 +59,7 @@ $(document).ready(function() {
|
||||||
$('#send-new-error').click(function(target) {
|
$('#send-new-error').click(function(target) {
|
||||||
target.preventDefault();
|
target.preventDefault();
|
||||||
// record restarted event
|
// record restarted event
|
||||||
window.analytics
|
sendEvent('sender', 'restarted', {
|
||||||
.sendEvent('sender', 'restarted', {
|
|
||||||
cd2: 'errored'
|
cd2: 'errored'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -95,8 +91,7 @@ $(document).ready(function() {
|
||||||
// copy link to clipboard
|
// copy link to clipboard
|
||||||
$copyBtn.click(() => {
|
$copyBtn.click(() => {
|
||||||
// record copied event from success screen
|
// record copied event from success screen
|
||||||
window.analytics
|
sendEvent('sender', 'copied', {
|
||||||
.sendEvent('sender', 'copied', {
|
|
||||||
cd4: 'success-screen'
|
cd4: 'success-screen'
|
||||||
});
|
});
|
||||||
const aux = document.createElement('input');
|
const aux = document.createElement('input');
|
||||||
|
@ -174,12 +169,11 @@ $(document).ready(function() {
|
||||||
storage.referrer = 'cancelled-upload';
|
storage.referrer = 'cancelled-upload';
|
||||||
|
|
||||||
// record upload-stopped (cancelled) by sender
|
// record upload-stopped (cancelled) by sender
|
||||||
window.analytics
|
sendEvent('sender', 'upload-stopped', {
|
||||||
.sendEvent('sender', 'upload-stopped', {
|
|
||||||
cm1: file.size,
|
cm1: file.size,
|
||||||
cm5: storage.totalUploads,
|
cm5: storage.totalUploads,
|
||||||
cm6: unexpiredFiles,
|
cm6: unexpiredFiles,
|
||||||
cm7: totalDownloads,
|
cm7: storage.totalDownloads,
|
||||||
cd1: event.type === 'drop' ? 'drop' : 'click',
|
cd1: event.type === 'drop' ? 'drop' : 'click',
|
||||||
cd2: 'cancelled'
|
cd2: 'cancelled'
|
||||||
});
|
});
|
||||||
|
@ -238,21 +232,14 @@ $(document).ready(function() {
|
||||||
|
|
||||||
let t;
|
let t;
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
const unexpiredFiles = storage.numFiles + 1;
|
const unexpiredFiles = storage.numFiles + 1;
|
||||||
|
|
||||||
let totalDownloads = 0;
|
|
||||||
if (storage.has('totalDownloads')) {
|
|
||||||
totalDownloads = storage.totalDownloads;
|
|
||||||
}
|
|
||||||
|
|
||||||
// record upload-started event by sender
|
// record upload-started event by sender
|
||||||
window.analytics
|
sendEvent('sender', 'upload-started', {
|
||||||
.sendEvent('sender', 'upload-started', {
|
|
||||||
cm1: file.size,
|
cm1: file.size,
|
||||||
cm5: storage.totalUploads,
|
cm5: storage.totalUploads,
|
||||||
cm6: unexpiredFiles,
|
cm6: unexpiredFiles,
|
||||||
cm7: totalDownloads,
|
cm7: storage.totalDownloads,
|
||||||
cd1: event.type === 'drop' ? 'drop' : 'click',
|
cd1: event.type === 'drop' ? 'drop' : 'click',
|
||||||
cd5: window.referrer
|
cd5: window.referrer
|
||||||
});
|
});
|
||||||
|
@ -266,14 +253,13 @@ $(document).ready(function() {
|
||||||
const uploadSpeed = file.size / (uploadTime / 1000);
|
const uploadSpeed = file.size / (uploadTime / 1000);
|
||||||
|
|
||||||
// record upload-stopped (completed) by sender
|
// record upload-stopped (completed) by sender
|
||||||
window.analytics
|
sendEvent('sender', 'upload-stopped', {
|
||||||
.sendEvent('sender', 'upload-stopped', {
|
|
||||||
cm1: file.size,
|
cm1: file.size,
|
||||||
cm2: totalTime,
|
cm2: totalTime,
|
||||||
cm3: uploadSpeed,
|
cm3: uploadSpeed,
|
||||||
cm5: storage.totalUploads,
|
cm5: storage.totalUploads,
|
||||||
cm6: unexpiredFiles,
|
cm6: unexpiredFiles,
|
||||||
cm7: totalDownloads,
|
cm7: storage.totalDownloads,
|
||||||
cd1: event.type === 'drop' ? 'drop' : 'click',
|
cd1: event.type === 'drop' ? 'drop' : 'click',
|
||||||
cd2: 'completed'
|
cd2: 'completed'
|
||||||
});
|
});
|
||||||
|
@ -316,12 +302,11 @@ $(document).ready(function() {
|
||||||
window.clearTimeout(t);
|
window.clearTimeout(t);
|
||||||
|
|
||||||
// record upload-stopped (errored) by sender
|
// record upload-stopped (errored) by sender
|
||||||
window.analytics
|
sendEvent('sender', 'upload-stopped', {
|
||||||
.sendEvent('sender', 'upload-stopped', {
|
|
||||||
cm1: file.size,
|
cm1: file.size,
|
||||||
cm5: storage.totalUploads,
|
cm5: storage.totalUploads,
|
||||||
cm6: unexpiredFiles,
|
cm6: unexpiredFiles,
|
||||||
cm7: totalDownloads,
|
cm7: storage.totalDownloads,
|
||||||
cd1: event.type === 'drop' ? 'drop' : 'click',
|
cd1: event.type === 'drop' ? 'drop' : 'click',
|
||||||
cd2: 'errored',
|
cd2: 'errored',
|
||||||
cd6: err
|
cd6: err
|
||||||
|
@ -398,8 +383,7 @@ $(document).ready(function() {
|
||||||
//copy link to clipboard when icon clicked
|
//copy link to clipboard when icon clicked
|
||||||
$copyIcon.click(function() {
|
$copyIcon.click(function() {
|
||||||
// record copied event from upload list
|
// record copied event from upload list
|
||||||
window.analytics
|
sendEvent('sender', 'copied', {
|
||||||
.sendEvent('sender', 'copied', {
|
|
||||||
cd4: 'upload-list'
|
cd4: 'upload-list'
|
||||||
});
|
});
|
||||||
const aux = document.createElement('input');
|
const aux = document.createElement('input');
|
||||||
|
@ -491,26 +475,20 @@ $(document).ready(function() {
|
||||||
|
|
||||||
const unexpiredFiles = storage.numFiles;
|
const unexpiredFiles = storage.numFiles;
|
||||||
|
|
||||||
let totalDownloads = 0;
|
|
||||||
if (storage.has('totalDownloads')) {
|
|
||||||
totalDownloads = storage.totalDownloads;
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete file
|
// delete file
|
||||||
$popupText.find('.del-file').click(e => {
|
$popupText.find('.del-file').click(e => {
|
||||||
FileSender.delete(file.fileId, file.deleteToken).then(() => {
|
FileSender.delete(file.fileId, file.deleteToken).then(() => {
|
||||||
$(e.target).parents('tr').remove();
|
$(e.target).parents('tr').remove();
|
||||||
const timeToExpiry = ONE_DAY_IN_MS - (Date.now() - file.creationDate.getTime());
|
const timeToExpiry = ONE_DAY_IN_MS - (Date.now() - file.creationDate.getTime());
|
||||||
// record upload-deleted from file list
|
// record upload-deleted from file list
|
||||||
window.analytics
|
sendEvent('sender', 'upload-deleted', {
|
||||||
.sendEvent('sender', 'upload-deleted', {
|
|
||||||
cm1: file.size,
|
cm1: file.size,
|
||||||
cm2: file.totalTime,
|
cm2: file.totalTime,
|
||||||
cm3: file.uploadSpeed,
|
cm3: file.uploadSpeed,
|
||||||
cm4: timeToExpiry,
|
cm4: timeToExpiry,
|
||||||
cm5: storage.totalUploads,
|
cm5: storage.totalUploads,
|
||||||
cm6: unexpiredFiles,
|
cm6: unexpiredFiles,
|
||||||
cm7: totalDownloads,
|
cm7: storage.totalDownloads,
|
||||||
cd1: file.typeOfUpload,
|
cd1: file.typeOfUpload,
|
||||||
cd4: 'upload-list'
|
cd4: 'upload-list'
|
||||||
})
|
})
|
||||||
|
@ -525,15 +503,14 @@ $(document).ready(function() {
|
||||||
FileSender.delete(file.fileId, file.deleteToken).then(() => {
|
FileSender.delete(file.fileId, file.deleteToken).then(() => {
|
||||||
const timeToExpiry = ONE_DAY_IN_MS - (Date.now() - file.creationDate.getTime());
|
const timeToExpiry = ONE_DAY_IN_MS - (Date.now() - file.creationDate.getTime());
|
||||||
// record upload-deleted from success screen
|
// record upload-deleted from success screen
|
||||||
window.analytics
|
sendEvent('sender', 'upload-deleted', {
|
||||||
.sendEvent('sender', 'upload-deleted', {
|
|
||||||
cm1: file.size,
|
cm1: file.size,
|
||||||
cm2: file.totalTime,
|
cm2: file.totalTime,
|
||||||
cm3: file.uploadSpeed,
|
cm3: file.uploadSpeed,
|
||||||
cm4: timeToExpiry,
|
cm4: timeToExpiry,
|
||||||
cm5: storage.totalUploads,
|
cm5: storage.totalUploads,
|
||||||
cm6: unexpiredFiles,
|
cm6: unexpiredFiles,
|
||||||
cm7: totalDownloads,
|
cm7: storage.totalDownloads,
|
||||||
cd1: file.typeOfUpload,
|
cd1: file.typeOfUpload,
|
||||||
cd4: 'success-screen'
|
cd4: 'success-screen'
|
||||||
})
|
})
|
||||||
|
|
|
@ -101,6 +101,13 @@ function isFile(id) {
|
||||||
'testpilot_ga__cid'].includes(id);
|
'testpilot_ga__cid'].includes(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendEvent() {
|
||||||
|
return window.analytics
|
||||||
|
.sendEvent
|
||||||
|
.apply(window.analytics, arguments)
|
||||||
|
.catch(() => 0);
|
||||||
|
}
|
||||||
|
|
||||||
const ONE_DAY_IN_MS = 86400000;
|
const ONE_DAY_IN_MS = 86400000;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -110,5 +117,6 @@ module.exports = {
|
||||||
gcmCompliant,
|
gcmCompliant,
|
||||||
findMetric,
|
findMetric,
|
||||||
isFile,
|
isFile,
|
||||||
|
sendEvent,
|
||||||
ONE_DAY_IN_MS
|
ONE_DAY_IN_MS
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,6 +43,6 @@
|
||||||
<img src="/resources/illustration_expired.svg" id="expired-img" data-l10n-id="linkExpiredAlt"/>
|
<img src="/resources/illustration_expired.svg" id="expired-img" data-l10n-id="linkExpiredAlt"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="expired-description" data-l10n-id="uploadPageExplainer"></div>
|
<div class="expired-description" data-l10n-id="uploadPageExplainer"></div>
|
||||||
<a class="send-new" id = "expired-send-new" data-l10n-id="sendYourFilesLink"></a>
|
<a class="send-new" id="expired-send-new" data-l10n-id="sendYourFilesLink"></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue