From 8089791f763bcdacd90568e8f189be1b4245dc64 Mon Sep 17 00:00:00 2001 From: Annmarie Ziegler Date: Thu, 11 Apr 2024 15:15:03 -0400 Subject: [PATCH] Implement tracking for post resolution conflict overlay --- .../android/ui/posts/PostListDialogHelper.kt | 10 +--------- .../ui/posts/PostResolutionOverlayUiState.kt | 6 +++--- .../posts/PostResolutionOverlayViewModel.kt | 20 +++++++++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListDialogHelper.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListDialogHelper.kt index 3d2d99b8d7ac..75dfcadbc8a4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListDialogHelper.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListDialogHelper.kt @@ -138,7 +138,6 @@ class PostListDialogHelper( } fun showAutoSaveRevisionDialog(post: PostModel) { - analyticsTracker.track(UNPUBLISHED_REVISION_DIALOG_SHOWN, mapOf(POST_TYPE to "post")) localPostIdForAutosaveRevisionResolutionDialog = post.id if (isPostConflictResolutionEnabled) { showConflictResolutionOverlay?.invoke( @@ -147,6 +146,7 @@ class PostListDialogHelper( ) ) } else { + analyticsTracker.track(UNPUBLISHED_REVISION_DIALOG_SHOWN, mapOf(POST_TYPE to "post")) val dialogHolder = DialogHolder( tag = CONFIRM_ON_AUTOSAVE_REVISION_DIALOG_TAG, title = UiStringRes(R.string.dialog_confirm_autosave_title), @@ -308,10 +308,6 @@ class PostListDialogHelper( localPostIdForAutosaveRevisionResolutionDialog?.let { // open the editor with the local post (don't use the auto save version) editLocalPost(it) - analyticsTracker.track( - UNPUBLISHED_REVISION_DIALOG_LOAD_LOCAL_VERSION_CLICKED, - mapOf(POST_TYPE to "post") - ) } } @@ -320,10 +316,6 @@ class PostListDialogHelper( // open the editor with the restored auto save localPostIdForAutosaveRevisionResolutionDialog = null editRestoredAutoSavePost(it) - analyticsTracker.track( - UNPUBLISHED_REVISION_DIALOG_LOAD_UNPUBLISHED_VERSION_CLICKED, - mapOf(POST_TYPE to "post") - ) } } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostResolutionOverlayUiState.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostResolutionOverlayUiState.kt index 0eedafe223ee..b09e0724d072 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostResolutionOverlayUiState.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostResolutionOverlayUiState.kt @@ -43,9 +43,9 @@ enum class PostResolutionType { AUTOSAVE_REVISION_CONFLICT } -enum class PostResolutionConfirmationType { - CONFIRM_LOCAL, - CONFIRM_OTHER +enum class PostResolutionConfirmationType(val analyticsLabel: String) { + CONFIRM_LOCAL("local_version"), + CONFIRM_OTHER("remote_version") } sealed class PostResolutionOverlayActionEvent { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostResolutionOverlayViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostResolutionOverlayViewModel.kt index 4e6dd7a75fea..70732b6ae4e5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostResolutionOverlayViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostResolutionOverlayViewModel.kt @@ -15,7 +15,8 @@ import javax.inject.Inject class PostResolutionOverlayViewModel @Inject constructor( private val dateTimeUtilsWrapper: DateTimeUtilsWrapper, - private val dateUtilsWrapper: DateUtilsWrapper + private val dateUtilsWrapper: DateUtilsWrapper, + private val tracker: PostResolutionOverlayAnalyticsTracker ) : ViewModel() { private val _uiState = MutableLiveData() val uiState: LiveData = _uiState @@ -42,6 +43,8 @@ class PostResolutionOverlayViewModel @Inject constructor( resolutionType = postResolutionType post = postModel + onDialogShown() + val uiState = when (resolutionType) { PostResolutionType.SYNC_CONFLICT -> getUiStateForSyncConflict(postModel) PostResolutionType.AUTOSAVE_REVISION_CONFLICT -> getUiStateForAutosaveRevisionConflict(postModel) @@ -133,26 +136,31 @@ class PostResolutionOverlayViewModel @Inject constructor( } private fun onConfirmClick() { - // todo: add logging _uiState.value?.selectedContentItem?.let { + val confirmationType = it.id.toPostResolutionConfirmationType() + tracker.trackConfirm(resolutionType, confirmationType) _triggerListeners.value = PostResolutionOverlayActionEvent.PostResolutionConfirmationEvent(resolutionType, - it.id.toPostResolutionConfirmationType()) + confirmationType) } _dismissDialog.value = true } private fun onCloseClick() { - // todo: add logging + tracker.trackClose(resolutionType) _dismissDialog.value = true } private fun onCancelClick() { - // todo: add logging + tracker.trackCancel(resolutionType) _dismissDialog.value = true } fun onDialogDismissed() { - // todo: add logging + tracker.trackDismissed(resolutionType) + } + + private fun onDialogShown() { + tracker.trackShown(resolutionType) } private fun onItemSelected(selectedItem: ContentItem) {