From 45233fe53079283b3af3021748c923a411a8ecbb Mon Sep 17 00:00:00 2001 From: Alex Gibson Date: Thu, 9 Nov 2023 10:54:41 +0000 Subject: [PATCH] Update Glean debugging docs (Fixes #13876) --- docs/attribution/0001-analytics.rst | 30 +++++++++++++---------------- glean/metrics.yaml | 6 ------ media/js/glean/init.es6.js | 22 +++++---------------- 3 files changed, 18 insertions(+), 40 deletions(-) diff --git a/docs/attribution/0001-analytics.rst b/docs/attribution/0001-analytics.rst index a1bb4d9c4f8..f17b5e8dc2c 100644 --- a/docs/attribution/0001-analytics.rst +++ b/docs/attribution/0001-analytics.rst @@ -350,12 +350,19 @@ to measure. Debugging pings --------------- -For all non-production environments, bedrock will automatically set a debug -view tag for all pings. This means that when running on localhost, on a demo, -or on a staging environment, ping data will be viewable in the -`Glean debug dashboard`_ which can be used to test that pings are working -correctly. All bedrock debug pings will register in the debug dashboard with -the tag name ``bedrock``. +Glean supports debugging pings via a set of flags that can be enabled directly +in the browser's web console. + +- ``window.Glean.setLogPings(true)`` (enable verbose ping logging in the web console). +- ``window.Glean.setDebugViewTag('bedrock')`` (send pings to the `Glean debug dashboard`_ with the tag name ``bedrock``). + +.. Note:: + + After enabling Glean debugging in the web console, it will be remembered + when navigating across pages using ``sessionStorage``. To stop debugging, + you need to either close the browser tab, or delete the items from + ``sessionStorage``. You can disable ping logging by calling + ``window.Glean.setLogPings(false)``. Filtering out non-production pings ---------------------------------- @@ -365,17 +372,6 @@ Bedrock will also set an ``app_channel`` tag with a value of either ``prod`` or ``client_info`` section, and is useful for filtering out non-production data in telemetry dashboards. -Logging pings in the console ----------------------------- - -When running bedrock locally, you can also set the following environment variable -in your ``.env``` file to automatically log pings in the browser's web console. -This can be especially useful when making updates to analytics code. - -.. code-block:: - - GLEAN_LOG_PINGS=True - Defining metrics and pings -------------------------- diff --git a/glean/metrics.yaml b/glean/metrics.yaml index a37fa623b18..d18e10eb291 100644 --- a/glean/metrics.yaml +++ b/glean/metrics.yaml @@ -6,7 +6,6 @@ page: type: datetime lifetime: application send_in_pings: - - page-view - events description: | The time a page was viewed. @@ -23,7 +22,6 @@ page: type: string lifetime: application send_in_pings: - - page-view - events description: | The URL path of the page that was viewed, excluding locale. @@ -40,7 +38,6 @@ page: type: string lifetime: application send_in_pings: - - page-view - events description: | The locale of the page that was viewed. @@ -57,7 +54,6 @@ page: type: labeled_string lifetime: application send_in_pings: - - page-view - events description: | Query parameters associated with the URL of @@ -84,7 +80,6 @@ page: type: string lifetime: application send_in_pings: - - page-view - events description: | The referring URL that linked to the page that was viewed. @@ -103,7 +98,6 @@ page: The HTTP status code of the page. lifetime: application send_in_pings: - - page-view - events data_sensitivity: - technical diff --git a/media/js/glean/init.es6.js b/media/js/glean/init.es6.js index 251e2335b7d..3cdbb003077 100644 --- a/media/js/glean/init.es6.js +++ b/media/js/glean/init.es6.js @@ -13,27 +13,15 @@ import Utils from './utils.es6'; const shouldInitialize = Utils.hasValidURLScheme(window.location.href); function initGlean() { + const pageUrl = window.location.href; const endpoint = 'https://www.mozilla.org'; - const channel = - window.location.href.indexOf('https://www.mozilla.org/') === -1 - ? 'non-prod' - : 'prod'; - - // Automatically console.log() pings. - // eslint-disable-next-line no-undef - if (process.env.GLEAN_LOG_PINGS === 'True') { - Glean.setLogPings(true); - } - - // Enable debug view for all non-production environments. - // https://debug-ping-preview.firebaseapp.com/ - if (channel === 'non-prod') { - Glean.setDebugViewTag('bedrock'); - } + const channel = pageUrl.startsWith('https://www.mozilla.org/') + ? 'prod' + : 'non-prod'; // Ensure telemetry coming from automated testing is tagged // https://mozilla.github.io/glean/book/reference/debug/sourceTags.html - if (window.location.href.indexOf('automation=true') !== -1) { + if (pageUrl.includes('automation=true')) { Glean.setSourceTags(['automation']); }