Refactor analytics

This commit is contained in:
crimean 2019-05-28 21:19:18 +03:00
parent 28f81077e3
commit 6c7175d175
27 changed files with 50 additions and 41 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View file

@ -48,6 +48,7 @@ import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dialogs.ErrorBottomSheetDialog;
import net.osmand.plus.dialogs.RateUsBottomSheetDialog;
import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.AvoidSpecificRoads;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
@ -918,10 +919,9 @@ public class OsmandApplication extends MultiDexApplication {
}
}
public void logEvent(Activity ctx, String event) {
public void logEvent(String event) {
try {
if (Version.isGooglePlayEnabled(this) && !Version.isPaidVersion(this)
&& !osmandSettings.DO_NOT_SEND_ANONYMOUS_APP_USAGE.get()) {
if (osmandSettings.SEND_ANONYMOUS_APP_USAGE_DATA.get()) {
analyticsHelper.addEvent(event);
}
} catch (Exception e) {
@ -929,6 +929,16 @@ public class OsmandApplication extends MultiDexApplication {
}
}
public void logMapDownloadEvent(String event, IndexItem item) {
try {
if (osmandSettings.SEND_ANONYMOUS_MAP_DOWNLOADS_DATA.get()) {
analyticsHelper.addEvent("map_download_" + event + ": " + item.getFileName());
}
} catch (Exception e) {
LOG.error(e);
}
}
public void restartApp(Context ctx) {
AlertDialog.Builder bld = new AlertDialog.Builder(ctx);
bld.setMessage(R.string.restart_is_required);

View file

@ -1036,7 +1036,8 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> DO_NOT_SHOW_STARTUP_MESSAGES = new BooleanPreference("do_not_show_startup_messages", false).makeGlobal().cache();
public final OsmandPreference<Boolean> DO_NOT_USE_ANIMATIONS = new BooleanPreference("do_not_use_animations", false).makeGlobal().cache();
public final OsmandPreference<Boolean> DO_NOT_SEND_ANONYMOUS_APP_USAGE = new BooleanPreference("do_not_send_anonymous_app_usage", false).makeGlobal().cache();
public final OsmandPreference<Boolean> SEND_ANONYMOUS_MAP_DOWNLOADS_DATA = new BooleanPreference("send_anonymous_map_downloads_data", false).makeGlobal().cache();
public final OsmandPreference<Boolean> SEND_ANONYMOUS_APP_USAGE_DATA = new BooleanPreference("send_anonymous_app_usage_data", false).makeGlobal().cache();
public final OsmandPreference<Boolean> MAP_EMPTY_STATE_ALLOWED = new BooleanPreference("map_empty_state_allowed", true).makeGlobal().cache();

View file

@ -637,7 +637,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_dashboard_open");
app.logEvent("drawer_dashboard_open");
MapActivity.clearPrevActivityIntent();
mapActivity.closeDrawer();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, viewCoordinates);
@ -651,7 +651,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_markers_open");
app.logEvent("drawer_markers_open");
MapActivity.clearPrevActivityIntent();
MapMarkersDialogFragment.showInstance(mapActivity);
return true;
@ -664,7 +664,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_myplaces_open");
app.logEvent("drawer_myplaces_open");
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getFavoritesActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@ -679,7 +679,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_search_open");
app.logEvent("drawer_search_open");
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW_IF_EXPIRED, false);
return true;
}
@ -692,7 +692,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_directions_open");
app.logEvent("drawer_directions_open");
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
if (mapControlsLayer != null) {
mapControlsLayer.doRoute(false);
@ -720,7 +720,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_config_map_open");
app.logEvent("drawer_config_map_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, viewCoordinates);
return false;
@ -740,7 +740,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_download_maps_open");
app.logEvent("drawer_download_maps_open");
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getDownloadActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@ -756,7 +756,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_osm_live_open");
app.logEvent("drawer_osm_live_open");
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);
@ -804,7 +804,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_config_screen_open");
app.logEvent("drawer_config_screen_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, viewCoordinates);
return false;
@ -817,7 +817,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_plugins_open");
app.logEvent("drawer_plugins_open");
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
.getPluginsActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@ -832,7 +832,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_settings_open");
app.logEvent("drawer_settings_open");
final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization()
.getSettingsActivity());
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@ -860,7 +860,7 @@ public class MapActivityActions implements DialogProvider {
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_help_open");
app.logEvent("drawer_help_open");
Intent intent = new Intent(mapActivity, HelpActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);

View file

@ -89,11 +89,11 @@ public class OsmandInAppPurchaseActivity extends AppCompatActivity implements In
if (app.isPlusVersionInApp()) {
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
if (purchaseHelper != null) {
app.logEvent(activity, "in_app_purchase_redirect");
app.logEvent("in_app_purchase_redirect");
purchaseHelper.purchaseFullVersion(activity);
}
} else {
app.logEvent(activity, "paid_version_redirect");
app.logEvent("paid_version_redirect");
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(Version.getUrlWithUtmRef(app, "net.osmand.plus")));
try {
@ -110,7 +110,7 @@ public class OsmandInAppPurchaseActivity extends AppCompatActivity implements In
if (app != null) {
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
if (purchaseHelper != null) {
app.logEvent(activity, "depth_contours_purchase_redirect");
app.logEvent("depth_contours_purchase_redirect");
purchaseHelper.purchaseDepthContours(activity);
}
}
@ -177,7 +177,7 @@ public class OsmandInAppPurchaseActivity extends AppCompatActivity implements In
@Override
public void onItemPurchased(String sku, boolean active) {
if (purchaseHelper != null && purchaseHelper.getLiveUpdates().containsSku(sku)) {
getMyApplication().logEvent(this, "live_osm_subscription_purchased");
getMyApplication().logEvent("live_osm_subscription_purchased");
if (!active) {
OsmLiveRestartBottomSheetDialogFragment fragment = new OsmLiveRestartBottomSheetDialogFragment();

View file

@ -504,10 +504,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
misc.addPreference(createCheckBoxPreference(settings.MAP_EMPTY_STATE_ALLOWED, R.string.tap_on_map_to_hide_interface, R.string.tap_on_map_to_hide_interface_descr));
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES, R.string.do_not_show_startup_messages, R.string.do_not_show_startup_messages_desc));
misc.addPreference(createCheckBoxPreference(settings.ANIMATE_MY_LOCATION,R.string.animate_my_location, R.string.animate_my_location_desc));
OsmandApplication app = getMyApplication();
if (Version.isGooglePlayEnabled(getMyApplication()) && !Version.isPaidVersion(app)) {
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SEND_ANONYMOUS_APP_USAGE, R.string.do_not_send_anonymous_app_usage, R.string.do_not_send_anonymous_app_usage_desc));
}
}

View file

@ -88,9 +88,9 @@ public class ChoosePlanFreeBannerDialogFragment extends ChoosePlanDialogFragment
if (activity != null) {
OsmandApplication app = getOsmandApplication();
if (app.isPlusVersionInApp()) {
app.logEvent(getActivity(), "in_app_purchase_redirect_from_banner");
app.logEvent("in_app_purchase_redirect_from_banner");
} else {
app.logEvent(getActivity(), "paid_version_redirect_from_banner");
app.logEvent("paid_version_redirect_from_banner");
dismiss();
}
OsmandInAppPurchaseActivity.purchaseFullVersion(activity);

View file

@ -402,7 +402,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
&& isDownlodingPermitted(ctx.getMyApplication().getSettings())) {
collapseBanner();
} else {
ctx.getMyApplication().logEvent(ctx, "click_free_dialog");
ctx.getMyApplication().logEvent("click_free_dialog");
ChoosePlanDialogFragment.showFreeVersionInstance(ctx.getSupportFragmentManager());
}
}

View file

@ -3,7 +3,6 @@ package net.osmand.plus.download;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
@ -35,7 +34,6 @@ import net.osmand.plus.Version;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.DownloadFileHelper.DownloadFileShowWarning;
import net.osmand.plus.helpers.DatabaseHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.util.Algorithms;
@ -264,7 +262,7 @@ public class DownloadIndexesThread {
}
}
if (uiActivity instanceof Activity) {
app.logEvent((Activity) uiActivity, "download_files");
app.logEvent("download_files");
}
for(IndexItem item : items) {
if (!item.equals(currentDownloadingItem) && !indexItemDownloading.contains(item)) {
@ -279,6 +277,7 @@ public class DownloadIndexesThread {
}
public void cancelDownload(IndexItem item) {
app.logMapDownloadEvent("cancel", item);
if (currentDownloadingItem == item) {
downloadFileHelper.setInterruptDownloading(true);
} else {
@ -291,6 +290,7 @@ public class DownloadIndexesThread {
if (items != null) {
boolean updateProgress = false;
for (IndexItem item : items) {
app.logMapDownloadEvent("cancel", item);
if (currentDownloadingItem == item) {
downloadFileHelper.setInterruptDownloading(true);
} else {
@ -532,9 +532,9 @@ public class DownloadIndexesThread {
}
setTag(item);
boolean result = downloadFile(item, filesToReindex, forceWifi);
checkDownload(item);
success = result || success;
if (result) {
checkDownload(item);
if (DownloadActivityType.isCountedInDownloads(item)) {
downloads.set(downloads.get() + 1);
}
@ -664,6 +664,7 @@ public class DownloadIndexesThread {
LOG.error("Copy exception", e);
}
} else {
app.logMapDownloadEvent("start", item);
res = downloadFileHelper.downloadFile(de, this, filesToReindex, this, forceWifi);
}
return res;
@ -677,6 +678,7 @@ public class DownloadIndexesThread {
}
private void checkDownload(IndexItem item) {
app.logMapDownloadEvent("done", item);
Map<String, String> params = new HashMap<>();
params.put("file_name", item.fileName);
params.put("file_size", item.size);

View file

@ -330,7 +330,7 @@ public class ItemViewHolder {
public void onClick(View v) {
switch (clickAction) {
case ASK_FOR_FULL_VERSION_PURCHASE:
context.getMyApplication().logEvent(context, "in_app_purchase_show_from_wiki_context_menu");
context.getMyApplication().logEvent("in_app_purchase_show_from_wiki_context_menu");
ChoosePlanDialogFragment.showWikipediaInstance(context.getSupportFragmentManager());
break;
case ASK_FOR_DEPTH_CONTOURS_PURCHASE:

View file

@ -261,7 +261,7 @@ public class DiscountHelper {
View.OnClickListener clickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
mapActivity.getMyApplication().logEvent(mapActivity, "motd_click");
mapActivity.getMyApplication().logEvent("motd_click");
mBannerVisible = false;
mapActivity.hideTopToolbar(toolbarController);
openUrl(mapActivity, data.url);
@ -274,7 +274,7 @@ public class DiscountHelper {
toolbarController.setOnCloseButtonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mapActivity.getMyApplication().logEvent(mapActivity, "motd_close");
mapActivity.getMyApplication().logEvent("motd_close");
mBannerVisible = false;
mapActivity.hideTopToolbar(toolbarController);
}
@ -303,7 +303,7 @@ public class DiscountHelper {
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
if (purchaseHelper != null) {
if (url.contains(purchaseHelper.getFullVersion().getSku())) {
app.logEvent(mapActivity, "in_app_purchase_redirect");
app.logEvent("in_app_purchase_redirect");
purchaseHelper.purchaseFullVersion(mapActivity);
} else {
for (InAppPurchase p : purchaseHelper.getLiveUpdates().getAllSubscriptions()) {

View file

@ -436,7 +436,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
@Nullable Object object) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null && init(latLon, pointDescription, object)) {
mapActivity.getMyApplication().logEvent(mapActivity, "open_context_menu");
mapActivity.getMyApplication().logEvent("open_context_menu");
showInternal();
}
}

View file

@ -252,7 +252,7 @@ public class MapillaryPlugin extends OsmandPlugin {
}
public static boolean installMapillary(Activity activity, OsmandApplication app) {
app.logEvent(activity, "install_mapillary");
app.logEvent("install_mapillary");
boolean success = execInstall(app, Version.getUrlWithUtmRef(app, MAPILLARY_PACKAGE_ID));
if (!success) {
success = execInstall(app, "https://play.google.com/store/apps/details?id=" + MAPILLARY_PACKAGE_ID);

View file

@ -58,7 +58,7 @@ public class FavoritesActivity extends TabActivity {
app.applyTheme(this);
super.onCreate(icicle);
app.logEvent(this, "myplaces_open");
app.logEvent("myplaces_open");
importHelper = new ImportHelper(this, getMyApplication(), null);

View file

@ -1966,7 +1966,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
return false;
}
mapActivity.getMyApplication().logEvent(mapActivity, "search_open");
mapActivity.getMyApplication().logEvent("search_open");
Bundle bundle = new Bundle();
if (object != null) {

View file

@ -703,7 +703,7 @@ public class MapControlsLayer extends OsmandMapLayer {
mapRouteInfoMenu.show();
} else {
touchEvent = 0;
app.logEvent(mapActivity, "start_navigation");
app.logEvent("start_navigation");
app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode());
mapActivity.getMapViewTrackingUtilities().backToLocationImpl(17, true);
app.getSettings().FOLLOW_THE_ROUTE.set(true);