Skip to content

Commit

Permalink
Implement tracking for post resolution conflict overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
zwarm committed Apr 11, 2024
1 parent e71f620 commit 8089791
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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),
Expand Down Expand Up @@ -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")
)
}
}

Expand All @@ -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")
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PostResolutionOverlayUiState>()
val uiState: LiveData<PostResolutionOverlayUiState> = _uiState
Expand All @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8089791

Please sign in to comment.