-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add search and sort observability metrics #3007
Merged
jotaemepereira
merged 7 commits into
feature/search-and-sort-bookmarks-panel
from
juan/search-and-sort-metrics
Jul 24, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1661ef5
Define pixels
jotaemepereira e8e1541
Create bookmarks metric class
jotaemepereira 0df6b60
Implement search metrics and add unit tests
jotaemepereira 942b7e9
Remove abstraction for metrics
jotaemepereira 6b27012
Rename BookmarkMetrics
jotaemepereira a217b5a
Refactor code
jotaemepereira 269848c
Fix SwiftLint
jotaemepereira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
DuckDuckGo/Bookmarks/Model/BookmarksSearchAndSortMetrics.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// BookmarksSearchAndSortMetrics.swift | ||
// | ||
// Copyright © 2024 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
import PixelKit | ||
|
||
enum BookmarkOperationOrigin: String { | ||
case panel | ||
case manager | ||
} | ||
|
||
struct BookmarksSearchAndSortMetrics { | ||
func fireSortButtonClicked(origin: BookmarkOperationOrigin) { | ||
PixelKit.fire(GeneralPixel.bookmarksSortButtonClicked(origin: origin.rawValue)) | ||
} | ||
|
||
func fireSortButtonDismissed(origin: BookmarkOperationOrigin) { | ||
PixelKit.fire(GeneralPixel.bookmarksSortButtonDismissed(origin: origin.rawValue)) | ||
} | ||
|
||
func fireSortByName(origin: BookmarkOperationOrigin) { | ||
PixelKit.fire(GeneralPixel.bookmarksSortByName(origin: origin.rawValue)) | ||
} | ||
|
||
func fireSearchExecuted(origin: BookmarkOperationOrigin) { | ||
PixelKit.fire(GeneralPixel.bookmarksSearchExecuted(origin: origin.rawValue), frequency: .daily) | ||
} | ||
|
||
func fireSearchResultClicked(origin: BookmarkOperationOrigin) { | ||
PixelKit.fire(GeneralPixel.bookmarksSearchResultClicked(origin: origin.rawValue)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's the motivation behind this versus using PixelKit directly?
In general I'd say we use PixelKit directly, and I'd rather keep things consistent unless there's a good reason for it
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.
I prefer to encapsulate this kind of logic; if you have multiple fires to the same pixel and need to change something (for example, the frequency), you have only one place to do it.
Finding the pixels related to a specific feature is easier. Now, you need to navigate through the large pixel list in the
GeneralPixel
enum.Do you think it’s a blocker for this PR?
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.
Nah it's not a blocker. I think your reasoning makes sense, but I would rather do it or not do it universally, and think the consistency is more valuable than the benefits of either approach.