| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/chrome/browser/desktop_promotion/desktop_promotion_sync_observer.h" | 5 #import "ios/chrome/browser/desktop_promotion/desktop_promotion_sync_observer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 pref_service_->GetInteger(prefs::kDesktopIOSPromotionSMSEntryPoint); | 68 pref_service_->GetInteger(prefs::kDesktopIOSPromotionSMSEntryPoint); |
| 69 int shown_entrypoints = | 69 int shown_entrypoints = |
| 70 pref_service_->GetInteger(prefs::kDesktopIOSPromotionShownEntryPoints); | 70 pref_service_->GetInteger(prefs::kDesktopIOSPromotionShownEntryPoints); |
| 71 | 71 |
| 72 // Entry points are represented on the preference by integers [1..4]. | 72 // Entry points are represented on the preference by integers [1..4]. |
| 73 // Entry points constants are defined on: | 73 // Entry points constants are defined on: |
| 74 // chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_util.h | 74 // chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_util.h |
| 75 int entrypoint_prefixes_count = | 75 int entrypoint_prefixes_count = |
| 76 arraysize(kDesktopIOSPromotionEntrypointHistogramPrefix); | 76 arraysize(kDesktopIOSPromotionEntrypointHistogramPrefix); |
| 77 for (int i = 1; i < entrypoint_prefixes_count + 1; i++) { | 77 for (int i = 1; i < entrypoint_prefixes_count + 1; i++) { |
| 78 // Note this fakes an enum UMA using an exact linear UMA, since the enum is |
| 79 // a modification of another enum, but isn't defined directly. |
| 78 if (sms_entrypoint == i) { | 80 if (sms_entrypoint == i) { |
| 79 UMA_HISTOGRAM_ENUMERATION("DesktopIOSPromotion.SMSSent.IOSSigninReason", | 81 UMA_HISTOGRAM_EXACT_LINEAR("DesktopIOSPromotion.SMSSent.IOSSigninReason", |
| 80 i, entrypoint_prefixes_count + 1); | 82 i, entrypoint_prefixes_count + 1); |
| 81 // If the time delta is negative due to client bad clock we log 0 instead. | 83 // If the time delta is negative due to client bad clock we log 0 instead. |
| 82 base::Histogram::FactoryGet( | 84 base::Histogram::FactoryGet( |
| 83 base::StringPrintf( | 85 base::StringPrintf( |
| 84 "DesktopIOSPromotion.%s.SMSToSigninTime", | 86 "DesktopIOSPromotion.%s.SMSToSigninTime", |
| 85 kDesktopIOSPromotionEntrypointHistogramPrefix[i - 1]), | 87 kDesktopIOSPromotionEntrypointHistogramPrefix[i - 1]), |
| 86 1, 168, 24, base::Histogram::kUmaTargetedHistogramFlag) | 88 1, 168, 24, base::Histogram::kUmaTargetedHistogramFlag) |
| 87 ->Add(std::max(0, delta.InHours())); | 89 ->Add(std::max(0, delta.InHours())); |
| 88 } else { | 90 } else { |
| 89 // If the user saw this promotion type, log that it could be a reason | 91 // If the user saw this promotion type, log that it could be a reason |
| 90 // for the signin. | 92 // for the signin. |
| 91 if ((1 << i) & shown_entrypoints) | 93 if ((1 << i) & shown_entrypoints) |
| 92 UMA_HISTOGRAM_ENUMERATION("DesktopIOSPromotion.NoSMS.IOSSigninReason", | 94 UMA_HISTOGRAM_EXACT_LINEAR("DesktopIOSPromotion.NoSMS.IOSSigninReason", |
| 93 i, entrypoint_prefixes_count + 1); | 95 i, entrypoint_prefixes_count + 1); |
| 94 } | 96 } |
| 95 } | 97 } |
| 96 | 98 |
| 97 // Check the variation id preference, if it's set then log to UMA that the | 99 // Check the variation id preference, if it's set then log to UMA that the |
| 98 // user has seen this promotion variation on desktop. | 100 // user has seen this promotion variation on desktop. |
| 99 int promo_variation_id = | 101 int promo_variation_id = |
| 100 pref_service_->GetInteger(prefs::kDesktopIOSPromotionVariationId); | 102 pref_service_->GetInteger(prefs::kDesktopIOSPromotionVariationId); |
| 101 if (promo_variation_id != 0) { | 103 if (promo_variation_id != 0) { |
| 102 if (sms_entrypoint != 0) { | 104 if (sms_entrypoint != 0) { |
| 103 UMA_HISTOGRAM_SPARSE_SLOWLY( | 105 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 104 "DesktopIOSPromotion.SMSSent.VariationSigninReason", | 106 "DesktopIOSPromotion.SMSSent.VariationSigninReason", |
| 105 promo_variation_id); | 107 promo_variation_id); |
| 106 } else { | 108 } else { |
| 107 UMA_HISTOGRAM_SPARSE_SLOWLY( | 109 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 108 "DesktopIOSPromotion.NoSMS.VariationSigninReason", | 110 "DesktopIOSPromotion.NoSMS.VariationSigninReason", |
| 109 promo_variation_id); | 111 promo_variation_id); |
| 110 } | 112 } |
| 111 } | 113 } |
| 112 | 114 |
| 113 pref_service_->SetBoolean(prefs::kDesktopIOSPromotionDone, true); | 115 pref_service_->SetBoolean(prefs::kDesktopIOSPromotionDone, true); |
| 114 sync_service_->RemoveObserver(this); | 116 sync_service_->RemoveObserver(this); |
| 115 } | 117 } |
| OLD | NEW |