[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-68.9.0esr-9.5-1] Revert "Bug 1633568 - Introduce a installation ping. r=Grisha, a=RyanVM"



commit 7f05e7ab2f1badfd0108d9bf0a6ef34d28a62b87
Author: Matthew Finkel <sysrqb@xxxxxxxxxxxxxx>
Date:   Thu May 28 17:55:04 2020 +0000

    Revert "Bug 1633568 - Introduce a installation ping. r=Grisha, a=RyanVM"
    
    This reverts commit 7163fd7d989bcf114b43cba342f48639024d1141.
---
 .../base/java/org/mozilla/gecko/BrowserApp.java    |   5 +-
 .../TelemetryInstallationPingDelegate.java         | 128 --------------
 .../TelemetryInstallationPingBuilder.java          | 186 ---------------------
 .../stores/TelemetryInstallationPingStore.java     | 102 -----------
 4 files changed, 1 insertion(+), 420 deletions(-)

diff --git a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
index 6ce56bcc7e68..2efae19ca7c5 100644
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -146,7 +146,6 @@ import org.mozilla.gecko.tabs.TabHistoryFragment;
 import org.mozilla.gecko.tabs.TabHistoryPage;
 import org.mozilla.gecko.tabs.TabsPanel;
 import org.mozilla.gecko.telemetry.TelemetryCorePingDelegate;
-import org.mozilla.gecko.telemetry.TelemetryInstallationPingDelegate;
 import org.mozilla.gecko.telemetry.TelemetryUploadService;
 import org.mozilla.gecko.telemetry.measurements.SearchCountMeasurements;
 import org.mozilla.gecko.telemetry.TelemetryActivationPingDelegate;
@@ -336,7 +335,6 @@ public class BrowserApp extends GeckoApp
 
     private final TelemetryCorePingDelegate mTelemetryCorePingDelegate = new TelemetryCorePingDelegate();
     private final TelemetryActivationPingDelegate mTelemetryActivationPingDelegate = new TelemetryActivationPingDelegate();
-    private final TelemetryInstallationPingDelegate mTelemetryInstallationPingDelegate = new TelemetryInstallationPingDelegate();
 
     private final List<BrowserAppDelegate> delegates = Collections.unmodifiableList(Arrays.asList(
             new ScreenshotDelegate(),
@@ -344,9 +342,8 @@ public class BrowserApp extends GeckoApp
             new ReaderViewBookmarkPromotion(),
             mTelemetryCorePingDelegate,
             mTelemetryActivationPingDelegate,
-            mTelemetryInstallationPingDelegate,
             new OfflineTabStatusDelegate(),
-            new AdjustBrowserAppDelegate(mTelemetryCorePingDelegate, mTelemetryInstallationPingDelegate)
+            new AdjustBrowserAppDelegate(mTelemetryCorePingDelegate)
     ));
 
     @NonNull
