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 <cmath> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <type_traits> | 9 #include <type_traits> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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[] = | 58 const char kHistogramMovedUpCategoryNewIndex[] = |
| 59 "NewTabPage.ContentSuggestions.MovedUpCategoryNewIndex"; | 59 "NewTabPage.ContentSuggestions.MovedUpCategoryNewIndex"; |
| 60 const char kHistogramCategoryDismissed[] = | 60 const char kHistogramCategoryDismissed[] = |
| 61 "NewTabPage.ContentSuggestions.CategoryDismissed"; | 61 "NewTabPage.ContentSuggestions.CategoryDismissed"; |
| 62 const char kHistogramContentSuggestionsTimeSinceLastBackgroundFetch[] = | 62 const char kHistogramContentSuggestionsTimeSinceLastBackgroundFetch[] = |
| 63 "NewTabPage.ContentSuggestions.TimeSinceLastBackgroundFetch"; | 63 "NewTabPage.ContentSuggestions.TimeSinceLastBackgroundFetch"; |
| 64 const char kHistogramContentSuggestionsTimeSinceSuggestionFetched[] = | |
|
Marc Treib
2017/02/21 09:14:09
optional nit: You could remove "ContentSuggestions
markusheintz_
2017/02/21 11:31:50
Done.
| |
| 65 "NewTabPage.ContentSuggestions.TimeSinceSuggestionFetched"; | |
| 64 | 66 |
| 65 const char kPerCategoryHistogramFormat[] = "%s.%s"; | 67 const char kPerCategoryHistogramFormat[] = "%s.%s"; |
| 66 | 68 |
| 67 // This mostly corresponds to the KnownCategories enum, but it is contiguous | 69 // This mostly corresponds to the KnownCategories enum, but it is contiguous |
| 68 // and contains exactly the values to be recorded in UMA. Don't remove or | 70 // and contains exactly the values to be recorded in UMA. Don't remove or |
| 69 // reorder elements, only add new ones at the end (before COUNT), and keep in | 71 // reorder elements, only add new ones at the end (before COUNT), and keep in |
| 70 // sync with ContentSuggestionsCategory in histograms.xml. | 72 // sync with ContentSuggestionsCategory in histograms.xml. |
| 71 enum HistogramCategories { | 73 enum HistogramCategories { |
| 72 EXPERIMENTAL, | 74 EXPERIMENTAL, |
| 73 RECENT_TABS, | 75 RECENT_TABS, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramShown, global_position, | 230 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramShown, global_position, |
| 229 kMaxSuggestionsTotal); | 231 kMaxSuggestionsTotal); |
| 230 LogCategoryHistogramPosition(kHistogramShown, category, position_in_category, | 232 LogCategoryHistogramPosition(kHistogramShown, category, position_in_category, |
| 231 kMaxSuggestionsPerCategory); | 233 kMaxSuggestionsPerCategory); |
| 232 | 234 |
| 233 base::TimeDelta age = base::Time::Now() - publish_date; | 235 base::TimeDelta age = base::Time::Now() - publish_date; |
| 234 LogCategoryHistogramAge(kHistogramShownAge, category, age); | 236 LogCategoryHistogramAge(kHistogramShownAge, category, age); |
| 235 | 237 |
| 236 LogCategoryHistogramScore(kHistogramShownScore, category, score); | 238 LogCategoryHistogramScore(kHistogramShownScore, category, score); |
| 237 | 239 |
| 240 // Records the time since the fetch time of the displayed snippet. | |
| 241 UMA_HISTOGRAM_CUSTOM_TIMES( | |
| 242 kHistogramContentSuggestionsTimeSinceSuggestionFetched, | |
| 243 base::Time::Now() - fetch_date, base::TimeDelta::FromSeconds(1), | |
| 244 base::TimeDelta::FromDays(7), | |
| 245 /*bucket_count=*/100); | |
|
Marc Treib
2017/02/21 09:14:09
Should we record this only for ARTICLES?
If not, s
markusheintz_
2017/02/21 11:31:50
Done.
No the fetch date for non Article suggestio
| |
| 246 | |
| 238 // TODO(markusheintz): Discuss whether the code below should be move into a | 247 // TODO(markusheintz): Discuss whether the code below should be move into a |
| 239 // separate method called OnSuggestionsListShown. | 248 // separate method called OnSuggestionsListShown. |
| 240 // When the first of the articles suggestions is shown, then we count this as | 249 // When the first of the articles suggestions is shown, then we count this as |
| 241 // a single usage of content suggestions. | 250 // a single usage of content suggestions. |
| 242 if (category.IsKnownCategory(KnownCategories::ARTICLES) && | 251 if (category.IsKnownCategory(KnownCategories::ARTICLES) && |
| 243 position_in_category == 0) { | 252 position_in_category == 0) { |
| 244 RecordContentSuggestionsUsage(); | 253 RecordContentSuggestionsUsage(); |
| 245 | 254 |
| 246 // Records the time since the last background fetch of the remote content | 255 // Records the time since the last background fetch of the remote content |
| 247 // suggestions. | 256 // suggestions. |
| 248 UMA_HISTOGRAM_CUSTOM_TIMES( | 257 UMA_HISTOGRAM_CUSTOM_TIMES( |
|
jkrcal
2017/02/20 18:38:37
I am wondering, do we still need the old histogram
markusheintz_
2017/02/21 11:31:50
I removed the code.
| |
| 249 kHistogramContentSuggestionsTimeSinceLastBackgroundFetch, | 258 kHistogramContentSuggestionsTimeSinceLastBackgroundFetch, |
| 250 base::Time::Now() - fetch_date, base::TimeDelta::FromSeconds(1), | 259 base::Time::Now() - fetch_date, base::TimeDelta::FromSeconds(1), |
| 251 base::TimeDelta::FromDays(7), | 260 base::TimeDelta::FromDays(7), |
| 252 /*bucket_count=*/100); | 261 /*bucket_count=*/100); |
| 253 } | 262 } |
| 254 } | 263 } |
| 255 | 264 |
| 256 void OnSuggestionOpened(int global_position, | 265 void OnSuggestionOpened(int global_position, |
| 257 Category category, | 266 Category category, |
| 258 int category_index, | 267 int category_index, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 } | 361 } |
| 353 | 362 |
| 354 void OnCategoryDismissed(Category category) { | 363 void OnCategoryDismissed(Category category) { |
| 355 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, | 364 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, |
| 356 GetHistogramCategory(category), | 365 GetHistogramCategory(category), |
| 357 HistogramCategories::COUNT); | 366 HistogramCategories::COUNT); |
| 358 } | 367 } |
| 359 | 368 |
| 360 } // namespace metrics | 369 } // namespace metrics |
| 361 } // namespace ntp_snippets | 370 } // namespace ntp_snippets |
| OLD | NEW |