[android] Added some new auth stats

This commit is contained in:
Dmitry Donskoy 2020-06-02 11:32:36 +03:00 committed by Aleksandr Zatsepin
parent faa0394fa4
commit 50beeb926e
20 changed files with 325 additions and 56 deletions

View file

@ -41,6 +41,7 @@ import com.mapswithme.maps.background.NotificationCandidate;
import com.mapswithme.maps.background.Notifier;
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
import com.mapswithme.maps.base.OnBackPressListener;
import com.mapswithme.maps.bookmarks.AuthBundleFactory;
import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity;
import com.mapswithme.maps.bookmarks.BookmarksCatalogActivity;
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
@ -2658,7 +2659,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void onGalleryGuideSelected(@NonNull String url)
{
BookmarksCatalogActivity.startForResult(
this, BookmarkCategoriesActivity.REQ_CODE_DOWNLOAD_BOOKMARK_CATEGORY, url);
this, BookmarkCategoriesActivity.REQ_CODE_DOWNLOAD_BOOKMARK_CATEGORY, url,
AuthBundleFactory.guideCatalogue());
}
private void toggleLayer(@NonNull Mode mode, @NonNull String from)

View file

@ -6,9 +6,12 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import android.os.Bundle;
import android.text.TextUtils;
import com.mapswithme.maps.Framework;
import com.mapswithme.util.statistics.Statistics;
/**
* An authorizer is responsible for an authorization for the Mapsme server,
@ -37,6 +40,9 @@ public class Authorizer implements AuthorizationListener
private Callback mCallback;
private boolean mIsAuthorizationInProgress;
@Framework.AuthTokenType
private int mTokenType = Framework.SOCIAL_TOKEN_INVALID;
public Authorizer(@NonNull Fragment fragment)
{
mFragment = fragment;
@ -52,7 +58,7 @@ public class Authorizer implements AuthorizationListener
mCallback = null;
}
public final void authorize()
public final void authorize(@NonNull Bundle bundle)
{
if (isAuthorized())
{
@ -68,6 +74,7 @@ public class Authorizer implements AuthorizationListener
return;
fragment = (DialogFragment) Fragment.instantiate(mFragment.getContext(), name);
fragment.setArguments(bundle);
// A communication with the SocialAuthDialogFragment is implemented via getParentFragment method
// because of 'setTargetFragment' paradigm doesn't survive the activity configuration change
// due to this issue https://issuetracker.google.com/issues/36969568
@ -89,11 +96,14 @@ public class Authorizer implements AuthorizationListener
boolean isCancel = data.getBooleanExtra(Constants.EXTRA_IS_CANCEL, false);
if (isCancel)
{
Statistics.INSTANCE.trackAuthDeclined(type);
mCallback.onSocialAuthenticationCancel(type);
return;
}
mCallback.onSocialAuthenticationError(type, data.getStringExtra(Constants.EXTRA_AUTH_ERROR));
String error = data.getStringExtra(Constants.EXTRA_AUTH_ERROR);
Statistics.INSTANCE.trackAuthError(type, error);
mCallback.onSocialAuthenticationError(type, error);
return;
}
@ -114,6 +124,8 @@ public class Authorizer implements AuthorizationListener
Framework.nativeAuthenticateUser(socialToken, type, privacyAccepted, termsOfUseAccepted,
promoAccepted, this);
mTokenType = type;
Statistics.INSTANCE.trackAuthExternalRequestSuccess(type);
}
}
@ -123,6 +135,8 @@ public class Authorizer implements AuthorizationListener
mIsAuthorizationInProgress = false;
if (mCallback != null)
mCallback.onAuthorizationFinish(success);
Statistics.INSTANCE.trackAuthRequestSuccess(mTokenType);
}
public boolean isAuthorizationInProgress()

View file

@ -37,7 +37,7 @@ public class PassportAuthDialogFragment extends BaseMwmDialogFragment
super.onStart();
mAuthorizer.attach(mAuthCallback);
if (mSavedInstanceState == null)
mAuthorizer.authorize();
mAuthorizer.authorize(getArgumentsOrThrow());
}
@Override

View file

@ -36,6 +36,7 @@ import com.mapswithme.util.statistics.Statistics;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class SocialAuthDialogFragment extends BaseMwmDialogFragment
{
@ -55,6 +56,7 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment
private final View.OnClickListener mPhoneClickListener = (View v) ->
{
PhoneAuthActivity.startForResult(this);
trackStatsIfArgsExist(Statistics.EventName.AUTH_START);
};
@NonNull
private final View.OnClickListener mGoogleClickListener = new View.OnClickListener()
@ -64,6 +66,7 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment
{
Intent intent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(intent, Constants.REQ_CODE_GOOGLE_SIGN_IN);
trackStatsIfArgsExist(Statistics.EventName.AUTH_START);
}
};
@NonNull
@ -72,6 +75,7 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment
lm.logInWithReadPermissions(SocialAuthDialogFragment.this,
Constants.FACEBOOK_PERMISSIONS);
lm.registerCallback(mFacebookCallbackManager, new FBCallback(SocialAuthDialogFragment.this));
trackStatsIfArgsExist(Statistics.EventName.AUTH_START);
};
@SuppressWarnings("NullableProblems")
@NonNull
@ -104,6 +108,17 @@ public class SocialAuthDialogFragment extends BaseMwmDialogFragment
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(getActivity(), gso);
trackStatsIfArgsExist(Statistics.EventName.AUTH_SHOWN);
}
private void trackStatsIfArgsExist(@NonNull String action)
{
Bundle args = getArguments();
if (args == null)
return;
Statistics.INSTANCE.trackAuthDialogAction(action,
Objects.requireNonNull(args.getString(Statistics.EventParam.FROM)));
}
private void setTargetCallback()

View file

@ -1,12 +1,15 @@
package com.mapswithme.maps.base;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mapswithme.maps.auth.Authorizer;
import com.mapswithme.maps.auth.TargetFragmentCallback;
import com.mapswithme.maps.bookmarks.AuthBundleFactory;
public abstract class BaseAuthFragment extends BaseAsyncOperationFragment
implements Authorizer.Callback, TargetFragmentCallback
@ -16,7 +19,12 @@ public abstract class BaseAuthFragment extends BaseAsyncOperationFragment
protected void authorize()
{
mAuthorizer.authorize();
mAuthorizer.authorize(AuthBundleFactory.subscription());
}
protected void authorize(@NonNull Bundle bundle)
{
mAuthorizer.authorize(bundle);
}
@Override

View file

@ -1,6 +1,8 @@
package com.mapswithme.maps.base;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -19,9 +21,9 @@ public abstract class BaseToolbarAuthFragment extends BaseMwmToolbarFragment
@NonNull
private final Authorizer mAuthorizer = new Authorizer(this);
protected void authorize()
protected void authorize(@NonNull Bundle bundle)
{
mAuthorizer.authorize();
mAuthorizer.authorize(bundle);
}
@Override

View file

@ -0,0 +1,42 @@
package com.mapswithme.maps.bookmarks;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.mapswithme.util.statistics.Statistics;
public abstract class AuthBundleFactory
{
public static Bundle saveReview()
{
return buildBundle(Statistics.EventParam.AFTER_SAVE_REVIEW);
}
public static Bundle bookmarksBackup()
{
return buildBundle(Statistics.EventParam.BOOKMARKS_BACKUP);
}
public static Bundle guideCatalogue()
{
return buildBundle(Statistics.EventParam.GUIDE_CATALOGUE);
}
public static Bundle subscription()
{
return buildBundle(Statistics.EventParam.SUBSCRIPTION);
}
public static Bundle exportBookmarks()
{
return buildBundle(Statistics.EventParam.EXPORT_BOOKMARKS);
}
private static Bundle buildBundle(@NonNull String value)
{
Bundle bundle = new Bundle();
bundle.putString(Statistics.EventParam.FROM, value);
return bundle;
}
}

View file

@ -60,7 +60,7 @@ public class BookmarkBackupController implements Authorizer.Callback,
@Override
public void onClick(View v)
{
mAuthorizer.authorize();
mAuthorizer.authorize(AuthBundleFactory.bookmarksBackup());
Statistics.INSTANCE.trackBmSyncProposalApproved(false);
}
};

View file

@ -3,6 +3,7 @@ package com.mapswithme.maps.bookmarks;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
@ -12,27 +13,36 @@ import com.mapswithme.maps.base.BaseToolbarActivity;
public class BookmarksCatalogActivity extends BaseToolbarActivity
{
public static final String EXTRA_DOWNLOADED_CATEGORY = "extra_downloaded_category";
public static final String EXTRA_ARGS = "extra_args";
public static void startForResult(@NonNull Fragment fragment, int requestCode,
@NonNull String catalogUrl)
{
fragment.startActivityForResult(makeLaunchIntent(fragment.requireContext(), catalogUrl),
fragment.startActivityForResult(makeLaunchIntent(fragment.requireContext(), catalogUrl,
AuthBundleFactory.guideCatalogue()),
requestCode);
}
public static void startForResult(@NonNull Activity context, int requestCode,
@NonNull String catalogUrl)
{
context.startActivityForResult(makeLaunchIntent(context, catalogUrl), requestCode);
startForResult(context, requestCode, catalogUrl, AuthBundleFactory.guideCatalogue());
}
public static void startForResult(@NonNull Activity context, int requestCode,
@NonNull String catalogUrl, @NonNull Bundle bundle)
{
context.startActivityForResult(makeLaunchIntent(context, catalogUrl, bundle), requestCode);
}
@NonNull
private static Intent makeLaunchIntent(@NonNull Context context, @NonNull String catalogUrl)
private static Intent makeLaunchIntent(@NonNull Context context, @NonNull String catalogUrl,
@NonNull Bundle bundle)
{
Intent intent = new Intent(context, BookmarksCatalogActivity.class);
intent.putExtra(BookmarksCatalogFragment.EXTRA_BOOKMARKS_CATALOG_URL, catalogUrl);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
return intent;
return new Intent(context, BookmarksCatalogActivity.class)
.putExtra(BookmarksCatalogFragment.EXTRA_BOOKMARKS_CATALOG_URL, catalogUrl)
.putExtra(EXTRA_ARGS, bundle)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
@Override

View file

@ -106,7 +106,9 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
public void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mDelegate = new BookmarksDownloadFragmentDelegate(this);
Bundle extra = requireActivity().getIntent()
.getBundleExtra(BookmarksCatalogActivity.EXTRA_ARGS);
mDelegate = new BookmarksDownloadFragmentDelegate(this, extra);
mDelegate.onCreate(savedInstanceState);
mInvalidSubsDialogCallback = new InvalidSubscriptionAlertDialogCallback(this);
}

View file

@ -43,11 +43,19 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark
@NonNull
private final InvalidCategoriesListener mInvalidCategoriesListener;
@NonNull
private final Bundle mBundle;
BookmarksDownloadFragmentDelegate(@NonNull Fragment fragment)
BookmarksDownloadFragmentDelegate(@NonNull Fragment fragment)
{
this(fragment, AuthBundleFactory.guideCatalogue());
}
BookmarksDownloadFragmentDelegate(@NonNull Fragment fragment, @NonNull Bundle bundle)
{
mFragment = fragment;
mInvalidCategoriesListener = new InvalidCategoriesListener(fragment);
mBundle = bundle;
}
void onCreate(@Nullable Bundle savedInstanceState)
@ -205,7 +213,7 @@ class BookmarksDownloadFragmentDelegate implements Authorizer.Callback, Bookmark
void authorize(@NonNull Runnable completionRunnable)
{
mAuthCompletionRunnable = completionRunnable;
mAuthorizer.authorize();
mAuthorizer.authorize(mBundle);
}
private static class InvalidCategoriesListener implements BookmarkManager.BookmarksInvalidCategoriesListener, Detachable<Fragment>

View file

@ -1,7 +1,11 @@
package com.mapswithme.maps.editor;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
@ -9,9 +13,31 @@ import android.view.ViewGroup;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseMwmDialogFragment;
import com.mapswithme.util.statistics.Statistics;
import java.util.Objects;
public class AuthDialogFragment extends BaseMwmDialogFragment
{
@Override
public void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (args == null)
return;
sendStats(args, Statistics.EventName.AUTH_SHOWN);
}
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState)
{
return new DialogImpl();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
@ -29,15 +55,50 @@ public class AuthDialogFragment extends BaseMwmDialogFragment
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
OsmAuthFragmentDelegate osmAuthDelegate = new OsmAuthFragmentDelegate(this)
{
@Override
protected void loginOsm()
{
startActivity(new Intent(getContext(), OsmAuthActivity.class));
dismiss();
}
};
OsmAuthFragmentDelegate osmAuthDelegate = new AuthFragmentDelegate();
osmAuthDelegate.onViewCreated(view, savedInstanceState);
}
private static void sendStats(@NonNull Bundle args, @NonNull String action)
{
Statistics.INSTANCE.trackAuthDialogAction(action,
Objects.requireNonNull(args.getString(Statistics.EventParam.FROM)));
}
private class AuthFragmentDelegate extends OsmAuthFragmentDelegate
{
AuthFragmentDelegate()
{
super(AuthDialogFragment.this);
}
@Override
protected void loginOsm()
{
startActivity(new Intent(getContext(), OsmAuthActivity.class));
dismiss();
if (getArguments() == null)
return;
sendStats(getArguments(), Statistics.EventName.AUTH_START);
}
}
private class DialogImpl extends Dialog
{
DialogImpl()
{
super(requireActivity(), getTheme());
}
@Override
public void onBackPressed()
{
super.onBackPressed();
if (getArguments() == null)
return;
sendStats(getArguments(), Statistics.EventName.AUTH_DECLINED);
}
}
}

View file

@ -29,6 +29,7 @@ import com.mapswithme.maps.intent.Factory;
import com.mapswithme.maps.widget.SearchToolbarController;
import com.mapswithme.maps.widget.ToolbarController;
import com.mapswithme.util.ConnectionState;
import com.mapswithme.util.KeyValue;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.statistics.Statistics;
@ -313,30 +314,53 @@ public class EditorHostFragment extends BaseMwmToolbarFragment
private void saveMapObjectEdits()
{
if (Editor.nativeSaveEditedFeature())
{
Statistics.INSTANCE.trackEditorSuccess(mIsNewObject);
if (OsmOAuth.isAuthorized() || !ConnectionState.isConnected())
Utils.navigateToParent(getActivity());
else
{
final Activity parent = getActivity();
Intent intent = new Intent(parent, MwmActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.putExtra(MwmActivity.EXTRA_TASK,
new Factory.ShowDialogTask(AuthDialogFragment.class.getName()));
parent.startActivity(intent);
if (parent instanceof MwmActivity)
((MwmActivity) parent).customOnNavigateUp();
else
parent.finish();
}
}
processEditedFeatures();
else
processNoFeatures();
}
private void processNoFeatures()
{
Statistics.INSTANCE.trackEditorError(mIsNewObject);
DialogUtils.showAlertDialog(getActivity(), R.string.downloader_no_space_title);
}
private void processEditedFeatures()
{
Statistics.INSTANCE.trackEditorSuccess(mIsNewObject);
if (OsmOAuth.isAuthorized() || !ConnectionState.isConnected())
{
Statistics.INSTANCE.trackEditorError(mIsNewObject);
DialogUtils.showAlertDialog(getActivity(), R.string.downloader_no_space_title);
Utils.navigateToParent(getActivity());
return;
}
final Intent intent = makeParentActivityIntent();
final Activity parent = getActivity();
parent.startActivity(intent);
if (parent instanceof MwmActivity)
((MwmActivity) parent).customOnNavigateUp();
else
parent.finish();
}
private Intent makeParentActivityIntent()
{
Activity parent = getActivity();
Factory.ShowDialogTask task = new Factory.ShowDialogTask(AuthDialogFragment.class.getName(),
makeParams());
return new Intent(parent, MwmActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
.putExtra(MwmActivity.EXTRA_TASK, task);
}
private ArrayList<KeyValue> makeParams()
{
ArrayList<KeyValue> params = new ArrayList<>();
params.add(new KeyValue(Statistics.EventParam.FROM, mIsNewObject
? Statistics.ParamValue.NEW_OBJECT
: Statistics.ParamValue.EDIT_OBJECT));
return params;
}
private void saveNote()

View file

@ -65,6 +65,8 @@ public abstract class OsmAuthFragmentDelegate implements View.OnClickListener
Statistics.INSTANCE.trackEvent(Statistics.EventName.EDITOR_AUTH_REQUEST_RESULT,
Statistics.params().add(Statistics.EventParam.IS_SUCCESS, false).add(Statistics.EventParam.TYPE, type.name));
}
Statistics.INSTANCE.trackOsmAuthRequestStats(Statistics.EventName.AUTH_ERROR);
return;
}
@ -73,6 +75,7 @@ public abstract class OsmAuthFragmentDelegate implements View.OnClickListener
Utils.navigateToParent(mFragment.getActivity());
Statistics.INSTANCE.trackEvent(Statistics.EventName.EDITOR_AUTH_REQUEST_RESULT,
Statistics.params().add(Statistics.EventParam.IS_SUCCESS, true).add(Statistics.EventParam.TYPE, type.name));
Statistics.INSTANCE.trackOsmAuthRequestStats(Statistics.EventName.AUTH_EXTERNAL_REQUEST_SUCCESS);
}
protected void register()

View file

@ -3,6 +3,7 @@ package com.mapswithme.maps.intent;
import android.content.ContentResolver;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
@ -42,6 +43,7 @@ import com.mapswithme.maps.ugc.UGC;
import com.mapswithme.maps.ugc.UGCEditorActivity;
import com.mapswithme.util.Constants;
import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.KeyValue;
import com.mapswithme.util.StorageUtils;
import com.mapswithme.util.UTM;
import com.mapswithme.util.Utils;
@ -54,6 +56,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class Factory
@ -1269,11 +1273,20 @@ public class Factory
{
private static final long serialVersionUID = 1548931513812565018L;
@NonNull
private String mDialogName;
private final String mDialogName;
@NonNull
private final ArrayList<KeyValue> mKeyValues;
public ShowDialogTask(@NonNull String dialogName)
{
this(dialogName, new ArrayList<>());
}
public ShowDialogTask(@NonNull String dialogName, @NonNull ArrayList<KeyValue> keyValues)
{
mDialogName = dialogName;
mKeyValues = keyValues;
}
@Override
@ -1284,9 +1297,18 @@ public class Factory
return true;
final DialogFragment fragment = (DialogFragment) Fragment.instantiate(target, mDialogName);
fragment.setArguments(toDialogArgs(mKeyValues));
fragment.show(target.getSupportFragmentManager(), mDialogName);
return true;
}
@NonNull
private static Bundle toDialogArgs(@NonNull List<KeyValue> pairs)
{
Bundle bundle = new Bundle();
for (KeyValue each : pairs) bundle.putString(each.getKey(), each.getValue());
return bundle;
}
}
public static class ShowTutorialTask implements MapTask

View file

@ -15,6 +15,7 @@ import com.mapswithme.maps.Framework;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseToolbarAuthFragment;
import com.mapswithme.maps.background.Notifier;
import com.mapswithme.maps.bookmarks.AuthBundleFactory;
import com.mapswithme.maps.bookmarks.data.FeatureId;
import com.mapswithme.maps.metrics.UserActionsLogger;
import com.mapswithme.maps.widget.ToolbarController;
@ -126,7 +127,7 @@ public class UGCEditorFragment extends BaseToolbarAuthFragment
finishActivity();
return;
}
authorize();
authorize(AuthBundleFactory.saveReview());
});
}

View file

@ -11,6 +11,7 @@ import android.view.ViewGroup;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseAuthFragment;
import com.mapswithme.maps.bookmarks.AuthBundleFactory;
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.maps.bookmarks.data.CatalogCustomProperty;
@ -106,7 +107,7 @@ public class SendLinkPlaceholderFragment extends BaseAuthFragment implements Boo
if (uploadResult == BookmarkManager.UploadResult.UPLOAD_RESULT_SUCCESS)
onUploadSucceeded();
else if (uploadResult == BookmarkManager.UploadResult.UPLOAD_RESULT_AUTH_ERROR)
authorize();
authorize(AuthBundleFactory.exportBookmarks());
else
onUploadFailed();
}

View file

@ -20,6 +20,7 @@ import com.mapswithme.maps.Framework;
import com.mapswithme.maps.R;
import com.mapswithme.maps.base.BaseToolbarAuthFragment;
import com.mapswithme.maps.base.FinishActivityToolbarController;
import com.mapswithme.maps.bookmarks.AuthBundleFactory;
import com.mapswithme.maps.bookmarks.data.AbstractCategoriesSnapshot;
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
@ -346,7 +347,7 @@ public class UgcSharingOptionsFragment extends BaseToolbarAuthFragment implement
if (isAuthorized())
onPostAuthCompleted();
else
authorize();
authorize(AuthBundleFactory.exportBookmarks());
}
private void onPostAuthCompleted()

View file

@ -3,8 +3,11 @@ package com.mapswithme.util;
import androidx.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
public final class KeyValue
import java.io.Serializable;
public final class KeyValue implements Serializable
{
private static final long serialVersionUID = -3079360274128509979L;
@NonNull
@SerializedName("key")
private final String mKey;

View file

@ -60,6 +60,9 @@ import static com.mapswithme.util.BatteryState.CHARGING_STATUS_PLUGGED;
import static com.mapswithme.util.BatteryState.CHARGING_STATUS_UNKNOWN;
import static com.mapswithme.util.BatteryState.CHARGING_STATUS_UNPLUGGED;
import static com.mapswithme.util.statistics.Statistics.EventName.APPLICATION_COLD_STARTUP_INFO;
import static com.mapswithme.util.statistics.Statistics.EventName.AUTH_DECLINED;
import static com.mapswithme.util.statistics.Statistics.EventName.AUTH_ERROR;
import static com.mapswithme.util.statistics.Statistics.EventName.AUTH_EXTERNAL_REQUEST_SUCCESS;
import static com.mapswithme.util.statistics.Statistics.EventName.BM_BOOKMARKS_VISIBILITY_CHANGE;
import static com.mapswithme.util.statistics.Statistics.EventName.BM_GUIDES_DOWNLOADDIALOGUE_CLICK;
import static com.mapswithme.util.statistics.Statistics.EventName.BM_RESTORE_PROPOSAL_CLICK;
@ -103,7 +106,6 @@ import static com.mapswithme.util.statistics.Statistics.EventName.TOOLBAR_CLICK;
import static com.mapswithme.util.statistics.Statistics.EventName.TOOLBAR_MENU_CLICK;
import static com.mapswithme.util.statistics.Statistics.EventName.UGC_AUTH_ERROR;
import static com.mapswithme.util.statistics.Statistics.EventName.UGC_AUTH_EXTERNAL_REQUEST_SUCCESS;
import static com.mapswithme.util.statistics.Statistics.EventName.UGC_AUTH_SHOWN;
import static com.mapswithme.util.statistics.Statistics.EventName.UGC_REVIEW_START;
import static com.mapswithme.util.statistics.Statistics.EventParam.ACTION;
import static com.mapswithme.util.statistics.Statistics.EventParam.BANNER;
@ -387,6 +389,7 @@ public enum Statistics
public static final String SETTINGS_RECENT_TRACK_CHANGE = "Settings_RecentTrack_change";
public static final String MOBILE_INTERNET_ALERT = "MobileInternet_alert";
public static final String MAP_TOAST_SHOW = "Map_Toast_show";
public static final String AUTH_ERROR = "Auth_error";
static final String SETTINGS_TRACKING_DETAILS = "Settings_Tracking_details";
static final String SETTINGS_TRACKING_TOGGLE = "Settings_Tracking_toggle";
@ -560,6 +563,10 @@ public enum Statistics
static final String UGC_AUTH_ERROR = "UGC_Auth_error";
static final String MAP_LAYERS_CLICK = "Map_Layers_click";
public static final String AUTH_SHOWN = "Auth_shown";
public static final String AUTH_DECLINED = "Auth_declined";
public static final String AUTH_START = "Auth_start";
// Purchases.
public static final String INAPP_PURCHASE_PREVIEW_PAY = "InAppPurchase_Preview_pay";
public static final String INAPP_PURCHASE_PREVIEW_CANCEL = "InAppPurchase_Preview_cancel";
@ -596,6 +603,8 @@ public enum Statistics
public static final String DEEPLINK_CALL = "Deeplink_call";
public static final String DEEPLINK_CALL_MISSED = "Deeplink_call_missed";
public static final String AUTH_EXTERNAL_REQUEST_SUCCESS = "Auth_external_request_success";
public static final String AUTH_REQUEST_SUCCESS = "Auth_request_success";
public static class Settings
{
@ -655,6 +664,11 @@ public enum Statistics
public static final String STATUS = "status";
public static final String SOURCE = "source";
static final String ID = "id";
public static final String GUIDE_CATALOGUE = "guide_catalogue";
public static final String SUBSCRIPTION = "subscription";
public static final String EXPORT_BOOKMARKS = "export_bookmarks";
public static final String BOOKMARKS_BACKUP = "bookmarks_backup";
public static final String AFTER_SAVE_REVIEW = "after_save_review";
static final String TRACKS = "tracks";
static final String POINTS = "points";
static final String TOLL = "toll";
@ -774,6 +788,8 @@ public enum Statistics
public static final String BOOKMARK_LIST = "bookmark_list";
public static final String SHOW = "show";
public static final String HIDE = "hide";
public static final String NEW_OBJECT = "new_object";
public static final String EDIT_OBJECT = "edit_object";
static final String CRASH_REPORTS = "crash_reports";
static final String PERSONAL_ADS = "personal_ads";
public static final String MAP = "map";
@ -1498,9 +1514,9 @@ public enum Statistics
.get());
}
public void trackUGCAuthDialogShown()
public void trackAuthDialogAction(@NonNull String action, @NonNull String value)
{
trackEvent(UGC_AUTH_SHOWN, params().add(EventParam.FROM, ParamValue.AFTER_SAVE).get());
trackEvent(action, params().add(EventParam.FROM, value).get());
}
public void trackUGCExternalAuthSucceed(@NonNull String provider)
@ -1516,6 +1532,40 @@ public enum Statistics
.get());
}
public void trackAuthError(@Framework.AuthTokenType int type, @Nullable String error)
{
ParameterBuilder params = params()
.add(PROVIDER, getAuthProvider(type))
.add(ERROR, error);
trackEvent(AUTH_ERROR, params);
}
public void trackAuthExternalRequestSuccess(int type)
{
Map<String, String> params = Collections.singletonMap(Statistics.EventParam.PROVIDER,
Statistics.getAuthProvider(type));
trackEvent(AUTH_EXTERNAL_REQUEST_SUCCESS, params);
}
public void trackAuthDeclined(int type)
{
ParameterBuilder params = params().add(PROVIDER, getAuthProvider(type));
trackEvent(AUTH_DECLINED, params);
}
public void trackAuthRequestSuccess(int tokenType)
{
Map<String, String> params = Collections.singletonMap(PROVIDER,
getAuthProvider(tokenType));
trackEvent(EventName.AUTH_REQUEST_SUCCESS, params);
}
public void trackOsmAuthRequestStats(@NonNull String event)
{
trackEvent(event, Collections.singletonMap(PROVIDER,
ParamValue.OSM.toLowerCase()));
}
@NonNull
public static String getAuthProvider(@Framework.AuthTokenType int type)
{