Bug 1502435 - 2 - Include new `bug_1501329_affected` property in the core ping; r=jchen
authorPetru Lingurar <petru.lingurar@softvision.ro>
Wed, 31 Oct 2018 01:13:57 +0200
changeset 443653 5cb4e28e1eb88a03a8a707f53f97cbf4cfe45b12
parent 443652 adb0830364326c1f92a6a4e0e614eed99270d77d
child 443654 3992a5ddbac3421ba1ecba0a95e7649644db2b38
push id109420
push useraciure@mozilla.com
push dateWed, 31 Oct 2018 05:11:56 +0000
treeherdermozilla-inbound@b357da105c49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1502435
milestone65.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 1502435 - 2 - Include new `bug_1501329_affected` property in the core ping; r=jchen Summary: Depends on D10202 Reviewers: jchen Reviewed By: jchen Subscribers: jchen, janerik Bug #: 1502435 Differential Revision: https://phabricator.services.mozilla.com/D10205
mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryCorePingBuilder.java
toolkit/components/telemetry/docs/data/core-ping.rst
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingDelegate.java
@@ -150,29 +150,32 @@ public class TelemetryCorePingDelegate e
 
                 final GeckoProfile profile = GeckoThread.getActiveProfile();
                 if (!TelemetryUploadService.isUploadEnabledByProfileConfig(activity, profile)) {
                     Log.d(LOGTAG, "Core ping upload disabled by profile config. Returning.");
                     return;
                 }
 
                 final String clientID;
+                final boolean hadCanaryClientId;
                 try {
                     clientID = profile.getClientId();
+                    hadCanaryClientId = profile.getIfHadCanaryClientId();
                 } catch (final IOException e) {
-                    Log.w(LOGTAG, "Unable to get client ID to generate core ping: " + e);
+                    Log.w(LOGTAG, "Unable to get client ID properties to generate core ping: " + e);
                     return;
                 }
 
                 // Each profile can have different telemetry data so we intentionally grab the shared prefs for the profile.
                 final SharedPreferences sharedPrefs = getSharedPreferences(activity);
                 final SessionMeasurements.SessionMeasurementsContainer sessionMeasurementsContainer =
                         sessionMeasurements.getAndResetSessionMeasurements(activity);
                 final TelemetryCorePingBuilder pingBuilder = new TelemetryCorePingBuilder(activity)
                         .setClientID(clientID)
+                        .setHadCanaryClientId(hadCanaryClientId)
                         .setDefaultSearchEngine(TelemetryCorePingBuilder.getEngineIdentifier(engine))
                         .setProfileCreationDate(TelemetryCorePingBuilder.getProfileCreationDate(activity, profile))
                         .setSequenceNumber(TelemetryCorePingBuilder.getAndIncrementSequenceNumber(sharedPrefs))
                         .setSessionCount(sessionMeasurementsContainer.sessionCount)
                         .setSessionDuration(sessionMeasurementsContainer.elapsedSeconds);
                 maybeSetOptionalMeasurements(activity, sharedPrefs, pingBuilder);
 
                 getTelemetryDispatcher(activity).queuePingForUpload(activity, pingBuilder);
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryCorePingBuilder.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryCorePingBuilder.java
@@ -49,17 +49,17 @@ import java.util.concurrent.TimeUnit;
  */
 public class TelemetryCorePingBuilder extends TelemetryPingBuilder {
     private static final String LOGTAG = StringUtils.safeSubstring(TelemetryCorePingBuilder.class.getSimpleName(), 0, 23);
 
     // For legacy reasons, this preference key is not namespaced with "core".
     private static final String PREF_SEQ_COUNT = "telemetry-seqCount";
 
     private static final String NAME = "core";
-    private static final int VERSION_VALUE = 9; // For version history, see toolkit/components/telemetry/docs/core-ping.rst
+    private static final int VERSION_VALUE = 10; // For version history, see toolkit/components/telemetry/docs/core-ping.rst
 
     private static final String DEFAULT_BROWSER = "defaultBrowser";
     private static final String ARCHITECTURE = "arch";
     private static final String CAMPAIGN_ID = "campaignId";
     private static final String CLIENT_ID = "clientId";
     private static final String DEFAULT_SEARCH_ENGINE = "defaultSearch";
     private static final String DEVICE = "device";
     private static final String DISTRIBUTION_ID = "distributionId";
@@ -73,16 +73,17 @@ public class TelemetryCorePingBuilder ex
     private static final String SEARCH_COUNTS = "searches";
     private static final String SEQ = "seq";
     private static final String SESSION_COUNT = "sessions";
     private static final String SESSION_DURATION = "durations";
     private static final String TIMEZONE_OFFSET = "tz";
     private static final String VERSION_ATTR = "v";
     private static final String FLASH_USAGE = "flashUsage";
     private static final String ACCESSIBILITY_SERVICES = "accessibilityServices";
+    private static final String HAD_CANARY_CLIENT_ID = "bug_1501329_affected";
 
     public TelemetryCorePingBuilder(final Context context) {
         initPayloadConstants(context);
     }
 
     private void initPayloadConstants(final Context context) {
         payload.put(VERSION_ATTR, VERSION_VALUE);
         payload.put(OS_ATTR, TelemetryPingBuilder.OS_NAME);
@@ -128,27 +129,33 @@ public class TelemetryCorePingBuilder ex
                 LOCALE,
                 OS_ATTR,
                 OS_VERSION,
                 PING_CREATION_DATE,
                 PROFILE_CREATION_DATE,
                 SEQ,
                 TIMEZONE_OFFSET,
                 VERSION_ATTR,
+                HAD_CANARY_CLIENT_ID,
         };
     }
 
     public TelemetryCorePingBuilder setClientID(@NonNull final String clientID) {
         if (clientID == null) {
             throw new IllegalArgumentException("Expected non-null clientID");
         }
         payload.put(CLIENT_ID, clientID);
         return this;
     }
 
+    public TelemetryCorePingBuilder setHadCanaryClientId(final boolean hadCanaryClientId) {
+        payload.put(HAD_CANARY_CLIENT_ID, hadCanaryClientId);
+        return this;
+    }
+
     /**
      * @param engine the default search engine identifier, or null if there is an error.
      */
     public TelemetryCorePingBuilder setDefaultSearchEngine(@Nullable final String engine) {
         if (engine != null && engine.isEmpty()) {
             throw new IllegalArgumentException("Received empty string. Expected identifier or null.");
         }
         payload.put(DEFAULT_SEARCH_ENGINE, engine);
--- a/toolkit/components/telemetry/docs/data/core-ping.rst
+++ b/toolkit/components/telemetry/docs/data/core-ping.rst
@@ -22,17 +22,17 @@ Submission will be per the Edge server s
 Note: Counts below (e.g. search & usage times) are “since the last
 ping”, not total for the whole application lifetime.
 
 Structure:
 
 .. code-block:: js
 
     {
-      "v": 9, // ping format version
+      "v": 10, // ping format version
       "clientId": <string>, // client id, e.g.
                             // "c641eacf-c30c-4171-b403-f077724e848a"
       "seq": <positive integer>, // running ping counter, e.g. 3
       "locale": <string>, // application locale, e.g. "en-US"
       "os": <string>, // OS name.
       "osversion": <string>, // OS version.
       "device": <string>, // Build.MANUFACTURER + " - " + Build.MODEL
                           // where manufacturer is truncated to 12 characters
@@ -57,16 +57,18 @@ Structure:
                             // e.g.: { "yahoo.suggestion": 3, "other.listitem": 1 }
       "experiments": [<string>, /* … */], // Optional, array of identifiers
                                     // for the active experiments
       "accessibilityServices": [<string>, /* … */], // Optional, array of identifiers for
                                                     // enabled accessibility services that
                                                     // interact with our android products.
       "flashUsage": <integer>, // number of times flash plugin is played since last upload
       "defaultBrowser": <boolean> // true if the user has set Firefox as default browser
+      "bug_1501329_affected": <boolean>  // true if Firefox previously used canary clientId
+                                         // when submitting telemetry
 
     }
 
 Field details
 -------------
 
 device
 ~~~~~~