Bug 1374889 - Update Leanplum user attribute for Focus/Klar installation, Sync, and Default Browser. r=maliu

MozReview-Commit-ID: Fl3Q6S0cDLg

--HG--
extra : rebase_source : 709206baab5aa228d7460ec58bc7bbcead7de5aa
This commit is contained in:
Nevin Chen 2017-06-21 17:39:14 +08:00
Родитель dc04af5ec3
Коммит bd2b3caea6
2 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -107,7 +107,7 @@ public class MmaDelegate {
}
private static boolean isDefaultBrowser(Context context) {
public static boolean isDefaultBrowser(Context context) {
final Intent viewIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mozilla.org"));
final ResolveInfo info = context.getPackageManager().resolveActivity(viewIntent, PackageManager.MATCH_DEFAULT_ONLY);
if (info == null) {

Просмотреть файл

@ -16,6 +16,7 @@ import com.leanplum.LeanplumActivityHelper;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.MmaConstants;
import org.mozilla.gecko.fxa.FirefoxAccounts;
import java.util.HashMap;
import java.util.Map;
@ -44,11 +45,17 @@ public class MmaLeanplumImp implements MmaInterface {
Map<String, Object> attributes = new HashMap<>();
boolean installedFocus = isPackageInstalled(activity, "org.mozilla.focus");
boolean installedKlar = isPackageInstalled(activity, "org.mozilla.klar");
if (installedFocus || installedKlar) {
attributes.put("focus", true);
if (installedFocus) {
attributes.put("Focus Installed", true);
} else {
attributes.put("focus", false);
attributes.put("Focus Installed", false);
}
if (installedKlar) {
attributes.put("Klar Installed", true);
} else {
attributes.put("Klar Installed", false);
}
final SharedPreferences sharedPreferences = activity.getPreferences(0);
String deviceId = sharedPreferences.getString(KEY_ANDROID_PREF_STRING_LEANPLUM_DEVICE_ID, null);
@ -57,6 +64,20 @@ public class MmaLeanplumImp implements MmaInterface {
sharedPreferences.edit().putString(KEY_ANDROID_PREF_STRING_LEANPLUM_DEVICE_ID, deviceId).apply();
}
Leanplum.setDeviceId(deviceId);
if (MmaDelegate.isDefaultBrowser(activity)) {
attributes.put("Default Browser", true);
} else {
attributes.put("Default Browser", false);
}
// In order to trigger the campaign lazily, you check the account existence as an attribute,
// not when account login success callback is invoked. Because the attribute update lazily when process start.
if (FirefoxAccounts.firefoxAccountsExist(activity)) {
attributes.put("Signed In Sync", true);
} else {
attributes.put("Signed In Sync", false);
}
Leanplum.start(activity, attributes);
// this is special to Leanplum. Since we defer LeanplumActivityHelper's onResume call till