| 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 <cmath> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <type_traits> | 9 #include <type_traits> |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const char kHistogramDismissedVisited[] = | 48 const char kHistogramDismissedVisited[] = |
| 49 "NewTabPage.ContentSuggestions.DismissedVisited"; | 49 "NewTabPage.ContentSuggestions.DismissedVisited"; |
| 50 const char kHistogramArticlesUsageTimeLocal[] = | 50 const char kHistogramArticlesUsageTimeLocal[] = |
| 51 "NewTabPage.ContentSuggestions.UsageTimeLocal"; | 51 "NewTabPage.ContentSuggestions.UsageTimeLocal"; |
| 52 const char kHistogramVisitDuration[] = | 52 const char kHistogramVisitDuration[] = |
| 53 "NewTabPage.ContentSuggestions.VisitDuration"; | 53 "NewTabPage.ContentSuggestions.VisitDuration"; |
| 54 const char kHistogramMoreButtonShown[] = | 54 const char kHistogramMoreButtonShown[] = |
| 55 "NewTabPage.ContentSuggestions.MoreButtonShown"; | 55 "NewTabPage.ContentSuggestions.MoreButtonShown"; |
| 56 const char kHistogramMoreButtonClicked[] = | 56 const char kHistogramMoreButtonClicked[] = |
| 57 "NewTabPage.ContentSuggestions.MoreButtonClicked"; | 57 "NewTabPage.ContentSuggestions.MoreButtonClicked"; |
| 58 const char kHistogramMovedUpCategoryNewIndex[] = |
| 59 "NewTabPage.ContentSuggestions.MovedUpCategoryNewIndex"; |
| 58 const char kHistogramCategoryDismissed[] = | 60 const char kHistogramCategoryDismissed[] = |
| 59 "NewTabPage.ContentSuggestions.CategoryDismissed"; | 61 "NewTabPage.ContentSuggestions.CategoryDismissed"; |
| 60 const char kHistogramContentSuggestionsTimeSinceLastBackgroundFetch[] = | 62 const char kHistogramContentSuggestionsTimeSinceLastBackgroundFetch[] = |
| 61 "NewTabPage.ContentSuggestions.TimeSinceLastBackgroundFetch"; | 63 "NewTabPage.ContentSuggestions.TimeSinceLastBackgroundFetch"; |
| 62 | 64 |
| 63 const char kPerCategoryHistogramFormat[] = "%s.%s"; | 65 const char kPerCategoryHistogramFormat[] = "%s.%s"; |
| 64 | 66 |
| 65 // This mostly corresponds to the KnownCategories enum, but it is contiguous | 67 // This mostly corresponds to the KnownCategories enum, but it is contiguous |
| 66 // and contains exactly the values to be recorded in UMA. Don't remove or | 68 // and contains exactly the values to be recorded in UMA. Don't remove or |
| 67 // reorder elements, only add new ones at the end (before COUNT), and keep in | 69 // reorder elements, only add new ones at the end (before COUNT), and keep in |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 kMaxSuggestionsPerCategory); | 325 kMaxSuggestionsPerCategory); |
| 324 } | 326 } |
| 325 } | 327 } |
| 326 | 328 |
| 327 void OnSuggestionTargetVisited(Category category, base::TimeDelta visit_time) { | 329 void OnSuggestionTargetVisited(Category category, base::TimeDelta visit_time) { |
| 328 std::string name = | 330 std::string name = |
| 329 GetCategoryHistogramName(kHistogramVisitDuration, category); | 331 GetCategoryHistogramName(kHistogramVisitDuration, category); |
| 330 base::UmaHistogramLongTimes(name, visit_time); | 332 base::UmaHistogramLongTimes(name, visit_time); |
| 331 } | 333 } |
| 332 | 334 |
| 335 void OnCategoryMovedUp(int new_index) { |
| 336 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramMovedUpCategoryNewIndex, new_index, |
| 337 kMaxCategories); |
| 338 } |
| 339 |
| 333 void OnMoreButtonShown(Category category, int position) { | 340 void OnMoreButtonShown(Category category, int position) { |
| 334 // The "more" card can appear in addition to the actual suggestions, so add | 341 // The "more" card can appear in addition to the actual suggestions, so add |
| 335 // one extra bucket to this histogram. | 342 // one extra bucket to this histogram. |
| 336 LogCategoryHistogramPosition(kHistogramMoreButtonShown, category, position, | 343 LogCategoryHistogramPosition(kHistogramMoreButtonShown, category, position, |
| 337 kMaxSuggestionsPerCategory + 1); | 344 kMaxSuggestionsPerCategory + 1); |
| 338 } | 345 } |
| 339 | 346 |
| 340 void OnMoreButtonClicked(Category category, int position) { | 347 void OnMoreButtonClicked(Category category, int position) { |
| 341 // The "more" card can appear in addition to the actual suggestions, so add | 348 // The "more" card can appear in addition to the actual suggestions, so add |
| 342 // one extra bucket to this histogram. | 349 // one extra bucket to this histogram. |
| 343 LogCategoryHistogramPosition(kHistogramMoreButtonClicked, category, position, | 350 LogCategoryHistogramPosition(kHistogramMoreButtonClicked, category, position, |
| 344 kMaxSuggestionsPerCategory + 1); | 351 kMaxSuggestionsPerCategory + 1); |
| 345 } | 352 } |
| 346 | 353 |
| 347 void OnCategoryDismissed(Category category) { | 354 void OnCategoryDismissed(Category category) { |
| 348 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, | 355 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, |
| 349 GetHistogramCategory(category), | 356 GetHistogramCategory(category), |
| 350 HistogramCategories::COUNT); | 357 HistogramCategories::COUNT); |
| 351 } | 358 } |
| 352 | 359 |
| 353 } // namespace metrics | 360 } // namespace metrics |
| 354 } // namespace ntp_snippets | 361 } // namespace ntp_snippets |
| OLD | NEW |