Bug 1646093. Modify printing telemetry to add a PDF-catch-all for possible unknown PDF printers. r=bobowen, a=jcristau
authorJonathan Watt <jwatt@jwatt.org>
Wed, 17 Jun 2020 00:09:05 +0000
changeset 597203 b0b8663161d5e9f92321e5f403b1a2f7ba7fb479
parent 597202 eaadc43b226ef9a91947d533a474213965421697
child 597204 3a7ca6a575499492b5979a17848379f29a93d282
push id13298
push userryanvm@gmail.com
push dateThu, 18 Jun 2020 01:54:04 +0000
treeherdermozilla-beta@207bbc30b012 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobowen, jcristau
bugs1646093
milestone78.0
Bug 1646093. Modify printing telemetry to add a PDF-catch-all for possible unknown PDF printers. r=bobowen, a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D79853
toolkit/components/telemetry/Scalars.yaml
widget/windows/nsDeviceContextSpecWin.cpp
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -3521,22 +3521,27 @@ printing:
     record_in_processes:
       - 'content'
 
   target_type:
     bug_numbers:
       - 1600623
     description: >
       A counter incremented every time the user prints to a certain target
-      type.  For the most part, the 'unknown' count will be prints to a
-      physical printer, but we can't know for sure since third party drivers
-      could also be print to file drivers.
+      type.  The 'pdf_unknown' count is for printers with names that we don't
+      know about/check for, but that have 'pdf' in their name, and is mainly a
+      sanity check that we're not missing significant counts in 'pdf_file'.
+      For the most part, the 'unknown' count will be prints to a physical
+      printer, but we can't know for sure since third party drivers could also
+      be print to file drivers that we don't otherwise catch in the other
+      counts.  
     keyed: true
     keys:
       - 'pdf_file'
+      - 'pdf_unknown'
       - 'xps_file'
       - 'unknown'
     expires: never
     kind: uint
     notification_emails:
       - jwatt@jwatt.org
     release_channel_collection: opt-out
     products:
--- a/widget/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/windows/nsDeviceContextSpecWin.cpp
@@ -176,18 +176,26 @@ NS_IMETHODIMP nsDeviceContextSpecWin::In
                  printerName,
                  NS_LITERAL_STRING("Universal Document Converter"))) {
     Telemetry::ScalarAdd(Telemetry::ScalarID::PRINTING_TARGET_TYPE,
                          NS_LITERAL_STRING("pdf_file"), 1);
   } else if (printerName.EqualsLiteral("Microsoft XPS Document Writer")) {
     Telemetry::ScalarAdd(Telemetry::ScalarID::PRINTING_TARGET_TYPE,
                          NS_LITERAL_STRING("xps_file"), 1);
   } else {
-    Telemetry::ScalarAdd(Telemetry::ScalarID::PRINTING_TARGET_TYPE,
-                         NS_LITERAL_STRING("unknown"), 1);
+    nsAString::const_iterator start, end;
+    printerName.BeginReading(start);
+    printerName.EndReading(end);
+    if (CaseInsensitiveFindInReadable(NS_LITERAL_STRING("pdf"), start, end)) {
+      Telemetry::ScalarAdd(Telemetry::ScalarID::PRINTING_TARGET_TYPE,
+                           NS_LITERAL_STRING("pdf_unknown"), 1);
+    } else {
+      Telemetry::ScalarAdd(Telemetry::ScalarID::PRINTING_TARGET_TYPE,
+                           NS_LITERAL_STRING("unknown"), 1);
+    }
   }
 
   nsresult rv = NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
   if (aPrintSettings) {
 #ifdef MOZ_ENABLE_SKIA_PDF
     nsAutoString printViaPdf;
     Preferences::GetString("print.print_via_pdf_encoder", printViaPdf);
     if (printViaPdf.EqualsLiteral("skia-pdf")) {