From 33798c6a1796206bf5cce7605dcfc7f1ffef5c6d Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 7 Oct 2019 10:52:59 +1100 Subject: [PATCH] Match iOS analytics --- .../ApplicationPreferencesActivity.java | 4 +++ .../securesms/CreateProfileActivity.java | 5 ++++ .../securesms/loki/BackgroundPollWorker.kt | 2 ++ .../securesms/loki/DisplayNameActivity.kt | 2 ++ .../securesms/loki/SeedActivity.kt | 5 ++++ .../AppProtectionPreferenceFragment.java | 26 ++++++++++++++++++- .../NotificationsPreferenceFragment.java | 6 ++++- .../registration/WelcomeActivity.java | 2 ++ 8 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java index 49390c5be8..3d44eabfce 100644 --- a/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java +++ b/src/org/thoughtcrime/securesms/ApplicationPreferencesActivity.java @@ -53,6 +53,7 @@ import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicTheme; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.whispersystems.signalservice.loki.crypto.MnemonicCodec; +import org.whispersystems.signalservice.loki.utilities.Analytics; import org.whispersystems.signalservice.loki.utilities.SerializationKt; import java.io.File; @@ -102,6 +103,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA if (getIntent() != null && getIntent().getCategories() != null && getIntent().getCategories().contains("android.intent.category.NOTIFICATION_PREFERENCES")) { initFragment(android.R.id.content, new NotificationsPreferenceFragment()); } else if (icicle == null) { + Analytics.Companion.getShared().track("Settings Opened"); initFragment(android.R.id.content, new ApplicationPreferenceFragment()); } } @@ -317,6 +319,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA break; */ case PREFERENCE_CATEGORY_PUBLIC_KEY: + Analytics.Companion.getShared().track("Public Key Shared"); String hexEncodedPublicKey = TextSecurePreferences.getLocalNumber(getContext()); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); @@ -331,6 +334,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA DeviceLinkingDialog.INSTANCE.show(getContext(), DeviceLinkingView.Mode.Master); break; case PREFERENCE_CATEGORY_SEED: + Analytics.Companion.getShared().track("Seed Modal Shown"); File languageFileDirectory = new File(getContext().getApplicationInfo().dataDir); try { String hexEncodedSeed = IdentityKeyUtil.retrieve(getContext(), IdentityKeyUtil.lokiSeedKey); diff --git a/src/org/thoughtcrime/securesms/CreateProfileActivity.java b/src/org/thoughtcrime/securesms/CreateProfileActivity.java index 7a3b7a3dc4..2d39b63fb7 100644 --- a/src/org/thoughtcrime/securesms/CreateProfileActivity.java +++ b/src/org/thoughtcrime/securesms/CreateProfileActivity.java @@ -62,6 +62,7 @@ import org.whispersystems.signalservice.api.SignalServiceAccountManager; import org.whispersystems.signalservice.api.crypto.ProfileCipher; import org.whispersystems.signalservice.api.util.StreamDetails; import org.whispersystems.signalservice.loki.api.LokiGroupChatAPI; +import org.whispersystems.signalservice.loki.utilities.Analytics; import java.io.ByteArrayInputStream; import java.io.File; @@ -115,6 +116,8 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje initializeProfileAvatar(getIntent().getBooleanExtra(EXCLUDE_SYSTEM, false)); ApplicationContext.getInstance(this).injectDependencies(this); + + Analytics.Companion.getShared().track("Display Name Screen Viewed"); } @Override @@ -371,6 +374,8 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje Context context = CreateProfileActivity.this; byte[] profileKey = ProfileKeyUtil.getProfileKey(CreateProfileActivity.this); + Analytics.Companion.getShared().track("Display Name Updated"); + TextSecurePreferences.setProfileName(context, name); String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context); diff --git a/src/org/thoughtcrime/securesms/loki/BackgroundPollWorker.kt b/src/org/thoughtcrime/securesms/loki/BackgroundPollWorker.kt index fa110320f6..b8b8cd7fe4 100644 --- a/src/org/thoughtcrime/securesms/loki/BackgroundPollWorker.kt +++ b/src/org/thoughtcrime/securesms/loki/BackgroundPollWorker.kt @@ -9,6 +9,7 @@ import org.thoughtcrime.securesms.service.PersistentAlarmManagerListener import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope import org.whispersystems.signalservice.loki.api.LokiAPI +import org.whispersystems.signalservice.loki.utilities.Analytics import java.util.concurrent.TimeUnit class BackgroundPollWorker : PersistentAlarmManagerListener() { @@ -28,6 +29,7 @@ class BackgroundPollWorker : PersistentAlarmManagerListener() { override fun onAlarm(context: Context, scheduledTime: Long): Long { if (scheduledTime != 0L) { + Analytics.shared.track("Performed Background Fetch") val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context) val lokiAPIDatabase = DatabaseFactory.getLokiAPIDatabase(context) try { diff --git a/src/org/thoughtcrime/securesms/loki/DisplayNameActivity.kt b/src/org/thoughtcrime/securesms/loki/DisplayNameActivity.kt index 43dc678c00..d581d8bbbf 100644 --- a/src/org/thoughtcrime/securesms/loki/DisplayNameActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/DisplayNameActivity.kt @@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.util.TextSecurePreferences import org.whispersystems.signalservice.api.crypto.ProfileCipher import org.whispersystems.signalservice.loki.api.LokiGroupChatAPI +import org.whispersystems.signalservice.loki.utilities.Analytics class DisplayNameActivity : BaseActionBarActivity() { @@ -29,6 +30,7 @@ class DisplayNameActivity : BaseActionBarActivity() { if (name.toByteArray().size > ProfileCipher.NAME_PADDED_LENGTH) { return nameEditText.input.setError("Too Long") } else { + Analytics.shared.track("Display Name Updated") TextSecurePreferences.setProfileName(this, name) } } diff --git a/src/org/thoughtcrime/securesms/loki/SeedActivity.kt b/src/org/thoughtcrime/securesms/loki/SeedActivity.kt index 03a1d03ba5..95c49de299 100644 --- a/src/org/thoughtcrime/securesms/loki/SeedActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/SeedActivity.kt @@ -47,6 +47,7 @@ class SeedActivity : BaseActionBarActivity() { copyButton.setOnClickListener { copy() } toggleModeButton.setOnClickListener { toggleMode() } registerOrRestoreButton.setOnClickListener { registerOrRestore() } + Analytics.shared.track("Seed Screen Viewed") } // endregion @@ -160,9 +161,13 @@ class SeedActivity : BaseActionBarActivity() { when (mode) { Mode.Register -> Analytics.shared.track("Seed Created") Mode.Restore -> Analytics.shared.track("Seed Restored") + // TODO: Mode.Link -> Analytics.shared.track("Device Linking Attempted") } startActivity(Intent(this, DisplayNameActivity::class.java)) finish() } + + // TODO: Analytics.shared.track("Device Linked Successfully") + // endregion } \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java index 633cc44517..f0407c15b7 100644 --- a/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java @@ -15,7 +15,6 @@ import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.ApplicationPreferencesActivity; import org.thoughtcrime.securesms.BlockedContactsActivity; import org.thoughtcrime.securesms.PassphraseChangeActivity; -import network.loki.messenger.R; import org.thoughtcrime.securesms.components.SwitchPreferenceCompat; import org.thoughtcrime.securesms.crypto.MasterSecretUtil; import org.thoughtcrime.securesms.dependencies.InjectableType; @@ -26,12 +25,14 @@ import org.thoughtcrime.securesms.service.KeyCachingService; import org.thoughtcrime.securesms.util.CommunicationActions; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.whispersystems.signalservice.api.SignalServiceAccountManager; +import org.whispersystems.signalservice.loki.utilities.Analytics; import java.util.concurrent.TimeUnit; import javax.inject.Inject; import mobi.upod.timedurationpicker.TimeDurationPickerDialog; +import network.loki.messenger.R; public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment implements InjectableType { @@ -71,6 +72,8 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment disablePassphrase.setOnPreferenceChangeListener(new DisablePassphraseClickListener()); initializeVisibility(); + + Analytics.Companion.getShared().track("Privacy Settings Opened"); } @Override @@ -128,6 +131,13 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean enabled = (Boolean)newValue; + + if (enabled) { + Analytics.Companion.getShared().track("Screen Lock Enabled"); + } else { + Analytics.Companion.getShared().track("Screen Lock Disabled"); + } + TextSecurePreferences.setScreenLockEnabled(getContext(), enabled); Intent intent = new Intent(getContext(), KeyCachingService.class); @@ -197,6 +207,13 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean enabled = (boolean)newValue; + + if (enabled) { + Analytics.Companion.getShared().track("Typing Indicators Enabled"); + } else { + Analytics.Companion.getShared().track("Typing Indicators Disabled"); + } + ApplicationContext.getInstance(getContext()) .getJobManager() .add(new MultiDeviceConfigurationUpdateJob(TextSecurePreferences.isReadReceiptsEnabled(requireContext()), @@ -216,6 +233,13 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean enabled = (boolean)newValue; + + if (enabled) { + Analytics.Companion.getShared().track("Link Previews Enabled"); + } else { + Analytics.Companion.getShared().track("Link Previews Disabled"); + } + ApplicationContext.getInstance(requireContext()) .getJobManager() .add(new MultiDeviceConfigurationUpdateJob(TextSecurePreferences.isReadReceiptsEnabled(requireContext()), diff --git a/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java b/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java index c50181b99f..01f014b8f0 100644 --- a/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java +++ b/src/org/thoughtcrime/securesms/preferences/NotificationsPreferenceFragment.java @@ -15,11 +15,13 @@ import android.support.v7.preference.Preference; import android.text.TextUtils; import org.thoughtcrime.securesms.ApplicationPreferencesActivity; -import network.loki.messenger.R; import org.thoughtcrime.securesms.components.SwitchPreferenceCompat; import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.notifications.NotificationChannels; import org.thoughtcrime.securesms.util.TextSecurePreferences; +import org.whispersystems.signalservice.loki.utilities.Analytics; + +import network.loki.messenger.R; import static android.app.Activity.RESULT_OK; @@ -119,6 +121,8 @@ public class NotificationsPreferenceFragment extends ListSummaryPreferenceFragme // initializeCallRingtoneSummary(findPreference(TextSecurePreferences.CALL_RINGTONE_PREF)); initializeMessageVibrateSummary((SwitchPreferenceCompat)findPreference(TextSecurePreferences.VIBRATE_PREF)); // initializeCallVibrateSummary((SwitchPreferenceCompat)findPreference(TextSecurePreferences.CALL_VIBRATE_PREF)); + + Analytics.Companion.getShared().track("Notification Settings Opened"); } @Override diff --git a/src/org/thoughtcrime/securesms/registration/WelcomeActivity.java b/src/org/thoughtcrime/securesms/registration/WelcomeActivity.java index 864b9c0dfa..5cd036f29c 100644 --- a/src/org/thoughtcrime/securesms/registration/WelcomeActivity.java +++ b/src/org/thoughtcrime/securesms/registration/WelcomeActivity.java @@ -8,6 +8,7 @@ import android.support.annotation.NonNull; import org.thoughtcrime.securesms.BaseActionBarActivity; import org.thoughtcrime.securesms.permissions.Permissions; import org.thoughtcrime.securesms.util.CommunicationActions; +import org.whispersystems.signalservice.loki.utilities.Analytics; import network.loki.messenger.R; @@ -19,6 +20,7 @@ public class WelcomeActivity extends BaseActionBarActivity { setContentView(R.layout.registration_welcome_activity); findViewById(R.id.welcome_terms_button).setOnClickListener(v -> onTermsClicked()); findViewById(R.id.welcome_continue_button).setOnClickListener(v -> onContinueClicked()); + Analytics.Companion.getShared().track("Landing Screen Viewed"); } @Override