diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 13227c678f..874b3fba00 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -82,6 +82,7 @@ import com.mapswithme.maps.promo.PromoBookingDialogFragment; import com.mapswithme.maps.purchase.AdsRemovalActivationCallback; import com.mapswithme.maps.purchase.AdsRemovalPurchaseControllerProvider; import com.mapswithme.maps.purchase.BookmarkSubscriptionActivity; +import com.mapswithme.maps.purchase.BookmarkSubscriptionFragment; import com.mapswithme.maps.purchase.FailedPurchaseChecker; import com.mapswithme.maps.purchase.PurchaseCallback; import com.mapswithme.maps.purchase.PurchaseController; @@ -742,7 +743,9 @@ public class MwmActivity extends BaseMwmFragmentActivity private void openBookmarkSubscriptionScreen() { - Intent intent = new Intent(this, BookmarkSubscriptionActivity.class); + Intent intent = new Intent(this, BookmarkSubscriptionActivity.class) + .putExtra(BookmarkSubscriptionFragment.EXTRA_ORIGIN_PARAM, + Statistics.ParamValue.SPONSORED_BUTTON); startActivityForResult(intent, PurchaseUtils.REQ_CODE_PAY_SUBSCRIPTION); } diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java b/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java index 9ae043dcc1..01eb553516 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java @@ -387,7 +387,8 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment if (frag == null || frag.getActivity() == null) return; - BookmarkSubscriptionActivity.startForResult(frag, PurchaseUtils.REQ_CODE_PAY_SUBSCRIPTION); + BookmarkSubscriptionActivity.startForResult(frag, PurchaseUtils.REQ_CODE_PAY_SUBSCRIPTION, + Statistics.ParamValue.WEBVIEW); } @Override diff --git a/android/src/com/mapswithme/maps/bookmarks/InvalidSubscriptionAlertDialogCallback.java b/android/src/com/mapswithme/maps/bookmarks/InvalidSubscriptionAlertDialogCallback.java index 04685df0a0..b31014d947 100644 --- a/android/src/com/mapswithme/maps/bookmarks/InvalidSubscriptionAlertDialogCallback.java +++ b/android/src/com/mapswithme/maps/bookmarks/InvalidSubscriptionAlertDialogCallback.java @@ -9,6 +9,7 @@ import com.mapswithme.maps.purchase.BookmarkSubscriptionActivity; import com.mapswithme.maps.purchase.PurchaseUtils; import com.mapswithme.util.log.Logger; import com.mapswithme.util.log.LoggerFactory; +import com.mapswithme.util.statistics.Statistics; class InvalidSubscriptionAlertDialogCallback implements AlertDialogCallback { @@ -23,7 +24,8 @@ class InvalidSubscriptionAlertDialogCallback implements AlertDialogCallback @Override public void onAlertDialogPositiveClick(int requestCode, int which) { - BookmarkSubscriptionActivity.startForResult(mFragment, PurchaseUtils.REQ_CODE_PAY_CONTINUE_SUBSCRIPTION); + BookmarkSubscriptionActivity.startForResult(mFragment, PurchaseUtils.REQ_CODE_PAY_CONTINUE_SUBSCRIPTION, + Statistics.ParamValue.POPUP); } @Override diff --git a/android/src/com/mapswithme/maps/purchase/BookmarkPaymentFragment.java b/android/src/com/mapswithme/maps/purchase/BookmarkPaymentFragment.java index 8872dcc58e..64cb2e24ef 100644 --- a/android/src/com/mapswithme/maps/purchase/BookmarkPaymentFragment.java +++ b/android/src/com/mapswithme/maps/purchase/BookmarkPaymentFragment.java @@ -110,7 +110,10 @@ public class BookmarkPaymentFragment extends BaseMwmFragment private void onBuySubscriptionClicked() { - BookmarkSubscriptionActivity.startForResult(this, PurchaseUtils.REQ_CODE_PAY_SUBSCRIPTION); + Bundle extras = new Bundle(); + extras.putString(BookmarkSubscriptionFragment.EXTRA_ORIGIN_PARAM, Statistics.ParamValue.CARD); + BookmarkSubscriptionActivity.startForResult(this, PurchaseUtils.REQ_CODE_PAY_SUBSCRIPTION, + Statistics.ParamValue.CARD); } @Override diff --git a/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionActivity.java b/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionActivity.java index c66fe4c484..8663cbe141 100644 --- a/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionActivity.java +++ b/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionActivity.java @@ -20,10 +20,12 @@ public class BookmarkSubscriptionActivity extends BaseMwmFragmentActivity return false; } - public static void startForResult(@NonNull Fragment fragment, int requestCode) + public static void startForResult(@NonNull Fragment fragment, int requestCode, + @NonNull String extra) { Intent intent = new Intent(fragment.getActivity(), BookmarkSubscriptionActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + intent.putExtra(BookmarkSubscriptionFragment.EXTRA_ORIGIN_PARAM, extra) + .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); fragment.startActivityForResult(intent, requestCode); } } diff --git a/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java b/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java index 0858f4ac34..0553ceea4b 100644 --- a/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java +++ b/android/src/com/mapswithme/maps/purchase/BookmarkSubscriptionFragment.java @@ -33,6 +33,8 @@ import java.util.List; public class BookmarkSubscriptionFragment extends BaseAuthFragment implements AlertDialogCallback, PurchaseStateActivator { + public static final String EXTRA_ORIGIN_PARAM = "extra_origin_from"; + private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.BILLING); private static final String TAG = BookmarkSubscriptionFragment.class.getSimpleName(); private final static String EXTRA_CURRENT_STATE = "extra_current_state"; @@ -91,10 +93,20 @@ public class BookmarkSubscriptionFragment extends BaseAuthFragment Statistics.INSTANCE.trackPurchasePreviewShow(PrivateVariables.bookmarksSubscriptionServerId(), PrivateVariables.bookmarksSubscriptionVendor(), - PrivateVariables.bookmarksSubscriptionYearlyProductId()); + PrivateVariables.bookmarksSubscriptionYearlyProductId(), + getExtraOriginParam()); return root; } + @Nullable + private String getExtraOriginParam() + { + if (getArguments() == null) + return null; + + return getArguments().getString(EXTRA_ORIGIN_PARAM, null); + } + @Override public void onDestroyView() { diff --git a/android/src/com/mapswithme/util/statistics/Statistics.java b/android/src/com/mapswithme/util/statistics/Statistics.java index 6d65924c02..bdeeb0c1a4 100644 --- a/android/src/com/mapswithme/util/statistics/Statistics.java +++ b/android/src/com/mapswithme/util/statistics/Statistics.java @@ -110,6 +110,7 @@ import static com.mapswithme.util.statistics.Statistics.EventParam.ERROR; import static com.mapswithme.util.statistics.Statistics.EventParam.ERROR_CODE; import static com.mapswithme.util.statistics.Statistics.EventParam.ERROR_MESSAGE; import static com.mapswithme.util.statistics.Statistics.EventParam.FEATURE_ID; +import static com.mapswithme.util.statistics.Statistics.EventParam.FROM; import static com.mapswithme.util.statistics.Statistics.EventParam.HAS_AUTH; import static com.mapswithme.util.statistics.Statistics.EventParam.HOTEL; import static com.mapswithme.util.statistics.Statistics.EventParam.HOTEL_LAT; @@ -684,6 +685,10 @@ public enum Statistics public static final String ASK = "ask"; public static final String TODAY = "today"; public static final String NOT_TODAY = "not_today"; + public static final String CARD = "card"; + public static final String SPONSORED_BUTTON = "sponsored_button"; + public static final String POPUP = "popup"; + public static final String WEBVIEW = "webview"; static final String SEARCH_BOOKING_COM = "Search.Booking.Com"; static final String OPENTABLE = "OpenTable"; static final String LOCALS_EXPERTS = "Locals.Maps.Me"; @@ -1608,13 +1613,23 @@ public enum Statistics .add(BUTTON, isCross ? 0 : 1)); } + public void trackPurchasePreviewShow(@NonNull String purchaseId, @NonNull String vendor, + @NonNull String productId, @Nullable String from) + { + ParameterBuilder params = params().add(VENDOR, vendor) + .add(PRODUCT, productId) + .add(PURCHASE, purchaseId); + if (!TextUtils.isEmpty(from)) + params.add(FROM, from); + + trackEvent(INAPP_PURCHASE_PREVIEW_SHOW, params, + STATISTICS_CHANNEL_REALTIME); + } + public void trackPurchasePreviewShow(@NonNull String purchaseId, @NonNull String vendor, @NonNull String productId) { - trackEvent(INAPP_PURCHASE_PREVIEW_SHOW, params().add(VENDOR, vendor) - .add(PRODUCT, productId) - .add(PURCHASE, purchaseId), - STATISTICS_CHANNEL_REALTIME); + trackPurchasePreviewShow(purchaseId, vendor, productId, null); } public void trackPurchaseEvent(@NonNull String event, @NonNull String purchaseId)