Skip to content

Commit

Permalink
Update Glean debugging docs (Fixes mozilla#13876)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson committed Nov 13, 2023
1 parent 967bb25 commit a189675
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 41 deletions.
30 changes: 13 additions & 17 deletions docs/attribution/0001-analytics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------------------
Expand All @@ -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
--------------------------

Expand Down
6 changes: 0 additions & 6 deletions glean/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ page:
type: datetime
lifetime: application
send_in_pings:
- page-view
- events
description: |
The time a page was viewed.
Expand All @@ -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.
Expand All @@ -40,7 +38,6 @@ page:
type: string
lifetime: application
send_in_pings:
- page-view
- events
description: |
The locale of the page that was viewed.
Expand All @@ -57,7 +54,6 @@ page:
type: labeled_string
lifetime: application
send_in_pings:
- page-view
- events
description: |
Query parameters associated with the URL of
Expand All @@ -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.
Expand All @@ -103,7 +98,6 @@ page:
The HTTP status code of the page.
lifetime: application
send_in_pings:
- page-view
- events
data_sensitivity:
- technical
Expand Down
23 changes: 5 additions & 18 deletions media/js/glean/init.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,22 @@
*/

import Glean from '@mozilla/glean/web';

import { initPageView, pageEvent } from './page.es6';
import { clickEvent } from './elements.es6';
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']);
}

Expand Down

0 comments on commit a189675

Please sign in to comment.