-
Notifications
You must be signed in to change notification settings - Fork 180
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 all 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 |
|---|---|---|
|
|
@@ -19,9 +19,11 @@ package org.dash.wallet.features.exploredash.ui | |
|
|
||
| import android.content.Context | ||
| import androidx.annotation.VisibleForTesting | ||
| import androidx.core.os.bundleOf | ||
| 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 | ||
|
|
@@ -31,6 +33,8 @@ import org.dash.wallet.common.data.Resource | |
| import org.dash.wallet.common.data.SingleLiveEvent | ||
| import org.dash.wallet.common.data.Status | ||
| import org.dash.wallet.common.livedata.ConnectionLiveData | ||
| import org.dash.wallet.common.services.analytics.AnalyticsConstants | ||
| import org.dash.wallet.common.services.analytics.AnalyticsService | ||
| import org.dash.wallet.features.exploredash.data.ExploreDataSource | ||
| import org.dash.wallet.features.exploredash.data.model.* | ||
| import org.dash.wallet.features.exploredash.data.model.GeoBounds | ||
|
|
@@ -77,7 +81,8 @@ class ExploreViewModel @Inject constructor( | |
| @ApplicationContext private val context: Context, | ||
| private val exploreData: ExploreDataSource, | ||
| private val locationProvider: UserLocationStateInt, | ||
| private val syncStatusService: DataSyncStatusService | ||
| private val syncStatusService: DataSyncStatusService, | ||
| private val analyticsService: AnalyticsService | ||
| ) : ViewModel() { | ||
| companion object { | ||
| const val QUERY_DEBOUNCE_VALUE = 300L | ||
|
|
@@ -97,7 +102,6 @@ class ExploreViewModel @Inject constructor( | |
| private var boundedFilterJob: Job? = null | ||
| private var pagingFilterJob: Job? = null | ||
| private var allMerchantLocationsJob: Job? = null | ||
|
|
||
| val isMetric = Locale.getDefault().isMetric | ||
|
|
||
| private val _searchQuery = MutableStateFlow("") | ||
|
|
@@ -106,7 +110,8 @@ class ExploreViewModel @Inject constructor( | |
|
|
||
| var exploreTopic = ExploreTopic.Merchants | ||
| private set | ||
|
|
||
| var previousCameraGeoBounds = GeoBounds.noBounds | ||
| var previousZoomLevel: Float = -1.0f | ||
| private var lastResolvedAddress: GeoBounds? = null | ||
| private var _currentUserLocation: MutableStateFlow<UserLocation?> = MutableStateFlow(null) | ||
| val currentUserLocation = _currentUserLocation.asLiveData() | ||
|
|
@@ -703,4 +708,30 @@ class ExploreViewModel @Inject constructor( | |
| syncStatusService.setObservedLastError() | ||
| } | ||
| } | ||
|
|
||
| fun triggerPanAndZoomEvents(currentZoomLevel: Float, currentGeoBounds: GeoBounds){ | ||
| when { | ||
| hasZoomLevelChanged(currentZoomLevel) -> { | ||
| if (exploreTopic == ExploreTopic.Merchants){ | ||
| analyticsService.logEvent(AnalyticsConstants.ExploreDash.ZOOM_MERCHANT_MAP, bundleOf()) | ||
| } | ||
| } | ||
| hasCameraCenterChanged(currentGeoBounds) -> { | ||
| if (exploreTopic == ExploreTopic.Merchants){ | ||
| analyticsService.logEvent(AnalyticsConstants.ExploreDash.PAN_MERCHANT_MAP, bundleOf()) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| private fun hasZoomLevelChanged(currentZoomLevel: Float): Boolean = | ||
| previousZoomLevel != currentZoomLevel | ||
|
|
||
| private fun hasCameraCenterChanged(currentCenterPosition: GeoBounds): Boolean = | ||
| locationProvider.distanceBetweenCenters(previousCameraGeoBounds, currentCenterPosition) != 0.0 | ||
|
|
||
| fun triggerMarkerClickEvent(){ | ||
| if (exploreTopic == ExploreTopic.Merchants){ | ||
| analyticsService.logEvent(AnalyticsConstants.ExploreDash.SELECT_MERCHANT_MARKER, bundleOf()) | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
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
pinch to zoomandpangestures. All other causes/reasons initiated or not by the user are to be ignored for the tracking