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