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,13 +18,12 @@ $(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(() => {
|
location.href = target.currentTarget.href;
|
||||||
location.href = target.currentTarget.href;
|
});
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -32,13 +31,12 @@ $(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(() => {
|
location.href = target.currentTarget.href;
|
||||||
location.href = target.currentTarget.href;
|
});
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#expired-send-new').click(function() {
|
$('#expired-send-new').click(function() {
|
||||||
@ -64,26 +62,21 @@ $(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: storage.totalUploads,
|
||||||
cm5: totalUploads,
|
cm6: unexpiredFiles,
|
||||||
cm6: unexpiredFiles,
|
cm7: storage.totalDownloads,
|
||||||
cm7: storage.totalDownloads,
|
cd2: 'cancelled'
|
||||||
cd2: 'cancelled'
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#download-page-one').attr('hidden', true);
|
$('#download-page-one').attr('hidden', true);
|
||||||
@ -141,28 +134,26 @@ $(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: storage.totalUploads,
|
||||||
cm5: totalUploads,
|
cm6: unexpiredFiles,
|
||||||
cm6: unexpiredFiles,
|
cm7: storage.totalDownloads
|
||||||
cm7: storage.totalDownloads
|
});
|
||||||
});
|
|
||||||
|
|
||||||
fileReceiver
|
fileReceiver
|
||||||
.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: storage.totalUploads,
|
||||||
cm5: totalUploads,
|
cm6: unexpiredFiles,
|
||||||
cm6: unexpiredFiles,
|
cm7: storage.totalDownloads,
|
||||||
cm7: storage.totalDownloads,
|
cd2: 'errored',
|
||||||
cd2: 'errored',
|
cd6: err
|
||||||
cd6: err
|
});
|
||||||
});
|
|
||||||
|
|
||||||
document.l10n.formatValue('expiredPageHeader')
|
document.l10n.formatValue('expiredPageHeader')
|
||||||
.then(translated => {
|
.then(translated => {
|
||||||
@ -181,16 +172,15 @@ $(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: storage.totalUploads,
|
||||||
cm5: totalUploads,
|
cm6: unexpiredFiles,
|
||||||
cm6: unexpiredFiles,
|
cm7: storage.totalDownloads,
|
||||||
cm7: storage.totalDownloads,
|
cd2: 'completed'
|
||||||
cd2: 'completed'
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const dataView = new DataView(decrypted);
|
const dataView = new DataView(decrypted);
|
||||||
const blob = new Blob([dataView]);
|
const blob = new Blob([dataView]);
|
||||||
|
@ -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,10 +25,9 @@ $(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
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#file-upload').change(onUpload);
|
$('#file-upload').change(onUpload);
|
||||||
@ -37,39 +36,36 @@ $(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(() => {
|
location.href = target.currentTarget.href;
|
||||||
location.href = target.currentTarget.href;
|
});
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#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(() => {
|
storage.referrer = 'completed-upload';
|
||||||
storage.referrer = 'completed-upload';
|
location.href = target.currentTarget.href;
|
||||||
location.href = target.currentTarget.href;
|
});
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#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(() => {
|
storage.referrer = 'errored-upload';
|
||||||
storage.referrer = 'errored-upload';
|
location.href = target.currentTarget.href;
|
||||||
location.href = target.currentTarget.href;
|
});
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$('body').on('dragover', allowDrop).on('drop', onUpload);
|
$('body').on('dragover', allowDrop).on('drop', onUpload);
|
||||||
@ -95,10 +91,9 @@ $(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');
|
||||||
aux.setAttribute('value', $('#link').attr('value'));
|
aux.setAttribute('value', $('#link').attr('value'));
|
||||||
document.body.appendChild(aux);
|
document.body.appendChild(aux);
|
||||||
@ -174,15 +169,14 @@ $(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: storage.totalDownloads,
|
||||||
cm7: totalDownloads,
|
cd1: event.type === 'drop' ? 'drop' : 'click',
|
||||||
cd1: event.type === 'drop' ? 'drop' : 'click',
|
cd2: 'cancelled'
|
||||||
cd2: 'cancelled'
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fileSender.on('progress', progress => {
|
fileSender.on('progress', progress => {
|
||||||
@ -238,24 +232,17 @@ $(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: storage.totalDownloads,
|
||||||
cm7: totalDownloads,
|
cd1: event.type === 'drop' ? 'drop' : 'click',
|
||||||
cd1: event.type === 'drop' ? 'drop' : 'click',
|
cd5: window.referrer
|
||||||
cd5: window.referrer
|
});
|
||||||
});
|
|
||||||
|
|
||||||
fileSender
|
fileSender
|
||||||
.upload()
|
.upload()
|
||||||
@ -266,17 +253,16 @@ $(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: storage.totalDownloads,
|
||||||
cm7: totalDownloads,
|
cd1: event.type === 'drop' ? 'drop' : 'click',
|
||||||
cd1: event.type === 'drop' ? 'drop' : 'click',
|
cd2: 'completed'
|
||||||
cd2: 'completed'
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const fileData = {
|
const fileData = {
|
||||||
name: file.name,
|
name: file.name,
|
||||||
@ -316,16 +302,15 @@ $(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: storage.totalDownloads,
|
||||||
cm7: totalDownloads,
|
cd1: event.type === 'drop' ? 'drop' : 'click',
|
||||||
cd1: event.type === 'drop' ? 'drop' : 'click',
|
cd2: 'errored',
|
||||||
cd2: 'errored',
|
cd6: err
|
||||||
cd6: err
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,10 +383,9 @@ $(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');
|
||||||
aux.setAttribute('value', url);
|
aux.setAttribute('value', url);
|
||||||
document.body.appendChild(aux);
|
document.body.appendChild(aux);
|
||||||
@ -491,32 +475,26 @@ $(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: storage.totalDownloads,
|
||||||
cm7: totalDownloads,
|
cd1: file.typeOfUpload,
|
||||||
cd1: file.typeOfUpload,
|
cd4: 'upload-list'
|
||||||
cd4: 'upload-list'
|
})
|
||||||
})
|
.then(() => {
|
||||||
.then(() => {
|
storage.remove(file.fileId);
|
||||||
storage.remove(file.fileId);
|
})
|
||||||
})
|
|
||||||
toggleHeader();
|
toggleHeader();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -525,22 +503,21 @@ $(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: storage.totalDownloads,
|
||||||
cm7: totalDownloads,
|
cd1: file.typeOfUpload,
|
||||||
cd1: file.typeOfUpload,
|
cd4: 'success-screen'
|
||||||
cd4: 'success-screen'
|
})
|
||||||
})
|
.then(() => {
|
||||||
.then(() => {
|
storage.remove(file.fileId);
|
||||||
storage.remove(file.fileId);
|
location.reload();
|
||||||
location.reload();
|
})
|
||||||
})
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// show popup
|
// show popup
|
||||||
|
@ -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
Block a user