Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/ntp_snippets/content_suggestions_metrics.h" | 5 #include "components/ntp_snippets/content_suggestions_metrics.h" |
| 6 | 6 |
| 7 #include <cmath> | |
| 7 #include <string> | 8 #include <string> |
| 8 #include <type_traits> | 9 #include <type_traits> |
| 9 | 10 |
| 10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/metrics/histogram_functions.h" | |
| 11 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/metrics/user_metrics.h" | 14 #include "base/metrics/user_metrics.h" |
| 13 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 14 #include "base/template_util.h" | 16 #include "base/template_util.h" |
| 15 | 17 |
| 16 namespace ntp_snippets { | 18 namespace ntp_snippets { |
| 17 namespace metrics { | 19 namespace metrics { |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 const int kMaxSuggestionsPerCategory = 10; | 23 const int kMaxSuggestionsPerCategory = 10; |
| 22 const int kMaxSuggestionsTotal = 50; | 24 const int kMaxSuggestionsTotal = 50; |
| 23 | 25 |
| 24 const char kHistogramCountOnNtpOpened[] = | 26 const char kHistogramCountOnNtpOpened[] = |
| 25 "NewTabPage.ContentSuggestions.CountOnNtpOpened"; | 27 "NewTabPage.ContentSuggestions.CountOnNtpOpened"; |
| 26 const char kHistogramShown[] = "NewTabPage.ContentSuggestions.Shown"; | 28 const char kHistogramShown[] = "NewTabPage.ContentSuggestions.Shown"; |
| 27 const char kHistogramShownAge[] = "NewTabPage.ContentSuggestions.ShownAge"; | 29 const char kHistogramShownAge[] = "NewTabPage.ContentSuggestions.ShownAge"; |
| 28 const char kHistogramShownScore[] = "NewTabPage.ContentSuggestions.ShownScore"; | 30 const char kHistogramShownScore[] = |
| 31 "NewTabPage.ContentSuggestions.ShownScoreNormalized"; | |
| 29 const char kHistogramOpened[] = "NewTabPage.ContentSuggestions.Opened"; | 32 const char kHistogramOpened[] = "NewTabPage.ContentSuggestions.Opened"; |
| 30 const char kHistogramOpenedAge[] = "NewTabPage.ContentSuggestions.OpenedAge"; | 33 const char kHistogramOpenedAge[] = "NewTabPage.ContentSuggestions.OpenedAge"; |
| 31 const char kHistogramOpenedScore[] = | 34 const char kHistogramOpenedScore[] = |
| 32 "NewTabPage.ContentSuggestions.OpenedScore"; | 35 "NewTabPage.ContentSuggestions.OpenedScoreNormalized"; |
| 33 const char kHistogramOpenDisposition[] = | 36 const char kHistogramOpenDisposition[] = |
| 34 "NewTabPage.ContentSuggestions.OpenDisposition"; | 37 "NewTabPage.ContentSuggestions.OpenDisposition"; |
| 35 const char kHistogramMenuOpened[] = "NewTabPage.ContentSuggestions.MenuOpened"; | 38 const char kHistogramMenuOpened[] = "NewTabPage.ContentSuggestions.MenuOpened"; |
| 36 const char kHistogramMenuOpenedAge[] = | 39 const char kHistogramMenuOpenedAge[] = |
| 37 "NewTabPage.ContentSuggestions.MenuOpenedAge"; | 40 "NewTabPage.ContentSuggestions.MenuOpenedAge"; |
| 38 const char kHistogramMenuOpenedScore[] = | 41 const char kHistogramMenuOpenedScore[] = |
| 39 "NewTabPage.ContentSuggestions.MenuOpenedScore"; | 42 "NewTabPage.ContentSuggestions.MenuOpenedScoreNormalized"; |
| 40 const char kHistogramDismissedUnvisited[] = | 43 const char kHistogramDismissedUnvisited[] = |
| 41 "NewTabPage.ContentSuggestions.DismissedUnvisited"; | 44 "NewTabPage.ContentSuggestions.DismissedUnvisited"; |
| 42 const char kHistogramDismissedVisited[] = | 45 const char kHistogramDismissedVisited[] = |
| 43 "NewTabPage.ContentSuggestions.DismissedVisited"; | 46 "NewTabPage.ContentSuggestions.DismissedVisited"; |
| 44 const char kHistogramArticlesUsageTimeLocal[] = | 47 const char kHistogramArticlesUsageTimeLocal[] = |
| 45 "NewTabPage.ContentSuggestions.UsageTimeLocal"; | 48 "NewTabPage.ContentSuggestions.UsageTimeLocal"; |
| 46 const char kHistogramVisitDuration[] = | 49 const char kHistogramVisitDuration[] = |
| 47 "NewTabPage.ContentSuggestions.VisitDuration"; | 50 "NewTabPage.ContentSuggestions.VisitDuration"; |
| 48 const char kHistogramMoreButtonShown[] = | 51 const char kHistogramMoreButtonShown[] = |
| 49 "NewTabPage.ContentSuggestions.MoreButtonShown"; | 52 "NewTabPage.ContentSuggestions.MoreButtonShown"; |
| 50 const char kHistogramMoreButtonClicked[] = | 53 const char kHistogramMoreButtonClicked[] = |
| 51 "NewTabPage.ContentSuggestions.MoreButtonClicked"; | 54 "NewTabPage.ContentSuggestions.MoreButtonClicked"; |
| 52 const char kHistogramCategoryDismissed[] = | 55 const char kHistogramCategoryDismissed[] = |
| 53 "NewTabPage.ContentSuggestions.CategoryDismissed"; | 56 "NewTabPage.ContentSuggestions.CategoryDismissed"; |
| 54 const char kHistogramContentSuggestionsTimeSinceLastBackgroundFetch[] = | 57 const char kHistogramContentSuggestionsTimeSinceLastBackgroundFetch[] = |
| 55 "NewTabPage.ContentSuggestions.TimeSinceLastBackgroundFetch"; | 58 "NewTabPage.ContentSuggestions.TimeSinceLastBackgroundFetch"; |
| 56 | 59 |
| 57 const char kPerCategoryHistogramFormat[] = "%s.%s"; | 60 const char kPerCategoryHistogramFormat[] = "%s.%s"; |
| 58 | 61 |
| 59 // This mostly corresponds to the KnownCategories enum, but it is contiguous | 62 // This mostly corresponds to the KnownCategories enum, but it is contiguous |
| 60 // and contains exactly the values to be recorded in UMA. Don't remove or | 63 // and contains exactly the values to be recorded in UMA. Don't remove or |
| 61 // reorder elements, only add new ones at the end (before COUNT), and keep in | 64 // reorder elements, only add new ones at the end (before COUNT), and keep in |
| 62 // sync with ContentSuggestionsCategory in histograms.xml. | 65 // sync with ContentSuggestionsCategory in histograms.xml. |
| 63 enum class HistogramCategories { | 66 enum HistogramCategories { |
| 64 EXPERIMENTAL, | 67 EXPERIMENTAL, |
| 65 RECENT_TABS, | 68 RECENT_TABS, |
| 66 DOWNLOADS, | 69 DOWNLOADS, |
| 67 BOOKMARKS, | 70 BOOKMARKS, |
| 68 PHYSICAL_WEB_PAGES, | 71 PHYSICAL_WEB_PAGES, |
| 69 FOREIGN_TABS, | 72 FOREIGN_TABS, |
| 70 ARTICLES, | 73 ARTICLES, |
| 71 // Insert new values here! | 74 // Insert new values here! |
| 72 COUNT | 75 COUNT |
| 73 }; | 76 }; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 break; | 131 break; |
| 129 } | 132 } |
| 130 return std::string(); | 133 return std::string(); |
| 131 } | 134 } |
| 132 | 135 |
| 133 std::string GetCategoryHistogramName(const char* base_name, Category category) { | 136 std::string GetCategoryHistogramName(const char* base_name, Category category) { |
| 134 return base::StringPrintf(kPerCategoryHistogramFormat, base_name, | 137 return base::StringPrintf(kPerCategoryHistogramFormat, base_name, |
| 135 GetCategorySuffix(category).c_str()); | 138 GetCategorySuffix(category).c_str()); |
| 136 } | 139 } |
| 137 | 140 |
| 138 // This corresponds to UMA_HISTOGRAM_ENUMERATION, for use with dynamic histogram | |
| 139 // names. | |
| 140 void UmaHistogramEnumeration(const std::string& name, | |
| 141 int value, | |
| 142 int boundary_value) { | |
| 143 base::LinearHistogram::FactoryGet( | |
| 144 name, 1, boundary_value, boundary_value + 1, | |
| 145 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 146 ->Add(value); | |
| 147 } | |
| 148 | |
| 149 // This corresponds to UMA_HISTOGRAM_LONG_TIMES for use with dynamic histogram | |
| 150 // names. | |
| 151 void UmaHistogramLongTimes(const std::string& name, | |
| 152 const base::TimeDelta& value) { | |
| 153 base::Histogram::FactoryTimeGet( | |
| 154 name, base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), | |
| 155 50, base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 156 ->AddTime(value); | |
| 157 } | |
| 158 | |
| 159 // This corresponds to UMA_HISTOGRAM_CUSTOM_TIMES (with min/max appropriate | 141 // This corresponds to UMA_HISTOGRAM_CUSTOM_TIMES (with min/max appropriate |
| 160 // for the age of suggestions) for use with dynamic histogram names. | 142 // for the age of suggestions) for use with dynamic histogram names. |
| 161 void UmaHistogramAge(const std::string& name, const base::TimeDelta& value) { | 143 void UmaHistogramAge(const std::string& name, const base::TimeDelta& value) { |
| 162 base::Histogram::FactoryTimeGet( | 144 base::Histogram::FactoryTimeGet( |
| 163 name, base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(7), 100, | 145 name, base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(7), 100, |
| 164 base::HistogramBase::kUmaTargetedHistogramFlag) | 146 base::HistogramBase::kUmaTargetedHistogramFlag) |
| 165 ->AddTime(value); | 147 ->AddTime(value); |
| 166 } | 148 } |
| 167 | 149 |
| 168 // This corresponds to UMA_HISTOGRAM_CUSTOM_COUNTS (with min/max appropriate | 150 void LogCategoryHistogramPosition(const char* base_name, |
| 169 // for the score of suggestions) for use with dynamic histogram names. | 151 Category category, |
| 170 void UmaHistogramScore(const std::string& name, float value) { | 152 int position, |
| 171 base::Histogram::FactoryGet(name, 1, 100000, 50, | 153 int max_position) { |
| 172 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 173 ->Add(value); | |
| 174 } | |
| 175 | |
| 176 void LogCategoryHistogramEnumeration(const char* base_name, | |
| 177 Category category, | |
| 178 int value, | |
| 179 int boundary_value) { | |
| 180 std::string name = GetCategoryHistogramName(base_name, category); | 154 std::string name = GetCategoryHistogramName(base_name, category); |
| 181 // Since the histogram name is dynamic, we can't use the regular macro. | 155 // Since the histogram name is dynamic, we can't use the regular macro. |
| 182 UmaHistogramEnumeration(name, value, boundary_value); | 156 base::UmaHistogramExactLinear(name, position, max_position); |
| 183 } | |
| 184 | |
| 185 void LogCategoryHistogramLongTimes(const char* base_name, | |
| 186 Category category, | |
| 187 const base::TimeDelta& value) { | |
| 188 std::string name = GetCategoryHistogramName(base_name, category); | |
| 189 // Since the histogram name is dynamic, we can't use the regular macro. | |
| 190 UmaHistogramLongTimes(name, value); | |
| 191 } | 157 } |
| 192 | 158 |
| 193 void LogCategoryHistogramAge(const char* base_name, | 159 void LogCategoryHistogramAge(const char* base_name, |
| 194 Category category, | 160 Category category, |
| 195 const base::TimeDelta& value) { | 161 const base::TimeDelta& value) { |
| 196 std::string name = GetCategoryHistogramName(base_name, category); | 162 std::string name = GetCategoryHistogramName(base_name, category); |
| 197 // Since the histogram name is dynamic, we can't use the regular macro. | 163 // Since the histogram name is dynamic, we can't use the regular macro. |
| 198 UmaHistogramAge(name, value); | 164 UmaHistogramAge(name, value); |
| 199 } | 165 } |
| 200 | 166 |
| 201 void LogCategoryHistogramScore(const char* base_name, | 167 void LogCategoryHistogramScore(const char* base_name, |
| 202 Category category, | 168 Category category, |
| 203 float score) { | 169 float score) { |
| 204 std::string name = GetCategoryHistogramName(base_name, category); | 170 std::string name = GetCategoryHistogramName(base_name, category); |
| 205 // Since the histogram name is dynamic, we can't use the regular macro. | 171 // Scores are typically reported in a range of (0,1]. As UMA does not support |
| 206 UmaHistogramScore(name, score); | 172 // floats, we put them on a discrete scale of [1,10]. We keep the extra bucket |
| 173 // 11 for unexpected over-flows as we want to distinguish them from scores | |
| 174 // close to 1. For instance, the discrete value 1 represents score values | |
| 175 // within (0.0, 0.1]. | |
| 176 base::UmaHistogramExactLinear(name, ceil(score * 10), 11); | |
| 207 } | 177 } |
| 208 | 178 |
| 209 // Records ContentSuggestions usage. Therefore the day is sliced into 20min | 179 // Records ContentSuggestions usage. Therefore the day is sliced into 20min |
| 210 // buckets. Depending on the current local time the count of the corresponding | 180 // buckets. Depending on the current local time the count of the corresponding |
| 211 // bucket is increased. | 181 // bucket is increased. |
| 212 void RecordContentSuggestionsUsage() { | 182 void RecordContentSuggestionsUsage() { |
| 213 const int kBucketSizeMins = 20; | 183 const int kBucketSizeMins = 20; |
| 214 const int kNumBuckets = 24 * 60 / kBucketSizeMins; | 184 const int kNumBuckets = 24 * 60 / kBucketSizeMins; |
| 215 | 185 |
| 216 base::Time::Exploded now_exploded; | 186 base::Time::Exploded now_exploded; |
| 217 base::Time::Now().LocalExplode(&now_exploded); | 187 base::Time::Now().LocalExplode(&now_exploded); |
| 218 int bucket = (now_exploded.hour * 60 + now_exploded.minute) / kBucketSizeMins; | 188 int bucket = (now_exploded.hour * 60 + now_exploded.minute) / kBucketSizeMins; |
| 219 | 189 |
| 220 const char* kWeekdayNames[] = {"Sunday", "Monday", "Tuesday", "Wednesday", | 190 const char* kWeekdayNames[] = {"Sunday", "Monday", "Tuesday", "Wednesday", |
| 221 "Thursday", "Friday", "Saturday"}; | 191 "Thursday", "Friday", "Saturday"}; |
| 222 std::string histogram_name( | 192 std::string histogram_name( |
| 223 base::StringPrintf("%s.%s", kHistogramArticlesUsageTimeLocal, | 193 base::StringPrintf("%s.%s", kHistogramArticlesUsageTimeLocal, |
| 224 kWeekdayNames[now_exploded.day_of_week])); | 194 kWeekdayNames[now_exploded.day_of_week])); |
| 225 UmaHistogramEnumeration(histogram_name, bucket, kNumBuckets); | 195 base::UmaHistogramExactLinear(histogram_name, bucket, kNumBuckets); |
| 226 | 196 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramArticlesUsageTimeLocal, bucket, |
| 227 UMA_HISTOGRAM_ENUMERATION(kHistogramArticlesUsageTimeLocal, bucket, | 197 kNumBuckets); |
| 228 kNumBuckets); | |
| 229 | 198 |
| 230 base::RecordAction( | 199 base::RecordAction( |
| 231 base::UserMetricsAction("NewTabPage_ContentSuggestions_ArticlesUsage")); | 200 base::UserMetricsAction("NewTabPage_ContentSuggestions_ArticlesUsage")); |
| 232 } | 201 } |
| 233 | 202 |
| 234 } // namespace | 203 } // namespace |
| 235 | 204 |
| 236 void OnPageShown( | 205 void OnPageShown( |
| 237 const std::vector<std::pair<Category, int>>& suggestions_per_category) { | 206 const std::vector<std::pair<Category, int>>& suggestions_per_category) { |
| 238 int suggestions_total = 0; | 207 int suggestions_total = 0; |
| 239 for (const std::pair<Category, int>& item : suggestions_per_category) { | 208 for (const std::pair<Category, int>& item : suggestions_per_category) { |
| 240 LogCategoryHistogramEnumeration(kHistogramCountOnNtpOpened, item.first, | 209 LogCategoryHistogramPosition(kHistogramCountOnNtpOpened, item.first, |
| 241 item.second, kMaxSuggestionsPerCategory); | 210 item.second, kMaxSuggestionsPerCategory); |
| 242 suggestions_total += item.second; | 211 suggestions_total += item.second; |
| 243 } | 212 } |
| 244 | 213 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramCountOnNtpOpened, suggestions_total, |
| 245 UMA_HISTOGRAM_ENUMERATION(kHistogramCountOnNtpOpened, suggestions_total, | 214 kMaxSuggestionsTotal); |
| 246 kMaxSuggestionsTotal); | |
| 247 } | 215 } |
| 248 | 216 |
| 249 void OnSuggestionShown(int global_position, | 217 void OnSuggestionShown(int global_position, |
| 250 Category category, | 218 Category category, |
| 251 int category_position, | 219 int category_position, |
| 252 base::Time publish_date, | 220 base::Time publish_date, |
| 253 base::Time last_background_fetch_time, | 221 base::Time last_background_fetch_time, |
| 254 float score) { | 222 float score) { |
| 255 UMA_HISTOGRAM_ENUMERATION(kHistogramShown, global_position, | 223 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramShown, global_position, |
| 256 kMaxSuggestionsTotal); | 224 kMaxSuggestionsTotal); |
| 257 LogCategoryHistogramEnumeration(kHistogramShown, category, category_position, | 225 LogCategoryHistogramPosition(kHistogramShown, category, category_position, |
| 258 kMaxSuggestionsPerCategory); | 226 kMaxSuggestionsPerCategory); |
| 259 | 227 |
| 260 base::TimeDelta age = base::Time::Now() - publish_date; | 228 base::TimeDelta age = base::Time::Now() - publish_date; |
| 261 LogCategoryHistogramAge(kHistogramShownAge, category, age); | 229 LogCategoryHistogramAge(kHistogramShownAge, category, age); |
| 262 | 230 |
| 263 LogCategoryHistogramScore(kHistogramShownScore, category, score); | 231 LogCategoryHistogramScore(kHistogramShownScore, category, score); |
| 264 | 232 |
| 265 // TODO(markusheintz): Discuss whether the code below should be move into a | 233 // TODO(markusheintz): Discuss whether the code below should be move into a |
| 266 // separate method called OnSuggestionsListShown. | 234 // separate method called OnSuggestionsListShown. |
| 267 // When the first of the articles suggestions is shown, then we count this as | 235 // When the first of the articles suggestions is shown, then we count this as |
| 268 // a single usage of content suggestions. | 236 // a single usage of content suggestions. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 279 /*bucket_count=*/100); | 247 /*bucket_count=*/100); |
| 280 } | 248 } |
| 281 } | 249 } |
| 282 | 250 |
| 283 void OnSuggestionOpened(int global_position, | 251 void OnSuggestionOpened(int global_position, |
| 284 Category category, | 252 Category category, |
| 285 int category_position, | 253 int category_position, |
| 286 base::Time publish_date, | 254 base::Time publish_date, |
| 287 float score, | 255 float score, |
| 288 WindowOpenDisposition disposition) { | 256 WindowOpenDisposition disposition) { |
| 289 UMA_HISTOGRAM_ENUMERATION(kHistogramOpened, global_position, | 257 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramOpened, global_position, |
| 290 kMaxSuggestionsTotal); | 258 kMaxSuggestionsTotal); |
| 291 LogCategoryHistogramEnumeration(kHistogramOpened, category, category_position, | 259 LogCategoryHistogramPosition(kHistogramOpened, category, category_position, |
| 292 kMaxSuggestionsPerCategory); | 260 kMaxSuggestionsPerCategory); |
| 293 | 261 |
| 294 base::TimeDelta age = base::Time::Now() - publish_date; | 262 base::TimeDelta age = base::Time::Now() - publish_date; |
| 295 LogCategoryHistogramAge(kHistogramOpenedAge, category, age); | 263 LogCategoryHistogramAge(kHistogramOpenedAge, category, age); |
| 296 | 264 |
| 297 LogCategoryHistogramScore(kHistogramOpenedScore, category, score); | 265 LogCategoryHistogramScore(kHistogramOpenedScore, category, score); |
| 298 | 266 |
| 299 UMA_HISTOGRAM_ENUMERATION( | 267 // TODO(tschumann): Why do we convert to int and incremenet by one?? |
| 268 // If not, we could use UmaHistogramEnumeration(). | |
|
Alexei Svitkine (slow)
2017/01/16 17:37:10
It's because WindowOpenDisposition::MAX_VALUE is i
| |
| 269 UMA_HISTOGRAM_EXACT_LINEAR( | |
|
Marc Treib
2017/01/16 14:35:12
I don't understand this change - what was wrong wi
tschumann
2017/01/16 15:00:52
well, we're not passing in an enum :-)
base::UmaHi
Marc Treib
2017/01/16 15:12:24
But we *are* passing in an enum here...? I guess t
tschumann
2017/01/16 15:27:32
nope, at least strictly speaking we're passing two
| |
| 300 kHistogramOpenDisposition, static_cast<int>(disposition), | 270 kHistogramOpenDisposition, static_cast<int>(disposition), |
| 301 static_cast<int>(WindowOpenDisposition::MAX_VALUE) + 1); | 271 static_cast<int>(WindowOpenDisposition::MAX_VALUE) + 1); |
| 302 LogCategoryHistogramEnumeration( | 272 base::UmaHistogramExactLinear( |
| 303 kHistogramOpenDisposition, category, static_cast<int>(disposition), | 273 GetCategoryHistogramName(kHistogramOpenDisposition, category), |
| 274 static_cast<int>(disposition), | |
| 304 static_cast<int>(WindowOpenDisposition::MAX_VALUE) + 1); | 275 static_cast<int>(WindowOpenDisposition::MAX_VALUE) + 1); |
| 305 | 276 |
| 306 if (category.IsKnownCategory(KnownCategories::ARTICLES)) { | 277 if (category.IsKnownCategory(KnownCategories::ARTICLES)) { |
| 307 RecordContentSuggestionsUsage(); | 278 RecordContentSuggestionsUsage(); |
| 308 } | 279 } |
| 309 } | 280 } |
| 310 | 281 |
| 311 void OnSuggestionMenuOpened(int global_position, | 282 void OnSuggestionMenuOpened(int global_position, |
| 312 Category category, | 283 Category category, |
| 313 int category_position, | 284 int category_position, |
| 314 base::Time publish_date, | 285 base::Time publish_date, |
| 315 float score) { | 286 float score) { |
| 316 UMA_HISTOGRAM_ENUMERATION(kHistogramMenuOpened, global_position, | 287 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramMenuOpened, global_position, |
| 317 kMaxSuggestionsTotal); | 288 kMaxSuggestionsTotal); |
| 318 LogCategoryHistogramEnumeration(kHistogramMenuOpened, category, | 289 LogCategoryHistogramPosition(kHistogramMenuOpened, category, |
| 319 category_position, | 290 category_position, kMaxSuggestionsPerCategory); |
| 320 kMaxSuggestionsPerCategory); | |
| 321 | 291 |
| 322 base::TimeDelta age = base::Time::Now() - publish_date; | 292 base::TimeDelta age = base::Time::Now() - publish_date; |
| 323 LogCategoryHistogramAge(kHistogramMenuOpenedAge, category, age); | 293 LogCategoryHistogramAge(kHistogramMenuOpenedAge, category, age); |
| 324 | 294 |
| 325 LogCategoryHistogramScore(kHistogramMenuOpenedScore, category, score); | 295 LogCategoryHistogramScore(kHistogramMenuOpenedScore, category, score); |
| 326 } | 296 } |
| 327 | 297 |
| 328 void OnSuggestionDismissed(int global_position, | 298 void OnSuggestionDismissed(int global_position, |
| 329 Category category, | 299 Category category, |
| 330 int category_position, | 300 int category_position, |
| 331 bool visited) { | 301 bool visited) { |
| 332 if (visited) { | 302 if (visited) { |
| 333 UMA_HISTOGRAM_ENUMERATION(kHistogramDismissedVisited, global_position, | 303 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramDismissedVisited, global_position, |
| 334 kMaxSuggestionsTotal); | 304 kMaxSuggestionsTotal); |
| 335 LogCategoryHistogramEnumeration(kHistogramDismissedVisited, category, | 305 LogCategoryHistogramPosition(kHistogramDismissedVisited, category, |
| 336 category_position, | 306 category_position, kMaxSuggestionsPerCategory); |
| 337 kMaxSuggestionsPerCategory); | |
| 338 } else { | 307 } else { |
| 339 UMA_HISTOGRAM_ENUMERATION(kHistogramDismissedUnvisited, global_position, | 308 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramDismissedUnvisited, global_position, |
| 340 kMaxSuggestionsTotal); | 309 kMaxSuggestionsTotal); |
| 341 LogCategoryHistogramEnumeration(kHistogramDismissedUnvisited, category, | 310 LogCategoryHistogramPosition(kHistogramDismissedUnvisited, category, |
| 342 category_position, | 311 category_position, kMaxSuggestionsPerCategory); |
| 343 kMaxSuggestionsPerCategory); | |
| 344 } | 312 } |
| 345 } | 313 } |
| 346 | 314 |
| 347 void OnSuggestionTargetVisited(Category category, base::TimeDelta visit_time) { | 315 void OnSuggestionTargetVisited(Category category, base::TimeDelta visit_time) { |
| 348 LogCategoryHistogramLongTimes(kHistogramVisitDuration, category, visit_time); | 316 std::string name = |
| 317 GetCategoryHistogramName(kHistogramVisitDuration, category); | |
| 318 base::UmaHistogramLongTimes(name, visit_time); | |
| 349 } | 319 } |
| 350 | 320 |
| 351 void OnMoreButtonShown(Category category, int position) { | 321 void OnMoreButtonShown(Category category, int position) { |
| 352 // The "more" card can appear in addition to the actual suggestions, so add | 322 // The "more" card can appear in addition to the actual suggestions, so add |
| 353 // one extra bucket to this histogram. | 323 // one extra bucket to this histogram. |
| 354 LogCategoryHistogramEnumeration(kHistogramMoreButtonShown, category, position, | 324 LogCategoryHistogramPosition(kHistogramMoreButtonShown, category, position, |
| 355 kMaxSuggestionsPerCategory + 1); | 325 kMaxSuggestionsPerCategory + 1); |
| 356 } | 326 } |
| 357 | 327 |
| 358 void OnMoreButtonClicked(Category category, int position) { | 328 void OnMoreButtonClicked(Category category, int position) { |
| 359 // The "more" card can appear in addition to the actual suggestions, so add | 329 // The "more" card can appear in addition to the actual suggestions, so add |
| 360 // one extra bucket to this histogram. | 330 // one extra bucket to this histogram. |
| 361 LogCategoryHistogramEnumeration(kHistogramMoreButtonClicked, category, | 331 LogCategoryHistogramPosition(kHistogramMoreButtonClicked, category, position, |
| 362 position, kMaxSuggestionsPerCategory + 1); | 332 kMaxSuggestionsPerCategory + 1); |
| 363 } | 333 } |
| 364 | 334 |
| 365 void OnCategoryDismissed(Category category) { | 335 void OnCategoryDismissed(Category category) { |
| 366 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, | 336 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, |
| 367 static_cast<int>(GetHistogramCategory(category)), | 337 GetHistogramCategory(category), |
| 368 static_cast<int>(HistogramCategories::COUNT)); | 338 HistogramCategories::COUNT); |
| 369 } | 339 } |
| 370 | 340 |
| 371 } // namespace metrics | 341 } // namespace metrics |
| 372 } // namespace ntp_snippets | 342 } // namespace ntp_snippets |
| OLD | NEW |