Commit ca039d98 authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Add logger for upgrade sign-in promo.

Add logging functionality to the upgrade sign-in operation
as a part of the sign-in architecture migration.

Bug: 971989
Change-Id: I2a7732b955ad563b4a8cac2d7aebdcdfedc976d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2110650
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752779}
parent 595c61cf
......@@ -7,6 +7,7 @@
#import "ios/chrome/browser/ui/authentication/signin/add_account_signin/add_account_signin_coordinator.h"
#import "ios/chrome/browser/ui/authentication/signin/advanced_settings_signin/advanced_settings_signin_coordinator.h"
#import "ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.h"
#import "ios/chrome/browser/ui/authentication/signin/user_signin/logging/upgrade_signin_logger.h"
#import "ios/chrome/browser/ui/authentication/signin/user_signin/user_signin_constants.h"
#import "ios/chrome/browser/ui/authentication/signin/user_signin/user_signin_coordinator.h"
......@@ -55,7 +56,7 @@ using signin_metrics::PromoAction;
upgradeSigninPromoCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)browser {
UserSigninLogger* logger = [[UserSigninLogger alloc]
UpgradeSigninLogger* logger = [[UpgradeSigninLogger alloc]
initWithAccessPoint:AccessPoint::ACCESS_POINT_SIGNIN_PROMO
promoAction:PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO];
return [[UserSigninCoordinator alloc]
......
......@@ -9,12 +9,16 @@ source_set("logging") {
sources = [
"first_run_signin_logger.h",
"first_run_signin_logger.mm",
"upgrade_signin_logger.h",
"upgrade_signin_logger.mm",
"user_signin_logger.h",
"user_signin_logger.mm",
]
deps = [
"//components/signin/public/base",
"//ios/chrome/browser/ui/settings/sync/utils",
"//ios/public/provider/chrome/browser",
"//ios/public/provider/chrome/browser/signin",
]
public_deps =
[ "//ios/chrome/browser/ui/authentication/signin:signin_headers" ]
......
......@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/authentication/signin/user_signin/logging/first_run_signin_logger.h"
#import "base/metrics/user_metrics.h"
#import "ios/chrome/browser/ui/authentication/signin/signin_utils.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -32,6 +33,7 @@ using signin_metrics::RecordSigninUserActionForAccessPoint;
LogSigninAccessPointStarted(self.accessPoint, self.promoAction);
RecordSigninUserActionForAccessPoint(self.accessPoint, self.promoAction);
}
SigninRecordVersionSeen();
}
@end
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_LOGGING_UPGRADE_SIGNIN_LOGGER_H_
#define IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_LOGGING_UPGRADE_SIGNIN_LOGGER_H_
#import "ios/chrome/browser/ui/authentication/signin/user_signin/logging/user_signin_logger.h"
// Logs metrics for Chrome upgrade operations.
@interface UpgradeSigninLogger : UserSigninLogger
@end
#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_LOGGING_UPGRADE_SIGNIN_LOGGER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/authentication/signin/user_signin/logging/upgrade_signin_logger.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "components/signin/public/base/signin_metrics.h"
#import "ios/chrome/browser/ui/authentication/signin/signin_utils.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity_service.h"
#include "net/base/network_change_notifier.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using signin_metrics::AccessPoint;
using signin_metrics::LogSigninAccessPointStarted;
using signin_metrics::PromoAction;
using signin_metrics::RecordSigninUserActionForAccessPoint;
namespace {
// Key in the UserDefaults to track how many times the SSO Recall promo has been
// displayed.
NSString* kDisplayedSSORecallPromoCountKey = @"DisplayedSSORecallPromoCount";
// Name of the UMA SSO Recall histogram.
const char* const kUMASSORecallPromoAction = "SSORecallPromo.PromoAction";
// Name of the histogram recording how many accounts were available on the
// device when the promo was shown.
const char* const kUMASSORecallAccountsAvailable =
"SSORecallPromo.AccountsAvailable";
// Name of the histogram recording how many times the promo has been shown.
const char* const kUMASSORecallPromoSeenCount = "SSORecallPromo.PromoSeenCount";
// Values of the UMA SSORecallPromo.PromoAction histogram.
typedef NS_ENUM(NSUInteger, UserSigninPromoAction) {
PromoActionDismissed,
PromoActionEnabledSSOAccount,
PromoActionAddedAnotherAccount,
PromoActionCount
};
} // namespace
@implementation UpgradeSigninLogger
#pragma mark - Public
- (void)logSigninStarted {
[super logSigninStarted];
RecordSigninUserActionForAccessPoint(self.accessPoint, self.promoAction);
// Records in user defaults that the promo has been shown as well as the
// number of times it's been displayed.
SigninRecordVersionSeen();
NSUserDefaults* standardDefaults = [NSUserDefaults standardUserDefaults];
int promoSeenCount =
[standardDefaults integerForKey:kDisplayedSSORecallPromoCountKey];
promoSeenCount++;
[standardDefaults setInteger:promoSeenCount
forKey:kDisplayedSSORecallPromoCountKey];
NSArray* identities = ios::GetChromeBrowserProvider()
->GetChromeIdentityService()
->GetAllIdentitiesSortedForDisplay();
UMA_HISTOGRAM_COUNTS_100(kUMASSORecallAccountsAvailable, [identities count]);
UMA_HISTOGRAM_COUNTS_100(kUMASSORecallPromoSeenCount, promoSeenCount);
}
- (void)logSigninCompletedWithResult:(SigninCoordinatorResult)signinResult
addedAcount:(BOOL)addedAccount
advancedSettingsShown:(BOOL)advancedSettingsShown {
[super logSigninCompletedWithResult:signinResult
addedAccount:addedAccount
advancedSettingsShown:advancedSettingsShown];
switch (signinResult) {
case SigninCoordinatorResultSuccess: {
UserSigninPromoAction promoAction = addedAccount
? PromoActionAddedAnotherAccount
: PromoActionEnabledSSOAccount;
UMA_HISTOGRAM_ENUMERATION(kUMASSORecallPromoAction, promoAction,
PromoActionCount);
break;
}
case SigninCoordinatorResultCanceledByUser: {
UMA_HISTOGRAM_ENUMERATION(kUMASSORecallPromoAction, PromoActionDismissed,
PromoActionCount);
break;
}
case SigninCoordinatorResultInterrupted: {
// TODO(crbug.com/951145): Add metric for when the sign-in has been
// interrupted.
break;
}
}
}
@end
......@@ -29,6 +29,7 @@
// Logs sign-in completed when the user has attempted sign-in and obtained a
// result.
- (void)logSigninCompletedWithResult:(SigninCoordinatorResult)signinResult
addedAccount:(BOOL)addedAccount
advancedSettingsShown:(BOOL)advancedSettingsShown;
// Logs sign-in cancellation when sign-in is in progress.
......
......@@ -36,6 +36,7 @@ using signin_metrics::PromoAction;
}
- (void)logSigninCompletedWithResult:(SigninCoordinatorResult)signinResult
addedAccount:(BOOL)addedAccount
advancedSettingsShown:(BOOL)advancedSettingsShown {
switch (signinResult) {
case SigninCoordinatorResultSuccess: {
......
......@@ -54,6 +54,8 @@ const CGFloat kFadeOutAnimationDuration = 0.16f;
@property(nonatomic, strong, readonly) UserSigninLogger* logger;
// Sign-in intent.
@property(nonatomic, assign, readonly) UserSigninIntent signinIntent;
// Whether an account has been added during sign-in flow.
@property(nonatomic, assign) BOOL addedAccount;
@end
......@@ -232,6 +234,7 @@ const CGFloat kFadeOutAnimationDuration = 0.16f;
^(SigninCoordinatorResult signinResult, ChromeIdentity* identity) {
if (signinResult == SigninCoordinatorResultSuccess) {
weakSelf.unifiedConsentCoordinator.selectedIdentity = identity;
weakSelf.addedAccount = YES;
}
[weakSelf.addAccountSigninCoordinator stop];
weakSelf.addAccountSigninCoordinator = nil;
......@@ -279,6 +282,7 @@ const CGFloat kFadeOutAnimationDuration = 0.16f;
- (void)userSigninMediatorSigninFinishedWithResult:
(SigninCoordinatorResult)signinResult {
[self.logger logSigninCompletedWithResult:signinResult
addedAccount:self.addedAccount
advancedSettingsShown:self.unifiedConsentCoordinator
.settingsLinkWasTapped];
......@@ -290,11 +294,18 @@ const CGFloat kFadeOutAnimationDuration = 0.16f;
identity:identity
settingsLinkWasTapped:settingsWasTapped];
};
// The caller is responsible for cleaning up the base view controller for
// first run sign-in.
if (self.signinIntent != UserSigninIntentFirstRun) {
[self.viewController dismissViewControllerAnimated:YES
completion:completion];
switch (self.signinIntent) {
case UserSigninIntentFirstRun: {
// The caller is responsible for cleaning up the base view controller for
// first run sign-in.
break;
}
case UserSigninIntentSignin:
case UserSigninIntentUpgrade: {
[self.viewController dismissViewControllerAnimated:YES
completion:completion];
break;
}
}
}
......
......@@ -41,7 +41,6 @@ source_set("first_run") {
"//ios/chrome/browser/ui/fancy_ui",
"//ios/chrome/browser/ui/icons",
"//ios/chrome/browser/ui/material_components",
"//ios/chrome/browser/ui/promos",
"//ios/chrome/browser/ui/settings/sync/utils",
"//ios/chrome/browser/ui/settings/utils",
"//ios/chrome/browser/ui/util",
......
......@@ -15,7 +15,6 @@
#import "ios/chrome/browser/ui/commands/show_signin_command.h"
#import "ios/chrome/browser/ui/first_run/first_run_constants.h"
#import "ios/chrome/browser/ui/first_run/first_run_util.h"
#import "ios/chrome/browser/ui/promos/signin_promo_view_controller.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment