Skip to content

Commit

Permalink
Merge pull request #5068 from wikimedia/T376350
Browse files Browse the repository at this point in the history
[YiR] Prompt user to log in after survey
  • Loading branch information
tonisevener authored Nov 19, 2024
2 parents 6772850 + 3a17d42 commit 449b0c4
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 11 deletions.
6 changes: 4 additions & 2 deletions WMF Framework/CommonStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,10 @@ public class CommonStrings: NSObject {
public static let logoutAlertTitle = WMFLocalizedString("main-menu-account-logout-are-you-sure", value: "Are you sure you want to log out?", comment: "Header asking if user is sure they wish to log out.")

public static let logoutAlertMessage = WMFLocalizedString("main-menu-account-logout-are-you-sure-message", value: "Logging out will delete your locally stored account data (notifications and messages), but your account data will still be available on the web and will be re-downloaded if you log back in.", comment: "Message explaining what happens to local data when logging out.")

public static let joinLoginTitle = WMFLocalizedString("profile-page-join-title", value: "Join Wikipedia / Log in", comment: "Link to sign up or sign in")

public static let noThanksTitle = WMFLocalizedString("variants-alert-dismiss-button", value: "No thanks", comment: "Dismiss button on alert used to inform users about variant support.")

// Donation history

Expand All @@ -791,8 +795,6 @@ public extension CommonStrings {

static let variantsAlertPreferencesButton = WMFLocalizedString("variants-alert-preferences-button", value: "Review your preferences", comment: "Action button on alert used to inform users about variant support.")

static let variantsAlertDismissButton = WMFLocalizedString("variants-alert-dismiss-button", value: "No thanks", comment: "Dismiss button on alert used to inform users about variant support.")

// Chinese (zh)

static let chineseVariantsAlertTitle = WMFLocalizedString("chinese-variants-alert-title", value: "Updates to Chinese variant support", comment: "Title of alert used to inform users about Chinese variant support.")
Expand Down
14 changes: 14 additions & 0 deletions Wikipedia/Code/DonateFunnel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import WMF
case nextClick = "next_click"
case continueClick = "continue_click"
case donateStartClickYir = "donate_start_click_yir"
case accountEngageClick = "account_engage_click"
case rejectClick = "reject_click"
case shareClick = "share_click"
case feedbackSubmitClick = "feedback_submit_click"
case feedbackSubmitted = "feedback_submitted"
Expand Down Expand Up @@ -352,6 +354,18 @@ import WMF
"slide": slideLoggingID,
"campaign_id": metricsID])
}

func logYearInReviewLoginPromptDidAppear() {
logEvent(activeInterface: .wikiYiR, action: .impression, actionData: ["slide": "new_account_engage"])
}

func logYearInReviewLoginPromptDidTapLogin() {
logEvent(activeInterface: .wikiYiR, action: .accountEngageClick, actionData: ["slide": "new_account_engage"])
}

func logYearInReviewLoginPromptDidTapNoThanks() {
logEvent(activeInterface: .wikiYiR, action: .rejectClick, actionData: ["slide": "new_account_engage"])
}

func logYearInReviewDidTapShare(slideLoggingID: String) {
logEvent(activeInterface: .wikiYiR, action: .shareClick, actionData: ["slide": slideLoggingID])
Expand Down
2 changes: 1 addition & 1 deletion Wikipedia/Code/Panels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class LanguageVariantEducationalPanelViewController: ScrollableEducationPanelVie
subheading = alertBodyForLanguageCode(languageCode) + "\n"
subheadingTextAlignment = .natural
primaryButtonTitle = isFinalAlert ? CommonStrings.variantsAlertPreferencesButton : CommonStrings.gotItButtonTitle
secondaryButtonTitle = isFinalAlert ? CommonStrings.variantsAlertDismissButton : nil
secondaryButtonTitle = isFinalAlert ? CommonStrings.noThanksTitle : nil
}

func alertTitleForLanguageCode(_ languageCode: String) -> String {
Expand Down
2 changes: 1 addition & 1 deletion Wikipedia/Code/ProfileCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ final class ProfileCoordinator: NSObject, Coordinator, ProfileCoordinatorDelegat
logOutTitle: CommonStrings.logoutTitle,
donateTitle: CommonStrings.donateTitle,
settingsTitle: CommonStrings.settingsTitle,
joinWikipediaTitle: WMFLocalizedString("profile-page-join-title", value: "Join Wikipedia / Log in", comment: "Link to sign up or sign in"),
joinWikipediaTitle: CommonStrings.joinLoginTitle,
joinWikipediaSubtext: WMFLocalizedString("profile-page-join-subtext", value:"Sign up for a Wikipedia account to track your contributions, save articles offline, and sync across devices.", comment: "Information about signing in or up"),
donateSubtext: WMFLocalizedString("profile-page-donate-subtext", value: "Or support Wikipedia with a donation to keep it free and accessible for everyone around the world.", comment: "Information about supporting Wikipedia through donations"),
yearInReviewTitle: CommonStrings.yirTitle,
Expand Down
57 changes: 50 additions & 7 deletions Wikipedia/Code/YearInReviewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,36 @@ final class YearInReviewCoordinator: NSObject, Coordinator {
self.dataController.hasPresentedYiRSurvey = true
}
}

private func needsLoginPrompt() -> Bool {
return !dataStore.authenticationManager.authStateIsPermanent
}

private func presentLoginPrompt() {
let title = WMFLocalizedString("year-in-review-login-title", value: "Improve your Year in Review", comment: "Title of alert that asks user to login. Displayed after they completed the feature for the first time.")
let subtitle = WMFLocalizedString("year-in-review-login-subtitle", value: "Login or create an account to be eligible for more personalied insights", comment: "Subtitle of alert that asks user to login. Displayed after they completed the feature for the first time.")
let button1Title = CommonStrings.joinLoginTitle
let button2Title = CommonStrings.noThanksTitle

let alert = UIAlertController(title: title, message: subtitle, preferredStyle: .alert)
let action1 = UIAlertAction(title: button1Title, style: .default) { [weak self] action in

guard let self else { return }

DonateFunnel.shared.logYearInReviewLoginPromptDidTapLogin()
let loginCoordinator = LoginCoordinator(navigationController: self.navigationController, theme: self.theme)
loginCoordinator.start()
}
let action2 = UIAlertAction(title: button2Title, style: .default) { action in
DonateFunnel.shared.logYearInReviewLoginPromptDidTapNoThanks()
}
alert.addAction(action1)
alert.addAction(action2)

DonateFunnel.shared.logYearInReviewLoginPromptDidAppear()

navigationController.present(alert, animated: true)
}

private func surveyViewController() -> UIViewController {
let title = WMFLocalizedString("year-in-review-survey-title", value: "Satisfaction survey", comment: "Year in review survey title. Survey is displayed after user has viewed the last slide of their year in review feature.")
Expand Down Expand Up @@ -452,15 +482,28 @@ final class YearInReviewCoordinator: NSObject, Coordinator {

let surveyView = WMFSurveyView(viewModel: WMFSurveyViewModel(localizedStrings: surveyLocalizedStrings, options: surveyOptions, selectionType: .single),
cancelAction: { [weak self] in
self?.navigationController.dismiss(animated: true)

self?.navigationController.dismiss(animated: true, completion: { [weak self] in
guard let self else { return }

if self.needsLoginPrompt() {
presentLoginPrompt()
}
})
DonateFunnel.shared.logYearInReviewSurveyDidTapCancel()
},
submitAction: { [weak self] options, otherText in
}, submitAction: { [weak self] options, otherText in
DonateFunnel.shared.logYearInReviewSurveyDidSubmit(selected: options, other: otherText)
self?.navigationController.dismiss(animated: true, completion: {
let image = UIImage(systemName: "checkmark.circle.fill")
WMFAlertManager.sharedInstance.showBottomAlertWithMessage(CommonStrings.feedbackSurveyToastTitle, subtitle: nil, image: image, type: .custom, customTypeName: "feedback-submitted", dismissPreviousAlerts: true)
DonateFunnel.shared.logYearinReviewSurveySubmitSuccessToast()
self?.navigationController.dismiss(animated: true, completion: { [weak self] in

guard let self else { return }

if self.needsLoginPrompt() {
presentLoginPrompt()
} else {
let image = UIImage(systemName: "checkmark.circle.fill")
WMFAlertManager.sharedInstance.showBottomAlertWithMessage(CommonStrings.feedbackSurveyToastTitle, subtitle: nil, image: image, type: .custom, customTypeName: "feedback-submitted", dismissPreviousAlerts: true)
DonateFunnel.shared.logYearinReviewSurveySubmitSuccessToast()
}
})
})

Expand Down
2 changes: 2 additions & 0 deletions Wikipedia/Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,8 @@
"year-in-review-feature-announcement-body" = "See insights about the articles you read on the Wikipedia app, share your journey, and discover highlights from your year.";
"year-in-review-feature-announcement-title" = "Explore your Wikipedia Year in Review";
"year-in-review-finish" = "Finish";
"year-in-review-login-subtitle" = "Login or create an account to be eligible for more personalied insights";
"year-in-review-login-title" = "Improve your Year in Review";
"year-in-review-personalized-donate-subtitle" = "Thank you for supporting Wikipedia and a world where knowledge is free for everyone. Every single edit and donation helps improve people’s access to accurate and reliable information, especially in a rapidly changing world. [Learn more about our work]($1).";
"year-in-review-personalized-donate-title" = "Thank you for your contribution!";
"year-in-review-personalized-editing-subtitle-format" = "You edited Wikipedia {{PLURAL:$1|$1 time|$1 times}}. Thank you for being one of the volunteer editors making a difference on Wikimedia projects around the world.";
Expand Down
2 changes: 2 additions & 0 deletions Wikipedia/Localizations/qqq.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,8 @@
"year-in-review-feature-announcement-body" = "Body for year in review feature announcement";
"year-in-review-feature-announcement-title" = "Title for year in review feature announcement";
"year-in-review-finish" = "Year in review finish button. Displayed on last slide and dismisses feature view.";
"year-in-review-login-subtitle" = "Subtitle of alert that asks user to login. Displayed after they completed the feature for the first time.";
"year-in-review-login-title" = "Title of alert that asks user to login. Displayed after they completed the feature for the first time.";
"year-in-review-personalized-donate-subtitle" = "Year in review, personalized donate slide subtitle for users that donated at least once that year. $1 is replaced with a MediaWiki url with more information about WMF. Do not alter markdown when translating.";
"year-in-review-personalized-donate-title" = "Year in review, personalized donate slide title for users that donated at least once that year.";
"year-in-review-personalized-editing-subtitle-format" = "Year in review, personalized editing article count slide subtitle for users that edited articles. $1 is replaced with the number of edits the user made.";
Expand Down
Binary file modified Wikipedia/iOS Native Localizations/en.lproj/Localizable.strings
Binary file not shown.

0 comments on commit 449b0c4

Please sign in to comment.