Skip to content

Commit

Permalink
Fix bug so that launcher search metrics session ends only if one is o…
Browse files Browse the repository at this point in the history
…pen.

This can occur when switching from clamshell mode to tablet mode. It also occurs when clicking on any item in the launcher in tablet mode, as two end session requests are made.

This fix checks if a current session is open before logging a session end.

Test: Added unit tests, works on DUT
Bug: b/307812616
Change-Id: I45d3583c3973ba08f0479ec3f50cb4bbd1ceec30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4974802
Reviewed-by: Dmitry Grebenyuk <dgrebenyuk@google.com>
Commit-Queue: Lauren Commeignes <laurencom@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1216728}
  • Loading branch information
Lauren Commeignes authored and Chromium LUCI CQ committed Oct 30, 2023
1 parent 2246af1 commit c996a96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "chrome/browser/ash/app_list/search/search_session_metrics_manager.h"

#include "ash/public/cpp/app_list/app_list_controller.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "chrome/browser/ash/app_list/search/common/keyword_util.h"
Expand Down Expand Up @@ -51,6 +52,11 @@ void SearchSessionMetricsManager::OnSearchSessionStarted() {

void SearchSessionMetricsManager::OnSearchSessionEnded(
const std::u16string& query) {
if (!session_active_) {
LOG(ERROR) << "A request for a launcher search session to end has been "
"made when there was no active session.";
return;
}
EndSearchSession(query);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ TEST_F(SearchSessionMetricsManagerTest, AbandonResult) {
histogram_tester()->ExpectTotalCount(SearchKeyHistogram, 1);
histogram_tester()->ExpectUniqueSample(
SearchKeyHistogram, ash::SearchSessionConclusion::kQuit, 1);

// No additional session should be logged if no session was started
metrics_manager()->OnSearchSessionEnded(u"");

histogram_tester()->ExpectTotalCount(SearchKeyHistogram, 1);
}

} // namespace app_list::test

0 comments on commit c996a96

Please sign in to comment.