-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix #315, fully implement Telemetry for Shield study * Also fixes #342, as an experiment wasn't necessary to check if the sidebar is open * Move the experiment/ directory into addon/, which makes packaging easier * Implement polling to identify if Side View is being used * Add a null/empty add-on
- Loading branch information
Showing
11 changed files
with
188 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
node_modules | ||
web-ext-artifacts | ||
addon.xpi | ||
addon*.xpi | ||
addon/build | ||
addon/manifest.json | ||
/experiment/study | ||
/addon/experiment/study | ||
/null-addon/addon/experiment | ||
.DS_Store | ||
/Profile |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
this.shieldSetup = (function () { | ||
|
||
// Every CHECK_SIDEBAR_PERIOD we see if the sidebar is open, and send a usage telemetry if it is | ||
// We also look for any normal events | ||
const CHECK_SIDEBAR_PERIOD = 1000 * 60 * 60; // 1 hour | ||
// And then if we find something, we send a telemetry event, but only this often: | ||
const SEND_OPEN_TELEMETRY_LIMIT = 1000 * 60 * 60 * 24; // 1 day | ||
let exports = {}; | ||
|
||
exports.sendShieldEvent = async function(args) { | ||
if (args.ec === "startup") { | ||
browser.study.sendTelemetry({message: "addon_init"}); | ||
} else if (args.ea === "load-url") { | ||
// Any kind of load event uses ea=load-url (pageAction, browserAction, contextMenu, etc) | ||
try { | ||
flagUsed(); | ||
await browser.study.sendTelemetry({message: "uri_to_sv", uri_sent: "true"}); | ||
} catch (e) { | ||
console.warn("Failure in sendTelemetry:", String(e), e.stack); | ||
} | ||
} | ||
}; | ||
|
||
let lastUsed = null; | ||
|
||
function flagUsed() { | ||
if (!lastUsed || Date.now() - lastUsed >= SEND_OPEN_TELEMETRY_LIMIT) { | ||
browser.study.sendTelemetry({message: "panel_used_today", panel_used: "true"}); | ||
lastUsed = Date.now(); | ||
} | ||
} | ||
|
||
setInterval(async () => { | ||
if (await browser.sidebarAction.isOpen({})) { | ||
flagUsed(); | ||
} | ||
}, CHECK_SIDEBAR_PERIOD); | ||
|
||
async function init() { | ||
try { | ||
await browser.study.setup({ | ||
activeExperimentName: "side-view-1", // Note: the control add-on must have the same activeExperimentName | ||
studyType: "shield", | ||
telemetry: { | ||
send: true, | ||
// Marks pings with testing=true. Set flag to `true` before final release | ||
removeTestingFlag: false, | ||
}, | ||
endings: { | ||
/** standard endings */ | ||
"user-disable": { | ||
baseUrls: [ | ||
"https://qsurvey.mozilla.com/s3/side-view-shield-study/?reason=user-disable", | ||
], | ||
}, | ||
ineligible: { | ||
baseUrls: [], | ||
}, | ||
expired: { | ||
baseUrls: [ | ||
"https://qsurvey.mozilla.com/s3/side-view-shield-study/?reason=expired", | ||
], | ||
}, | ||
/** Study specific endings */ | ||
"user-used-the-feature": { | ||
baseUrls: [ | ||
// FIXME: do we want this? | ||
// If we do, we have to use browser.study.endStudy("user-used-the-feature") | ||
"https://qsurvey.mozilla.com/s3/side-view-shield-study/?reason=user-used-the-feature", | ||
], | ||
category: "ended-positive", | ||
}, | ||
}, | ||
weightedVariations: [ | ||
{ | ||
name: "feature-active", | ||
weight: 1, | ||
}, | ||
], | ||
// maximum time that the study should run, from the first run | ||
expire: { | ||
days: 365, | ||
}, | ||
}); | ||
} catch (e) { | ||
console.warn("Error in Shield init():", String(e), e.stack); | ||
} | ||
} | ||
|
||
init(); | ||
|
||
return exports; | ||
})(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Null Add-on | ||
|
||
This is a temporary add-on we are using for the control in a [Shield study](https://wiki.mozilla.org/Firefox/Shield) | ||
|
||
## Installation | ||
|
||
You can build an XPI with the command: | ||
|
||
```sh | ||
npm run package-null | ||
``` | ||
|
||
This creates `addon-null.xpi` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
async function init() { | ||
try { | ||
await browser.study.setup({ | ||
activeExperimentName: "side-view-1", // Note: the control add-on must have the same activeExperimentName | ||
studyType: "shield", | ||
telemetry: { | ||
send: true, | ||
// Marks pings with testing=true. Set flag to `true` before final release | ||
removeTestingFlag: false, | ||
}, | ||
endings: { | ||
}, | ||
weightedVariations: [ | ||
{ | ||
name: "control", | ||
weight: 1, | ||
}, | ||
], | ||
// maximum time that the study should run, from the first run | ||
expire: { | ||
days: 365, | ||
}, | ||
}); | ||
browser.study.sendTelemetry({message: "addon_control_init"}); | ||
} catch (e) { | ||
console.warn("Error in Shield init():", String(e), e.stack); | ||
} | ||
} | ||
|
||
init(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "Side View Control", | ||
"version": "0.1", | ||
"description": "This is an empty add-on that has no functionality", | ||
"icons": { | ||
// "48": "side-view.png", | ||
// "96": "side-view.png" | ||
}, | ||
"author": "Mozilla (https://mozilla.org/)", | ||
"homepage_url": "https://github.com/mozilla/side-view/", | ||
"applications": { | ||
"gecko": { | ||
"id": "[email protected]", | ||
"strict_min_version": "57.0a1" | ||
} | ||
}, | ||
"experiment_apis": { | ||
"study": { | ||
"schema": "./experiment/study/schema.json", | ||
"parent": { | ||
"scopes": ["addon_parent"], | ||
"script": "./experiment/study/api.js", | ||
"paths": [["study"]] | ||
} | ||
} | ||
}, | ||
"background": { | ||
"scripts": [ | ||
"background.js" | ||
] | ||
} | ||
} |
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