From 097fa4e778d74a43b4b9e17a5a9640655209d98b Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Fri, 19 Mar 2021 12:33:25 +0100 Subject: [PATCH 01/14] Make sure Python is available on CI --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e5b55b4d..9c9ad4b1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ version: 2.1 jobs: Build: docker: - - image: cimg/node:14.13.1 + - image: cimg/python:3.8.8-node steps: - checkout - run: @@ -23,7 +23,7 @@ jobs: Addon unit tests: docker: - - image: cimg/node:14.13.1 + - image: cimg/python:3.8.8-node steps: - checkout - run: @@ -35,7 +35,7 @@ jobs: Addon code linting: docker: - - image: cimg/node:14.13.1 + - image: cimg/python:3.8.8-node steps: - checkout - run: @@ -53,7 +53,7 @@ jobs: Firefox integration tests: docker: - - image: cimg/node:14.13.1 + - image: cimg/python:3.8.8-node steps: - checkout - run: From f5891032ba5598642352c6dfda453e54be27db97 Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Thu, 18 Mar 2021 11:42:58 +0100 Subject: [PATCH 02/14] Update the .gitignore to exclude Glean stuff --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 4e54387c..f58a0b00 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,8 @@ public/protocol.css .DS_Store /web-ext-artifacts/ + +# Ignore Glean's virtual environment and +# generated files. +.venv +generated/ From 0651a20e9100ec3aa57cdfc3087fd425297d6b04 Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Tue, 16 Mar 2021 17:44:30 +0100 Subject: [PATCH 03/14] Add Glean.js to Rally --- package-lock.json | 56 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 57 insertions(+) diff --git a/package-lock.json b/package-lock.json index 362a1044..ef8574b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "devDependencies": { "@babel/core": "^7.13.10", "@mozilla-protocol/core": "^12.1.0", + "@mozilla/glean": "^0.7.0", "@rollup/plugin-commonjs": "^17.1.0", "@rollup/plugin-node-resolve": "^11.2.0", "@rollup/plugin-replace": "^2.4.1", @@ -2533,6 +2534,28 @@ "integrity": "sha512-KiuTc6HFBXcfo5dUBsXX4MP6C5wjBsDt4WbKsUO8jDQz4g/wx7T7++Q9wc45gu7lS0QKklJ0FWsqJpGrXVFY3Q==", "dev": true }, + "node_modules/@mozilla/glean": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@mozilla/glean/-/glean-0.7.0.tgz", + "integrity": "sha512-yG0+OfNRv2ctnr/aka+mIs9ATf93Ni7jA1MWu6FEt9K4BTtjs+VR7h7KIzAeaTvmTv6Xdp57/+gedxGYZqq23w==", + "dev": true, + "dependencies": { + "jose": "^3.7.0", + "uuid": "^8.3.2" + }, + "bin": { + "glean": "dist/cli/cli.js" + } + }, + "node_modules/@mozilla/glean/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@mrmlnc/readdir-enhanced": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", @@ -15957,6 +15980,15 @@ "node": ">=8" } }, + "node_modules/jose": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/jose/-/jose-3.10.0.tgz", + "integrity": "sha512-rbVUNWkGSsvbGPdpBjnLgw0YNYr2zc50T3vutT8Mx/7QOTyilt5urqgyxySRR6aMzxCEh7N+y8PO16H4P57Chg==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, "node_modules/js-string-escape": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", @@ -30385,6 +30417,24 @@ "integrity": "sha512-KiuTc6HFBXcfo5dUBsXX4MP6C5wjBsDt4WbKsUO8jDQz4g/wx7T7++Q9wc45gu7lS0QKklJ0FWsqJpGrXVFY3Q==", "dev": true }, + "@mozilla/glean": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@mozilla/glean/-/glean-0.7.0.tgz", + "integrity": "sha512-yG0+OfNRv2ctnr/aka+mIs9ATf93Ni7jA1MWu6FEt9K4BTtjs+VR7h7KIzAeaTvmTv6Xdp57/+gedxGYZqq23w==", + "dev": true, + "requires": { + "jose": "^3.7.0", + "uuid": "^8.3.2" + }, + "dependencies": { + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } + } + }, "@mrmlnc/readdir-enhanced": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", @@ -41327,6 +41377,12 @@ } } }, + "jose": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/jose/-/jose-3.10.0.tgz", + "integrity": "sha512-rbVUNWkGSsvbGPdpBjnLgw0YNYr2zc50T3vutT8Mx/7QOTyilt5urqgyxySRR6aMzxCEh7N+y8PO16H4P57Chg==", + "dev": true + }, "js-string-escape": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", diff --git a/package.json b/package.json index e41e1b88..27ec2f2a 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "devDependencies": { "@babel/core": "^7.13.10", "@mozilla-protocol/core": "^12.1.0", + "@mozilla/glean": "^0.7.0", "@rollup/plugin-commonjs": "^17.1.0", "@rollup/plugin-node-resolve": "^11.2.0", "@rollup/plugin-replace": "^2.4.1", From 0965aba3ea952913f5cf6cdde8e5102ac72da548 Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Wed, 17 Mar 2021 12:09:49 +0100 Subject: [PATCH 04/14] Generate Glean artifacts when building Rally This ensures that the docs and the metrics code is regenerated when building the core-addon. --- docs/metrics.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ metrics.yaml | 31 ++++++++++++++++++++++++++++ package.json | 7 +++++-- pings.yaml | 25 +++++++++++++++++++++++ 4 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 docs/metrics.md create mode 100644 metrics.yaml create mode 100644 pings.yaml diff --git a/docs/metrics.md b/docs/metrics.md new file mode 100644 index 00000000..be327be4 --- /dev/null +++ b/docs/metrics.md @@ -0,0 +1,54 @@ + + +# Metrics + +This document enumerates the metrics collected by this project using the [Glean SDK](https://mozilla.github.io/glean/book/index.html). +This project may depend on other projects which also collect metrics. +This means you might have to go searching through the dependency tree to get a full picture of everything collected by this project. + +# Pings + +- [deletion-request](#deletion-request) +- [onboarding](#onboarding) + +## deletion-request + +This is a built-in ping that is assembled out of the box by the Glean SDK. + +See the Glean SDK documentation for the [`deletion-request` ping](https://mozilla.github.io/glean/book/user/pings/deletion-request.html). + +All Glean pings contain built-in metrics in the [`ping_info`](https://mozilla.github.io/glean/book/user/pings/index.html#the-ping_info-section) and [`client_info`](https://mozilla.github.io/glean/book/user/pings/index.html#the-client_info-section) sections. + +In addition to those built-in metrics, the following metrics are added to the ping: + +| Name | Type | Description | Data reviews | Extras | Expiration | [Data Sensitivity](https://wiki.mozilla.org/Firefox/Data_Collection) | +| --- | --- | --- | --- | --- | --- | --- | +| rally.id |[uuid](https://mozilla.github.io/glean/book/user/metrics/uuid.html) |The id of the Rally client. |[Review 1](TODO)||never | | + +## onboarding + +This ping is sent at the end of the user onboarding journey. +It helps the Rally team assess the usability of the onboarding +experience. + + +**Data reviews for this ping:** + +- + +**Bugs related to this ping:** + +- + +All Glean pings contain built-in metrics in the [`ping_info`](https://mozilla.github.io/glean/book/user/pings/index.html#the-ping_info-section) and [`client_info`](https://mozilla.github.io/glean/book/user/pings/index.html#the-client_info-section) sections. + +In addition to those built-in metrics, the following metrics are added to the ping: + +| Name | Type | Description | Data reviews | Extras | Expiration | [Data Sensitivity](https://wiki.mozilla.org/Firefox/Data_Collection) | +| --- | --- | --- | --- | --- | --- | --- | +| rally.id |[uuid](https://mozilla.github.io/glean/book/user/metrics/uuid.html) |The id of the Rally client. |[Review 1](TODO)||never | | + +Data categories are [defined here](https://wiki.mozilla.org/Firefox/Data_Collection). + + + diff --git a/metrics.yaml b/metrics.yaml new file mode 100644 index 00000000..8f89420c --- /dev/null +++ b/metrics.yaml @@ -0,0 +1,31 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# This file defines the metrics that are recorded by the Glean SDK. +# APIs to use these pings are automatically generated at build time using +# the `glean_parser` PyPI package. + +# Metrics in this file may make use of SDK reserved ping names. See +# https://mozilla.github.io/glean/book/dev/core/internal/reserved-ping-names.html +# for additional information. + +--- +$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0 + +rally: + id: + type: uuid + lifetime: user + send_in_pings: + - deletion-request + - onboarding + description: | + The id of the Rally client. + bugs: + - https://github.com/mozilla-rally/rally-core-addon/issues/117 + data_reviews: + - TODO + notification_emails: + - than@mozilla.com + expires: never diff --git a/package.json b/package.json index 27ec2f2a..687f7d69 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,12 @@ "type": "module", "scripts": { "build": "rollup -c && npm run build-addon && web-ext --config=web-ext-config.cjs build --overwrite-dest && mv web-ext-artifacts/*.zip web-ext-artifacts/rally_core.xpi", - "build-addon": "rollup -c rollup.config.addon.js --config-enable-data-submission", - "build-local-addon": "rollup -c rollup.config.addon.js --config-disable-remote-settings --config-studies-list-url=/public/locally-available-studies.json", + "build-addon": "npm run glean && rollup -c rollup.config.addon.js --config-enable-data-submission", + "build-local-addon": "npm run glean && rollup -c rollup.config.addon.js --config-disable-remote-settings --config-studies-list-url=/public/locally-available-studies.json", "build-storybook": "build-storybook -s ./public", + "glean": "npm run glean-metrics && npm run glean-docs", + "glean-metrics": "glean translate ./metrics.yaml ./pings.yaml -f javascript -o public/generated", + "glean-docs": "glean translate ./metrics.yaml ./pings.yaml -f markdown -o docs", "lint": "npm run build && npm-run-all lint-*", "lint-addon": "web-ext --config=web-ext-config.cjs lint", "lint-css": "stylelint 'public/*.css' '.storybook/*.css' 'src/**/*.svelte' 'stories/**/*.svelte'", diff --git a/pings.yaml b/pings.yaml new file mode 100644 index 00000000..02854b90 --- /dev/null +++ b/pings.yaml @@ -0,0 +1,25 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# This file defines the pings that are recorded by the Glean SDK. +# Their code APIs is automatically generated, at build time using, +# the `glean_parser` PyPI package. + +--- +$schema: moz://mozilla.org/schemas/glean/pings/2-0-0 + +onboarding: + description: | + This ping is sent at the end of the user onboarding journey. + It helps the Rally team assess the usability of the onboarding + experience. + include_client_id: false + send_if_empty: false + bugs: + - https://github.com/mozilla-rally/rally-core-addon/issues/117 + data_reviews: + - TODO + notification_emails: + - than@mozilla.com + - hulmer@mozilla.com From 645494a60da6025b15340a7631421372185b363e Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Thu, 18 Mar 2021 15:07:18 +0100 Subject: [PATCH 05/14] Initialize Glean and enable ping encryption --- core-addon/Core.js | 8 ++++++++ core-addon/DataCollection.js | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/core-addon/Core.js b/core-addon/Core.js index d1ba5611..7fcff23f 100644 --- a/core-addon/Core.js +++ b/core-addon/Core.js @@ -4,6 +4,7 @@ import Storage from "./Storage.js"; import DataCollection from "./DataCollection.js"; +import * as rallyMetrics from "../public/generated/rally.js"; // The path of the embedded resource used to control options. const OPTIONS_PAGE_PATH = "public/index.html"; @@ -27,6 +28,11 @@ export default class Core { this._storage = new Storage(); this._dataCollection = new DataCollection(); + // Initialize the collection engine once we know if + // user is enrolled or not. + this._storage.getRallyID().finally(id => + this._dataCollection.initialize(id !== undefined)); + // Asynchronously get the available studies. We don't need to wait // for this to finish, the UI can handle the wait. this._availableStudies = this._fetchAvailableStudies().then((studies) => @@ -397,6 +403,8 @@ export default class Core { await this._storage.setRallyID(rallyId); await this._storage.setDeletionID(deletionId); + rallyMetrics.id.set(rallyId); + // Override the uninstall URL to include the rallyID, for deleting data without exposing the Rally ID. await this.setUninstallURL(); diff --git a/core-addon/DataCollection.js b/core-addon/DataCollection.js index 332c67b6..084bfbe1 100644 --- a/core-addon/DataCollection.js +++ b/core-addon/DataCollection.js @@ -2,6 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +import Glean from "@mozilla/glean/webext"; +import PingEncryptionPlugin from "@mozilla/glean/webext/plugins/encryption"; + // The encryption key id and JWK to encrypt data that go // to the "core" environment (i.e. `pioneer-core`). See // bug 1677761 for additional details. @@ -15,6 +18,24 @@ const CORE_ENCRYPTION_JWK = { }; export default class DataCollection { + /** + * Initializes the data collection engine. + * + * @param {boolean} userEnrolled + * Whether or not user has enrolled in the platform. + */ + initialize(userEnrolled) { + // Initialize Glean. Note that we always set 'uploadEnabled=true' if user + // consented to join Rally. Upload is always enabled unless the web-extension + // is uninstalled. + Glean.initialize("rally-core", userEnrolled, { + plugins: [ + new PingEncryptionPlugin(CORE_ENCRYPTION_JWK) + ] + } + ); + } + /** * Sends an otherwise-empty ping with the deletion ID other provided info. * From 913bce535c3267b15ede63fc8ecde92630ce0d18 Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Mon, 22 Mar 2021 15:57:10 +0100 Subject: [PATCH 06/14] Make sure to build the addon before running tests This guarantees Glean files get generated. --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9c9ad4b1..4bdacb4e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,6 +29,9 @@ jobs: - run: name: Install the dependencies command: npm install + - run: + name: Build the Addon + command: npm run build-addon - run: name: MochaJS unit tests command: npm run test-addon @@ -59,6 +62,9 @@ jobs: - run: name: Install the dependencies command: npm install && sudo add-apt-repository ppa:ubuntu-mozilla-daily/ppa && sudo apt update && sudo apt install firefox-trunk + - run: + name: Build the Addon + command: npm run build-addon - run: name: Run Selenium tests command: export PATH=.:$PATH && npm run test-integration From ef0c417f655b0ca85c9d6df2d1855fc61ce3de49 Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Tue, 23 Mar 2021 09:34:11 +0100 Subject: [PATCH 07/14] Disable 'preferBuiltins' to load local utils This fixes the warning (!) Plugin node-resolve: preferring built-in module 'util' over local alternative at '/home/dexter/rally-core-addon/node_modules/util/util.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning --- rollup.config.addon.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rollup.config.addon.js b/rollup.config.addon.js index bed39bfc..3eef10d5 100644 --- a/rollup.config.addon.js +++ b/rollup.config.addon.js @@ -35,6 +35,9 @@ export default (cliArgs) => { }), resolve({ browser: true, + // This is required in order for rollup to pick up + // the correct dependencies for ping encryption. + preferBuiltins: false, }), commonjs(), ], From f9ffdefa49d5b2ab57f23bbdf8807b05a2e6bf1d Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Thu, 25 Mar 2021 13:27:42 +0100 Subject: [PATCH 08/14] Resolve imports exported using "browser" This works around rollup/plugins#843. See the documentation: https://github.com/rollup/plugins/tree/master/packages/node-resolve#exportconditions --- rollup.config.addon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rollup.config.addon.js b/rollup.config.addon.js index 3eef10d5..3f54e630 100644 --- a/rollup.config.addon.js +++ b/rollup.config.addon.js @@ -34,7 +34,7 @@ export default (cliArgs) => { "'https://rally.mozilla.org'", }), resolve({ - browser: true, + exportConditions: ["browser"], // This is required in order for rollup to pick up // the correct dependencies for ping encryption. preferBuiltins: false, From 1c0c1120e74f818d2f380c1eb769abef90c09f1a Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Fri, 26 Mar 2021 08:10:23 +0100 Subject: [PATCH 09/14] Add the 'config-enable-glean' Rollup option Glean is disabled by default when building the core-addon. The config-enable-glean option enables Glean. Note that, if Glean is not initialized, no metric recording happens, even if the Glean specific metrics APIs are called. --- .eslintrc.cjs | 1 + core-addon/DataCollection.js | 5 +++++ rollup.config.addon.js | 3 +++ tests/hooks.cjs | 2 ++ 4 files changed, 11 insertions(+) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index b45fa181..10e3c5c6 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -22,6 +22,7 @@ module.exports = { __DISABLE_REMOTE_SETTINGS__: false, __DISABLE_LOCALE_CHECK__: false, __ENABLE_DATA_SUBMISSION__: false, + __ENABLE_GLEAN__: false, __WEBSITE_URL__: false, }, overrides: [ diff --git a/core-addon/DataCollection.js b/core-addon/DataCollection.js index 084bfbe1..4aea78ab 100644 --- a/core-addon/DataCollection.js +++ b/core-addon/DataCollection.js @@ -25,6 +25,11 @@ export default class DataCollection { * Whether or not user has enrolled in the platform. */ initialize(userEnrolled) { + if (!__ENABLE_GLEAN__) { + console.warn("DataCollection - Glean disabled by the build configuration."); + return; + } + // Initialize Glean. Note that we always set 'uploadEnabled=true' if user // consented to join Rally. Upload is always enabled unless the web-extension // is uninstalled. diff --git a/rollup.config.addon.js b/rollup.config.addon.js index 3f54e630..aa508a41 100644 --- a/rollup.config.addon.js +++ b/rollup.config.addon.js @@ -29,6 +29,9 @@ export default (cliArgs) => { // to enable it for testing until https://github.com/mozilla-rally/core-addon/issues/304 // is fixed. __ENABLE_DATA_SUBMISSION__: !!cliArgs["config-enable-data-submission"], + // In order to ease the integration, Glean will be embedded in the code but disabled + // until the integration is fully complete. + __ENABLE_GLEAN__: !!cliArgs["config-enable-glean"], __WEBSITE_URL__: cliArgs['config-website'] ? `'${cliArgs['config-website']}'` : "'https://rally.mozilla.org'", diff --git a/tests/hooks.cjs b/tests/hooks.cjs index 5c4f019b..b8c0d01d 100644 --- a/tests/hooks.cjs +++ b/tests/hooks.cjs @@ -18,6 +18,7 @@ exports.mochaHooks = { // TODO: remove the next line once https://github.com/mozilla-rally/core-addon/issues/304 // is merged. global.__ENABLE_DATA_SUBMISSION__ = true; + global.__ENABLE_GLEAN__ = true; }, afterAll() { chrome.flush(); @@ -26,5 +27,6 @@ exports.mochaHooks = { // TODO: remove the next line once https://github.com/mozilla-rally/core-addon/issues/304 // is merged. delete global.__ENABLE_DATA_SUBMISSION__; + delete global.__ENABLE_GLEAN__; }, }; From 99ea75304ad7e8865709b8e19d7067488c13979a Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Fri, 26 Mar 2021 08:36:04 +0100 Subject: [PATCH 10/14] Add a simple test for the Rally id in Glean --- tests/core-addon/unit/Core.test.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/core-addon/unit/Core.test.js b/tests/core-addon/unit/Core.test.js index 8d88d512..e733f212 100644 --- a/tests/core-addon/unit/Core.test.js +++ b/tests/core-addon/unit/Core.test.js @@ -6,7 +6,11 @@ import { strict as assert } from 'assert'; // eslint-disable-next-line node/no-extraneous-import import sinon from 'sinon'; +import Glean from "@mozilla/glean/webext"; + import Core from '../../../core-addon/Core.js'; +import * as rallyMetrics from "../../../public/generated/rally.js"; + // The website to post deletion IDs to. const OFFBOARD_URL = "https://production.rally.mozilla.org/offboard"; @@ -27,7 +31,12 @@ const FAKE_UUID = "c0ffeec0-ffee-c0ff-eec0-ffeec0ffeec0"; const FAKE_WEBSITE = "https://test.website"; describe('Core', function () { - beforeEach(function () { + // eslint-disable-next-line mocha/no-setup-in-describe + const testAppId = `core.test.${this.title}`; + + beforeEach(async function() { + await Glean.testResetGlean(testAppId); + // Force the sinon-chrome stubbed API to resolve its promise // in tests. Without the next two lines, tests querying the // `browser.management.getAll` API will be stuck and timeout. @@ -203,6 +212,8 @@ describe('Core', function () { {type: "enrollment", data: {}} ); + assert.equal(await rallyMetrics.id.testGetValue(), FAKE_UUID); + // We expect to store the fake ion ID. assert.ok(this.core._storage.setRallyID.withArgs(FAKE_UUID).calledOnce); assert.ok(this.core._dataCollection.sendEnrollmentPing.calledOnce); From ab3c0f318e18f65644ddfba115c1c51c94d80879 Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Fri, 26 Mar 2021 17:08:53 +0100 Subject: [PATCH 11/14] Add a CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b8c7737..27f43559 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ [Full changelog](https://github.com/mozilla-rally/core-addon/compare/v1.1.0...master) * [#295](https://github.com/mozilla-rally/rally-core-addon/pull/295): Enable watching the repository and a better developer workflow using `npm run watch`. +* [#505](https://github.com/mozilla-rally/rally-core-addon/pull/505): Integrate Glean.js (disabled by default) and provide a way to enable it, as a developer, using the `config-enable-glean` option. # v1.1.0 (2021-03-10) From d37be7cdc1f3669b736e90a13541d2d6e28eab8f Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Mon, 29 Mar 2021 09:37:11 +0200 Subject: [PATCH 12/14] Ensure the right dependencies are available on TaskCluster Unfortunately this "hack" is required because the add-ons pipeline does not enable consumers to customize the installed packages. --- package.json | 1 + scripts/setupTaskcluster.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 scripts/setupTaskcluster.js diff --git a/package.json b/package.json index 687f7d69..e10f9fb9 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.1.0", "type": "module", "scripts": { + "prebuild": "node scripts/setupTaskcluster.js", "build": "rollup -c && npm run build-addon && web-ext --config=web-ext-config.cjs build --overwrite-dest && mv web-ext-artifacts/*.zip web-ext-artifacts/rally_core.xpi", "build-addon": "npm run glean && rollup -c rollup.config.addon.js --config-enable-data-submission", "build-local-addon": "npm run glean && rollup -c rollup.config.addon.js --config-disable-remote-settings --config-studies-list-url=/public/locally-available-studies.json", diff --git a/scripts/setupTaskcluster.js b/scripts/setupTaskcluster.js new file mode 100644 index 00000000..aac92910 --- /dev/null +++ b/scripts/setupTaskcluster.js @@ -0,0 +1,22 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import * as exec from "child_process"; +import { promisify } from "util"; + +// Define an async/await version of "exec". +const execAsync = promisify(exec.exec); + +// If this is not running on TaskCluster, exit +// without an error code. +if ('TASK_ID' in process.env) { + console.log("Running in TaskCluster. Running set-up."); + + // The TaskCluster instance on the Mozilla add-ons pipeline + // does not allow image customization, so python3 venv cannot + // be installed. That package is required for Glean to build. + // We make sure to have all the dependencies in place when on + // TaskCluster by running the commands manually. + execAsync("sudo apt-get -y install python3-venv"); +} From 8955cb39a2efbf0357c10a91ab5d8ee019d147e4 Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Sun, 4 Apr 2021 15:53:40 +0200 Subject: [PATCH 13/14] Remove pings.yaml In the spirit of keeping this PR simple, this commit removes the pings definition file. --- docs/metrics.md | 13 ------------- package.json | 4 ++-- pings.yaml | 25 ------------------------- 3 files changed, 2 insertions(+), 40 deletions(-) delete mode 100644 pings.yaml diff --git a/docs/metrics.md b/docs/metrics.md index be327be4..62f13319 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -27,19 +27,6 @@ In addition to those built-in metrics, the following metrics are added to the pi ## onboarding -This ping is sent at the end of the user onboarding journey. -It helps the Rally team assess the usability of the onboarding -experience. - - -**Data reviews for this ping:** - -- - -**Bugs related to this ping:** - -- - All Glean pings contain built-in metrics in the [`ping_info`](https://mozilla.github.io/glean/book/user/pings/index.html#the-ping_info-section) and [`client_info`](https://mozilla.github.io/glean/book/user/pings/index.html#the-client_info-section) sections. In addition to those built-in metrics, the following metrics are added to the ping: diff --git a/package.json b/package.json index e10f9fb9..56748e8a 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "build-local-addon": "npm run glean && rollup -c rollup.config.addon.js --config-disable-remote-settings --config-studies-list-url=/public/locally-available-studies.json", "build-storybook": "build-storybook -s ./public", "glean": "npm run glean-metrics && npm run glean-docs", - "glean-metrics": "glean translate ./metrics.yaml ./pings.yaml -f javascript -o public/generated", - "glean-docs": "glean translate ./metrics.yaml ./pings.yaml -f markdown -o docs", + "glean-metrics": "glean translate ./metrics.yaml -f javascript -o public/generated", + "glean-docs": "glean translate ./metrics.yaml -f markdown -o docs", "lint": "npm run build && npm-run-all lint-*", "lint-addon": "web-ext --config=web-ext-config.cjs lint", "lint-css": "stylelint 'public/*.css' '.storybook/*.css' 'src/**/*.svelte' 'stories/**/*.svelte'", diff --git a/pings.yaml b/pings.yaml deleted file mode 100644 index 02854b90..00000000 --- a/pings.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# This file defines the pings that are recorded by the Glean SDK. -# Their code APIs is automatically generated, at build time using, -# the `glean_parser` PyPI package. - ---- -$schema: moz://mozilla.org/schemas/glean/pings/2-0-0 - -onboarding: - description: | - This ping is sent at the end of the user onboarding journey. - It helps the Rally team assess the usability of the onboarding - experience. - include_client_id: false - send_if_empty: false - bugs: - - https://github.com/mozilla-rally/rally-core-addon/issues/117 - data_reviews: - - TODO - notification_emails: - - than@mozilla.com - - hulmer@mozilla.com From 0a2c9b7f129e48b62fa16ff2900bf142d0448aa9 Mon Sep 17 00:00:00 2001 From: Alessio Placitelli Date: Thu, 8 Apr 2021 14:34:59 +0200 Subject: [PATCH 14/14] Do not use async exec in setupTaskcluster.js --- scripts/setupTaskcluster.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/setupTaskcluster.js b/scripts/setupTaskcluster.js index aac92910..8832accb 100644 --- a/scripts/setupTaskcluster.js +++ b/scripts/setupTaskcluster.js @@ -3,10 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as exec from "child_process"; -import { promisify } from "util"; - -// Define an async/await version of "exec". -const execAsync = promisify(exec.exec); // If this is not running on TaskCluster, exit // without an error code. @@ -18,5 +14,5 @@ if ('TASK_ID' in process.env) { // be installed. That package is required for Glean to build. // We make sure to have all the dependencies in place when on // TaskCluster by running the commands manually. - execAsync("sudo apt-get -y install python3-venv"); + exec.exec("sudo apt-get -y install python3-venv"); }