Repository navigation
feat: explore dash merchant search event tracking #917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
0c69cc1
961e23d
87b8af2
802cb09
3d47624
f022f12
e849250
2483bb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,7 +84,9 @@ class ExploreMapFragment : SupportMapFragment() { | |
|
|
||
| @Inject | ||
| lateinit var userLocationState: UserLocationStateInt | ||
|
|
||
| private var previousZoomLevel: Float = -1.0f | ||
| private var cameraMovementReason: Int = -1 | ||
| private lateinit var previousCameraCenterPosition: LatLng | ||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
| super.onViewCreated(view, savedInstanceState) | ||
|
|
||
|
|
@@ -97,6 +99,22 @@ class ExploreMapFragment : SupportMapFragment() { | |
| googleMap?.let { map -> | ||
| map.setOnCameraIdleListener { | ||
| val bounds = map.projection.visibleRegion.latLngBounds | ||
| if (cameraMovementReason == GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE){ | ||
| when { | ||
| viewModel.hasZoomLevelChanged(previousZoomLevel, map.cameraPosition.zoom) -> { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if the user zoomed (in/out) the map
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| viewModel.zoomLevelChangeCallback.call() | ||
| } | ||
| viewModel.hasCameraCenterChanged(previousCameraCenterPosition, | ||
| map.cameraPosition.target | ||
| ) -> { | ||
| viewModel.cameraCenterChangeCallback.call() | ||
| } | ||
| else -> {} | ||
| } | ||
| } | ||
|
|
||
| previousZoomLevel = map.cameraPosition.zoom | ||
| previousCameraCenterPosition = map.cameraPosition.target | ||
| viewModel.searchBounds = GeoBounds( | ||
| bounds.northeast.latitude, | ||
| bounds.northeast.longitude, | ||
|
|
@@ -107,6 +125,10 @@ class ExploreMapFragment : SupportMapFragment() { | |
| map.cameraPosition.zoom | ||
| ) | ||
| } | ||
|
|
||
| map.setOnCameraMoveStartedListener { reason -> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are various reasons that can cause the camera to be in motion in a map: however our tracking only focuses on the Camera motion initiated in response to user gestures on the map including |
||
| cameraMovementReason = reason | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -227,6 +249,7 @@ class ExploreMapFragment : SupportMapFragment() { | |
| if (isGooglePlayServicesAvailable()) { | ||
| markerCollection = MarkerManager(googleMap).newCollection() | ||
| markerCollection?.setOnMarkerClickListener { marker -> | ||
| viewModel.markerClickCallback.call() | ||
| viewModel.onMapMarkerSelected(marker.tag as Int) | ||
| true | ||
| } | ||
|
|
@@ -351,6 +374,8 @@ class ExploreMapFragment : SupportMapFragment() { | |
| val radiusBounds = getRadiusBounds(mCurrentUserLocation, radius) | ||
| map.moveCamera(radiusBounds) | ||
| lastFocusedUserLocation = mCurrentUserLocation | ||
| previousZoomLevel = map.cameraPosition.zoom | ||
| previousCameraCenterPosition = map.cameraPosition.target | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import androidx.annotation.VisibleForTesting | |
| import androidx.lifecycle.* | ||
| import androidx.paging.* | ||
| import androidx.paging.PagingData | ||
| import com.google.android.gms.maps.model.LatLng | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The viewModel should not reference LatLng since it's implementation-dependent and we're working with an interface in case of |
||
| import com.google.firebase.FirebaseNetworkException | ||
| import dagger.hilt.android.lifecycle.HiltViewModel | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
|
|
@@ -97,7 +98,9 @@ class ExploreViewModel @Inject constructor( | |
| private var boundedFilterJob: Job? = null | ||
| private var pagingFilterJob: Job? = null | ||
| private var allMerchantLocationsJob: Job? = null | ||
|
|
||
| val zoomLevelChangeCallback = SingleLiveEvent<Unit>() | ||
| val cameraCenterChangeCallback = SingleLiveEvent<Unit>() | ||
| val markerClickCallback = SingleLiveEvent<Unit>() | ||
| val isMetric = Locale.getDefault().isMetric | ||
|
|
||
| private val _searchQuery = MutableStateFlow("") | ||
|
|
@@ -703,4 +706,11 @@ class ExploreViewModel @Inject constructor( | |
| syncStatusService.setObservedLastError() | ||
| } | ||
| } | ||
|
|
||
| fun hasZoomLevelChanged(previousZoomLevel: Float, currentZoomLevel: Float): Boolean = | ||
| previousZoomLevel != currentZoomLevel | ||
|
|
||
| fun hasCameraCenterChanged(previousCenterPosition: LatLng, currentCenterPosition: LatLng) | ||
| : Boolean = locationProvider.distanceBetween(previousCenterPosition.latitude, previousCenterPosition.longitude, | ||
| currentCenterPosition.latitude, currentCenterPosition.longitude) != 0.0 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ import androidx.constraintlayout.widget.ConstraintLayout | |
| import androidx.core.animation.doOnEnd | ||
| import androidx.core.content.ContextCompat | ||
| import androidx.core.content.res.ResourcesCompat | ||
| import androidx.core.os.bundleOf | ||
| import androidx.core.view.* | ||
| import androidx.fragment.app.Fragment | ||
| import androidx.fragment.app.activityViewModels | ||
|
|
@@ -59,6 +60,8 @@ import org.dash.wallet.features.exploredash.ui.extensions.* | |
| import org.dash.wallet.common.Configuration | ||
| import org.dash.wallet.common.data.Resource | ||
| import org.dash.wallet.common.data.Status | ||
| import org.dash.wallet.common.services.analytics.AnalyticsConstants | ||
| import org.dash.wallet.common.services.analytics.AnalyticsService | ||
| import org.dash.wallet.features.exploredash.ui.adapters.MerchantLocationsHeaderAdapter | ||
| import org.dash.wallet.features.exploredash.ui.adapters.MerchantsLocationsAdapter | ||
| import javax.inject.Inject | ||
|
|
@@ -73,7 +76,8 @@ class SearchFragment : Fragment(R.layout.fragment_search) { | |
|
|
||
| @Inject | ||
| lateinit var configuration: Configuration | ||
|
|
||
| @Inject | ||
| lateinit var analyticsService: AnalyticsService | ||
| private val binding by viewBinding(FragmentSearchBinding::bind) | ||
| private val viewModel: ExploreViewModel by activityViewModels() | ||
| private val args by navArgs<SearchFragmentArgs>() | ||
|
|
@@ -107,6 +111,7 @@ class SearchFragment : Fragment(R.layout.fragment_search) { | |
| hideKeyboard() | ||
|
|
||
| if (item is Merchant) { | ||
| analyticsService.logEvent(AnalyticsConstants.ExploreDash.SELECT_MERCHANT_LOCATION, bundleOf()) | ||
| viewModel.openMerchantDetails(item, true) | ||
| } else if (item is Atm) { | ||
| viewModel.openAtmDetails(item) | ||
|
|
@@ -150,6 +155,9 @@ class SearchFragment : Fragment(R.layout.fragment_search) { | |
|
|
||
| binding.toolbar.setOnMenuItemClickListener { | ||
| if (it.itemId == R.id.menu_info) { | ||
| if (args.type == ExploreTopic.Merchants){ | ||
| analyticsService.logEvent(AnalyticsConstants.ExploreDash.INFO_EXPLORE_MERCHANT, bundleOf()) | ||
| } | ||
| safeNavigate(SearchFragmentDirections.exploreToInfo()) | ||
| } | ||
| true | ||
|
|
@@ -222,6 +230,21 @@ class SearchFragment : Fragment(R.layout.fragment_search) { | |
| } | ||
| } | ||
| } | ||
| viewModel.markerClickCallback.observe(viewLifecycleOwner){ | ||
| if (viewModel.exploreTopic == ExploreTopic.Merchants){ | ||
| analyticsService.logEvent(AnalyticsConstants.ExploreDash.SELECT_MERCHANT_MARKER, bundleOf()) | ||
| } | ||
| } | ||
| viewModel.zoomLevelChangeCallback.observe(viewLifecycleOwner){ | ||
| if (viewModel.exploreTopic == ExploreTopic.Merchants){ | ||
| analyticsService.logEvent(AnalyticsConstants.ExploreDash.ZOOM_MERCHANT_MAP, bundleOf()) | ||
| } | ||
| } | ||
| viewModel.cameraCenterChangeCallback.observe(viewLifecycleOwner){ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (viewModel.exploreTopic == ExploreTopic.Merchants){ | ||
| analyticsService.logEvent(AnalyticsConstants.ExploreDash.PAN_MERCHANT_MAP, bundleOf()) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun showError( | ||
|
|
@@ -304,14 +327,27 @@ class SearchFragment : Fragment(R.layout.fragment_search) { | |
| viewModel.setFilterMode(defaultMode) | ||
|
|
||
| searchHeaderAdapter.setOnFilterOptionChosen { mode -> | ||
| if (topic == ExploreTopic.Merchants){ | ||
| when(mode){ | ||
| FilterMode.Online -> analyticsService.logEvent(AnalyticsConstants.ExploreDash.ONLINE_MERCHANTS, bundleOf()) | ||
| FilterMode.Nearby -> analyticsService.logEvent(AnalyticsConstants.ExploreDash.NEARBY_MERCHANTS, bundleOf()) | ||
| else -> analyticsService.logEvent(AnalyticsConstants.ExploreDash.ALL_MERCHANTS, bundleOf()) | ||
| } | ||
| } | ||
| viewModel.setFilterMode(mode) | ||
| } | ||
|
|
||
| searchHeaderAdapter.setOnFilterButtonClicked { | ||
| if (topic == ExploreTopic.Merchants){ | ||
| analyticsService.logEvent(AnalyticsConstants.ExploreDash.FILTER_MERCHANTS_TOP, bundleOf()) | ||
| } | ||
| openFilters() | ||
| } | ||
|
|
||
| binding.filterPanel.setOnClickListener { | ||
| if (topic == ExploreTopic.Merchants){ | ||
| analyticsService.logEvent(AnalyticsConstants.ExploreDash.FILTER_MERCHANTS_BOTTOM, bundleOf()) | ||
| } | ||
| openFilters() | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as #915, there should be a prefix, otherwise within the list of events, some explore dash events are at A and others at Z.