forked from organicmaps/organicmaps
[android] Recovered and finally fixed place page view tracking statistic
This commit is contained in:
parent
21ade67ef1
commit
f01b4f3516
6 changed files with 122 additions and 78 deletions
|
@ -1482,61 +1482,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
});
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public void onPreviewVisibilityChanged(boolean isVisible)
|
||||
{
|
||||
if (mVisibleRectMeasurer != null)
|
||||
mVisibleRectMeasurer.setPreviewVisible(isVisible);
|
||||
|
||||
if (isVisible)
|
||||
{
|
||||
if (mMainMenu.isAnimating() || mMainMenu.isOpen())
|
||||
UiThread.runLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (mMainMenu.close(true))
|
||||
mFadeView.fadeOut();
|
||||
}
|
||||
}, BaseMenu.ANIMATION_DURATION * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Framework.nativeDeactivatePopup();
|
||||
mPlacePage.setMapObject(null, false, null);
|
||||
if (mPlacePageTracker != null)
|
||||
mPlacePageTracker.onHidden();
|
||||
}
|
||||
}*/
|
||||
|
||||
/* @Override
|
||||
public void onPlacePageVisibilityChanged(boolean isVisible)
|
||||
{
|
||||
if (mVisibleRectMeasurer != null)
|
||||
mVisibleRectMeasurer.setPlacePageVisible(isVisible);
|
||||
|
||||
Statistics.INSTANCE.trackEvent(isVisible ? Statistics.EventName.PP_OPEN
|
||||
: Statistics.EventName.PP_CLOSE);
|
||||
AlohaHelper.logClick(isVisible ? AlohaHelper.PP_OPEN
|
||||
: AlohaHelper.PP_CLOSE);
|
||||
if (mPlacePageTracker != null && isVisible)
|
||||
{
|
||||
mPlacePageTracker.onOpened();
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void onProgress(float translationX, float translationY)
|
||||
{
|
||||
if (mNavAnimationController != null)
|
||||
mNavAnimationController.move(translationY);
|
||||
if (mPlacePageTracker != null)
|
||||
mPlacePageTracker.onMove();
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onPlacePageSlide(int top)
|
||||
{
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import static com.mapswithme.util.statistics.Statistics.EventName.PP_BANNER_CLICK;
|
||||
import static com.mapswithme.util.statistics.Statistics.EventName.PP_BANNER_SHOW;
|
||||
import static com.mapswithme.util.statistics.Statistics.PP_BANNER_STATE_DETAILS;
|
||||
import static com.mapswithme.util.statistics.Statistics.PP_BANNER_STATE_PREVIEW;
|
||||
|
||||
|
@ -117,11 +116,14 @@ final class BannerController
|
|||
private int mOpenedHeight;
|
||||
@NonNull
|
||||
private final BannerDetailsRequester mBannerDetailsRequester;
|
||||
@NonNull
|
||||
private final BannerStateListener mBannerStateListener;
|
||||
|
||||
BannerController(@NonNull ViewGroup bannerContainer, @NonNull CompoundNativeAdLoader loader,
|
||||
@Nullable AdTracker tracker,
|
||||
@NonNull AdsRemovalPurchaseControllerProvider adsRemovalProvider,
|
||||
@NonNull BannerDetailsRequester bannerDetailsRequester)
|
||||
@NonNull BannerDetailsRequester bannerDetailsRequester,
|
||||
@NonNull BannerStateListener bannerStateListener)
|
||||
{
|
||||
LOGGER.d(TAG, "Constructor()");
|
||||
mContainerView = bannerContainer;
|
||||
|
@ -134,6 +136,7 @@ final class BannerController
|
|||
mOpenedHeight = resources.getDimensionPixelSize(R.dimen.placepage_banner_large_height);
|
||||
mAdsRemovalProvider = adsRemovalProvider;
|
||||
mBannerDetailsRequester = bannerDetailsRequester;
|
||||
mBannerStateListener = bannerStateListener;
|
||||
initBannerViews();
|
||||
}
|
||||
|
||||
|
@ -267,8 +270,8 @@ final class BannerController
|
|||
if (mCurrentAd != null)
|
||||
{
|
||||
loadIcon(mCurrentAd);
|
||||
Statistics.INSTANCE.trackPPBanner(PP_BANNER_SHOW, mCurrentAd, 1);
|
||||
mCurrentAd.registerView(mBannerView);
|
||||
mBannerStateListener.onBannerDetails(mCurrentAd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +302,10 @@ final class BannerController
|
|||
mTitle.setMaxLines(MIN_TITLE_LINES);
|
||||
updateVisibility();
|
||||
if (mCurrentAd != null)
|
||||
{
|
||||
mCurrentAd.registerView(mBannerView);
|
||||
mBannerStateListener.onBannerPreview(mCurrentAd);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadIcon(@NonNull MwmNativeAd ad)
|
||||
|
@ -385,7 +391,7 @@ final class BannerController
|
|||
else
|
||||
{
|
||||
close();
|
||||
Statistics.INSTANCE.trackPPBanner(PP_BANNER_SHOW, mCurrentAd, PP_BANNER_STATE_PREVIEW);
|
||||
mBannerStateListener.onBannerPreview(mCurrentAd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,4 +455,10 @@ final class BannerController
|
|||
{
|
||||
boolean shouldShowBannerDetails();
|
||||
}
|
||||
|
||||
interface BannerStateListener
|
||||
{
|
||||
void onBannerDetails(@NonNull MwmNativeAd ad);
|
||||
void onBannerPreview(@NonNull MwmNativeAd ad);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.mapswithme.maps.Framework;
|
|||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.ads.CompoundNativeAdLoader;
|
||||
import com.mapswithme.maps.ads.DefaultAdTracker;
|
||||
import com.mapswithme.maps.ads.MwmNativeAd;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.maps.location.LocationListener;
|
||||
|
@ -30,7 +31,8 @@ import com.trafi.anchorbottomsheetbehavior.AnchorBottomSheetBehavior;
|
|||
|
||||
public class BottomSheetPlacePageController implements PlacePageController, LocationListener,
|
||||
View.OnLayoutChangeListener,
|
||||
BannerController.BannerDetailsRequester
|
||||
BannerController.BannerDetailsRequester,
|
||||
BannerController.BannerStateListener
|
||||
{
|
||||
private static final float ANCHOR_RATIO = 0.3f;
|
||||
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
|
||||
|
@ -82,18 +84,21 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
|
|||
LOGGER.d(TAG, "State change, new = " + BottomSheetPlacePageController.toString(newState)
|
||||
+ " old = " + BottomSheetPlacePageController.toString(oldState)
|
||||
+ " placepage height = " + mPlacePage.getHeight());
|
||||
if (newState == AnchorBottomSheetBehavior.STATE_SETTLING
|
||||
|| newState == AnchorBottomSheetBehavior.STATE_DRAGGING)
|
||||
if (isSettlingState(newState) || isDraggingState(newState))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (newState == AnchorBottomSheetBehavior.STATE_HIDDEN)
|
||||
if (isHiddenState(newState))
|
||||
{
|
||||
Framework.nativeDeactivatePopup();
|
||||
UiUtils.invisible(mButtonsLayout);
|
||||
mPlacePageTracker.onHidden();
|
||||
}
|
||||
|
||||
if (isAnchoredState(newState) || isExpandedState(newState))
|
||||
mPlacePageTracker.onDetails();
|
||||
|
||||
setPeekHeight();
|
||||
}
|
||||
|
||||
|
@ -101,6 +106,7 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
|
|||
public void onSlide(@NonNull View bottomSheet, float slideOffset)
|
||||
{
|
||||
mSlideListener.onPlacePageSlide(bottomSheet.getTop());
|
||||
mPlacePageTracker.onMove();
|
||||
|
||||
if (slideOffset < 0)
|
||||
return;
|
||||
|
@ -188,16 +194,17 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
|
|||
|
||||
ViewGroup bannerContainer = mPlacePage.findViewById(R.id.banner_container);
|
||||
DefaultAdTracker tracker = new DefaultAdTracker();
|
||||
CompoundNativeAdLoader loader = com.mapswithme.maps.ads.Factory.createCompoundLoader(tracker, tracker);
|
||||
CompoundNativeAdLoader loader = com.mapswithme.maps.ads.Factory.createCompoundLoader(tracker,
|
||||
tracker);
|
||||
mBannerController = new BannerController(bannerContainer, loader, tracker,
|
||||
mPurchaseControllerProvider, this);
|
||||
mPurchaseControllerProvider, this, this);
|
||||
|
||||
mButtonsLayout = mActivity.findViewById(R.id.pp_buttons_layout);
|
||||
ViewGroup buttons = mButtonsLayout.findViewById(R.id.container);
|
||||
mPlacePage.initButtons(buttons);
|
||||
UiUtils.bringViewToFrontOf(mButtonsLayout, mPlacePage);
|
||||
UiUtils.bringViewToFrontOf(mActivity.findViewById(R.id.app_bar), mPlacePage);
|
||||
mPlacePageTracker = new PlacePageTracker(mPlacePage, buttons);
|
||||
mPlacePageTracker = new PlacePageTracker(mPlacePage, mButtonsLayout);
|
||||
LocationHelper.INSTANCE.addListener(this);
|
||||
}
|
||||
|
||||
|
@ -229,7 +236,8 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
|
|||
|
||||
private void showBanner(@NonNull MapObject object, NetworkPolicy policy)
|
||||
{
|
||||
boolean canShowBanner = object.getMapObjectType() != MapObject.MY_POSITION && policy.сanUseNetwork();
|
||||
boolean canShowBanner = object.getMapObjectType() != MapObject.MY_POSITION
|
||||
&& policy.сanUseNetwork();
|
||||
mBannerController.updateData(canShowBanner ? object.getBanners() : null);
|
||||
}
|
||||
|
||||
|
@ -420,12 +428,14 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
|
|||
@Override
|
||||
public void onSave(@NonNull Bundle outState)
|
||||
{
|
||||
mPlacePageTracker.onSave(outState);
|
||||
outState.putParcelable(EXTRA_MAP_OBJECT, mPlacePage.getMapObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestore(@NonNull Bundle inState)
|
||||
{
|
||||
mPlacePageTracker.onRestore(inState);
|
||||
if (mPlacePageBehavior.getState() == AnchorBottomSheetBehavior.STATE_HIDDEN)
|
||||
return;
|
||||
|
||||
|
@ -528,4 +538,16 @@ public class BottomSheetPlacePageController implements PlacePageController, Loca
|
|||
int state = mPlacePageBehavior.getState();
|
||||
return isAnchoredState(state) || isExpandedState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBannerDetails(@NonNull MwmNativeAd ad)
|
||||
{
|
||||
mPlacePageTracker.onBannerDetails(ad);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBannerPreview(@NonNull MwmNativeAd ad)
|
||||
{
|
||||
mPlacePageTracker.onBannerPreview(ad);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1283,7 +1283,6 @@ public class PlacePageView extends NestedScrollView
|
|||
logo.setImageResource(type.getIcon());
|
||||
TextView title = mTaxi.findViewById(R.id.tv__place_page_taxi);
|
||||
title.setText(type.getTitle());
|
||||
Statistics.INSTANCE.trackTaxiEvent(Statistics.EventName.ROUTING_TAXI_SHOW_IN_PP, type.getProviderName());
|
||||
}
|
||||
|
||||
private void hideHotelDetailViews()
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package com.mapswithme.util.statistics;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.ads.MwmNativeAd;
|
||||
import com.mapswithme.maps.base.Savable;
|
||||
import com.mapswithme.maps.bookmarks.data.MapObject;
|
||||
import com.mapswithme.maps.taxi.TaxiType;
|
||||
import com.mapswithme.maps.widget.placepage.PlacePageView;
|
||||
|
@ -14,9 +17,18 @@ import com.mapswithme.util.UiUtils;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class PlacePageTracker
|
||||
import static com.mapswithme.util.statistics.Statistics.EventName.PP_BANNER_SHOW;
|
||||
import static com.mapswithme.util.statistics.Statistics.PP_BANNER_STATE_DETAILS;
|
||||
import static com.mapswithme.util.statistics.Statistics.PP_BANNER_STATE_PREVIEW;
|
||||
|
||||
public class PlacePageTracker implements Savable<Bundle>
|
||||
{
|
||||
private static final float VISIBILITY_RATIO_TAXI = 0.6f;
|
||||
private static final String EXTRA_TAXI_TRACKED = "extra_taxi_tracked";
|
||||
private static final String EXTRA_SPONSORED_TRACKED = "extra_sponsored_tracked";
|
||||
private static final String EXTRA_BANNER_DETAILS_TRACKED = "extra_banner_details_tracked";
|
||||
private static final String EXTRA_BANNER_PREVIEW_TRACKED = "extra_banner_preview_tracked";
|
||||
private static final String EXTRA_PP_DETAILS_OPENED_TRACKED = "extra_pp_details_opened_tracked";
|
||||
@NonNull
|
||||
private final PlacePageView mPlacePageView;
|
||||
@NonNull
|
||||
|
@ -26,6 +38,10 @@ public class PlacePageTracker
|
|||
@Nullable
|
||||
private MapObject mMapObject;
|
||||
private boolean mTaxiTracked;
|
||||
private boolean mSponsoredTracked;
|
||||
private boolean mBannerDetailsTracked;
|
||||
private boolean mBannerPreviewTracked;
|
||||
private boolean mPpDetailsOpenedTracked;
|
||||
|
||||
public PlacePageTracker(@NonNull PlacePageView placePageView, @NonNull View bottomButtons)
|
||||
{
|
||||
|
@ -46,18 +62,49 @@ public class PlacePageTracker
|
|||
|
||||
public void onHidden()
|
||||
{
|
||||
mMapObject = null;
|
||||
mTaxiTracked = false;
|
||||
mSponsoredTracked = false;
|
||||
mBannerDetailsTracked = false;
|
||||
mBannerPreviewTracked = false;
|
||||
mPpDetailsOpenedTracked = false;
|
||||
}
|
||||
|
||||
public void onOpened()
|
||||
public void onBannerDetails(@Nullable MwmNativeAd ad)
|
||||
{
|
||||
// TODO:
|
||||
/* if (mPlacePageView.getState() == PlacePageView.State.DETAILS)
|
||||
if (mBannerDetailsTracked)
|
||||
return;
|
||||
|
||||
Statistics.INSTANCE.trackPPBanner(PP_BANNER_SHOW, ad, PP_BANNER_STATE_DETAILS);
|
||||
mBannerDetailsTracked = true;
|
||||
}
|
||||
|
||||
public void onBannerPreview(@Nullable MwmNativeAd ad)
|
||||
{
|
||||
if (mBannerPreviewTracked)
|
||||
return;
|
||||
|
||||
Statistics.INSTANCE.trackPPBanner(PP_BANNER_SHOW, ad, PP_BANNER_STATE_PREVIEW);
|
||||
mBannerPreviewTracked = true;
|
||||
}
|
||||
|
||||
public void onDetails()
|
||||
{
|
||||
if (!mSponsoredTracked)
|
||||
{
|
||||
Sponsored sponsored = mPlacePageView.getSponsored();
|
||||
if (sponsored != null)
|
||||
{
|
||||
Statistics.INSTANCE.trackSponsoredOpenEvent(sponsored);
|
||||
}*/
|
||||
mSponsoredTracked = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mPpDetailsOpenedTracked)
|
||||
{
|
||||
Statistics.INSTANCE.trackEvent(Statistics.EventName.PP_DETAILS_OPEN);
|
||||
mPpDetailsOpenedTracked = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void trackTaxiVisibility()
|
||||
|
@ -68,7 +115,7 @@ public class PlacePageTracker
|
|||
if (taxiTypes != null && !taxiTypes.isEmpty())
|
||||
{
|
||||
String providerName = taxiTypes.get(0).getProviderName();
|
||||
Statistics.INSTANCE.trackTaxiEvent(Statistics.EventName.ROUTING_TAXI_REAL_SHOW_IN_PP,
|
||||
Statistics.INSTANCE.trackTaxiEvent(Statistics.EventName.ROUTING_TAXI_SHOW,
|
||||
providerName);
|
||||
mTaxiTracked = true;
|
||||
}
|
||||
|
@ -80,6 +127,7 @@ public class PlacePageTracker
|
|||
* @param visibilityRatio Describes what the portion of view should be visible before
|
||||
* the view is considered visible on the screen. It can be from 0 to 1.
|
||||
*/
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private boolean isViewOnScreen(@NonNull View view, float visibilityRatio) {
|
||||
|
||||
if (UiUtils.isInvisible(mPlacePageView))
|
||||
|
@ -95,4 +143,24 @@ public class PlacePageTracker
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSave(@NonNull Bundle outState)
|
||||
{
|
||||
outState.putBoolean(EXTRA_SPONSORED_TRACKED, mSponsoredTracked);
|
||||
outState.putBoolean(EXTRA_TAXI_TRACKED, mTaxiTracked);
|
||||
outState.putBoolean(EXTRA_BANNER_DETAILS_TRACKED, mBannerDetailsTracked);
|
||||
outState.putBoolean(EXTRA_BANNER_PREVIEW_TRACKED, mBannerPreviewTracked);
|
||||
outState.putBoolean(EXTRA_PP_DETAILS_OPENED_TRACKED, mPpDetailsOpenedTracked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestore(@NonNull Bundle inState)
|
||||
{
|
||||
mSponsoredTracked = inState.getBoolean(EXTRA_SPONSORED_TRACKED);
|
||||
mTaxiTracked = inState.getBoolean(EXTRA_TAXI_TRACKED);
|
||||
mBannerDetailsTracked = inState.getBoolean(EXTRA_BANNER_DETAILS_TRACKED);
|
||||
mBannerPreviewTracked = inState.getBoolean(EXTRA_BANNER_PREVIEW_TRACKED);
|
||||
mPpDetailsOpenedTracked = inState.getBoolean(EXTRA_PP_DETAILS_OPENED_TRACKED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -298,8 +298,7 @@ public enum Statistics
|
|||
public static final String SEARCH_FILTER_CLICK = "Search_Filter_Click";
|
||||
|
||||
// place page
|
||||
public static final String PP_OPEN = "PP. Open";
|
||||
public static final String PP_CLOSE = "PP. Close";
|
||||
public static final String PP_DETAILS_OPEN = "Placepage_Details_open";
|
||||
public static final String PP_SHARE = "PP. Share";
|
||||
public static final String PP_BOOKMARK = "PP. Bookmark";
|
||||
public static final String PP_ROUTE = "PP. Route";
|
||||
|
@ -369,8 +368,7 @@ public enum Statistics
|
|||
public static final String ROUTING_SETTINGS = "Routing. Settings";
|
||||
public static final String ROUTING_TAXI_ORDER = "Routing_Taxi_order";
|
||||
public static final String ROUTING_TAXI_INSTALL = "Routing_Taxi_install";
|
||||
public static final String ROUTING_TAXI_SHOW_IN_PP = "Placepage_Taxi_show";
|
||||
public static final String ROUTING_TAXI_REAL_SHOW_IN_PP = "Placepage_Taxi_show_real";
|
||||
public static final String ROUTING_TAXI_SHOW = "Placepage_Taxi_show";
|
||||
public static final String ROUTING_TAXI_CLICK_IN_PP = "Placepage_Taxi_click";
|
||||
public static final String ROUTING_TAXI_ROUTE_BUILT = "Routing_Build_Taxi";
|
||||
public static final String ROUTING_POINT_ADD = "Routing_Point_add";
|
||||
|
|
Loading…
Add table
Reference in a new issue