Created
April 26, 2017 20:07
-
-
Save gregglind/18d985d79c70a5fbefc0d471894d4c6b to your computer and use it in GitHub Desktop.
A bootstrap file for a simple pref flip study helper addon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/gregglind/quantum-preference-telemetry-annotation-pretender/blob/master/index.js | |
const CID = Cu.import('resource://gre/modules/ClientID.jsm'); | |
const { TelemetryController } = Cu.import('resource://gre/modules/TelemetryController.jsm'); | |
const { TelemetryEnvironment } = Cu.import('resource://gre/modules/TelemetryEnvironment.jsm'); | |
function generateTelemetryIdIfNeeded() { | |
let id = TelemetryController.clientID; | |
/* istanbul ignore next */ | |
if (id === undefined) { | |
return CID.ClientIDImpl._doLoadClientID(); | |
} else { | |
return Promise.resolve(id); | |
} | |
} | |
const experimentName = "screenshots-rollout-test-1"; | |
const variations = ['control', 'screenshots-on']; | |
function chooseVariation (clientId) { | |
// do some hashing magic of the client id, such as: | |
let last = clientId.substr(clientId.length-3); | |
let which = parseInt(last,16) % variations.length; | |
return variations[which]; | |
} | |
function isEligible() { | |
// check locales or whatever | |
return true; | |
} | |
function markTelemetry (which) { | |
} | |
function unmarkTelemetry (which) { | |
} | |
function implement(variation) { | |
markTelemetry(variation) | |
switch (variation) { | |
case "control": | |
// don't set the pref to the value | |
break; | |
default: | |
setThePref(someValue) | |
} | |
} | |
function startup () { | |
let variation = chooseVariation(clientId); | |
impelement(variation) | |
} | |
function shutdown () { | |
// blah blah | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment