Skip to content

Commit

Permalink
Merge pull request #20182 from wordpress-mobile/issue/20040-notificat…
Browse files Browse the repository at this point in the history
…ions-add-tracks-event

Notifications add tracks events for inline actions
  • Loading branch information
Antonis Lilis authored Feb 15, 2024
2 parents 6c0ef89 + 1e4cbe0 commit 4131e88
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.wordpress.android.BuildConfig
import org.wordpress.android.R
import org.wordpress.android.WordPress
import org.wordpress.android.analytics.AnalyticsTracker.Stat.APP_REVIEWS_EVENT_INCREMENTED_BY_CHECKING_NOTIFICATION
import org.wordpress.android.analytics.AnalyticsTracker.Stat.NOTIFICATIONS_INLINE_ACTION_TAPPED
import org.wordpress.android.databinding.NotificationsListFragmentPageBinding
import org.wordpress.android.datasets.NotificationsTable
import org.wordpress.android.fluxc.model.CommentStatus
Expand Down Expand Up @@ -62,6 +63,7 @@ import org.wordpress.android.util.AppLog.T
import org.wordpress.android.util.DisplayUtils
import org.wordpress.android.util.NetworkUtils
import org.wordpress.android.util.WPSwipeToRefreshHelper
import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
import org.wordpress.android.util.helpers.SwipeToRefreshHelper
import org.wordpress.android.widgets.AppRatingDialog.incrementInteractions
import javax.inject.Inject
Expand All @@ -83,6 +85,9 @@ class NotificationsListFragmentPage : ViewPagerFragment(R.layout.notifications_l
@Inject
lateinit var gcmMessageHandler: GCMMessageHandler

@Inject
lateinit var analyticsTrackerWrapper: AnalyticsTrackerWrapper

private val showNewUnseenNotificationsRunnable = Runnable {
if (isAdded) {
binding?.notificationsList?.addOnScrollListener(mOnScrollListener)
Expand Down Expand Up @@ -410,6 +415,9 @@ class NotificationsListFragmentPage : ViewPagerFragment(R.layout.notifications_l
}

private fun handleInlineActionEvent(actionEvent: InlineActionEvent) {
analyticsTrackerWrapper.track(NOTIFICATIONS_INLINE_ACTION_TAPPED, mapOf(
InlineActionEvent.KEY_INLINE_ACTION to actionEvent::class.simpleName
))
when (actionEvent) {
is SharePostButtonTapped -> actionEvent.notification.let { postNotification ->
context?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,9 @@ class NotificationsListViewModel @Inject constructor(
sealed class InlineActionEvent {
data class SharePostButtonTapped(val notification: PostNotification) : InlineActionEvent()
class LikeCommentButtonTapped(val note: Note, val liked: Boolean) : InlineActionEvent()

companion object {
const val KEY_INLINE_ACTION = "inline_action"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@ public enum Stat {
SITE_MONITORING_TAB_LOADING_ERROR,
NOTIFICATION_MENU_TAPPED,
NOTIFICATIONS_MARK_ALL_READ_TAPPED,
NOTIFICATIONS_INLINE_ACTION_TAPPED,
WEBVIEW_TOO_LARGE_PAYLOAD_ERROR,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2711,6 +2711,8 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) {
return "notification_menu_tapped";
case NOTIFICATIONS_MARK_ALL_READ_TAPPED:
return "notifications_mark_all_read_tapped";
case NOTIFICATIONS_INLINE_ACTION_TAPPED:
return "notifications_inline_action_tapped";
case WEBVIEW_TOO_LARGE_PAYLOAD_ERROR:
return "webview_too_large_payload_error";
}
Expand Down

0 comments on commit 4131e88

Please sign in to comment.