This commit is contained in:
Rehan Dalal 2018-02-01 12:11:45 -05:00
Родитель 185965d9fb
Коммит 7c5f6f94e7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 410D198EEF339E0B
3 изменённых файлов: 23 добавлений и 16 удалений

Просмотреть файл

@ -15,11 +15,17 @@ const HOUR = 60 * MINUTE;
const DAY = 24 * HOUR;
const WEEK = 7 * DAY;
const KILOBYTE = 1024;
const MEGABYTE = 1024 * KILOBYTE;
const Config = {
addonId: "pioneer-study-pathfinder@pioneer.mozilla.org",
studyName: "pathfinder",
branches: [
{ name: "control", weight: 1 },
{ name: "control", weight: 1, limit: 1 * MEGABYTE },
// Limit set as per: https://bugzilla.mozilla.org/show_bug.cgi?id=1434714
{ name: "safe", weight: 1, limit: 500000 },
],
telemetryEnv: Services.prefs.getCharPref(TELEMETRY_ENV_PREF, "prod"),

Просмотреть файл

@ -27,10 +27,6 @@ const UPLOAD_DATE_PREF = "extensions.pioneer-study-pathfinder.lastLogUploadDate"
const TIMER_NAME = "pioneer-pathfinder-timer";
const KILOBYTE = 1024;
const MEGABYTE = 1024 * KILOBYTE;
const UPLOAD_LIMIT = 1 * MEGABYTE;
let padding = 0.95;
let perEntryPingSizeIncrease = {};
@ -82,7 +78,8 @@ this.LogHandler = {
async generateEntries(type) {
const pingCount = Math.floor(Math.random() * 5) + 1; // Returns a random number from 1-5
const entriesMinSize = UPLOAD_LIMIT * (pingCount - 1);
const branch = Pioneer.utils.chooseBranch();
const entriesMinSize = branch.limit * (pingCount - 1);
const entry = {
url: "pathfinder",
@ -135,11 +132,12 @@ this.LogHandler = {
if (timesinceLastUpload > Config.logSubmissionInterval) {
let entries = await this.generateEntries(type);
let payload = { entries };
const branch = Pioneer.utils.chooseBranch();
const entriesPingSize = await Pioneer.utils.getEncryptedPingSize(
"pathfinder-log", 1, payload
);
if (entriesPingSize < UPLOAD_LIMIT) {
if (entriesPingSize < branch.limit) {
// If the ping is small enough, just submit it directly
await Pioneer.submitEncryptedPing("pathfinder-log", 1, payload);
PrefUtils.setLongPref(uploadDatePrefName, Date.now());
@ -151,7 +149,7 @@ this.LogHandler = {
});
} else {
// Otherwise, break it into batches below the minimum size
const reduceRatio = UPLOAD_LIMIT / entriesPingSize;
const reduceRatio = branch.limit / entriesPingSize;
const originalEntriesLength = entries.length;
let batch = [];
@ -167,7 +165,7 @@ this.LogHandler = {
"pathfinder-log", 1, payload
);
if (batchPingSize >= UPLOAD_LIMIT) {
if (batchPingSize >= branch.limit) {
// not small enough, put the batch back in the pool,
// reduce the batch size and try again
padding -= 0.05;

Просмотреть файл

@ -1,5 +1,6 @@
const { utils: Cu } = Components;
Cu.import("resource://gre/modules/Console.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(
@ -15,13 +16,15 @@ const Pioneer = {
},
submitEncryptedPing(schemaName, schemaVersion, data, options) {
console.log('Ping submitted');
console.log({
schemaName,
schemaVersion,
data,
options,
});
if (Services.prefs.getBoolPref("extensions.pioneer-pathfinder.debug", false)) {
console.log('Ping submitted');
console.log({
schemaName,
schemaVersion,
data,
options,
});
}
this.utils.submitEncryptedPing(schemaName, schemaVersion, data, options)
}
};