Created
April 26, 2017 20:07
-
-
Save gregglind/18d985d79c70a5fbefc0d471894d4c6b to your computer and use it in GitHub Desktop.
Revisions
-
gregglind created this gist
Apr 26, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ // 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 }