diff --git a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryInstallationPingDelegate.java b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryInstallationPingDelegate.java
deleted file mode 100644
index 55657a0d0efa..000000000000
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryInstallationPingDelegate.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-package org.mozilla.gecko.telemetry;
-
-import android.support.annotation.NonNull;
-import android.util.Log;
-
-import com.adjust.sdk.AdjustAttribution;
-
-import org.mozilla.gecko.BrowserApp;
-import org.mozilla.gecko.GeckoAppShell;
-import org.mozilla.gecko.adjust.AttributionHelperListener;
-import org.mozilla.gecko.delegates.BrowserAppDelegate;
-import org.mozilla.gecko.telemetry.pingbuilders.TelemetryInstallationPingBuilder;
-import org.mozilla.gecko.telemetry.pingbuilders.TelemetryInstallationPingBuilder.PingReason;
-import org.mozilla.gecko.telemetry.schedulers.TelemetryUploadAllPingsImmediatelyScheduler;
-import org.mozilla.gecko.telemetry.stores.TelemetryInstallationPingStore;
-import org.mozilla.gecko.util.ThreadUtils;
-
-import java.io.IOException;
-
-public class TelemetryInstallationPingDelegate
-        extends BrowserAppDelegate
-        implements AttributionHelperListener {
-
-    private static final String LOGTAG = "InstallPingDelegate";
-
-    @Override
-    public void onStart(BrowserApp browserApp) {
-        if (!TelemetryUploadService.isUploadEnabledByAppConfig(browserApp)) {
-            return;
-        }
-
-        // Keep everything off of main thread. Don't need to burden it with telemetry.
-        ThreadUtils.postToBackgroundThread(() -> {
-            TelemetryInstallationPingStore store;
-            try {
-                store = new TelemetryInstallationPingStore();
-            } catch (IllegalStateException e) {
-                // The store constructor might throw an IllegalStateException if it cannot access
-                // the store directory.
-                // This has been observed on CI mochitests, not sure about if this would also reproduce
-                // in the real world.
-                // We'll retry at the next app start.
-                Log.w(LOGTAG, "Cannot access ping's storage directory. Will retry later");
-                return;
-            }
-
-            // First allow for stored pings to be re-uploaded if the previous upload did not succeed.
-            // (A successful upload would delete the pings persisted to disk)
-            if (store.getCount() != 0) {
-                store.queuePingsForUpload(new TelemetryUploadAllPingsImmediatelyScheduler());
-            }
-
-            // Only need one of each pings. Check if we should create a new one.
-            if (!TelemetryInstallationPingStore.hasLightPingBeenQueuedForUpload()) {
-                TelemetryOutgoingPing ping = new TelemetryInstallationPingBuilder()
-                        .setReason(PingReason.APP_STARTED)
-                        .build();
-
-                try {
-                    store.storePing(ping);
-                    store.queuePingsForUpload(new TelemetryUploadAllPingsImmediatelyScheduler());
-                    store.setLightPingQueuedForUpload();
-                } catch (IOException e) {
-                    // #storePing() might throw in the process of persisting to disk.
-                    // Nothing to do. At the next app start we'll try again to create a new ping,
-                    // store and upload that.
-                    Log.w(LOGTAG, "Could not store ping. Will try again later");
-                }
-            }
-        });
-    }
-
-    @Override
-    public void onAttributionChanged(@NonNull final AdjustAttribution attribution) {
-        if (!TelemetryUploadService.isUploadEnabledByAppConfig(GeckoAppShell.getApplicationContext())) {
-            return;
-        }
-
-        // Keep everything off of main thread. Don't need to burden it with telemetry.
-        ThreadUtils.postToBackgroundThread(() -> {
-            TelemetryInstallationPingStore store;
-            try {
-                store = new TelemetryInstallationPingStore();
-            } catch (IllegalStateException e) {
-                // The store constructor might throw an IllegalStateException if it cannot access
-                // the store directory.
-                // This has been observed on CI mochitests, not sure about if this would also reproduce
-                // in the real world.
-                // Since the attributionChanged callback only fire once IRL this would mean we won't
-                // be sending the "adjust-available" ping.
-                Log.w(LOGTAG, "Cannot access ping's storage directory. " +
-                        "Cannot send the \"adjust-available\" ping");
-                return;
-            }
-
-            // First allow for stored pings to be re-uploaded if the previous upload did not succeed.
-            // (A successful upload would delete the pings persisted to disk)
-            if (store.getCount() != 0) {
-                store.queuePingsForUpload(new TelemetryUploadAllPingsImmediatelyScheduler());
-            }
-
-            // It may be possible that in the app's lifetime Adjust campaigns are changed.
-            // Sanity check that the "adjust-available" ping has not yet been send.
-            if (!TelemetryInstallationPingStore.hasFullPingBeenQueuedForUpload()) {
-                TelemetryOutgoingPing ping = new TelemetryInstallationPingBuilder()
-                        .setReason(PingReason.ADJUST_AVAILABLE)
-                        .setAdjustProperties(attribution)
-                        .build();
-
-                try {
-                    store.storePing(ping);
-                    store.queuePingsForUpload(new TelemetryUploadAllPingsImmediatelyScheduler());
-                    store.setFullPingQueuedForUpload();
-                } catch (IOException e) {
-                    // #storePing() might throw in the process of persisting to disk.
-                    // Nothing we can do. The "adjust-available" ping is lost.
-                    Log.w(LOGTAG, "Could not store the \"adjust-available\" ping");
-                }
-            }
-        });
-    }
-}
diff --git a/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryInstallationPingBuilder.java b/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryInstallationPingBuilder.java
deleted file mode 100644
index 24f94c1d06a3..000000000000
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetryInstallationPingBuilder.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-package org.mozilla.gecko.telemetry.pingbuilders;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.os.Build;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.util.Log;
-
-import com.adjust.sdk.AdjustAttribution;
-
-import org.mozilla.gecko.AppConstants;
-import org.mozilla.gecko.GeckoAppShell;
-import org.mozilla.gecko.GeckoSharedPrefs;
-import org.mozilla.gecko.GeckoThread;
-import org.mozilla.gecko.Locales;
-import org.mozilla.gecko.util.DateUtil;
-import org.mozilla.gecko.util.HardwareUtils;
-
-import java.lang.reflect.Method;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-
-public class TelemetryInstallationPingBuilder extends TelemetryPingBuilder {
-    private static final String LOGTAG = "InstallPingBuilder";
-
-    public enum PingReason {
-        APP_STARTED("app-started"),
-        ADJUST_AVAILABLE("adjust-available");
-
-        PingReason(String reason) {
-            this.value = reason;
-        }
-
-        public final String value;
-    }
-
-    private static final String PING_TYPE = "installation";
-    private static final int PING_FORMAT_VERSION = 1;
-
-    private static final String PREF_KEY_SEQ_NUMBER = "installationPingSeqNumber";
-
-    private static final String PING_VERSION = "v";
-    private static final String REASON = "reason";
-    private static final String PING_QUEUED_TIMES = "seq";
-    private static final String CLIENT_ID = "client_id";
-    private static final String DEVICE_ID = "device_id";
-    private static final String LOCALE = "locale";
-    private static final String OS_NAME = "os";
-    private static final String OS_VERSION = "osversion";
-    private static final String DEVICE_MANUFACTURER = "manufacturer";
-    private static final String DEVICE_MODEL = "model";
-    private static final String DEVICE_ABI = "arch";
-    private static final String PROFILE_DATE = "profile_date";
-    private static final String PING_CREATION_TIME = "created";
-    private static final String TIMEZONE_OFFSET = "tz";
-    private static final String APP_NAME = "app_name";
-    private static final String RELEASE_CHANNEL = "channel";
-    private static final String ADJUST_CAMPAIGN = "campaign";
-    private static final String ADJUST_ADGROUP = "adgroup";
-    private static final String ADJUST_CREATIVE = "creative";
-    private static final String ADJUST_NETWORK = "network";
-
-    public TelemetryInstallationPingBuilder() {
-        super(UNIFIED_TELEMETRY_VERSION, false);
-        setPayloadConstants();
-    }
-
-    @Override
-    public String getDocType() {
-        return PING_TYPE;
-    }
-
-    @Override
-    public String[] getMandatoryFields() {
-        return new String[]{
-                PING_VERSION,
-                REASON,
-                PING_QUEUED_TIMES,
-                CLIENT_ID,
-                DEVICE_ID,
-                LOCALE,
-                OS_NAME,
-                OS_VERSION,
-                DEVICE_MANUFACTURER,
-                DEVICE_MODEL,
-                DEVICE_ABI,
-                PROFILE_DATE,
-                PING_CREATION_TIME,
-                TIMEZONE_OFFSET,
-                APP_NAME,
-                RELEASE_CHANNEL,
-        };
-    }
-
-    public @NonNull TelemetryInstallationPingBuilder setReason(@NonNull PingReason reason) {
-        payload.put(REASON, reason.value);
-
-        return this;
-    }
-
-    public @NonNull TelemetryInstallationPingBuilder setAdjustProperties(@NonNull final AdjustAttribution attribution) {
-        payload.put(ADJUST_CAMPAIGN, attribution.campaign);
-        payload.put(ADJUST_ADGROUP, attribution.adgroup);
-        payload.put(ADJUST_CREATIVE, attribution.creative);
-        payload.put(ADJUST_NETWORK, attribution.network);
-
-        return this;
-    }
-
-    private void setPayloadConstants() {
-        payload.put(PING_VERSION, PING_FORMAT_VERSION);
-        payload.put(PING_QUEUED_TIMES, incrementAndGetQueueTimes());
-        payload.put(CLIENT_ID, getGeckoClientID());
-        payload.put(DEVICE_ID, getAdvertisingId());
-        payload.put(LOCALE, Locales.getLanguageTag(Locale.getDefault()));
-        payload.put(OS_NAME, TelemetryPingBuilder.OS_NAME);
-        payload.put(OS_VERSION, Integer.toString(Build.VERSION.SDK_INT));
-        payload.put(DEVICE_MANUFACTURER, Build.MANUFACTURER);
-        payload.put(DEVICE_MODEL, Build.MODEL);
-        payload.put(DEVICE_ABI, HardwareUtils.getRealAbi());
-        payload.put(PROFILE_DATE, getGeckoProfileCreationDate());
-        payload.put(PING_CREATION_TIME, new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(new Date()));
-        payload.put(TIMEZONE_OFFSET, DateUtil.getTimezoneOffsetInMinutesForGivenDate(Calendar.getInstance()));
-        payload.put(APP_NAME, AppConstants.MOZ_APP_BASENAME);
-        payload.put(RELEASE_CHANNEL, AppConstants.MOZ_UPDATE_CHANNEL);
-    }
-
-    private @Nullable String getGeckoClientID() {
-        // zero-ed Gecko profile that respects the expected format "8-4-4-4-12" chars
-        String clientID = "00000000-0000-0000-0000-000000000000";
-        try {
-            clientID = GeckoThread.getActiveProfile().getClientId();
-        } catch (Exception e) {
-            Log.w(LOGTAG, "Could not get Gecko Client ID", e);
-        }
-
-        return clientID;
-    }
-
-    private @Nullable String getAdvertisingId() {
-        String advertisingId = null;
-        try {
-            final Class<?> clazz = Class.forName("org.mozilla.gecko.advertising.AdvertisingUtil");
-            final Method getAdvertisingId = clazz.getMethod("getAdvertisingId", Context.class);
-            advertisingId = (String) getAdvertisingId.invoke(clazz, GeckoAppShell.getApplicationContext());
-        } catch (Exception e) {
-            Log.w(LOGTAG, "Could not get advertising ID", e);
-        }
-
-        return advertisingId;
-    }
-
-    // Ensure sequential increment and return in all instances.
-    private static synchronized int incrementAndGetQueueTimes() {
-        final SharedPreferences sharedPrefs = GeckoSharedPrefs.forProfile(GeckoAppShell.getApplicationContext());
-
-        // 1-based, always incremented
-        final int incrementedSeqNumber = sharedPrefs.getInt(PREF_KEY_SEQ_NUMBER, 0) + 1;
-        sharedPrefs.edit().putInt(PREF_KEY_SEQ_NUMBER, incrementedSeqNumber).apply();
-
-        return incrementedSeqNumber;
-    }
-
-    private int getGeckoProfileCreationDate() {
-        // The method returns days since epoch. An int is enough.
-        int date = 0;
-        try {
-            date = TelemetryActivationPingBuilder.getProfileCreationDate(
-                    GeckoAppShell.getApplicationContext(),
-                    GeckoThread.getActiveProfile()).intValue();
-        } catch (NullPointerException e) {
-            Log.w(LOGTAG, "Could not get Gecko profile creation date", e);
-        }
-
-        return date;
-    }
-}
diff --git a/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryInstallationPingStore.java b/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryInstallationPingStore.java
deleted file mode 100644
index c6aacab25e73..000000000000
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryInstallationPingStore.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-package org.mozilla.gecko.telemetry.stores;
-
-import android.content.SharedPreferences;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.support.annotation.NonNull;
-
-import org.mozilla.gecko.GeckoAppShell;
-import org.mozilla.gecko.GeckoSharedPrefs;
-import org.mozilla.gecko.GeckoThread;
-import org.mozilla.gecko.telemetry.schedulers.TelemetryUploadAllPingsImmediatelyScheduler;
-
-import java.io.File;
-
-public class TelemetryInstallationPingStore extends TelemetryJSONFilePingStore {
-    private static final String PREF_KEY_WAS_LIGHT_PING_STORED = "wasLightInstallationPingStored";
-    private static final String PREF_KEY_WAS_FULL_PING_STORED = "wasFullInstallationPingStored";
-    private static final String INSTALLATION_PING_STORE_DIR = "installation_ping";
-    private static final String DEFAULT_PROFILE = "default";
-
-    public TelemetryInstallationPingStore() {
-        super(getInstallationPingStoreDir(), getCurrentProfileName());
-    }
-
-    public TelemetryInstallationPingStore(@NonNull final File storeDir, @NonNull final String profileName) {
-        super(storeDir, profileName);
-    }
-
-    @Override
-    public void maybePrunePings() {
-        // no-op
-        // Successfully uploaded pings will be deleted in onUploadAttemptComplete(..).
-    }
-
-    public void queuePingsForUpload(@NonNull final TelemetryUploadAllPingsImmediatelyScheduler scheduler) {
-        scheduler.scheduleUpload(GeckoAppShell.getApplicationContext(), this);
-    }
-
-    public static boolean hasLightPingBeenQueuedForUpload() {
-        return getSharedPrefs().getBoolean(PREF_KEY_WAS_LIGHT_PING_STORED, false);
-    }
-
-    public static boolean hasFullPingBeenQueuedForUpload() {
-        return getSharedPrefs().getBoolean(PREF_KEY_WAS_FULL_PING_STORED, false);
-    }
-
-    public void setLightPingQueuedForUpload() {
-        getSharedPrefs().edit().putBoolean(PREF_KEY_WAS_LIGHT_PING_STORED, true).apply();
-    }
-
-    public void setFullPingQueuedForUpload() {
-        getSharedPrefs().edit().putBoolean(PREF_KEY_WAS_FULL_PING_STORED, true).apply();
-    }
-
-    private static @NonNull SharedPreferences getSharedPrefs() {
-        return GeckoSharedPrefs.forProfile(GeckoAppShell.getApplicationContext());
-    }
-
-    private static @NonNull File getInstallationPingStoreDir() {
-        return GeckoAppShell.getApplicationContext().getFileStreamPath(INSTALLATION_PING_STORE_DIR);
-    }
-
-    private static @NonNull String getCurrentProfileName() {
-        return GeckoThread.getActiveProfile() != null ?
-                GeckoThread.getActiveProfile().getName() :
-                DEFAULT_PROFILE;
-    }
-
-
-    // Class needs to be Parcelable as it will be passed through Intents
-    public static final Parcelable.Creator<TelemetryInstallationPingStore> CREATOR =
-            new Parcelable.Creator<TelemetryInstallationPingStore>() {
-
-        @Override
-        public TelemetryInstallationPingStore createFromParcel(final Parcel source) {
-            final String storeDirPath = source.readString();
-            final String profileName = source.readString();
-            return new TelemetryInstallationPingStore(new File(storeDirPath), profileName);
-        }
-
-        @Override
-        public TelemetryInstallationPingStore[] newArray(final int size) {
-            return new TelemetryInstallationPingStore[size];
-        }
-    };
-
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    @Override
-    public void writeToParcel(final Parcel dest, final int flags) {
-        super.writeToParcel(dest, flags);
-    }
-}



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits