[android] Added statistic for sight seeings in pp and added new gallery placements

This commit is contained in:
Александр Зацепин 2019-09-14 11:55:22 +03:00 committed by Aleksandr Zatsepin
parent 9591110749
commit f222592fdc
6 changed files with 100 additions and 30 deletions

View file

@ -6,6 +6,7 @@ import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import com.mapswithme.maps.base.BaseToolbarActivity;
import com.mapswithme.util.statistics.Statistics;
public class PlaceDescriptionActivity extends BaseToolbarActivity
{
@ -15,10 +16,15 @@ public class PlaceDescriptionActivity extends BaseToolbarActivity
return PlaceDescriptionFragment.class;
}
public static void start(@NonNull Context context, @NonNull String description)
public static void start(@NonNull Context context, @NonNull String description,
@NonNull String source)
{
Intent intent = new Intent(context, PlaceDescriptionActivity.class)
.putExtra(PlaceDescriptionFragment.EXTRA_DESCRIPTION, description);
context.startActivity(intent);
Statistics.ParameterBuilder builder = new Statistics.ParameterBuilder()
.add(Statistics.EventParam.SOURCE, source);
Statistics.INSTANCE.trackEvent(Statistics.EventName.PLACEPAGE_DESCRIPTION_MORE, builder.get(),
Statistics.STATISTICS_CHANNEL_REALTIME);
}
}

View file

@ -3,20 +3,17 @@ package com.mapswithme.maps.gallery.impl;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import com.mapswithme.maps.R;
import com.mapswithme.maps.discovery.LocalExpert;
import com.mapswithme.maps.gallery.Constants;
import com.mapswithme.maps.gallery.GalleryAdapter;
import com.mapswithme.maps.gallery.Holders;
import com.mapswithme.maps.gallery.ItemSelectedListener;
import com.mapswithme.maps.gallery.Items;
import com.mapswithme.maps.promo.PromoCityGallery;
import com.mapswithme.maps.promo.PromoEntity;
import com.mapswithme.maps.search.SearchResult;
import com.mapswithme.maps.widget.placepage.PlacePageView;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.statistics.GalleryPlacement;
import com.mapswithme.util.statistics.GalleryState;
import com.mapswithme.util.statistics.GalleryType;
@ -128,6 +125,6 @@ public class Factory
if (products.length == 0)
Statistics.INSTANCE.trackGalleryError(type, placement, Statistics.ParamValue.NO_PRODUCTS);
else
Statistics.INSTANCE.trackGalleryShown(type, state, placement);
Statistics.INSTANCE.trackGalleryShown(type, state, placement, products.length);
}
}

View file

@ -28,7 +28,9 @@ import com.mapswithme.maps.widget.recycler.ItemDecoratorFactory;
import com.mapswithme.util.NetworkPolicy;
import com.mapswithme.util.UTM;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.statistics.Destination;
import com.mapswithme.util.statistics.GalleryPlacement;
import com.mapswithme.util.statistics.GalleryState;
import com.mapswithme.util.statistics.GalleryType;
import com.mapswithme.util.statistics.Statistics;
@ -44,6 +46,8 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
private TextView mPromoTitle;
@NonNull
private final PlacePageView mPlacePageView;
@Nullable
private PromoRequester mPromoRequester;
public CatalogPromoController(@NonNull PlacePageView placePageView)
{
@ -81,7 +85,16 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
@Override
public void onErrorReceived()
{
Statistics.INSTANCE.trackGalleryError(GalleryType.PROMO, GalleryPlacement.PLACEPAGE,
if (mPromoRequester == null)
return;
GalleryPlacement placement;
if (mPromoRequester.getSponsoredType() == Sponsored.TYPE_PROMO_CATALOG_CITY)
placement = GalleryPlacement.PLACEPAGE_LARGE_TOPONYMS;
else
placement = GalleryPlacement.PLACEPAGE_SIGHTSEEINGS;
Statistics.INSTANCE.trackGalleryError(GalleryType.PROMO, placement,
Statistics.ParamValue.NO_PRODUCTS);
}
@ -96,11 +109,11 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
if (sponsored == null || mapObject == null)
return;
PromoRequester requester = createPromoRequester(sponsored.getType());
if (requester == null)
mPromoRequester = createPromoRequester(sponsored.getType());
if (mPromoRequester == null)
return;
requester.requestPromo(policy, mapObject);
mPromoRequester.requestPromo(policy, mapObject);
}
@Override
@ -124,7 +137,7 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
switch (type)
{
case Sponsored.TYPE_PROMO_CATALOG_SIGHTSEEINGS:
return new PoiPromoRequester();
return new SightseeingsPromoRequester();
case Sponsored.TYPE_PROMO_CATALOG_CITY:
return new CityPromoRequester();
default:
@ -145,17 +158,19 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
return null;
if (items.length == 1)
return new PoiPromoResponseHandler();
return new SinglePromoResponseHandler(type);
return new GalleryPromoResponseHandler();
return new GalleryPromoResponseHandler(type);
}
interface PromoRequester
{
void requestPromo(@NonNull NetworkPolicy policy, @NonNull MapObject mapObject);
@Sponsored.SponsoredType
int getSponsoredType();
}
static class PoiPromoRequester implements PromoRequester
static class SightseeingsPromoRequester implements PromoRequester
{
@Override
public void requestPromo(@NonNull NetworkPolicy policy, @NonNull MapObject mapObject)
@ -163,6 +178,12 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
Promo.INSTANCE.nativeRequestPoiGallery(policy, mapObject.getLat(), mapObject.getLon(),
mapObject.getRawTypes(), UTM.UTM_SIGHTSEEINGS_PLACEPAGE_GALLERY);
}
@Override
public int getSponsoredType()
{
return Sponsored.TYPE_PROMO_CATALOG_SIGHTSEEINGS;
}
}
static class CityPromoRequester implements PromoRequester
@ -173,6 +194,12 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
Promo.INSTANCE.nativeRequestCityGallery(policy, mapObject.getLat(), mapObject.getLon(),
UTM.UTM_LARGE_TOPONYMS_PLACEPAGE_GALLERY);
}
@Override
public int getSponsoredType()
{
return Sponsored.TYPE_PROMO_CATALOG_CITY;
}
}
interface PromoResponseHandler
@ -180,8 +207,16 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
void handleResponse(@NonNull PromoCityGallery promo);
}
class PoiPromoResponseHandler implements PromoResponseHandler
class SinglePromoResponseHandler implements PromoResponseHandler
{
@Sponsored.SponsoredType
private final int mSponsoredType;
SinglePromoResponseHandler(int sponsoredType)
{
mSponsoredType = sponsoredType;
}
@Override
public void handleResponse(@NonNull PromoCityGallery promo)
{
@ -195,7 +230,10 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
UiUtils.hide(mPromoRecycler);
mPromoTitle.setText(R.string.pp_discovery_place_related_header);
PromoCityGallery.Item item = items[0];
final PromoCityGallery.Item item = items[0];
final GalleryPlacement placement = mSponsoredType == Sponsored.TYPE_PROMO_CATALOG_SIGHTSEEINGS
? GalleryPlacement.PLACEPAGE_SIGHTSEEINGS
: GalleryPlacement.PLACEPAGE_LARGE_TOPONYMS;
ImageView poiImage = mPlacePageView.findViewById(R.id.promo_poi_image);
Glide.with(poiImage.getContext())
@ -208,8 +246,7 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
TextView authorName = mPlacePageView.findViewById(R.id.place_single_bookmark_author);
authorName.setText(item.getAuthor().getName());
View cta = mPlacePageView.findViewById(R.id.place_single_bookmark_cta);
cta.setOnClickListener(v -> BookmarksCatalogActivity.start(mPlacePageView.getContext(),
item.getUrl()));
cta.setOnClickListener(v -> onCtaClicked(placement, item.getUrl()));
PromoCityGallery.Place place = item.getPlace();
@ -220,12 +257,31 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
poiDescription.setText(Html.fromHtml(place.getDescription()));
View more = mPlacePageView.findViewById(R.id.promo_poi_more);
more.setOnClickListener(v -> PlaceDescriptionActivity.start(mPlacePageView.getContext(),
place.getDescription()));
place.getDescription(),
Statistics.ParamValue.MAPSME_GUIDES));
Statistics.INSTANCE.trackGalleryShown(GalleryType.PROMO, GalleryState.OFFLINE,
placement, 1);
}
private void onCtaClicked(@NonNull GalleryPlacement placement, @NonNull String url)
{
BookmarksCatalogActivity.start(mPlacePageView.getContext(), url);
Statistics.INSTANCE.trackGalleryProductItemSelected(GalleryType.PROMO, placement, 0,
Destination.CATALOGUE);
}
}
class GalleryPromoResponseHandler implements PromoResponseHandler
{
@Sponsored.SponsoredType
private final int mSponsoredType;
GalleryPromoResponseHandler(int sponsoredType)
{
mSponsoredType = sponsoredType;
}
@Override
public void handleResponse(@NonNull PromoCityGallery promo)
{
@ -236,17 +292,22 @@ public class CatalogPromoController implements Promo.Listener, Detachable<Activi
Resources resources = mPlacePageView.getResources();
String category = promo.getCategory();
String title = TextUtils.isEmpty(category) ? resources.getString(R.string.guides)
: resources.getString(R.string.pp_discovery_place_related_tag_header,
promo.getCategory());
boolean isSightseeings = !TextUtils.isEmpty(category)
&& mSponsoredType == Sponsored.TYPE_PROMO_CATALOG_SIGHTSEEINGS;
String title;
if (isSightseeings)
title = resources.getString(R.string.pp_discovery_place_related_tag_header, promo.getCategory());
else
title = resources.getString(R.string.guides);
mPromoTitle.setText(title);
String url = promo.getMoreUrl();
GalleryPlacement placement = isSightseeings ? GalleryPlacement.PLACEPAGE_SIGHTSEEINGS :
GalleryPlacement.PLACEPAGE_LARGE_TOPONYMS;
RegularCatalogPromoListener promoListener = new RegularCatalogPromoListener(Objects.requireNonNull(mActivity),
GalleryPlacement.PLACEPAGE);
placement);
GalleryAdapter adapter = Factory.createCatalogPromoAdapter(mActivity, promo, url,
promoListener,
GalleryPlacement.PLACEPAGE);
promoListener, placement);
mPromoRecycler.setAdapter(adapter);
}
}

View file

@ -772,11 +772,9 @@ public class PlacePageView extends NestedScrollView
private void showDescriptionScreen()
{
Statistics.INSTANCE.trackEvent(Statistics.EventName.PLACEPAGE_DESCRIPTION_MORE,
Statistics.STATISTICS_CHANNEL_REALTIME);
Context context = mPlaceDescriptionContainer.getContext();
String description = Objects.requireNonNull(mMapObject).getDescription();
PlaceDescriptionActivity.start(context, description);
PlaceDescriptionActivity.start(context, description, Statistics.ParamValue.WIKIPEDIA);
}
private void initEditMapObjectBtn()

View file

@ -3,5 +3,7 @@ package com.mapswithme.util.statistics;
public enum GalleryPlacement
{
PLACEPAGE,
DISCOVERY;
DISCOVERY,
PLACEPAGE_LARGE_TOPONYMS,
PLACEPAGE_SIGHTSEEINGS;
}

View file

@ -105,6 +105,8 @@ import static com.mapswithme.util.statistics.Statistics.EventParam.BATTERY;
import static com.mapswithme.util.statistics.Statistics.EventParam.BUTTON;
import static com.mapswithme.util.statistics.Statistics.EventParam.CATEGORY;
import static com.mapswithme.util.statistics.Statistics.EventParam.CHARGING;
import static com.mapswithme.util.statistics.Statistics.EventParam.COUNT;
import static com.mapswithme.util.statistics.Statistics.EventParam.COUNT_LOWERCASE;
import static com.mapswithme.util.statistics.Statistics.EventParam.DESTINATION;
import static com.mapswithme.util.statistics.Statistics.EventParam.ERROR;
import static com.mapswithme.util.statistics.Statistics.EventParam.ERROR_CODE;
@ -599,6 +601,7 @@ public enum Statistics
static final String CATEGORY = "category";
public static final String TAB = "tab";
static final String COUNT = "Count";
static final String COUNT_LOWERCASE = "count";
static final String CHANNEL = "Channel";
static final String CALLER_ID = "Caller ID";
public static final String ENABLED = "Enabled";
@ -660,6 +663,7 @@ public enum Statistics
static final String PURCHASE = "purchase";
static final String SERVER_ID = "server_id";
static final String SERVER_IDS = "server_ids";
public static final String SOURCE = "source";
private EventParam() {}
}
@ -747,6 +751,7 @@ public enum Statistics
public static final String BY_TYPE = "Type";
public static final String BOOKMARKS_LIST = "BookmarksList";
static final String PARTNER = "Partner";
public static final String WIKIPEDIA = "wikipedia";
}
// Initialized once in constructor and does not change until the process restarts.
@ -1207,12 +1212,13 @@ public enum Statistics
}
public void trackGalleryShown(@NonNull GalleryType type, @NonNull GalleryState state,
@NonNull GalleryPlacement placement)
@NonNull GalleryPlacement placement, int itemsCount)
{
trackEvent(PP_SPONSORED_SHOWN, Statistics.params()
.add(PROVIDER, type.getProvider())
.add(PLACEMENT, placement.toString())
.add(STATE, state.toString()));
.add(STATE, state.toString())
.add(COUNT_LOWERCASE, itemsCount));
if (state == GalleryState.ONLINE)
MyTracker.trackEvent(PP_SPONSORED_SHOWN + "_" + type.getProvider());