Bug 1413844 - add utm parameters to about:devtools links;r=pbro
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 09 Nov 2017 19:17:35 +0100
changeset 444575 d6bb75646859f5f6ea2f3a82e7670f9c5acc516d
parent 444574 898bb619f62764a0c73db7324288eb30bc969774
child 444576 1be6d94e801583f8c38964a90d6130741decab17
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1413844
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1413844 - add utm parameters to about:devtools links;r=pbro MozReview-Commit-ID: EjgklOeYQ2g
devtools/shim/aboutdevtools/aboutdevtools.js
--- a/devtools/shim/aboutdevtools/aboutdevtools.js
+++ b/devtools/shim/aboutdevtools/aboutdevtools.js
@@ -18,16 +18,22 @@ const TELEMETRY_NOINSTALL_EXITS = "devto
 const MESSAGES = {
   AboutDebugging: "about-debugging-message",
   ContextMenu: "inspect-element-message",
   HamburgerMenu: "menu-message",
   KeyShortcut: "key-shortcut-message",
   SystemMenu: "menu-message",
 };
 
+// Google analytics parameters that should be added to all outgoing links.
+const GA_PARAMETERS = [
+  ["utm_source", "devtools"],
+  ["utm_medium", "onboarding"],
+];
+
 const ABOUTDEVTOOLS_STRINGS = "chrome://devtools-shim/locale/aboutdevtools.properties";
 const aboutDevtoolsBundle = Services.strings.createBundle(ABOUTDEVTOOLS_STRINGS);
 
 const KEY_SHORTCUTS_STRINGS = "chrome://devtools-shim/locale/key-shortcuts.properties";
 const keyShortcutsBundle = Services.strings.createBundle(KEY_SHORTCUTS_STRINGS);
 
 // URL constructor doesn't support about: scheme,
 // we have to use http in order to have working searchParams.
@@ -181,16 +187,24 @@ window.addEventListener("load", function
   document.getElementById("close").addEventListener("click", onCloseButtonClick);
   Services.prefs.addObserver(DEVTOOLS_ENABLED_PREF, updatePage);
 
   let featuresContainer = document.querySelector(".features-list");
   for (let feature of features) {
     featuresContainer.appendChild(createFeatureEl(feature));
   }
 
+  // Add Google Analytics parameters to all the external links.
+  let externalLinks = [...document.querySelectorAll("a.external")];
+  for (let link of externalLinks) {
+    let linkUrl = new URL(link.getAttribute("href"));
+    GA_PARAMETERS.forEach(([key, value]) => linkUrl.searchParams.set(key, value));
+    link.setAttribute("href", linkUrl.href);
+  }
+
   // Update the current page based on the current value of DEVTOOLS_ENABLED_PREF.
   updatePage();
 
   try {
     if (reason) {
       Services.telemetry.getHistogramById(TELEMETRY_OPENED_REASON).add(reason);
     }