Refactored, fixed and improved routing start/finish statistic

This commit is contained in:
Alexander Zatsepin 2018-07-09 15:07:57 +03:00 committed by Vlad Mihaylenko
parent a6f1e73022
commit d31350b452
8 changed files with 199 additions and 191 deletions

View file

@ -793,11 +793,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
}
}
public void closeMenu(String statEvent, String alohaStatEvent, @Nullable Runnable procAfterClose)
public void closeMenu(@Nullable Runnable procAfterClose)
{
Statistics.INSTANCE.trackEvent(statEvent);
AlohaHelper.logClick(alohaStatEvent);
mFadeView.fadeOut();
mMainMenu.close(true, procAfterClose);
}
@ -813,20 +810,15 @@ public class MwmActivity extends BaseMwmFragmentActivity
return false;
}
public void startLocationToPoint(String statisticsEvent, String alohaEvent,
final @Nullable MapObject endPoint,
public void startLocationToPoint(String statisticsEvent, final @Nullable MapObject endPoint,
final boolean canUseMyPositionAsStart)
{
closeMenu(statisticsEvent, alohaEvent, new Runnable()
{
@Override
public void run()
{
RoutingController.get().prepare(canUseMyPositionAsStart, endPoint);
Statistics.INSTANCE.trackEvent(statisticsEvent);
closeMenu(() -> {
RoutingController.get().prepare(canUseMyPositionAsStart, endPoint);
if (mPlacePage != null && (mPlacePage.isDocked() || !mPlacePage.isFloating()))
closePlacePage();
}
if (mPlacePage != null && (mPlacePage.isDocked() || !mPlacePage.isFloating()))
closePlacePage();
});
}
@ -846,113 +838,75 @@ public class MwmActivity extends BaseMwmFragmentActivity
private void initMainMenu()
{
mMainMenu = new MainMenu(findViewById(R.id.menu_frame), new BaseMenu.ItemClickListener<MainMenu.Item>()
{
@Override
public void onItemClick(MainMenu.Item item)
mMainMenu = new MainMenu(findViewById(R.id.menu_frame), item -> {
if (mIsFullscreenAnimating)
return;
switch (item)
{
if (mIsFullscreenAnimating)
return;
switch (item)
case TOGGLE:
if (!mMainMenu.isOpen())
{
case TOGGLE:
if (!mMainMenu.isOpen())
{
if (mPlacePage == null || (mPlacePage.isDocked() && closePlacePage()))
return;
if (mPlacePage == null || (mPlacePage.isDocked() && closePlacePage()))
return;
if (closeSidePanel())
return;
}
Statistics.INSTANCE.trackEvent(Statistics.EventName.TOOLBAR_MENU);
AlohaHelper.logClick(AlohaHelper.TOOLBAR_MENU);
toggleMenu();
break;
case ADD_PLACE:
closePlacePage();
if (mIsTabletLayout)
closeSidePanel();
closeMenu(Statistics.EventName.MENU_ADD_PLACE, AlohaHelper.MENU_ADD_PLACE, new Runnable()
{
@Override
public void run()
{
Statistics.INSTANCE.trackEvent(Statistics.EventName.EDITOR_ADD_CLICK,
Statistics.params().add(Statistics.EventParam.FROM, "main_menu"));
showPositionChooser(false, false);
}
});
break;
case SEARCH:
RoutingController.get().cancel();
closeMenu(Statistics.EventName.TOOLBAR_SEARCH, AlohaHelper.TOOLBAR_SEARCH, new Runnable()
{
@Override
public void run()
{
showSearch(mSearchController.getQuery());
}
});
break;
case P2P:
startLocationToPoint(Statistics.EventName.MENU_P2P, AlohaHelper.MENU_POINT2POINT,
null /* endPoint */, false /* canUseMyPositionAsStart */);
break;
case DISCOVERY:
showDiscovery();
break;
case BOOKMARKS:
closeMenu(Statistics.EventName.TOOLBAR_BOOKMARKS, AlohaHelper.TOOLBAR_BOOKMARKS, new Runnable()
{
@Override
public void run()
{
showBookmarks();
}
});
break;
case SHARE:
closeMenu(Statistics.EventName.MENU_SHARE, AlohaHelper.MENU_SHARE, new Runnable()
{
@Override
public void run()
{
shareMyLocation();
}
});
break;
case DOWNLOADER:
RoutingController.get().cancel();
closeMenu(Statistics.EventName.MENU_DOWNLOADER, AlohaHelper.MENU_DOWNLOADER, new Runnable()
{
@Override
public void run()
{
showDownloader(false);
}
});
break;
case SETTINGS:
closeMenu(Statistics.EventName.MENU_SETTINGS, AlohaHelper.MENU_SETTINGS, new Runnable()
{
@Override
public void run()
{
startActivity(new Intent(MwmActivity.this, SettingsActivity.class));
}
});
break;
if (closeSidePanel())
return;
}
Statistics.INSTANCE.trackEvent(Statistics.EventName.TOOLBAR_MENU);
AlohaHelper.logClick(AlohaHelper.TOOLBAR_MENU);
toggleMenu();
break;
case ADD_PLACE:
closePlacePage();
if (mIsTabletLayout)
closeSidePanel();
Statistics.INSTANCE.trackEvent(Statistics.EventName.MENU_ADD_PLACE);
closeMenu(() -> {
Statistics.INSTANCE.trackEvent(Statistics.EventName.EDITOR_ADD_CLICK,
Statistics.params()
.add(Statistics.EventParam.FROM, "main_menu"));
showPositionChooser(false, false);
});
break;
case SEARCH:
RoutingController.get().cancel();
Statistics.INSTANCE.trackEvent(Statistics.EventName.TOOLBAR_SEARCH);
closeMenu(() -> showSearch(mSearchController.getQuery()));
break;
case P2P:
startLocationToPoint(Statistics.EventName.MENU_P2P, null, false);
break;
case DISCOVERY:
showDiscovery();
break;
case BOOKMARKS:
Statistics.INSTANCE.trackEvent(Statistics.EventName.TOOLBAR_BOOKMARKS);
closeMenu(this::showBookmarks);
break;
case SHARE:
Statistics.INSTANCE.trackEvent(Statistics.EventName.MENU_SHARE);
closeMenu(this::shareMyLocation);
break;
case DOWNLOADER:
RoutingController.get().cancel();
Statistics.INSTANCE.trackEvent(Statistics.EventName.MENU_DOWNLOADER);
closeMenu(() -> showDownloader(false));
break;
case SETTINGS:
Statistics.INSTANCE.trackEvent(Statistics.EventName.MENU_SETTINGS);
Intent intent = new Intent(MwmActivity.this, SettingsActivity.class);
closeMenu(() -> startActivity(intent));
break;
}
});
@ -1417,7 +1371,16 @@ public class MwmActivity extends BaseMwmFragmentActivity
return;
}
if (!closePlacePage() && !closeSidePanel() && !RoutingController.get().cancel()
boolean isRoutingCancelled = RoutingController.get().cancel();
if (isRoutingCancelled)
{
@Framework.RouterType
int type = RoutingController.get().getLastRouterType();
Statistics.INSTANCE.trackRoutingFinish(true, type,
TrafficManager.INSTANCE.isEnabled());
}
if (!closePlacePage() && !closeSidePanel() && !isRoutingCancelled
&& !closePositionChooser())
{
try
@ -2406,6 +2369,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
showLocationNotFoundDialog();
}
@Override
public void onRoutingFinish()
{
Statistics.INSTANCE.trackRoutingFinish(false, RoutingController.get().getLastRouterType(),
TrafficManager.INSTANCE.isEnabled());
}
private void showLocationNotFoundDialog()
{
String message = String.format("%s\n\n%s", getString(R.string.current_location_unknown_message),
@ -2446,6 +2416,15 @@ public class MwmActivity extends BaseMwmFragmentActivity
}
}
@Override
public void onRoutingStart()
{
@Framework.RouterType
int routerType = RoutingController.get().getLastRouterType();
Statistics.INSTANCE.trackRoutingStart(routerType, TrafficManager.INSTANCE.isEnabled());
closeMenu(() -> RoutingController.get().start());
}
@Override
public void onBookmarksLoadingStarted()
{

View file

@ -283,6 +283,8 @@ public enum LocationHelper
{
mLogger.d(TAG, "End point is reached");
restart();
if (mUiCallback != null)
mUiCallback.onRoutingFinish();
RoutingController.get().cancel();
}
}
@ -680,5 +682,6 @@ public enum LocationHelper
void onCompassUpdated(@NonNull CompassData compass);
void onLocationError();
void onLocationNotFound();
void onRoutingFinish();
}
}

View file

@ -21,9 +21,9 @@ import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity;
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.maplayer.traffic.TrafficManager;
import com.mapswithme.maps.settings.SettingsActivity;
import com.mapswithme.maps.sound.TtsPlayer;
import com.mapswithme.maps.maplayer.traffic.TrafficManager;
import com.mapswithme.maps.widget.FlatProgressView;
import com.mapswithme.maps.widget.menu.NavMenu;
import com.mapswithme.util.Animations;
@ -31,7 +31,6 @@ import com.mapswithme.util.Graphics;
import com.mapswithme.util.StringUtils;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.statistics.AlohaHelper;
import com.mapswithme.util.statistics.Statistics;
import java.text.DateFormat;
@ -148,51 +147,39 @@ public class NavigationController implements TrafficManager.TrafficCallback, Vie
private NavMenu createNavMenu()
{
return new NavMenu(mBottomFrame, new NavMenu.ItemClickListener<NavMenu.Item>()
{
@Override
public void onItemClick(NavMenu.Item item)
return new NavMenu(mBottomFrame, item -> {
final MwmActivity parent = ((MwmActivity) mFrame.getContext());
switch (item)
{
final MwmActivity parent = ((MwmActivity) mFrame.getContext());
switch (item)
{
case STOP:
mNavMenu.close(false /* animate */);
RoutingController.get().cancel();
break;
case SETTINGS:
parent.closeMenu(Statistics.EventName.ROUTING_SETTINGS, AlohaHelper.MENU_SETTINGS, new Runnable()
{
@Override
public void run()
{
parent.startActivity(new Intent(parent, SettingsActivity.class));
}
});
break;
case TTS_VOLUME:
TtsPlayer.setEnabled(!TtsPlayer.isEnabled());
mNavMenu.refreshTts();
Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_CLOSE);
AlohaHelper.logClick(AlohaHelper.ROUTING_CLOSE);
break;
case TRAFFIC:
TrafficManager.INSTANCE.toggle();
mNavMenu.refreshTraffic();
//TODO: Add statistics reporting (in separate task)
break;
case TOGGLE:
mNavMenu.toggle(true);
parent.refreshFade();
}
case STOP:
mNavMenu.close(false /* animate */);
Statistics.INSTANCE.trackRoutingFinish(true,
RoutingController.get().getLastRouterType(),
TrafficManager.INSTANCE.isEnabled());
RoutingController.get().cancel();
break;
case SETTINGS:
Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_SETTINGS);
parent.closeMenu(() -> parent.startActivity(new Intent(parent, SettingsActivity.class)));
break;
case TTS_VOLUME:
TtsPlayer.setEnabled(!TtsPlayer.isEnabled());
mNavMenu.refreshTts();
break;
case TRAFFIC:
TrafficManager.INSTANCE.toggle();
mNavMenu.refreshTraffic();
//TODO: Add statistics reporting (in separate task)
break;
case TOGGLE:
mNavMenu.toggle(true);
parent.refreshFade();
}
});
}
public void stop(MwmActivity parent)
{
Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_CLOSE);
AlohaHelper.logClick(AlohaHelper.ROUTING_CLOSE);
parent.refreshFade();
mSearchWheel.reset();
}

View file

@ -22,23 +22,20 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.mapswithme.maps.Framework;
import com.mapswithme.maps.MwmActivity;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.data.MapObject;
import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.maps.taxi.TaxiAdapter;
import com.mapswithme.maps.taxi.TaxiInfo;
import com.mapswithme.util.SponsoredLinks;
import com.mapswithme.maps.taxi.TaxiManager;
import com.mapswithme.maps.widget.DotPager;
import com.mapswithme.maps.widget.recycler.DotDividerItemDecoration;
import com.mapswithme.maps.widget.recycler.MultilineLayoutManager;
import com.mapswithme.util.Graphics;
import com.mapswithme.util.SponsoredLinks;
import com.mapswithme.util.ThemeUtils;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
import com.mapswithme.util.statistics.AlohaHelper;
import com.mapswithme.util.statistics.Statistics;
import java.util.List;
import java.util.Locale;
@ -254,31 +251,13 @@ final class RoutingBottomMenuController implements View.OnClickListener
{
mStart.setText(Utils.isAppInstalled(mContext, mTaxiInfo.getType().getPackageName())
? R.string.taxi_order : R.string.install_app);
mStart.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
handleTaxiClick();
}
});
mStart.setOnClickListener(v -> handleTaxiClick());
} else
{
mStart.setText(mContext.getText(R.string.p2p_start));
mStart.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
((MwmActivity)mContext).closeMenu(Statistics.EventName.ROUTING_START, AlohaHelper.ROUTING_START, new Runnable()
{
@Override
public void run()
{
RoutingController.get().start();
}
});
}
mStart.setOnClickListener(v -> {
if (mListener != null)
mListener.onRoutingStart();
});
}

View file

@ -4,4 +4,5 @@ public interface RoutingBottomMenuListener
{
void onUseMyPositionAsStart();
void onSearchRoutePoint(@RoutePointInfo.RouteMarkType int type);
void onRoutingStart();
}

View file

@ -512,8 +512,6 @@ public class RoutingController implements TaxiManager.TaxiListener
return;
}
Statistics.INSTANCE.trackEvent(Statistics.EventName.ROUTING_START);
AlohaHelper.logClick(AlohaHelper.ROUTING_START);
setState(State.NAVIGATION);
if (mContainer != null)
@ -1047,6 +1045,12 @@ public class RoutingController implements TaxiManager.TaxiListener
build();
}
@Framework.RouterType
public int getLastRouterType()
{
return mLastRouterType;
}
private void openRemovingIntermediatePointsTransaction()
{
if (mRemovingIntermediatePointsTransactionId == mInvalidRoutePointsTransactionId)

View file

@ -576,8 +576,8 @@ public class PlacePageView extends RelativeLayout
}
else
{
getActivity().startLocationToPoint(Statistics.EventName.PP_ROUTE, AlohaHelper.PP_ROUTE,
getMapObject(), true /* canUseMyPositionAsStart */);
getActivity().startLocationToPoint(Statistics.EventName.PP_ROUTE, getMapObject(),
true);
}
break;

