Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
shield(addon): Closes #1515 Try addon as shield study
Browse files Browse the repository at this point in the history
  • Loading branch information
sarracini committed Nov 8, 2016
1 parent 17d58da commit 27413a3
Show file tree
Hide file tree
Showing 12 changed files with 425 additions and 15 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ common/vendor.js
data/content/
firefox/
logs/
addon/shield-utils/
test/test-SimpleStorage.js
test/test-ColorAnalyzer.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ logs/
dist/
data/content/
activity-streams-env/
addon/shield-utils/
firefox/
config.yml
.amo_config.json
Expand Down
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ deploy:
script: bin/continuous-integration.sh prerelease
on:
branch: release-1.1.7
- provider: script
skip_cleanup: true
script: bin/continuous-integration.sh shield
on:
branch: shield_study

notifications:
email: false
99 changes: 99 additions & 0 deletions SHIELD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#Activity Stream SHIELD Study

## How to run this SHIELD study

tldr; Run the command ```npm run once``` and get a randomly assigned variant.

The SHIELD study work currently lives on branch ```shield_study``` in this repo. To run the study, checkout the branch, run command ```npm start``` in one terminal window, and in another terminal window run command ```shield run . -- -b nightly```. This will randomly pick one of the two variants provided in the study and start it in Nightly. At this point you can see which variant it chose. You can click around and print the ping payloads that get sent. If you want to see one variant specifically, run either ```shield run . Tiles -- -b nightly``` or ```shield run . ActivityStream -- -b nightly``` instead to load up the variant specified.

## How it works

#### Specifics of this study
In this [SHIELD study](https://wiki.mozilla.org/Firefox/Shield/Shield_Studies) a user will be randomly assigned into either the control group or the variant group. If they are in the control group, Activity Stream will **not** be loaded into their browser, and instead they will have the original about:newtab page as their default.
#### About the metrics
At this point any interaction that the user makes with about:newtab will send a ping to our custom data pipeline where it will be recorded for analysis. If they are in the variant group, normal Activity Stream will be loaded and all user events will be collected and recorded as normal. The pings belonging to a SHIELD study user will contain an extra field named ```shield_variant``` which will contain either the name of the control group or the name of the variant group. This will be what we use to distinguish which group each unique user belongs to.

**Sample pings:**
```json
{
"event":"CLICK",
"action_position":0,
"source":"AFFILIATE",
"shield_variant":"shield-study-01-Tiles",
"action":"activity_stream_event",
"tab_id":"-3-2",
"client_id":"ee88c4ef-4f1d-8149-9582-b727dc92e89f",
"addon_version":"1.1.5",
"locale":"en-US",
"page":"NEW_TAB",
"session_id":"{ab6f3b3e-dfc6-f944-b082-6f4bbbc21e72}"
}
```
```json
{
"event":"SEARCH",
"action":"activity_stream_event",
"tab_id":"-3-2",
"client_id":"daf5dc62-08e4-e840-837d-c2adb3b62463",
"addon_version":"1.1.5",
"locale":"en-US",
"page":"NEW_TAB",
"session_id":"{2426a185-b9bf-a84d-b359-61eb11452382}",
"shield_variant":"shield-study-01-Tiles"}
```
```json
{
"tab_id":"-3-2",
"session_id":"{2426a185-b9bf-a84d-b359-61eb11452382}",
"total_history_size":100,
"total_bookmarks":10,
"load_reason":"newtab",
"url":"about:newtab",
"unload_reason":"search",
"client_id":"daf5dc62-08e4-e840-837d-c2adb3b62463",
"addon_version":"1.1.5",
"locale":"en-US",
"page":"NEW_TAB",
"shield_variant":"shield-study-01-Tiles",
"action":"activity_stream_session",
"session_duration":6242
}
```

## What we hope to achieve

The success criteria for the SHIELD study is as follows:
- Increase the average number of top sites clicks per user per day
- Increase the average number of newtab searches per user per day
- Increase the average number of newtab sessions per user per day
- Maintain search volume


## Studies
###shield-study-01

Dates of study: November xx 2016 - November xx 2016

Duration: 14 days

Activity Stream addon version: 1.1.x

Metrics measured: Clicks and blocks on top sites, search, sessions, performance related events

Total number of users: 20,000

Total number of users per arm: 10,000

Control group: 'Tiles'

Variant group: 'Activity Stream'

User eligibility criteria:

- Must have about:newtab enabled
- Must have local set to en-US
- Must not have Test Pilot add on installed

Findings: *links to dashboards go here*

###shield-study-02
12 changes: 12 additions & 0 deletions addon/TabTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ function TabTracker(options) {
this._addListeners();
}
simplePrefs.on(TELEMETRY_PREF, this._onPrefChange);

// shield fields
this._shieldVariant = options.shield_variant;
this._testPilotVersion = options.tp_version;
}

TabTracker.prototype = {
Expand Down Expand Up @@ -84,6 +88,14 @@ TabTracker.prototype = {
if (this._experimentID) {
payload.experiment_id = this._experimentID;
}

// shield fields
if (this._shieldVariant) {
payload.shield_variant = this._shieldVariant;
}
if (this._testPilotVersion) {
payload.tp_version = this._testPilotVersion;
}
},

uninit() {
Expand Down
38 changes: 38 additions & 0 deletions addon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* globals require, exports */
"use strict";
const self = require("sdk/self");
const shield = require("./shield-utils/index");
const {when: unload} = require("sdk/system/unload");
const {Feature} = require("./shield");
const {Cu} = require("chrome");
const feature = new Feature();

const studyConfig = {
name: "ACTIVITY_STREAM",
days: 14,
variations: {
"ActivityStream": () => feature.loadActivityStream(),
"Tiles": () => feature.loadTiles()
}
};

class OurStudy extends shield.Study {
isEligible() {
return super.isEligible() && feature.isEligible();
}
shutdown(reason, variant) {
feature.shutdown(reason, variant);
}
setVariant(variant) {
feature.setVariant(variant);
}
checkTestPilot() {
return new Promise(resolve => {
feature.doesHaveTestPilot().then(resolve).catch(err => Cu.reportError(err));
});
}
}
const thisStudy = new OurStudy(studyConfig);
thisStudy.setVariant(thisStudy.variation);
thisStudy.checkTestPilot().then(() => thisStudy.startup(self.loadReason)).catch(err => Cu.reportError(err));
unload(reason => thisStudy.shutdown(reason, thisStudy.variation));

0 comments on commit 27413a3

Please sign in to comment.