Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ jobs:
path: "test-addon/dist"
destination: "test-addon/dist"

- run:
name: Import and build the Pioneer opt-in add-on
command: npm run import-pioneer-opt-in

# Needs signed add-on to work on branded releases
#- run:
# name: Test with Firefox Release
Expand Down
20 changes: 0 additions & 20 deletions bin/import-pioneer-opt-in.sh

This file was deleted.

3 changes: 0 additions & 3 deletions examples/small-study/src/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ module.exports = {
es6: true,
webextensions: true,
},
rules: {
"no-console": "off",
},
};
22 changes: 6 additions & 16 deletions examples/small-study/src/studySetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ const baseStudySetup = {
// used for activeExperiments tagging (telemetryEnvironment.setActiveExperiment)
activeExperimentName: browser.runtime.id,

// use either "shield" or "pioneer" telemetry semantics and data pipelines
// uses shield sampling and telemetry semantics. Future: will support "pioneer"
studyType: "shield",

// telemetry
telemetry: {
// Actually submit the pings to Telemetry. [default if omitted: false]
// default false. Actually send pings.
send: true,
// Marks pings with testing=true. Set flag to `true` for pings are meant to be seen by analysts [default if omitted: false]
// Marks pings with testing=true. Set flag to `true` before final release
removeTestingFlag: false,
// Keep an internal telemetry archive. Useful for verifying payloads of Pioneer studies without risking actually sending any unencrypted payloads [default if omitted: false]
internalTelemetryArchive: false,
},

// endings with urls
Expand Down Expand Up @@ -101,11 +99,10 @@ const baseStudySetup = {
*
* This implementation caches in local storage to speed up second run.
*
* @param {object} studySetup A complete study setup object
* @returns {Promise<boolean>} answer An boolean answer about whether the user should be
* allowed to enroll in the study
*/
async function cachingFirstRunShouldAllowEnroll(studySetup) {
async function cachingFirstRunShouldAllowEnroll() {
// Cached answer. Used on 2nd run
let allowed = await browser.storage.local.get("allowedEnrollOnFirstRun");
if (allowed.allowedEnrollOnFirstRun === true) return true;
Expand All @@ -116,13 +113,7 @@ async function cachingFirstRunShouldAllowEnroll(studySetup) {
*/

// could have other reasons to be eligible, such add-ons, prefs
const dataPermissions = await browser.study.getDataPermissions();
if (studySetup.studyType === "shield") {
allowed = dataPermissions.shield;
}
if (studySetup.studyType === "pioneer") {
allowed = dataPermissions.pioneer;
}
allowed = true;

// cache the answer
await browser.storage.local.set({ allowedEnrollOnFirstRun: allowed });
Expand All @@ -138,14 +129,13 @@ async function getStudySetup() {
// shallow copy
const studySetup = Object.assign({}, baseStudySetup);

studySetup.allowEnroll = await cachingFirstRunShouldAllowEnroll(studySetup);
studySetup.allowEnroll = await cachingFirstRunShouldAllowEnroll();

const testingOverrides = await browser.study.getTestingOverrides();
studySetup.testing = {
variationName: testingOverrides.variationName,
firstRunTimestamp: testingOverrides.firstRunTimestamp,
expired: testingOverrides.expired,
};

return studySetup;
}
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"version": "5.1.1",
"author": "Mozilla",
"bin": {
"copyStudyUtils": "bin/copyStudyUtils.js",
"importPioneerOptIn": "bin/import-pioneer-opt-in.sh"
"copyStudyUtils": "bin/copyStudyUtils.js"
},
"bugs": {
"url": "https://github.com/mozilla/shield-studies-addon-utils/issues"
Expand All @@ -14,7 +13,6 @@
"ajv": "^6.5.0",
"commander": "^2.15.1",
"fs-extra": "^6.0.1",
"jose-jwe-jws": "0.1.6",
"shield-study-schemas": "^0.8.3"
},
"devDependencies": {
Expand Down Expand Up @@ -43,7 +41,6 @@
},
"files": [
"bin/copyStudyUtils.js",
"bin/import-pioneer-opt-in.sh",
"testUtils",
"webExtensionApis/study/api.js",
"webExtensionApis/study/schema.json",
Expand Down Expand Up @@ -83,15 +80,14 @@
"generate:generateSchema:study": "cd webExtensionApis/study && yaml2json schema.yaml -p > schema.json",
"generate:generateStubApi:study": "cd webExtensionApis/study && generateStubApi ./schema.json > stubApi.js",
"generate:verifyWeeSchema:study": "cd webExtensionApis/study && verifyWeeSchema schema.json",
"import-pioneer-opt-in": "bin/import-pioneer-opt-in.sh",
"lint": "npm-run-all lint:*",
"lint:eslint": "npm run eslint",
"lint:fixpack": "fixpack # cleans up package.json",
"postbuild": "if [ -z ${SKIPLINT} ]; then npm run format; fi",
"postformat": "run-p lint:fixpack eslint-fix",
"prebuild": "if [ -z ${SKIPLINT} ]; then npm run lint; fi",
"prepare": "export SKIPLINT=1 && fixpack && npm run build",
"pretest": "npm run build && npm run test-addon:bundle-utils && npm run test-addon:build && npm run import-pioneer-opt-in",
"pretest": "npm run build && npm run test-addon:bundle-utils && npm run test-addon:build",
"pretest-addon": "npm run pretest",
"small-study": "cd examples/small-study && npm run rebuild && npm start",
"test": "npm run test:func",
Expand Down
28 changes: 7 additions & 21 deletions test-addon/src/studySetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ const baseStudySetup = {
// used for activeExperiments tagging (telemetryEnvironment.setActiveExperiment)
activeExperimentName: browser.runtime.id,

// use either "shield" or "pioneer" telemetry semantics and data pipelines
studyType: null, // set by internal test override below in getStudySetup()
// uses shield sampling and telemetry semantics. Future: will support "pioneer"
studyType: "shield",

// telemetry
telemetry: {
// Actually submit the pings to Telemetry. [default if omitted: false]
// default false. Actually send pings.
send: true,
// Marks pings with testing=true. Set flag to `true` for pings are meant to be seen by analysts [default if omitted: false]
// Marks pings with testing=true. Set flag to `true` before final release
removeTestingFlag: false,
// Keep an internal telemetry archive. Useful for verifying payloads of Pioneer studies without risking actually sending any unencrypted payloads [default if omitted: false]
internalTelemetryArchive: true,
},

// endings with urls
Expand Down Expand Up @@ -101,11 +99,10 @@ const baseStudySetup = {
*
* This implementation caches in local storage to speed up second run.
*
* @param {object} studySetup A complete study setup object
* @returns {Promise<boolean>} answer An boolean answer about whether the user should be
* allowed to enroll in the study
*/
async function cachingFirstRunShouldAllowEnroll(studySetup) {
async function cachingFirstRunShouldAllowEnroll() {
// Cached answer. Used on 2nd run
let allowed = await browser.storage.local.get("allowedEnrollOnFirstRun");
if (allowed.allowedEnrollOnFirstRun === true) return true;
Expand All @@ -116,13 +113,7 @@ async function cachingFirstRunShouldAllowEnroll(studySetup) {
*/

// could have other reasons to be eligible, such add-ons, prefs
const dataPermissions = await browser.study.getDataPermissions();
if (studySetup.studyType === "shield") {
allowed = dataPermissions.shield;
}
if (studySetup.studyType === "pioneer") {
allowed = dataPermissions.pioneer;
}
allowed = true;

// cache the answer
await browser.storage.local.set({ allowedEnrollOnFirstRun: allowed });
Expand All @@ -138,18 +129,13 @@ async function getStudySetup() {
// shallow copy
const studySetup = Object.assign({}, baseStudySetup);

// internal testing override necessary to be able to test all study types
const internalTestingOverrides = await browser.studyDebug.getInternalTestingOverrides();
studySetup.studyType = internalTestingOverrides.studyType;

studySetup.allowEnroll = await cachingFirstRunShouldAllowEnroll(studySetup);
studySetup.allowEnroll = await cachingFirstRunShouldAllowEnroll();

const testingOverrides = await browser.study.getTestingOverrides();
studySetup.testing = {
variationName: testingOverrides.variationName,
firstRunTimestamp: testingOverrides.firstRunTimestamp,
expired: testingOverrides.expired,
};

return studySetup;
}
Loading