Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
Add the 'config-enable-glean' Rollup option
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dexterp37 committed Mar 26, 2021
1 parent f9ffdef commit 1c0c112
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
5 changes: 5 additions & 0 deletions core-addon/DataCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions rollup.config.addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down
2 changes: 2 additions & 0 deletions tests/hooks.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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__;
},
};

0 comments on commit 1c0c112

Please sign in to comment.