Commit 3883e3db authored by Brandon Wylie's avatar Brandon Wylie Committed by Commit Bot

[EOC] Refactor metrics reporting and adding support for Referrer

Bug: 875087
Change-Id: I1165ed0c6e65caf377d556de769bec878c0698cd
Reviewed-on: https://chromium-review.googlesource.com/1179223
Commit-Queue: Brandon Wylie <wylieb@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584816}
parent f7b0863d
...@@ -22,11 +22,12 @@ ...@@ -22,11 +22,12 @@
#include "components/ntp_snippets/content_suggestions_service.h" #include "components/ntp_snippets/content_suggestions_service.h"
#include "components/ntp_snippets/contextual/contextual_content_suggestions_service.h" #include "components/ntp_snippets/contextual/contextual_content_suggestions_service.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_features.h" #include "components/ntp_snippets/contextual/contextual_suggestions_features.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
#include "components/policy/core/common/policy_map.h" #include "components/policy/core/common/policy_map.h"
#include "components/policy/core/common/policy_service.h" #include "components/policy/core/common/policy_service.h"
#include "components/policy/policy_constants.h" #include "components/policy/policy_constants.h"
#include "components/ukm/content/source_url_recorder.h" #include "components/ukm/content/source_url_recorder.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "jni/ContextualSuggestionsBridge_jni.h" #include "jni/ContextualSuggestionsBridge_jni.h"
#include "ui/gfx/android/java_bitmap.h" #include "ui/gfx/android/java_bitmap.h"
...@@ -39,6 +40,13 @@ using base::android::JavaParamRef; ...@@ -39,6 +40,13 @@ using base::android::JavaParamRef;
using base::android::ScopedJavaGlobalRef; using base::android::ScopedJavaGlobalRef;
using base::android::ScopedJavaLocalRef; using base::android::ScopedJavaLocalRef;
namespace {
// Keep this in sync with CHROME_CONTEXTUAL_SUGGESTIONS_REFERRER. They should
// together.
const char kContextualSuggestionsReferrerURL[] =
"https://goto.google.com/explore-on-content-viewer";
} // namespace
namespace contextual_suggestions { namespace contextual_suggestions {
// A whitelisted method to inject synthetic field trials to Chrome Metrics. // A whitelisted method to inject synthetic field trials to Chrome Metrics.
...@@ -158,8 +166,16 @@ void ContextualSuggestionsBridge::ReportEvent( ...@@ -158,8 +166,16 @@ void ContextualSuggestionsBridge::ReportEvent(
static_cast<contextual_suggestions::ContextualSuggestionsEvent>( static_cast<contextual_suggestions::ContextualSuggestionsEvent>(
j_event_id); j_event_id);
service_proxy_->ReportEvent( const std::string& referrer_url =
ukm_source_id, web_contents->GetLastCommittedURL().spec(), event); web_contents->GetController().GetActiveEntry()->GetReferrer().url.spec();
ArticleSource article_source = ArticleSource::OTHER;
if (referrer_url == kContextualSuggestionsReferrerURL) {
article_source = ArticleSource::CONTEXTUAL_SUGGESTIONS;
}
service_proxy_->ReportEvent(ukm_source_id,
web_contents->GetLastCommittedURL().spec(),
article_source, event);
} }
void ContextualSuggestionsBridge::OnSuggestionsAvailable( void ContextualSuggestionsBridge::OnSuggestionsAvailable(
......
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
#include "components/image_fetcher/core/image_fetcher_impl.h" #include "components/image_fetcher/core/image_fetcher_impl.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/ntp_snippets/contextual/contextual_content_suggestions_service.h" #include "components/ntp_snippets/contextual/contextual_content_suggestions_service.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_debugging_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_features.h" #include "components/ntp_snippets/contextual/contextual_suggestions_features.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_fetcher_impl.h" #include "components/ntp_snippets/contextual/contextual_suggestions_fetcher_impl.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_debugging_reporter.h"
#include "components/ntp_snippets/contextual/reporting/contextual_suggestions_reporter.h"
#include "components/ntp_snippets/remote/cached_image_fetcher.h" #include "components/ntp_snippets/remote/cached_image_fetcher.h"
#include "components/ntp_snippets/remote/remote_suggestions_database.h" #include "components/ntp_snippets/remote/remote_suggestions_database.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
......
...@@ -54,10 +54,6 @@ static_library("ntp_snippets") { ...@@ -54,10 +54,6 @@ static_library("ntp_snippets") {
"contextual/contextual_suggestion.h", "contextual/contextual_suggestion.h",
"contextual/contextual_suggestions_cache.cc", "contextual/contextual_suggestions_cache.cc",
"contextual/contextual_suggestions_cache.h", "contextual/contextual_suggestions_cache.h",
"contextual/contextual_suggestions_composite_reporter.cc",
"contextual/contextual_suggestions_composite_reporter.h",
"contextual/contextual_suggestions_debugging_reporter.cc",
"contextual/contextual_suggestions_debugging_reporter.h",
"contextual/contextual_suggestions_features.cc", "contextual/contextual_suggestions_features.cc",
"contextual/contextual_suggestions_features.h", "contextual/contextual_suggestions_features.h",
"contextual/contextual_suggestions_fetch.cc", "contextual/contextual_suggestions_fetch.cc",
...@@ -65,14 +61,18 @@ static_library("ntp_snippets") { ...@@ -65,14 +61,18 @@ static_library("ntp_snippets") {
"contextual/contextual_suggestions_fetcher.h", "contextual/contextual_suggestions_fetcher.h",
"contextual/contextual_suggestions_fetcher_impl.cc", "contextual/contextual_suggestions_fetcher_impl.cc",
"contextual/contextual_suggestions_fetcher_impl.h", "contextual/contextual_suggestions_fetcher_impl.h",
"contextual/contextual_suggestions_metrics_reporter.cc",
"contextual/contextual_suggestions_metrics_reporter.h",
"contextual/contextual_suggestions_reporter.cc",
"contextual/contextual_suggestions_reporter.h",
"contextual/contextual_suggestions_result.cc", "contextual/contextual_suggestions_result.cc",
"contextual/contextual_suggestions_result.h", "contextual/contextual_suggestions_result.h",
"contextual/contextual_suggestions_ukm_entry.cc", "contextual/reporting/contextual_suggestions_composite_reporter.cc",
"contextual/contextual_suggestions_ukm_entry.h", "contextual/reporting/contextual_suggestions_composite_reporter.h",
"contextual/reporting/contextual_suggestions_debugging_reporter.cc",
"contextual/reporting/contextual_suggestions_debugging_reporter.h",
"contextual/reporting/contextual_suggestions_metrics_reporter.cc",
"contextual/reporting/contextual_suggestions_metrics_reporter.h",
"contextual/reporting/contextual_suggestions_reporter.cc",
"contextual/reporting/contextual_suggestions_reporter.h",
"contextual/reporting/contextual_suggestions_ukm_entry.cc",
"contextual/reporting/contextual_suggestions_ukm_entry.h",
"features.cc", "features.cc",
"features.h", "features.h",
"logger.cc", "logger.cc",
...@@ -192,7 +192,7 @@ if (is_android) { ...@@ -192,7 +192,7 @@ if (is_android) {
"category_info.h", "category_info.h",
"category_status.h", "category_status.h",
"content_suggestions_service.cc", "content_suggestions_service.cc",
"contextual/contextual_suggestions_reporter.h", "contextual/reporting/contextual_suggestions_reporter.h",
] ]
} }
} }
...@@ -219,11 +219,11 @@ source_set("unit_tests") { ...@@ -219,11 +219,11 @@ source_set("unit_tests") {
"content_suggestions_service_unittest.cc", "content_suggestions_service_unittest.cc",
"contextual/contextual_content_suggestions_service_proxy_unittest.cc", "contextual/contextual_content_suggestions_service_proxy_unittest.cc",
"contextual/contextual_content_suggestions_service_unittest.cc", "contextual/contextual_content_suggestions_service_unittest.cc",
"contextual/contextual_suggestions_composite_reporter_unittest.cc",
"contextual/contextual_suggestions_fetch_unittest.cc", "contextual/contextual_suggestions_fetch_unittest.cc",
"contextual/contextual_suggestions_fetcher_impl_unittest.cc", "contextual/contextual_suggestions_fetcher_impl_unittest.cc",
"contextual/contextual_suggestions_metrics_reporter_unittest.cc", "contextual/reporting/contextual_suggestions_composite_reporter_unittest.cc",
"contextual/contextual_suggestions_ukm_entry_unittest.cc", "contextual/reporting/contextual_suggestions_metrics_reporter_unittest.cc",
"contextual/reporting/contextual_suggestions_ukm_entry_unittest.cc",
"logger_unittest.cc", "logger_unittest.cc",
"reading_list/reading_list_suggestions_provider_unittest.cc", "reading_list/reading_list_suggestions_provider_unittest.cc",
"remote/cached_image_fetcher_unittest.cc", "remote/cached_image_fetcher_unittest.cc",
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_H_ #ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_H_
#define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_H_ #define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_H_
#include <map> #include <map>
#include <memory> #include <memory>
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#include "components/ntp_snippets/callbacks.h" #include "components/ntp_snippets/callbacks.h"
#include "components/ntp_snippets/content_suggestion.h" #include "components/ntp_snippets/content_suggestion.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_cache.h" #include "components/ntp_snippets/contextual/contextual_suggestions_cache.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_debugging_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_fetcher.h" #include "components/ntp_snippets/contextual/contextual_suggestions_fetcher.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_debugging_reporter.h"
#include "components/ntp_snippets/contextual/reporting/contextual_suggestions_reporter.h"
#include "services/metrics/public/cpp/ukm_source_id.h" #include "services/metrics/public/cpp/ukm_source_id.h"
namespace ntp_snippets { namespace ntp_snippets {
...@@ -106,4 +106,4 @@ class ContextualContentSuggestionsService : public KeyedService { ...@@ -106,4 +106,4 @@ class ContextualContentSuggestionsService : public KeyedService {
} // namespace contextual_suggestions } // namespace contextual_suggestions
#endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_H_ #endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_H_
...@@ -46,7 +46,8 @@ void ContextualContentSuggestionsServiceProxy::FetchContextualSuggestions( ...@@ -46,7 +46,8 @@ void ContextualContentSuggestionsServiceProxy::FetchContextualSuggestions(
weak_ptr_factory_.GetWeakPtr(), std::move(callback)), weak_ptr_factory_.GetWeakPtr(), std::move(callback)),
base::BindRepeating( base::BindRepeating(
&ContextualContentSuggestionsServiceProxy::ReportEvent, &ContextualContentSuggestionsServiceProxy::ReportEvent,
weak_ptr_factory_.GetWeakPtr(), last_ukm_source_id_, url.spec())); weak_ptr_factory_.GetWeakPtr(), last_ukm_source_id_, url.spec(),
ArticleSource::CONTEXTUAL_SUGGESTIONS));
} }
void ContextualContentSuggestionsServiceProxy::FetchContextualSuggestionImage( void ContextualContentSuggestionsServiceProxy::FetchContextualSuggestionImage(
...@@ -89,6 +90,7 @@ void ContextualContentSuggestionsServiceProxy::ClearState() { ...@@ -89,6 +90,7 @@ void ContextualContentSuggestionsServiceProxy::ClearState() {
void ContextualContentSuggestionsServiceProxy::ReportEvent( void ContextualContentSuggestionsServiceProxy::ReportEvent(
ukm::SourceId ukm_source_id, ukm::SourceId ukm_source_id,
const std::string& url, const std::string& url,
ArticleSource article_source,
ContextualSuggestionsEvent event) { ContextualSuggestionsEvent event) {
// TODO(pnoland): investigate how we can get into this state(one known // TODO(pnoland): investigate how we can get into this state(one known
// example is if we switch tabs and there's no committed navigation in the new // example is if we switch tabs and there's no committed navigation in the new
...@@ -103,7 +105,7 @@ void ContextualContentSuggestionsServiceProxy::ReportEvent( ...@@ -103,7 +105,7 @@ void ContextualContentSuggestionsServiceProxy::ReportEvent(
if (last_ukm_source_id_ != ukm::kInvalidSourceId) if (last_ukm_source_id_ != ukm::kInvalidSourceId)
reporter_->Flush(); reporter_->Flush();
last_ukm_source_id_ = ukm_source_id; last_ukm_source_id_ = ukm_source_id;
reporter_->SetupForPage(url, ukm_source_id); reporter_->SetupForPage(url, article_source, ukm_source_id);
} }
reporter_->RecordEvent(event); reporter_->RecordEvent(event);
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_PROXY_H_ #ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_PROXY_H_
#define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_PROXY_H_ #define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_PROXY_H_
#include <map> #include <map>
#include <memory> #include <memory>
...@@ -52,6 +52,7 @@ class ContextualContentSuggestionsServiceProxy { ...@@ -52,6 +52,7 @@ class ContextualContentSuggestionsServiceProxy {
// Reports user interface event to the service. // Reports user interface event to the service.
void ReportEvent(ukm::SourceId, void ReportEvent(ukm::SourceId,
const std::string& url, const std::string& url,
ArticleSource article_source,
ContextualSuggestionsEvent event); ContextualSuggestionsEvent event);
// Ensures that all metrics are properly flushed. // Ensures that all metrics are properly flushed.
...@@ -86,4 +87,4 @@ class ContextualContentSuggestionsServiceProxy { ...@@ -86,4 +87,4 @@ class ContextualContentSuggestionsServiceProxy {
} // namespace contextual_suggestions } // namespace contextual_suggestions
#endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_PROXY_H_ #endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_CONTENT_SUGGESTIONS_SERVICE_PROXY_H_
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "components/ntp_snippets/contextual/contextual_content_suggestions_service.h" #include "components/ntp_snippets/contextual/contextual_content_suggestions_service.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_test_utils.h" #include "components/ntp_snippets/contextual/contextual_suggestions_test_utils.h"
#include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
#include "components/ntp_snippets/remote/cached_image_fetcher.h" #include "components/ntp_snippets/remote/cached_image_fetcher.h"
#include "components/ntp_snippets/remote/remote_suggestions_database.h" #include "components/ntp_snippets/remote/remote_suggestions_database.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
......
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
#include "components/ntp_snippets/category_info.h" #include "components/ntp_snippets/category_info.h"
#include "components/ntp_snippets/content_suggestion.h" #include "components/ntp_snippets/content_suggestion.h"
#include "components/ntp_snippets/contextual/contextual_suggestion.h" #include "components/ntp_snippets/contextual/contextual_suggestion.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_debugging_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_fetcher.h" #include "components/ntp_snippets/contextual/contextual_suggestions_fetcher.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_test_utils.h" #include "components/ntp_snippets/contextual/contextual_suggestions_test_utils.h"
#include "components/ntp_snippets/contextual/reporting/contextual_suggestions_debugging_reporter.h"
#include "components/ntp_snippets/contextual/reporting/contextual_suggestions_reporter.h"
#include "components/ntp_snippets/remote/cached_image_fetcher.h" #include "components/ntp_snippets/remote/cached_image_fetcher.h"
#include "components/ntp_snippets/remote/json_to_categories.h" #include "components/ntp_snippets/remote/json_to_categories.h"
#include "components/ntp_snippets/remote/remote_suggestions_database.h" #include "components/ntp_snippets/remote/remote_suggestions_database.h"
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include <utility> #include <utility>
#include "base/callback.h" #include "base/callback.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_result.h" #include "components/ntp_snippets/contextual/contextual_suggestions_result.h"
#include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
#include "url/gurl.h" #include "url/gurl.h"
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_FETCHER_H_ #define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_FETCHER_H_
#include "components/ntp_snippets/contextual/contextual_suggestion.h" #include "components/ntp_snippets/contextual/contextual_suggestion.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_result.h" #include "components/ntp_snippets/contextual/contextual_suggestions_result.h"
#include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
using contextual_suggestions::FetchClustersCallback; using contextual_suggestions::FetchClustersCallback;
using contextual_suggestions::ReportFetchMetricsCallback; using contextual_suggestions::ReportFetchMetricsCallback;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_TEST_UTILS_H_ #define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_TEST_UTILS_H_
#include "base/bind.h" #include "base/bind.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_result.h" #include "components/ntp_snippets/contextual/contextual_suggestions_result.h"
#include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace contextual_suggestions { namespace contextual_suggestions {
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/ntp_snippets/contextual/contextual_suggestions_composite_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_composite_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_ukm_entry.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_ukm_entry.h"
namespace contextual_suggestions { namespace contextual_suggestions {
...@@ -16,9 +16,10 @@ ContextualSuggestionsCompositeReporter:: ...@@ -16,9 +16,10 @@ ContextualSuggestionsCompositeReporter::
void ContextualSuggestionsCompositeReporter::SetupForPage( void ContextualSuggestionsCompositeReporter::SetupForPage(
const std::string& url, const std::string& url,
ArticleSource article_source,
ukm::SourceId source_id) { ukm::SourceId source_id) {
for (ContextualSuggestionsReporter* reporter : raw_reporters_) for (ContextualSuggestionsReporter* reporter : raw_reporters_)
reporter->SetupForPage(url, source_id); reporter->SetupForPage(url, article_source, source_id);
} }
void ContextualSuggestionsCompositeReporter::RecordEvent( void ContextualSuggestionsCompositeReporter::RecordEvent(
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_COMPOSITE_REPORTER_H_ #ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_COMPOSITE_REPORTER_H_
#define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_COMPOSITE_REPORTER_H_ #define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_COMPOSITE_REPORTER_H_
#include <memory> #include <memory>
#include <set> #include <set>
#include "base/macros.h" #include "base/macros.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_reporter.h"
#include "services/metrics/public/cpp/ukm_source_id.h" #include "services/metrics/public/cpp/ukm_source_id.h"
namespace contextual_suggestions { namespace contextual_suggestions {
...@@ -25,7 +25,9 @@ class ContextualSuggestionsCompositeReporter ...@@ -25,7 +25,9 @@ class ContextualSuggestionsCompositeReporter
~ContextualSuggestionsCompositeReporter() override; ~ContextualSuggestionsCompositeReporter() override;
// ContextualSuggestionsReporter // ContextualSuggestionsReporter
void SetupForPage(const std::string& url, ukm::SourceId source_id) override; void SetupForPage(const std::string& url,
ArticleSource article_source,
ukm::SourceId source_id) override;
void RecordEvent(ContextualSuggestionsEvent event) override; void RecordEvent(ContextualSuggestionsEvent event) override;
void Flush() override; void Flush() override;
...@@ -49,4 +51,4 @@ class ContextualSuggestionsCompositeReporter ...@@ -49,4 +51,4 @@ class ContextualSuggestionsCompositeReporter
}; };
} // namespace contextual_suggestions } // namespace contextual_suggestions
#endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_COMPOSITE_REPORTER_H_ #endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_COMPOSITE_REPORTER_H_
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/ntp_snippets/contextual/contextual_suggestions_composite_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_composite_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_reporter.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace contextual_suggestions { namespace contextual_suggestions {
...@@ -19,8 +19,11 @@ class TestReporter : public ContextualSuggestionsReporter { ...@@ -19,8 +19,11 @@ class TestReporter : public ContextualSuggestionsReporter {
/* ContextualSuggestionsReporter */ /* ContextualSuggestionsReporter */
void SetupForPage(const std::string& url, ukm::SourceId source_id) override { void SetupForPage(const std::string& url,
ArticleSource article_source,
ukm::SourceId source_id) override {
this->url_ = url; this->url_ = url;
this->article_source_ = article_source;
this->source_id_ = source_id; this->source_id_ = source_id;
called_setup_for_page_count_++; called_setup_for_page_count_++;
} }
...@@ -46,6 +49,7 @@ class TestReporter : public ContextualSuggestionsReporter { ...@@ -46,6 +49,7 @@ class TestReporter : public ContextualSuggestionsReporter {
static int reporter_destroy_count_; static int reporter_destroy_count_;
std::string url_; std::string url_;
ArticleSource article_source_;
ukm::SourceId source_id_; ukm::SourceId source_id_;
int called_setup_for_page_count_ = 0; int called_setup_for_page_count_ = 0;
int called_record_event_count_ = 0; int called_record_event_count_ = 0;
...@@ -65,7 +69,8 @@ TEST(ContextualSuggestionsCompositeReporterTest, AddAndReportUnique) { ...@@ -65,7 +69,8 @@ TEST(ContextualSuggestionsCompositeReporterTest, AddAndReportUnique) {
composite_reporter->AddOwnedReporter(std::move(reporter)); composite_reporter->AddOwnedReporter(std::move(reporter));
} }
composite_reporter->SetupForPage(kTestUrl, kSourceId); composite_reporter->SetupForPage(
kTestUrl, ArticleSource::CONTEXTUAL_SUGGESTIONS, kSourceId);
composite_reporter->RecordEvent(ContextualSuggestionsEvent::FETCH_REQUESTED); composite_reporter->RecordEvent(ContextualSuggestionsEvent::FETCH_REQUESTED);
composite_reporter->Flush(); composite_reporter->Flush();
...@@ -90,7 +95,8 @@ TEST(ContextualSuggestionsCompositeReporterTest, AddAndReportRaw) { ...@@ -90,7 +95,8 @@ TEST(ContextualSuggestionsCompositeReporterTest, AddAndReportRaw) {
reporters.push_back(std::move(reporter)); reporters.push_back(std::move(reporter));
} }
composite_reporter->SetupForPage(kTestUrl, kSourceId); composite_reporter->SetupForPage(
kTestUrl, ArticleSource::CONTEXTUAL_SUGGESTIONS, kSourceId);
composite_reporter->RecordEvent(ContextualSuggestionsEvent::FETCH_REQUESTED); composite_reporter->RecordEvent(ContextualSuggestionsEvent::FETCH_REQUESTED);
composite_reporter->Flush(); composite_reporter->Flush();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/ntp_snippets/contextual/contextual_suggestions_debugging_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_debugging_reporter.h"
#include <algorithm> #include <algorithm>
...@@ -29,6 +29,7 @@ void ContextualSuggestionsDebuggingReporter::ClearEvents() { ...@@ -29,6 +29,7 @@ void ContextualSuggestionsDebuggingReporter::ClearEvents() {
void ContextualSuggestionsDebuggingReporter::SetupForPage( void ContextualSuggestionsDebuggingReporter::SetupForPage(
const std::string& url, const std::string& url,
ArticleSource article_source,
ukm::SourceId source_id) { ukm::SourceId source_id) {
current_event_ = ContextualSuggestionsDebuggingEvent(); current_event_ = ContextualSuggestionsDebuggingEvent();
current_event_.url = url; current_event_.url = url;
...@@ -44,7 +45,6 @@ void ContextualSuggestionsDebuggingReporter::RecordEvent( ...@@ -44,7 +45,6 @@ void ContextualSuggestionsDebuggingReporter::RecordEvent(
case FETCH_BELOW_THRESHOLD: case FETCH_BELOW_THRESHOLD:
case FETCH_EMPTY: case FETCH_EMPTY:
case FETCH_COMPLETED: case FETCH_COMPLETED:
return;
case UI_PEEK_REVERSE_SCROLL: case UI_PEEK_REVERSE_SCROLL:
current_event_.sheet_peeked = true; current_event_.sheet_peeked = true;
return; return;
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_DEBUGGING_REPORTER_H_ #ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_DEBUGGING_REPORTER_H_
#define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_DEBUGGING_REPORTER_H_ #define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_DEBUGGING_REPORTER_H_
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_reporter.h"
#include "services/metrics/public/cpp/ukm_source_id.h" #include "services/metrics/public/cpp/ukm_source_id.h"
namespace contextual_suggestions { namespace contextual_suggestions {
...@@ -54,7 +54,9 @@ class ContextualSuggestionsDebuggingReporter ...@@ -54,7 +54,9 @@ class ContextualSuggestionsDebuggingReporter
void ClearEvents(); void ClearEvents();
// ContextualSuggestionsReporter // ContextualSuggestionsReporter
void SetupForPage(const std::string& url, ukm::SourceId source_id) override; void SetupForPage(const std::string& url,
ArticleSource article_source,
ukm::SourceId source_id) override;
void RecordEvent( void RecordEvent(
contextual_suggestions::ContextualSuggestionsEvent event) override; contextual_suggestions::ContextualSuggestionsEvent event) override;
void Flush() override; void Flush() override;
...@@ -67,4 +69,4 @@ class ContextualSuggestionsDebuggingReporter ...@@ -67,4 +69,4 @@ class ContextualSuggestionsDebuggingReporter
}; };
} // namespace contextual_suggestions } // namespace contextual_suggestions
#endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_DEBUGGING_REPORTER_H_ #endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_DEBUGGING_REPORTER_H_
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
#include <string> #include <string>
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_ukm_entry.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_ukm_entry.h"
#include "services/metrics/public/cpp/ukm_recorder.h" #include "services/metrics/public/cpp/ukm_recorder.h"
namespace contextual_suggestions { namespace contextual_suggestions {
...@@ -27,6 +27,7 @@ ContextualSuggestionsMetricsReporter::~ContextualSuggestionsMetricsReporter() { ...@@ -27,6 +27,7 @@ ContextualSuggestionsMetricsReporter::~ContextualSuggestionsMetricsReporter() {
void ContextualSuggestionsMetricsReporter::SetupForPage( void ContextualSuggestionsMetricsReporter::SetupForPage(
const std::string& url, const std::string& url,
ArticleSource article_source,
ukm::SourceId source_id) { ukm::SourceId source_id) {
DCHECK(!ukm_entry_) << "Flush should be called before SetupForPage!"; DCHECK(!ukm_entry_) << "Flush should be called before SetupForPage!";
DCHECK(source_id != ukm::kInvalidSourceId); DCHECK(source_id != ukm::kInvalidSourceId);
......
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_METRICS_REPORTER_H_ #ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_METRICS_REPORTER_H_
#define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_METRICS_REPORTER_H_ #define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_METRICS_REPORTER_H_
#include <memory> #include <memory>
#include "base/callback.h" #include "base/callback.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/macros.h" #include "base/macros.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_reporter.h"
#include "services/metrics/public/cpp/ukm_source_id.h" #include "services/metrics/public/cpp/ukm_source_id.h"
namespace contextual_suggestions { namespace contextual_suggestions {
...@@ -27,7 +27,9 @@ class ContextualSuggestionsMetricsReporter ...@@ -27,7 +27,9 @@ class ContextualSuggestionsMetricsReporter
~ContextualSuggestionsMetricsReporter() override; ~ContextualSuggestionsMetricsReporter() override;
// ContextualSuggestionsReporter // ContextualSuggestionsReporter
void SetupForPage(const std::string& url, ukm::SourceId source_id) override; void SetupForPage(const std::string& url,
ArticleSource article_source,
ukm::SourceId source_id) override;
void RecordEvent(ContextualSuggestionsEvent event) override; void RecordEvent(ContextualSuggestionsEvent event) override;
void Flush() override; void Flush() override;
...@@ -65,4 +67,4 @@ using ReportFetchMetricsCallback = base::RepeatingCallback<void( ...@@ -65,4 +67,4 @@ using ReportFetchMetricsCallback = base::RepeatingCallback<void(
} // namespace contextual_suggestions } // namespace contextual_suggestions
#endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_METRICS_REPORTER_H_ #endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_METRICS_REPORTER_H_
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_ukm_entry.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_ukm_entry.h"
#include "components/ukm/test_ukm_recorder.h" #include "components/ukm/test_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h" #include "services/metrics/public/cpp/ukm_builders.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -73,7 +73,8 @@ ukm::SourceId ContextualSuggestionsMetricsReporterTest::GetSourceId() { ...@@ -73,7 +73,8 @@ ukm::SourceId ContextualSuggestionsMetricsReporterTest::GetSourceId() {
TEST_F(ContextualSuggestionsMetricsReporterTest, BaseTest) { TEST_F(ContextualSuggestionsMetricsReporterTest, BaseTest) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
GetReporter().SetupForPage(kTestNavigationUrl, GetSourceId()); GetReporter().SetupForPage(
kTestNavigationUrl, ArticleSource::CONTEXTUAL_SUGGESTIONS, GetSourceId());
GetReporter().RecordEvent(FETCH_REQUESTED); GetReporter().RecordEvent(FETCH_REQUESTED);
GetReporter().RecordEvent(FETCH_COMPLETED); GetReporter().RecordEvent(FETCH_COMPLETED);
GetReporter().RecordEvent(UI_PEEK_REVERSE_SCROLL); GetReporter().RecordEvent(UI_PEEK_REVERSE_SCROLL);
...@@ -123,7 +124,8 @@ void ContextualSuggestionsMetricsReporterTest::ExpectMultipleEventsCountOnce( ...@@ -123,7 +124,8 @@ void ContextualSuggestionsMetricsReporterTest::ExpectMultipleEventsCountOnce(
ContextualSuggestionsEvent event) { ContextualSuggestionsEvent event) {
std::unique_ptr<base::HistogramTester> histogram_tester = std::unique_ptr<base::HistogramTester> histogram_tester =
std::make_unique<base::HistogramTester>(); std::make_unique<base::HistogramTester>();
GetReporter().SetupForPage(kTestNavigationUrl, GetSourceId()); GetReporter().SetupForPage(
kTestNavigationUrl, ArticleSource::CONTEXTUAL_SUGGESTIONS, GetSourceId());
// Always report a single FETCH_DELAYED event so we ensure there's a // Always report a single FETCH_DELAYED event so we ensure there's a
// histogram (otherwise the ExpectBucketCount may crash). // histogram (otherwise the ExpectBucketCount may crash).
GetReporter().RecordEvent(FETCH_DELAYED); GetReporter().RecordEvent(FETCH_DELAYED);
...@@ -166,7 +168,8 @@ TEST_F(ContextualSuggestionsMetricsReporterTest, SuggestionClickedTest) { ...@@ -166,7 +168,8 @@ TEST_F(ContextualSuggestionsMetricsReporterTest, SuggestionClickedTest) {
TEST_F(ContextualSuggestionsMetricsReporterTest, MultipleEventsTest) { TEST_F(ContextualSuggestionsMetricsReporterTest, MultipleEventsTest) {
std::unique_ptr<base::HistogramTester> histogram_tester = std::unique_ptr<base::HistogramTester> histogram_tester =
std::make_unique<base::HistogramTester>(); std::make_unique<base::HistogramTester>();
GetReporter().SetupForPage(kTestNavigationUrl, GetSourceId()); GetReporter().SetupForPage(
kTestNavigationUrl, ArticleSource::CONTEXTUAL_SUGGESTIONS, GetSourceId());
// Test multiple cycles of FETCH_REQUESTED, FETCH_COMPLETED. // Test multiple cycles of FETCH_REQUESTED, FETCH_COMPLETED.
GetReporter().RecordEvent(FETCH_REQUESTED); GetReporter().RecordEvent(FETCH_REQUESTED);
histogram_tester->ExpectBucketCount(kEventsHistogramName, kFetchRequested, 1); histogram_tester->ExpectBucketCount(kEventsHistogramName, kFetchRequested, 1);
...@@ -187,7 +190,8 @@ TEST_F(ContextualSuggestionsMetricsReporterTest, MultipleEventsTest) { ...@@ -187,7 +190,8 @@ TEST_F(ContextualSuggestionsMetricsReporterTest, MultipleEventsTest) {
TEST_F(ContextualSuggestionsMetricsReporterTest, EnumNotReorderedTest) { TEST_F(ContextualSuggestionsMetricsReporterTest, EnumNotReorderedTest) {
std::unique_ptr<base::HistogramTester> histogram_tester = std::unique_ptr<base::HistogramTester> histogram_tester =
std::make_unique<base::HistogramTester>(); std::make_unique<base::HistogramTester>();
GetReporter().SetupForPage(kTestNavigationUrl, GetSourceId()); GetReporter().SetupForPage(
kTestNavigationUrl, ArticleSource::CONTEXTUAL_SUGGESTIONS, GetSourceId());
// Peek the UI, which starts the timer, expected by all the other UI or // Peek the UI, which starts the timer, expected by all the other UI or
// suggestion events. // suggestion events.
GetReporter().RecordEvent(UI_PEEK_REVERSE_SCROLL); GetReporter().RecordEvent(UI_PEEK_REVERSE_SCROLL);
...@@ -200,7 +204,8 @@ TEST_F(ContextualSuggestionsMetricsReporterTest, EnumNotReorderedTest) { ...@@ -200,7 +204,8 @@ TEST_F(ContextualSuggestionsMetricsReporterTest, EnumNotReorderedTest) {
TEST_F(ContextualSuggestionsMetricsReporterTest, ButtonTest) { TEST_F(ContextualSuggestionsMetricsReporterTest, ButtonTest) {
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
GetReporter().SetupForPage(kTestNavigationUrl, GetSourceId()); GetReporter().SetupForPage(
kTestNavigationUrl, ArticleSource::CONTEXTUAL_SUGGESTIONS, GetSourceId());
GetReporter().RecordEvent(FETCH_REQUESTED); GetReporter().RecordEvent(FETCH_REQUESTED);
GetReporter().RecordEvent(FETCH_COMPLETED); GetReporter().RecordEvent(FETCH_COMPLETED);
GetReporter().RecordEvent(UI_BUTTON_SHOWN); GetReporter().RecordEvent(UI_BUTTON_SHOWN);
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/ntp_snippets/contextual/contextual_suggestions_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_reporter.h"
#include "base/debug/stack_trace.h" #include "base/debug/stack_trace.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_composite_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_composite_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_debugging_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_debugging_reporter.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
namespace contextual_suggestions { namespace contextual_suggestions {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_REPORTER_H_ #ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_REPORTER_H_
#define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_REPORTER_H_ #define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_REPORTER_H_
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -13,6 +13,11 @@ ...@@ -13,6 +13,11 @@
namespace contextual_suggestions { namespace contextual_suggestions {
// This represents the source of the navigation to the current page. It's set
// via referrer links. We only need EOC/other since we only want to compare
// metrics across this dimension.
enum class ArticleSource { CONTEXTUAL_SUGGESTIONS, OTHER };
class ContextualSuggestionsDebuggingReporter; class ContextualSuggestionsDebuggingReporter;
class ContextualSuggestionsReporter; class ContextualSuggestionsReporter;
...@@ -130,6 +135,7 @@ class ContextualSuggestionsReporter { ...@@ -130,6 +135,7 @@ class ContextualSuggestionsReporter {
// Sets up the page with the given |source_id| for event reporting. // Sets up the page with the given |source_id| for event reporting.
// All subsequent RecordEvent calls will apply to this page // All subsequent RecordEvent calls will apply to this page
virtual void SetupForPage(const std::string& url, virtual void SetupForPage(const std::string& url,
ArticleSource article_source,
ukm::SourceId source_id) = 0; ukm::SourceId source_id) = 0;
// Reports that an event occurred for the current page. // Reports that an event occurred for the current page.
...@@ -147,4 +153,4 @@ class ContextualSuggestionsReporter { ...@@ -147,4 +153,4 @@ class ContextualSuggestionsReporter {
} // namespace contextual_suggestions } // namespace contextual_suggestions
#endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_REPORTER_H_ #endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_REPORTER_H_
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/ntp_snippets/contextual/contextual_suggestions_ukm_entry.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_ukm_entry.h"
#include <algorithm> #include <algorithm>
#include "base/timer/elapsed_timer.h" #include "base/timer/elapsed_timer.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
#include "services/metrics/public/cpp/metrics_utils.h" #include "services/metrics/public/cpp/metrics_utils.h"
#include "services/metrics/public/cpp/ukm_builders.h" #include "services/metrics/public/cpp/ukm_builders.h"
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_UKM_ENTRY_H_ #ifndef COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_UKM_ENTRY_H_
#define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_UKM_ENTRY_H_ #define COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_UKM_ENTRY_H_
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
#include "services/metrics/public/cpp/ukm_source_id.h" #include "services/metrics/public/cpp/ukm_source_id.h"
namespace base { namespace base {
...@@ -85,4 +85,4 @@ class ContextualSuggestionsUkmEntry { ...@@ -85,4 +85,4 @@ class ContextualSuggestionsUkmEntry {
} // namespace contextual_suggestions } // namespace contextual_suggestions
#endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_CONTEXTUAL_SUGGESTIONS_UKM_ENTRY_H_ #endif // COMPONENTS_NTP_SNIPPETS_CONTEXTUAL_REPORTING_CONTEXTUAL_SUGGESTIONS_UKM_ENTRY_H_
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/ntp_snippets/contextual/contextual_suggestions_ukm_entry.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_ukm_entry.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#include "components/ntp_snippets/contextual/contextual_suggestions_metrics_reporter.h" #include "components/ntp_snippets/contextual/reporting/contextual_suggestions_metrics_reporter.h"
#include "components/ukm/test_ukm_recorder.h" #include "components/ukm/test_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h" #include "services/metrics/public/cpp/ukm_builders.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment