Skip to content

Commit

Permalink
Enable automatic page load instrumentation (#2084)
Browse files Browse the repository at this point in the history
* Enable automatic page load instrumentation

* Remove glean.js legacy debugging methods

Glean.js now allows turning debugging on
directly from the browser console, deprecating
the need to set env variables at server startup
time. We retain the 'source tags' option in case
this is currently used to tag automation tests.

* Record page loads using standard events
  • Loading branch information
Dexterp37 authored Jan 26, 2024
1 parent c688e7d commit e1e595e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
6 changes: 0 additions & 6 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ export default {
"process.env.NODE_ENV": JSON.stringify(
production ? "production" : "development"
),
// These environment variables are always strings,
// so _any_ value will be read as `true` here
// i.e. GLEAN_LOG_PINGS=false will become `true` here.
// The only option when GLEAN_LOG_PINGS is `false` is when it is not set at all
GLEAN_LOG_PINGS: !!process.env.GLEAN_LOG_PINGS,
GLEAN_DEBUG_VIEW_TAG: process.env.GLEAN_DEBUG_VIEW_TAG || "",
GLEAN_SOURCE_TAGS: process.env.GLEAN_SOURCE_TAGS || "",
__DISPLAY_VERSION__: execSync("git describe --abbrev=0 --tags")
.toString()
Expand Down
18 changes: 6 additions & 12 deletions src/telemetry/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// ESlint does not support subpath exports, which are used by Glean.
// https://github.com/import-js/eslint-plugin-import/issues/1868
//
// eslint-disable-next-line import/no-unresolved
/* eslint-disable import/no-unresolved */
import Glean from "@mozilla/glean/web";
import GleanMetrics from "@mozilla/glean/metrics";
/* eslint-enable import/no-unresolved */

import { googleAnalytics } from "./ga";

Expand Down Expand Up @@ -42,17 +44,6 @@ export function initializeTelemetry() {
});

/* eslint-disable no-undef, no-constant-condition */

// GLEAN_LOG_PINGS is a boolean value,
// thus it should not have quotes around it.
if (GLEAN_LOG_PINGS === true) {
Glean.setLogPings(true);
}

if ("GLEAN_DEBUG_VIEW_TAG") {
Glean.setDebugViewTag("GLEAN_DEBUG_VIEW_TAG");
}

if ("GLEAN_SOURCE_TAGS") {
// GLEAN_SOURCE_TAGS is supposed to be a comma separated string of tags
const sourceTags = "GLEAN_SOURCE_TAGS".split(",").map((tag) => tag.trim());
Expand All @@ -74,6 +65,9 @@ export function submitPageViewTelemetry(path) {
ga("send", "pageview");
}

// Use the standard events.
GleanMetrics.pageLoad({ url: path });

// Send telemetry to Glean.
pageMetrics.loaded.set();
// Remove query params and trailing `/` characters.
Expand Down

0 comments on commit e1e595e

Please sign in to comment.