| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 suggestions_total += item.second; | 216 suggestions_total += item.second; |
| 217 } | 217 } |
| 218 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramCountOnNtpOpened, suggestions_total, | 218 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramCountOnNtpOpened, suggestions_total, |
| 219 kMaxSuggestionsTotal); | 219 kMaxSuggestionsTotal); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void OnSuggestionShown(int global_position, | 222 void OnSuggestionShown(int global_position, |
| 223 Category category, | 223 Category category, |
| 224 int position_in_category, | 224 int position_in_category, |
| 225 base::Time publish_date, | 225 base::Time publish_date, |
| 226 base::Time last_background_fetch_time, | 226 float score, |
| 227 float score) { | 227 base::Time fetch_date) { |
| 228 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramShown, global_position, | 228 UMA_HISTOGRAM_EXACT_LINEAR(kHistogramShown, global_position, |
| 229 kMaxSuggestionsTotal); | 229 kMaxSuggestionsTotal); |
| 230 LogCategoryHistogramPosition(kHistogramShown, category, position_in_category, | 230 LogCategoryHistogramPosition(kHistogramShown, category, position_in_category, |
| 231 kMaxSuggestionsPerCategory); | 231 kMaxSuggestionsPerCategory); |
| 232 | 232 |
| 233 base::TimeDelta age = base::Time::Now() - publish_date; | 233 base::TimeDelta age = base::Time::Now() - publish_date; |
| 234 LogCategoryHistogramAge(kHistogramShownAge, category, age); | 234 LogCategoryHistogramAge(kHistogramShownAge, category, age); |
| 235 | 235 |
| 236 LogCategoryHistogramScore(kHistogramShownScore, category, score); | 236 LogCategoryHistogramScore(kHistogramShownScore, category, score); |
| 237 | 237 |
| 238 // TODO(markusheintz): Discuss whether the code below should be move into a | 238 // TODO(markusheintz): Discuss whether the code below should be move into a |
| 239 // separate method called OnSuggestionsListShown. | 239 // separate method called OnSuggestionsListShown. |
| 240 // When the first of the articles suggestions is shown, then we count this as | 240 // When the first of the articles suggestions is shown, then we count this as |
| 241 // a single usage of content suggestions. | 241 // a single usage of content suggestions. |
| 242 if (category.IsKnownCategory(KnownCategories::ARTICLES) && | 242 if (category.IsKnownCategory(KnownCategories::ARTICLES) && |
| 243 position_in_category == 0) { | 243 position_in_category == 0) { |
| 244 RecordContentSuggestionsUsage(); | 244 RecordContentSuggestionsUsage(); |
| 245 | 245 |
| 246 // Records the time since the last background fetch of the remote content | 246 // Records the time since the last background fetch of the remote content |
| 247 // suggestions. | 247 // suggestions. |
| 248 UMA_HISTOGRAM_CUSTOM_TIMES( | 248 UMA_HISTOGRAM_CUSTOM_TIMES( |
| 249 kHistogramContentSuggestionsTimeSinceLastBackgroundFetch, | 249 kHistogramContentSuggestionsTimeSinceLastBackgroundFetch, |
| 250 base::Time::Now() - last_background_fetch_time, | 250 base::Time::Now() - fetch_date, base::TimeDelta::FromSeconds(1), |
| 251 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromDays(7), | 251 base::TimeDelta::FromDays(7), |
| 252 /*bucket_count=*/100); | 252 /*bucket_count=*/100); |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 | 255 |
| 256 void OnSuggestionOpened(int global_position, | 256 void OnSuggestionOpened(int global_position, |
| 257 Category category, | 257 Category category, |
| 258 int category_index, | 258 int category_index, |
| 259 int position_in_category, | 259 int position_in_category, |
| 260 base::Time publish_date, | 260 base::Time publish_date, |
| 261 float score, | 261 float score, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 352 } |
| 353 | 353 |
| 354 void OnCategoryDismissed(Category category) { | 354 void OnCategoryDismissed(Category category) { |
| 355 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, | 355 UMA_HISTOGRAM_ENUMERATION(kHistogramCategoryDismissed, |
| 356 GetHistogramCategory(category), | 356 GetHistogramCategory(category), |
| 357 HistogramCategories::COUNT); | 357 HistogramCategories::COUNT); |
| 358 } | 358 } |
| 359 | 359 |
| 360 } // namespace metrics | 360 } // namespace metrics |
| 361 } // namespace ntp_snippets | 361 } // namespace ntp_snippets |
| OLD | NEW |