View file

@ -73,6 +73,8 @@ import static com.mapswithme.util.statistics.Statistics.EventName.PP_SPONSORED_O
import static com.mapswithme.util.statistics.Statistics.EventName.PP_SPONSORED_SHOWN;
import static com.mapswithme.util.statistics.Statistics.EventName.PP_SPONSOR_ITEM_SELECTED;
import static com.mapswithme.util.statistics.Statistics.EventName.ROUTING_PLAN_TOOLTIP_CLICK;
import static com.mapswithme.util.statistics.Statistics.EventName.ROUTING_ROUTE_FINISH;
import static com.mapswithme.util.statistics.Statistics.EventName.ROUTING_ROUTE_START;
import static com.mapswithme.util.statistics.Statistics.EventName.SEARCH_FILTER_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;
@ -91,6 +93,7 @@ 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;
import static com.mapswithme.util.statistics.Statistics.EventParam.HOTEL_LON;
import static com.mapswithme.util.statistics.Statistics.EventParam.INTERRUPTED;
import static com.mapswithme.util.statistics.Statistics.EventParam.ITEM;
import static com.mapswithme.util.statistics.Statistics.EventParam.MAP_DATA_SIZE;
import static com.mapswithme.util.statistics.Statistics.EventParam.METHOD;
@ -109,6 +112,7 @@ import static com.mapswithme.util.statistics.Statistics.EventParam.STATE;
import static com.mapswithme.util.statistics.Statistics.EventParam.TYPE;
import static com.mapswithme.util.statistics.Statistics.EventParam.VALUE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.BACKUP;
import static com.mapswithme.util.statistics.Statistics.ParamValue.BICYCLE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.BOOKING_COM;
import static com.mapswithme.util.statistics.Statistics.ParamValue.DISK_NO_SPACE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.FACEBOOK;
@ -117,10 +121,15 @@ import static com.mapswithme.util.statistics.Statistics.ParamValue.HOLIDAY;
import static com.mapswithme.util.statistics.Statistics.ParamValue.MAPSME;
import static com.mapswithme.util.statistics.Statistics.ParamValue.NO_BACKUP;
import static com.mapswithme.util.statistics.Statistics.ParamValue.OPENTABLE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.PEDESTRIAN;
import static com.mapswithme.util.statistics.Statistics.ParamValue.PHONE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.RESTORE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.SEARCH_BOOKING_COM;
import static com.mapswithme.util.statistics.Statistics.ParamValue.TAXI;
import static com.mapswithme.util.statistics.Statistics.ParamValue.TRAFFIC;
import static com.mapswithme.util.statistics.Statistics.ParamValue.TRANSIT;
import static com.mapswithme.util.statistics.Statistics.ParamValue.UNKNOWN;
import static com.mapswithme.util.statistics.Statistics.ParamValue.VEHICLE;
import static com.mapswithme.util.statistics.Statistics.ParamValue.VIATOR;
public enum Statistics
@ -259,8 +268,8 @@ public enum Statistics
// routing
public static final String ROUTING_BUILD = "Routing. Build";
public static final String ROUTING_START_SUGGEST_REBUILD = "Routing. Suggest rebuild";
public static final String ROUTING_START = "Routing. Start";
public static final String ROUTING_CLOSE = "Routing. Close";
public static final String ROUTING_ROUTE_START = "Routing_Route_start";
public static final String ROUTING_ROUTE_FINISH = "Routing_Route_finish";
public static final String ROUTING_CANCEL = "Routing. Cancel";
public static final String ROUTING_VEHICLE_SET = "Routing. Set vehicle";
public static final String ROUTING_PEDESTRIAN_SET = "Routing. Set pedestrian";
@ -398,6 +407,7 @@ public enum Statistics
public static final String DATE = "date";
static final String HAS_AUTH = "has_auth";
public static final String STATUS = "status";
static final String INTERRUPTED = "interrupted";
private EventParam() {}
}
@ -449,6 +459,11 @@ public enum Statistics
static final String TRAFFIC = "traffic";
public static final String SUCCESS = "success";
public static final String UNAVAILABLE = "unavailable";
static final String PEDESTRIAN = "pedestrian";
static final String VEHICLE = "vehicle";
static final String BICYCLE = "bicycle";
static final String TAXI = "taxi";
static final String TRANSIT = "transit";
}
// Initialized once in constructor and does not change until the process restarts.
@ -1013,6 +1028,46 @@ public enum Statistics
.get());
}
public void trackRoutingStart(@Framework.RouterType int type,
boolean trafficEnabled)
{
trackEvent(ROUTING_ROUTE_START, prepareRouteParams(type, trafficEnabled));
}
public void trackRoutingFinish(boolean interrupted, @Framework.RouterType int type,
boolean trafficEnabled)
{
ParameterBuilder params = prepareRouteParams(type, trafficEnabled);
trackEvent(ROUTING_ROUTE_FINISH, params.add(INTERRUPTED, interrupted ? 1 : 0));
}
@NonNull
private static ParameterBuilder prepareRouteParams(@Framework.RouterType int type,
boolean trafficEnabled)
{
return params().add(MODE, toRouterType(type)).add(TRAFFIC, trafficEnabled ? 1 : 0);
}
@NonNull
private static String toRouterType(@Framework.RouterType int type)
{
switch (type)
{
case Framework.ROUTER_TYPE_VEHICLE:
return VEHICLE;
case Framework.ROUTER_TYPE_PEDESTRIAN:
return PEDESTRIAN;
case Framework.ROUTER_TYPE_BICYCLE:
return BICYCLE;
case Framework.ROUTER_TYPE_TAXI:
return TAXI;
case Framework.ROUTER_TYPE_TRANSIT:
return TRANSIT;
default:
throw new AssertionError("Unsupported router type: " + type);
}
}
public void trackRoutingTooltipEvent(@RoutePointInfo.RouteMarkType int type,
boolean isPlanning)
{