finished metrics

This commit is contained in:
Abhinav Adduri 2017-07-20 15:16:00 -07:00
parent 76a6f02eb7
commit 99477774cf
9 changed files with 542 additions and 173 deletions

View File

@ -1,20 +1,53 @@
const FileReceiver = require('./fileReceiver'); const FileReceiver = require('./fileReceiver');
const { notify } = require('./utils'); const { notify, findMetric } = require('./utils');
const $ = require('jquery'); const $ = require('jquery');
require('jquery-circle-progress'); require('jquery-circle-progress');
const Raven = window.Raven; const Raven = window.Raven;
if (!localStorage.hasOwnProperty('totalDownloads')) {
localStorage.setItem('totalDownloads', 0);
}
$(document).ready(function() { $(document).ready(function() {
//link back to homepage //link back to homepage
$('.send-new').attr('href', window.location.origin); $('.send-new').attr('href', window.location.origin);
$('.send-new').click(function() {
window.analytics if (location.pathname.toString().includes('download')) {
.sendEvent('recipient', 'restarted', { $('.send-new').click(function(target) {
cd2: 'completed' target.preventDefault();
}); window.analytics
}) .sendEvent('recipient', 'restarted', {
cd2: 'completed'
})
.then(() => {
location.href = target.currentTarget.href;
});
})
$('.legal-links a, .social-links a, #dl-firefox').click(function(target) {
target.preventDefault();
let metric = findMetric(target.currentTarget.href);
// record exited event by recipient
window.analytics
.sendEvent('recipient', 'exited', {
cd3: metric
})
.then(() => {
location.href = target.currentTarget.href;
});
})
$('#expired-send-new').click(function() {
localStorage.setItem('referrer', 'errored-download');
})
}
const filename = $('#dl-filename').html(); const filename = $('#dl-filename').html();
const bytelength = $('#dl-bytelength').html();
const timeToExpiry = $('#dl-ttl').html();
//initiate progress bar //initiate progress bar
$('#dl-progress').circleProgress({ $('#dl-progress').circleProgress({
@ -26,9 +59,41 @@ $(document).ready(function() {
}); });
$('#download-btn').click(download); $('#download-btn').click(download);
function download() { function download() {
let totalDownloads = localStorage.getItem('totalDownloads');
localStorage.setItem('totalDownloads', Number(totalDownloads) + 1);
const fileReceiver = new FileReceiver(); const fileReceiver = new FileReceiver();
let unexpiredFiles = 0;
for (let i = 0; i < localStorage.length; i++) {
const id = localStorage.key(i);
if (id != 'totalUploads' &&
id != 'totalDownloads' &&
id != 'referrer') {
unexpiredFiles += 1;
}
}
let totalUploads = 0;
if (localStorage.hasOwnProperty('totalUploads')) {
totalUploads = localStorage.getItem('totalUploads');
}
fileReceiver.on('progress', progress => { fileReceiver.on('progress', progress => {
window.onunload = function() {
localStorage.setItem('referrer', 'cancelled-download');
// record download-stopped (cancelled by tab close or reload)
window.analytics
.sendEvent('recipient', 'download-stopped', {
cm1: bytelength,
cm5: totalUploads,
cm6: unexpiredFiles,
cm7: localStorage.getItem('totalDownloads'),
cd2: 'cancelled'
})
}
$('#download-page-one').attr('hidden', true); $('#download-page-one').attr('hidden', true);
$('#download-progress').removeAttr('hidden'); $('#download-progress').removeAttr('hidden');
const percent = progress[0] / progress[1]; const percent = progress[0] / progress[1];
@ -57,15 +122,18 @@ $(document).ready(function() {
notify(translated[0]); notify(translated[0]);
$('.title').html(translated[1]); $('.title').html(translated[1]);
}); });
window.onunload = null;
} }
}); });
let downloadEnd;
fileReceiver.on('decrypting', isStillDecrypting => { fileReceiver.on('decrypting', isStillDecrypting => {
// The file is being decrypted // The file is being decrypted
if (isStillDecrypting) { if (isStillDecrypting) {
console.log('Decrypting'); console.log('Decrypting');
} else { } else {
console.log('Done decrypting'); console.log('Done decrypting');
downloadEnd = new Date().getTime();
} }
}); });
@ -78,9 +146,32 @@ $(document).ready(function() {
} }
}); });
const startTime = new Date().getTime();
// record download-started by recipient
window.analytics
.sendEvent('recipient', 'download-started', {
cm1: bytelength,
cm4: timeToExpiry,
cm5: totalUploads,
cm6: unexpiredFiles,
cm7: localStorage.getItem('totalDownloads')
});
fileReceiver fileReceiver
.download() .download()
.catch(() => { .catch(err => {
// record download-stopped (errored) by recipient
window.analytics
.sendEvent('recipient', 'download-stopped', {
cm1: bytelength,
cm5: totalUploads,
cm6: unexpiredFiles,
cm7: localStorage.getItem('totalDownloads'),
cd2: 'errored',
cd6: err
});
document.l10n.formatValue('expiredPageHeader') document.l10n.formatValue('expiredPageHeader')
.then(translated => { .then(translated => {
$('.title').text(translated); $('.title').text(translated);
@ -91,6 +182,24 @@ $(document).ready(function() {
return; return;
}) })
.then(([decrypted, fname]) => { .then(([decrypted, fname]) => {
const endTime = new Date().getTime();
const totalTime = endTime - startTime;
const downloadTime = endTime - downloadEnd;
const downloadSpeed = bytelength / (downloadTime / 1000);
localStorage.setItem('referrer', 'completed-download');
// record download-stopped (completed) by recipient
window.analytics
.sendEvent('recipient', 'download-stopped', {
cm1: bytelength,
cm2: totalTime,
cm3: downloadSpeed,
cm5: totalUploads,
cm6: unexpiredFiles,
cm7: localStorage.getItem('totalDownloads'),
cd2: 'completed'
});
const dataView = new DataView(decrypted); const dataView = new DataView(decrypted);
const blob = new Blob([dataView]); const blob = new Blob([dataView]);
const downloadUrl = URL.createObjectURL(blob); const downloadUrl = URL.createObjectURL(blob);

View File

@ -1,98 +1,142 @@
const FileSender = require('./fileSender'); const FileSender = require('./fileSender');
const { notify, gcmCompliant } = require('./utils'); const { notify, gcmCompliant, findMetric } = require('./utils');
const $ = require('jquery'); const $ = require('jquery');
require('jquery-circle-progress'); require('jquery-circle-progress');
const Raven = window.Raven; const Raven = window.Raven;
if (!localStorage.hasOwnProperty('totalUploads')) {
localStorage.setItem('totalUploads', 0);
}
if (localStorage.hasOwnProperty('referrer')) {
window.referrer = localStorage.getItem('referrer');
localStorage.removeItem('referrer');
} else {
window.referrer = 'external';
}
$(document).ready(function() { $(document).ready(function() {
gcmCompliant() if (!location.pathname.toString().includes('download')) {
.catch(err => { gcmCompliant()
$('#page-one').attr('hidden', true); .catch(err => {
$('#unsupported-browser').removeAttr('hidden'); $('#page-one').attr('hidden', true);
$('#unsupported-browser').removeAttr('hidden');
// record unsupported event
window.analytics
.sendEvent('sender', 'unsupported', {
cd6: err
});
});
$('#file-upload').change(onUpload);
$('.legal-links a, .social-links a, #dl-firefox').click(function(target) {
target.preventDefault();
let metric = findMetric(target.currentTarget.href);
// record exited event by recipient
window.analytics window.analytics
.sendEvent('sender', 'unsupported', { .sendEvent('sender', 'exited', {
cd7: err cd3: metric
})
.then(() => {
location.href = target.currentTarget.href;
}); });
}); })
$('#file-upload').change(onUpload); $('#send-new-completed').click(function(target) {
target.preventDefault();
// record restarted event
window.analytics
.sendEvent('sender', 'restarted', {
cd2: 'completed'
})
.then(() => {
localStorage.setItem('referrer', 'completed-upload');
location.href = target.currentTarget.href;
});
})
$('#send-new-completed').click(function() { $('#send-new-error').click(function(target) {
window.analytics target.preventDefault();
.sendEvent('sender', 'restarted', { // record restarted event
cd2: 'completed' window.analytics
}); .sendEvent('sender', 'restarted', {
}) cd2: 'errored'
})
.then(() => {
localStorage.setItem('referrer', 'errored-upload');
location.href = target.currentTarget.href;
});
})
$('#send-new-error').click(function() { $('body').on('dragover', allowDrop).on('drop', onUpload);
window.analytics // reset copy button
.sendEvent('sender', 'restarted', { const $copyBtn = $('#copy-btn');
cd2: 'errored' $copyBtn.attr('disabled', false);
}); $('#link').attr('disabled', false);
}) $copyBtn.attr('data-l10n-id', 'copyUrlFormButton');
$('body').on('dragover', allowDrop).on('drop', onUpload); if (localStorage.length === 0) {
// reset copy button toggleHeader();
const $copyBtn = $('#copy-btn'); } else {
$copyBtn.attr('disabled', false); for (let i = 0; i < localStorage.length; i++) {
$('#link').attr('disabled', false); const id = localStorage.key(i);
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton'); //check if file exists before adding to list
checkExistence(id, true);
if (localStorage.length === 0) { }
toggleHeader();
} else {
for (let i = 0; i < localStorage.length; i++) {
const id = localStorage.key(i);
//check if file exists before adding to list
checkExistence(id, true);
} }
// copy link to clipboard
$copyBtn.click(() => {
// record copied event from success screen
window.analytics
.sendEvent('sender', 'copied', {
cd4: 'success-screen'
});
const aux = document.createElement('input');
aux.setAttribute('value', $('#link').attr('value'));
document.body.appendChild(aux);
aux.select();
document.execCommand('copy');
document.body.removeChild(aux);
//disable button for 3s
$copyBtn.attr('disabled', true);
$('#link').attr('disabled', true);
$copyBtn.html('<img src="/resources/check-16.svg" class="icon-check"></img>');
window.setTimeout(() => {
$copyBtn.attr('disabled', false);
$('#link').attr('disabled', false);
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton');
}, 3000);
});
$('.upload-window').on('dragover', () => {
$('.upload-window').addClass('ondrag');
});
$('.upload-window').on('dragleave', () => {
$('.upload-window').removeClass('ondrag');
});
//initiate progress bar
$('#ul-progress').circleProgress({
value: 0.0,
startAngle: -Math.PI / 2,
fill: '#3B9DFF',
size: 158,
animation: { duration: 300 }
});
} }
// copy link to clipboard
$copyBtn.click(() => {
window.analytics
.sendEvent('sender', 'copied', {
cd6: 'success-screen'
});
const aux = document.createElement('input');
aux.setAttribute('value', $('#link').attr('value'));
document.body.appendChild(aux);
aux.select();
document.execCommand('copy');
document.body.removeChild(aux);
//disable button for 3s
$copyBtn.attr('disabled', true);
$('#link').attr('disabled', true);
$copyBtn.html('<img src="/resources/check-16.svg" class="icon-check"></img>');
window.setTimeout(() => {
$copyBtn.attr('disabled', false);
$('#link').attr('disabled', false);
$copyBtn.attr('data-l10n-id', 'copyUrlFormButton');
}, 3000);
});
$('.upload-window').on('dragover', () => {
$('.upload-window').addClass('ondrag');
});
$('.upload-window').on('dragleave', () => {
$('.upload-window').removeClass('ondrag');
});
//initiate progress bar
$('#ul-progress').circleProgress({
value: 0.0,
startAngle: -Math.PI / 2,
fill: '#3B9DFF',
size: 158,
animation: { duration: 300 }
});
//link back to homepage //link back to homepage
$('.send-new').attr('href', window.location); $('.send-new').attr('href', window.location);
// on file upload by browse or drag & drop // on file upload by browse or drag & drop
function onUpload(event) { function onUpload(event) {
event.preventDefault(); event.preventDefault();
let totalUploads = localStorage.getItem('totalUploads');
localStorage.setItem('totalUploads', Number(totalUploads) + 1);
let file = ''; let file = '';
if (event.type === 'drop') { if (event.type === 'drop') {
if (event.originalEvent.dataTransfer.files.length > 1 || event.originalEvent.dataTransfer.files[0].size === 0){ if (event.originalEvent.dataTransfer.files.length > 1 || event.originalEvent.dataTransfer.files[0].size === 0){
@ -123,6 +167,18 @@ $(document).ready(function() {
.then(str => { .then(str => {
notify(str); notify(str);
}); });
localStorage.setItem('referrer', 'cancelled-upload');
// record upload-stopped (cancelled) by sender
window.analytics
.sendEvent('sender', 'upload-stopped', {
cm1: file.size,
cm5: localStorage.getItem('totalUploads'),
cm6: unexpiredFiles,
cm7: totalDownloads,
cd1: event.type === 'drop' ? 'drop' : 'click',
cd2: 'cancelled'
});
}); });
fileSender.on('progress', progress => { fileSender.on('progress', progress => {
@ -165,27 +221,82 @@ $(document).ready(function() {
} }
}); });
let uploadStart;
fileSender.on('encrypting', isStillEncrypting => { fileSender.on('encrypting', isStillEncrypting => {
// The file is being encrypted // The file is being encrypted
if (isStillEncrypting) { if (isStillEncrypting) {
console.log('Encrypting'); console.log('Encrypting');
} else { } else {
console.log('Finished encrypting'); console.log('Finished encrypting');
uploadStart = new Date().getTime();
} }
}); });
let t = '';
let t;
const startTime = new Date().getTime();
let unexpiredFiles = 0;
for (let i = 0; i < localStorage.length; i++) {
const id = localStorage.key(i);
if (id != 'totalUploads' &&
id != 'totalDownloads' &&
id != 'referrer') {
unexpiredFiles += 1;
}
}
let totalDownloads = 0;
if (localStorage.hasOwnProperty('totalDownloads')) {
totalDownloads = localStorage.getItem('totalDownloads');
}
// record upload-started event by sender
window.analytics
.sendEvent('sender', 'upload-started', {
cm1: file.size,
cm5: localStorage.getItem('totalUploads'),
cm6: unexpiredFiles,
cm7: totalDownloads,
cd1: event.type === 'drop' ? 'drop' : 'click',
cd5: window.referrer
});
fileSender fileSender
.upload() .upload()
.then(info => { .then(info => {
const endTime = new Date().getTime();
const totalTime = endTime - startTime;
const uploadTime = endTime - uploadStart;
const uploadSpeed = file.size / (uploadTime / 1000);
// record upload-stopped (completed) by sender
window.analytics
.sendEvent('sender', 'upload-stopped', {
cm1: file.size,
cm2: totalTime,
cm3: uploadSpeed,
cm5: localStorage.getItem('totalUploads'),
cm6: unexpiredFiles,
cm7: totalDownloads,
cd1: event.type === 'drop' ? 'drop' : 'click',
cd2: 'completed'
});
const fileData = { const fileData = {
name: file.name, name: file.name,
size: file.size,
fileId: info.fileId, fileId: info.fileId,
url: info.url, url: info.url,
secretKey: info.secretKey, secretKey: info.secretKey,
deleteToken: info.deleteToken, deleteToken: info.deleteToken,
creationDate: new Date(), creationDate: new Date(),
expiry: expiration expiry: expiration,
totalTime: totalTime,
typeOfUpload: event.type === 'drop' ? 'drop' : 'click',
uploadSpeed: uploadSpeed
}; };
localStorage.setItem(info.fileId, JSON.stringify(fileData)); localStorage.setItem(info.fileId, JSON.stringify(fileData));
$('#upload-filename').attr('data-l10n-id', 'uploadSuccessConfirmHeader'); $('#upload-filename').attr('data-l10n-id', 'uploadSuccessConfirmHeader');
t = window.setTimeout(() => { t = window.setTimeout(() => {
@ -208,6 +319,18 @@ $(document).ready(function() {
$('#upload-progress').attr('hidden', true); $('#upload-progress').attr('hidden', true);
$('#upload-error').removeAttr('hidden'); $('#upload-error').removeAttr('hidden');
window.clearTimeout(t); window.clearTimeout(t);
// record upload-stopped (errored) by sender
window.analytics
.sendEvent('sender', 'upload-stopped', {
cm1: file.size,
cm5: localStorage.getItem('totalUploads'),
cm6: unexpiredFiles,
cm7: totalDownloads,
cd1: event.type === 'drop' ? 'drop' : 'click',
cd2: 'errored',
cd6: err
});
}); });
} }
@ -224,7 +347,11 @@ $(document).ready(function() {
populateFileList(localStorage.getItem(id)); populateFileList(localStorage.getItem(id));
} }
} else if (xhr.status === 404) { } else if (xhr.status === 404) {
localStorage.removeItem(id); if (id != 'totalUploads' &&
id != 'totalDownloads' &&
id != 'referrer') {
localStorage.removeItem(id);
}
} }
} }
}; };
@ -282,9 +409,10 @@ $(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
window.analytics window.analytics
.sendEvent('sender', 'copied', { .sendEvent('sender', 'copied', {
cd6: 'upload-list' cd4: 'upload-list'
}); });
const aux = document.createElement('input'); const aux = document.createElement('input');
aux.setAttribute('value', url); aux.setAttribute('value', url);
@ -362,7 +490,6 @@ $(document).ready(function() {
popupNvmSpan popupNvmSpan
]); ]);
// add data cells to table row // add data cells to table row
row.appendChild(name); row.appendChild(name);
$(link).append($copyIcon); $(link).append($copyIcon);
@ -374,18 +501,67 @@ $(document).ready(function() {
row.appendChild(del); row.appendChild(del);
$('tbody').append(row); //add row to table $('tbody').append(row); //add row to table
let unexpiredFiles = 0;
for (let i = 0; i < localStorage.length; i++) {
const id = localStorage.key(i);
if (id != 'totalUploads' &&
id != 'totalDownloads' &&
id != 'referrer') {
unexpiredFiles += 1;
}
}
let totalDownloads = 0;
if (localStorage.hasOwnProperty('totalDownloads')) {
totalDownloads = localStorage.getItem('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();
localStorage.removeItem(file.fileId); const timeToExpiry = 86400000 - (new Date().getTime() - file.creationDate.getTime());
// record upload-deleted from file list
window.analytics
.sendEvent('sender', 'upload-deleted', {
cm1: file.size,
cm2: file.totalTime,
cm3: file.uploadSpeed,
cm4: timeToExpiry,
cm5: localStorage.getItem('totalUploads'),
cm6: unexpiredFiles,
cm7: totalDownloads,
cd1: file.typeOfUpload,
cd4: 'upload-list'
})
.then(() => {
localStorage.removeItem(file.fileId);
})
toggleHeader(); toggleHeader();
}); });
}); });
document.getElementById('delete-file').onclick = () => { document.getElementById('delete-file').onclick = () => {
FileSender.delete(file.fileId, file.deleteToken).then(() => { FileSender.delete(file.fileId, file.deleteToken).then(() => {
localStorage.removeItem(file.fileId); const timeToExpiry = 86400000 - (new Date().getTime() - file.creationDate.getTime());
location.reload(); // record upload-deleted from success screen
window.analytics
.sendEvent('sender', 'upload-deleted', {
cm1: file.size,
cm2: file.totalTime,
cm3: file.uploadSpeed,
cm4: timeToExpiry,
cm5: localStorage.getItem('totalUploads'),
cm6: unexpiredFiles,
cm7: totalDownloads,
cd1: file.typeOfUpload,
cd4: 'success-screen'
})
.then(() => {
localStorage.removeItem(file.fileId);
location.reload();
})
}); });
}; };
// show popup // show popup

View File

@ -69,9 +69,35 @@ function gcmCompliant() {
} }
} }
function findMetric(href) {
switch(href) {
case 'https://www.mozilla.org/':
return 'mozilla';
case 'https://www.mozilla.org/about/legal':
return 'legal';
case 'https://testpilot.firefox.com/about':
return 'about';
case 'https://testpilot.firefox.com/privacy':
return 'privacy';
case 'https://testpilot.firefox.com/terms':
return 'terms';
case 'https://www.mozilla.org/en-US/privacy/websites/#cookies':
return 'cookies';
case 'https://github.com/mozilla/send':
return 'github';
case 'https://twitter.com/FxTestPilot':
return 'twitter';
case 'https://www.mozilla.org/firefox/new/?scene=2':
return 'download-firefox';
default:
return 'other';
}
}
module.exports = { module.exports = {
arrayToHex, arrayToHex,
hexToArray, hexToArray,
notify, notify,
gcmCompliant gcmCompliant,
findMetric
}; };

168
package-lock.json generated
View File

@ -208,9 +208,21 @@
"dev": true "dev": true
}, },
"aws-sdk": { "aws-sdk": {
"version": "2.77.0", "version": "2.87.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.77.0.tgz", "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.87.0.tgz",
"integrity": "sha1-gJCQu4dNj0//ysUxZilYdjjnhlw=" "integrity": "sha1-lW+Ey48yah0j/ioJ1JVlbhobato=",
"dependencies": {
"buffer": {
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
"integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg="
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
}
}
}, },
"babel-code-frame": { "babel-code-frame": {
"version": "6.22.0", "version": "6.22.0",
@ -384,7 +396,8 @@
"buffer": { "buffer": {
"version": "5.0.6", "version": "5.0.6",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.0.6.tgz", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.0.6.tgz",
"integrity": "sha1-LqZp9+7Atu2gWwj4tf9mGyhXNYg=" "integrity": "sha1-LqZp9+7Atu2gWwj4tf9mGyhXNYg=",
"dev": true
}, },
"buffer-xor": { "buffer-xor": {
"version": "1.0.3", "version": "1.0.3",
@ -526,12 +539,24 @@
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
"dev": true "dev": true
}, },
"color-convert": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz",
"integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=",
"dev": true
},
"color-diff": { "color-diff": {
"version": "0.1.7", "version": "0.1.7",
"resolved": "https://registry.npmjs.org/color-diff/-/color-diff-0.1.7.tgz", "resolved": "https://registry.npmjs.org/color-diff/-/color-diff-0.1.7.tgz",
"integrity": "sha1-bbeM2UgqjkWdQIIer0tQMoPcuOI=", "integrity": "sha1-bbeM2UgqjkWdQIIer0tQMoPcuOI=",
"dev": true "dev": true
}, },
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
},
"colorguard": { "colorguard": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/colorguard/-/colorguard-1.2.0.tgz", "resolved": "https://registry.npmjs.org/colorguard/-/colorguard-1.2.0.tgz",
@ -1067,11 +1092,17 @@
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
}, },
"eslint": { "eslint": {
"version": "4.1.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-4.1.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.2.0.tgz",
"integrity": "sha1-u7VaKCIO4Itp2pVU1FprLr/X2RM=", "integrity": "sha1-orMYQRGxmOAunH88ymJaXgHFaz0=",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"ajv": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.2.tgz",
"integrity": "sha1-R8aNaehvXZUxA7AHSpQw3GPaXjk=",
"dev": true
},
"concat-stream": { "concat-stream": {
"version": "1.6.0", "version": "1.6.0",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz",
@ -1103,9 +1134,9 @@
"dev": true "dev": true
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.2", "version": "2.3.3",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.2.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz",
"integrity": "sha1-WgTfBeT1f+Pw3Gj90R3FyXx+b00=", "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==",
"dev": true "dev": true
}, },
"string_decoder": { "string_decoder": {
@ -1123,9 +1154,9 @@
"dev": true "dev": true
}, },
"eslint-plugin-node": { "eslint-plugin-node": {
"version": "5.0.0", "version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-5.0.0.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-5.1.1.tgz",
"integrity": "sha512-9xERRx9V/8ciUHlTDlz9S4JiTL6Dc5oO+jKTy2mvQpxjhycpYZXzTT1t90IXjf+nAYw6/8sDnZfkeixJHxromA==", "integrity": "sha512-3xdoEbPyyQNyGhhqttjgSO3cU/non8QDBJF8ttGaHM2h8CaY5zFIngtqW6ZbLEIvhpoFPDVwiQg61b8zanx5zQ==",
"dev": true "dev": true
}, },
"eslint-plugin-security": { "eslint-plugin-security": {
@ -1198,8 +1229,7 @@
"events": { "events": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
"integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ="
"dev": true
}, },
"evp_bytestokey": { "evp_bytestokey": {
"version": "1.0.0", "version": "1.0.0",
@ -1265,6 +1295,12 @@
"integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=",
"dev": true "dev": true
}, },
"fast-deep-equal": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz",
"integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=",
"dev": true
},
"fast-levenshtein": { "fast-levenshtein": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
@ -2179,18 +2215,6 @@
"integrity": "sha1-szmUr0V6gRVwDUEPMXczy+egkEs=", "integrity": "sha1-szmUr0V6gRVwDUEPMXczy+egkEs=",
"dev": true "dev": true
}, },
"generate-function": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz",
"integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=",
"dev": true
},
"generate-object-property": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz",
"integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=",
"dev": true
},
"get-stdin": { "get-stdin": {
"version": "5.0.1", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz",
@ -2349,12 +2373,6 @@
"resolved": "https://registry.npmjs.org/hsts/-/hsts-2.0.0.tgz", "resolved": "https://registry.npmjs.org/hsts/-/hsts-2.0.0.tgz",
"integrity": "sha1-pSI0xgcN7PIUsra3C7FE0H5Hdsc=" "integrity": "sha1-pSI0xgcN7PIUsra3C7FE0H5Hdsc="
}, },
"html-tags": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/html-tags/-/html-tags-1.2.0.tgz",
"integrity": "sha1-x43mW1Zjqll5id0rerSSANfk25g=",
"dev": true
},
"htmlescape": { "htmlescape": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz",
@ -2561,12 +2579,6 @@
"integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=",
"dev": true "dev": true
}, },
"is-my-json-valid": {
"version": "2.16.0",
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.16.0.tgz",
"integrity": "sha1-8Hndm/2uZe4gOKrorLyGqxCeNpM=",
"dev": true
},
"is-number": { "is-number": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz",
@ -2615,12 +2627,6 @@
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=",
"dev": true "dev": true
}, },
"is-property": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
"integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=",
"dev": true
},
"is-regex": { "is-regex": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
@ -2725,6 +2731,12 @@
"integrity": "sha1-KqEH8UKvQSHRRWWdRPUIMJYeaZo=", "integrity": "sha1-KqEH8UKvQSHRRWWdRPUIMJYeaZo=",
"dev": true "dev": true
}, },
"json-schema-traverse": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
"integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=",
"dev": true
},
"json-stable-stringify": { "json-stable-stringify": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz",
@ -2798,12 +2810,6 @@
"integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=",
"dev": true "dev": true
}, },
"jsonpointer": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz",
"integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=",
"dev": true
},
"JSONStream": { "JSONStream": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz",
@ -3551,9 +3557,9 @@
"dev": true "dev": true
}, },
"prettier": { "prettier": {
"version": "1.4.4", "version": "1.5.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.4.4.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.5.3.tgz",
"integrity": "sha512-GuuPazIvjW1DG26yLQgO+nagmRF/h9M4RaCtZWqu/eFW7csdZkQEwPJUeXX10d+LzmCnR9DuIZndqIOn3p2YoA==", "integrity": "sha1-WdrcaDNF7GuI+IuU7Urn4do5S/4=",
"dev": true "dev": true
}, },
"process": { "process": {
@ -3698,9 +3704,9 @@
} }
}, },
"raven-js": { "raven-js": {
"version": "3.16.0", "version": "3.17.0",
"resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.16.0.tgz", "resolved": "https://registry.npmjs.org/raven-js/-/raven-js-3.17.0.tgz",
"integrity": "sha1-p5naT90ExjlD9n3rk9qg7P4QHqs=" "integrity": "sha1-d5RXrHkQUSw8LMm7bQqe61mpaew="
}, },
"raw-body": { "raw-body": {
"version": "2.2.0", "version": "2.2.0",
@ -4063,9 +4069,9 @@
"dev": true "dev": true
}, },
"sinon": { "sinon": {
"version": "2.3.5", "version": "2.3.8",
"resolved": "https://registry.npmjs.org/sinon/-/sinon-2.3.5.tgz", "resolved": "https://registry.npmjs.org/sinon/-/sinon-2.3.8.tgz",
"integrity": "sha1-mi/A/41SbacW8wlTqixl1RiRf2w=", "integrity": "sha1-Md4G/tj7o6Zx5XbdltClhjeW8lw=",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"path-to-regexp": { "path-to-regexp": {
@ -4348,17 +4354,29 @@
} }
}, },
"stylelint": { "stylelint": {
"version": "7.11.1", "version": "7.13.0",
"resolved": "https://registry.npmjs.org/stylelint/-/stylelint-7.11.1.tgz", "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-7.13.0.tgz",
"integrity": "sha1-yBbGWLr32eXRZ9gic/6tN8l65J0=", "integrity": "sha1-ER+Xttpy53XICADWu29fhpmXeF0=",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"ansi-styles": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.1.0.tgz",
"integrity": "sha1-CcIC1ckX7CMYjKpcnLkXnNlUd1A=",
"dev": true
},
"balanced-match": { "balanced-match": {
"version": "0.4.2", "version": "0.4.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz",
"integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=",
"dev": true "dev": true
}, },
"chalk": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.0.1.tgz",
"integrity": "sha512-Mp+FXEI+FrwY/XYV45b2YD3E8i3HwnEAoFcM0qlZzq/RZ9RwWitt2Y/c7cqRAz70U7hfekqx6qNYthuKFO6K0g==",
"dev": true
},
"glob": { "glob": {
"version": "7.1.2", "version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
@ -4371,11 +4389,29 @@
"integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=",
"dev": true "dev": true
}, },
"has-flag": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz",
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
"dev": true
},
"html-tags": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/html-tags/-/html-tags-2.0.0.tgz",
"integrity": "sha1-ELMKOGCF9Dzt41PMj6fLDe7qZos=",
"dev": true
},
"resolve-from": { "resolve-from": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz",
"integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=",
"dev": true "dev": true
},
"supports-color": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.2.0.tgz",
"integrity": "sha512-Ts0Mu/A1S1aZxEJNG88I4Oc9rcZSBFNac5e27yh4j2mqbhZSSzR1Ah79EYwSn9Zuh7lrlGD2cVGzw1RKGzyLSg==",
"dev": true
} }
} }
}, },
@ -4467,9 +4503,9 @@
"dev": true "dev": true
}, },
"testpilot-ga": { "testpilot-ga": {
"version": "0.2.1", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/testpilot-ga/-/testpilot-ga-0.2.1.tgz", "resolved": "https://registry.npmjs.org/testpilot-ga/-/testpilot-ga-0.3.0.tgz",
"integrity": "sha512-vuV8ukXMVy4g2ZEuNHo9y92MXoZrjfPdJqCrFUR1CXk45oJ25Tm2SjUStH3ZeNZRv4O+8Hs0AzsXCaH4/J9mUg==" "integrity": "sha512-z4PJbw3KK0R0iflA+u/3BhWZrtsLHLu+0rMviMd8H1wp8qPV0rggNBjsKckBJCcXq4uEjXETGZzApHH7Tovpzw=="
}, },
"text-encoding": { "text-encoding": {
"version": "0.6.4", "version": "0.6.4",

View File

@ -4,7 +4,7 @@
"version": "0.1.2", "version": "0.1.2",
"author": "Mozilla (https://mozilla.org)", "author": "Mozilla (https://mozilla.org)",
"dependencies": { "dependencies": {
"aws-sdk": "^2.62.0", "aws-sdk": "^2.87.0",
"body-parser": "^1.17.2", "body-parser": "^1.17.2",
"bytes": "^2.5.0", "bytes": "^2.5.0",
"connect-busboy": "0.0.2", "connect-busboy": "0.0.2",
@ -18,26 +18,26 @@
"l20n": "^5.0.0", "l20n": "^5.0.0",
"mozlog": "^2.1.1", "mozlog": "^2.1.1",
"raven": "^2.1.0", "raven": "^2.1.0",
"raven-js": "^3.16.0", "raven-js": "^3.17.0",
"redis": "^2.7.1", "redis": "^2.7.1",
"selenium-webdriver": "^3.4.0", "selenium-webdriver": "^3.4.0",
"supertest": "^3.0.0", "supertest": "^3.0.0",
"testpilot-ga": "^0.2.1", "testpilot-ga": "^0.3.0",
"uglify-es": "3.0.19" "uglify-es": "3.0.19"
}, },
"devDependencies": { "devDependencies": {
"browserify": "^14.4.0", "browserify": "^14.4.0",
"eslint": "^4.0.0", "eslint": "^4.2.0",
"eslint-plugin-mocha": "^4.11.0", "eslint-plugin-mocha": "^4.11.0",
"eslint-plugin-node": "^5.0.0", "eslint-plugin-node": "^5.1.1",
"eslint-plugin-security": "^1.4.0", "eslint-plugin-security": "^1.4.0",
"git-rev-sync": "^1.9.1", "git-rev-sync": "^1.9.1",
"mocha": "^3.4.2", "mocha": "^3.4.2",
"npm-run-all": "^4.0.2", "npm-run-all": "^4.0.2",
"prettier": "^1.4.4", "prettier": "^1.5.3",
"proxyquire": "^1.8.0", "proxyquire": "^1.8.0",
"sinon": "^2.3.5", "sinon": "^2.3.8",
"stylelint": "^7.11.0", "stylelint": "^7.13.0",
"stylelint-config-standard": "^16.0.0", "stylelint-config-standard": "^16.0.0",
"watchify": "^3.9.0" "watchify": "^3.9.0"
}, },

View File

@ -107,12 +107,18 @@ app.get('/download/:id', (req, res) => {
storage storage
.length(id) .length(id)
.then(contentLength => { .then(contentLength => {
res.render('download', { storage
filename: decodeURIComponent(filename), .ttl(id)
filesize: bytes(contentLength), .then(timeToExpiry => {
trackerId: conf.analytics_id, res.render('download', {
dsn: conf.sentry_id filename: decodeURIComponent(filename),
}); filesize: bytes(contentLength),
sizeInBytes: contentLength,
timeToExpiry: timeToExpiry,
trackerId: conf.analytics_id,
dsn: conf.sentry_id
});
})
}) })
.catch(() => { .catch(() => {
res.render('download'); res.render('download');

View File

@ -23,6 +23,7 @@ if (conf.s3_bucket) {
module.exports = { module.exports = {
filename: filename, filename: filename,
exists: exists, exists: exists,
ttl: ttl,
length: awsLength, length: awsLength,
get: awsGet, get: awsGet,
set: awsSet, set: awsSet,
@ -39,6 +40,7 @@ if (conf.s3_bucket) {
module.exports = { module.exports = {
filename: filename, filename: filename,
exists: exists, exists: exists,
ttl: ttl,
length: localLength, length: localLength,
get: localGet, get: localGet,
set: localSet, set: localSet,
@ -73,6 +75,18 @@ function metadata(id) {
}); });
} }
function ttl(id) {
return new Promise((resolve, reject) => {
redis_client.ttl(id, (err, reply) => {
if (!err) {
resolve(reply * 1000);
} else {
reject(err);
}
})
})
}
function filename(id) { function filename(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
redis_client.hget(id, 'filename', (err, reply) => { redis_client.hget(id, 'filename', (err, reply) => {

View File

@ -7,6 +7,8 @@
data-l10n-args='{"filename": "{{filename}}"}'></span> data-l10n-args='{"filename": "{{filename}}"}'></span>
<span data-l10n-id="downloadFileSize" <span data-l10n-id="downloadFileSize"
data-l10n-args='{"size": "{{filesize}}"}'></span> data-l10n-args='{"size": "{{filesize}}"}'></span>
<span id="dl-bytelength" hidden="true">{{sizeInBytes}}</span>
<span id="dl-ttl" hidden="true">{{timeToExpiry}}</span>
</div> </div>
<div class="description" data-l10n-id="downloadMessage"></div> <div class="description" data-l10n-id="downloadMessage"></div>
<img src="/resources/illustration_download.svg" id="download-img" data-l10n-id="downloadAltText"/> <img src="/resources/illustration_download.svg" id="download-img" data-l10n-id="downloadAltText"/>
@ -41,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" data-l10n-id="sendYourFilesLink"></a> <a class="send-new" id = "expired-send-new" data-l10n-id="sendYourFilesLink"></a>
{{/if}} {{/if}}
</div> </div>

View File

@ -22,8 +22,8 @@
</div> </div>
<div class="footer"> <div class="footer">
<div class="legal-links"> <div class="legal-links">
<a href="https://www.mozilla.org"><img class="mozilla-logo" src="/resources/mozilla-logo.svg"/></a> <a href="https://www.mozilla.org"><img class="mozilla-logo" src="/resources/mozilla-logo.svg"/></a>
<a href="https://www.mozilla.org/about/legal/" data-l10n-id="footerLinkLegal"></a> <a href="https://www.mozilla.org/about/legal" data-l10n-id="footerLinkLegal"></a>
<a href="https://testpilot.firefox.com/about" data-l10n-id="footerLinkAbout"></a> <a href="https://testpilot.firefox.com/about" data-l10n-id="footerLinkAbout"></a>
<a href="https://testpilot.firefox.com/privacy" data-l10n-id="footerLinkPrivacy"></a> <a href="https://testpilot.firefox.com/privacy" data-l10n-id="footerLinkPrivacy"></a>
<a href="https://testpilot.firefox.com/terms" data-l10n-id="footerLinkTerms"></a> <a href="https://testpilot.firefox.com/terms" data-l10n-id="footerLinkTerms"></a>