From ba242fb3b9357fb545af806c9640b48e79a52d1a Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Fri, 18 Sep 2020 20:00:20 -0700 Subject: [PATCH] [fenix] Closes https://github.com/mozilla-mobile/fenix/issues/15206: Only track 'move' event if bookmark parent was changed --- .../library/bookmarks/edit/EditBookmarkFragment.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/library/bookmarks/edit/EditBookmarkFragment.kt b/app/src/main/java/org/mozilla/fenix/library/bookmarks/edit/EditBookmarkFragment.kt index 6ddce90684..a2375e02cf 100644 --- a/app/src/main/java/org/mozilla/fenix/library/bookmarks/edit/EditBookmarkFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/library/bookmarks/edit/EditBookmarkFragment.kt @@ -58,6 +58,7 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) { } private var bookmarkNode: BookmarkNode? = null private var bookmarkParent: BookmarkNode? = null + private var initialParentGuid: String? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -77,6 +78,10 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) { bookmarksStorage.getBookmark(args.guidToEdit) } + if (initialParentGuid == null) { + initialParentGuid = bookmarkNode?.parentGuid + } + bookmarkParent = withContext(IO) { // Use user-selected parent folder if it's set, or node's current parent otherwise. if (sharedViewModel.selectedFolder != null) { @@ -225,13 +230,15 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark) { if (title != bookmarkNode?.title || url != bookmarkNode?.url) { components.analytics.metrics.track(Event.EditedBookmark) } - if (sharedViewModel.selectedFolder != null) { + val parentGuid = sharedViewModel.selectedFolder?.guid ?: bookmarkNode!!.parentGuid + // Only track the 'moved' event if new parent was selected. + if (initialParentGuid != parentGuid) { components.analytics.metrics.track(Event.MovedBookmark) } components.core.bookmarksStorage.updateNode( args.guidToEdit, BookmarkInfo( - sharedViewModel.selectedFolder?.guid ?: bookmarkNode!!.parentGuid, + parentGuid, bookmarkNode?.position, title, if (bookmarkNode?.type == BookmarkNodeType.ITEM) url else null