Bug 1374758 - Move sync data format version to sync ping bundle r=nalexander
This is being done to be consistent with how other platforms (desktop, iOS) are
reporting their data format version.
MozReview-Commit-ID: 4rmCTaY44h6
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetrySyncPingBuilder.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetrySyncPingBuilder.java
@@ -22,18 +22,16 @@ import java.util.ArrayList;
import java.util.HashMap;
/**
* Local ping builder which understands how to process sync data.
* Whenever hashing of data is involved, we expect it to be performed at the time of collection,
* somewhere in {@link org.mozilla.gecko.sync.telemetry.TelemetryCollector} and friends.
*/
public class TelemetrySyncPingBuilder extends TelemetryLocalPingBuilder {
- private static final int DATA_FORMAT_VERSION = 1;
-
public TelemetrySyncPingBuilder setStages(@NonNull final Serializable data) {
HashMap<String, TelemetryStageCollector> stages = castSyncData(data);
final JSONArray engines = new JSONArray();
for (String stageName : stages.keySet()) {
final TelemetryStageCollector stage = stages.get(stageName);
// Skip stages that did nothing.
@@ -138,17 +136,16 @@ public class TelemetrySyncPingBuilder ex
public TelemetrySyncPingBuilder setTook(long took) {
payload.put("took", took);
return this;
}
@Override
public TelemetryLocalPing build() {
- payload.put("version", DATA_FORMAT_VERSION);
return new TelemetryLocalPing(payload, docID);
}
@SuppressWarnings("unchecked")
private static void addUnchecked(final JSONArray list, final ExtendedJSONObject obj) {
list.add(obj);
}
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetrySyncPingBundleBuilder.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetrySyncPingBundleBuilder.java
@@ -34,17 +34,18 @@ import java.util.TimeZone;
* Sample result will look something like:
* {
* "syncs": [list of syncs, as produced by the SyncBuilder],
* "events": [list of events, as produced by the EventBuilder]
* }
*/
public class TelemetrySyncPingBundleBuilder extends TelemetryPingBuilder {
private static final String PING_TYPE = "sync";
- private static final int PING_VERSION = 4;
+ private static final int PING_BUNDLE_VERSION = 5; // Bug 1374758
+ private static final int PING_SYNC_DATA_FORMAT_VERSION = 1; // Bug 1374758
public static final String UPLOAD_REASON_FIRST = "first";
public static final String UPLOAD_REASON_CLOCK_DRIFT = "clockdrift";
public static final String UPLOAD_REASON_SCHEDULE = "schedule";
public static final String UPLOAD_REASON_IDCHANGE = "idchange";
public static final String UPLOAD_REASON_COUNT = "count";
private final ExtendedJSONObject pingData = new ExtendedJSONObject();
@@ -66,32 +67,35 @@ public class TelemetrySyncPingBundleBuil
@Override
public TelemetryOutgoingPing build() {
final DateFormat pingCreationDateFormat = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
pingCreationDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
payload.put("type", PING_TYPE);
- payload.put("version", PING_VERSION);
+ payload.put("version", PING_BUNDLE_VERSION);
payload.put("id", docID);
payload.put("creationDate", pingCreationDateFormat.format(new Date()));
final ExtendedJSONObject application = new ExtendedJSONObject();
application.put("architecture", Build.CPU_ABI);
application.put("buildID", AppConstants.MOZ_APP_BUILDID);
application.put("platformVersion", AppConstants.MOZ_APP_VERSION);
application.put("name", AppConstants.MOZ_APP_BASENAME);
application.put("version", AppConstants.MOZ_APP_VERSION);
application.put("displayVersion", AppConstants.MOZ_APP_VERSION);
application.put("vendor", AppConstants.MOZ_APP_VENDOR);
application.put("xpcomAbi", AppConstants.MOZ_APP_ABI);
application.put("channel", AppConstants.MOZ_UPDATE_CHANNEL);
payload.put("application", application);
+
+ pingData.put("version", PING_SYNC_DATA_FORMAT_VERSION);
+
payload.put("payload", pingData);
return super.build();
}
@SuppressWarnings("unchecked")
public TelemetrySyncPingBundleBuilder setSyncStore(TelemetryPingStore store) {
final JSONArray syncs = new JSONArray();
List<TelemetryPing> pings = store.getAllPings();