From 25844da2aff5968df9846cd1db7a3219dc472241 Mon Sep 17 00:00:00 2001 From: emilylaguna Date: Wed, 1 Dec 2021 15:13:04 -0500 Subject: [PATCH 1/5] Add event when the add site button is tapped --- WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift b/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift index 3000256a6397..682df060cf44 100644 --- a/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift +++ b/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift @@ -289,6 +289,8 @@ import Foundation // Preview WebKitView case previewWebKitViewDeviceChanged + case addSiteAlertDisplayed + /// A String that represents the event var value: String { switch self { @@ -778,6 +780,9 @@ import Foundation case .previewWebKitViewDeviceChanged: return "preview_webkitview_device_changed" + case .addSiteAlertDisplayed: + return "add_site_alert_displayed" + } // END OF SWITCH } From 385c67e2ce3d4d6e31cc25b017d5fca2abab3cc4 Mon Sep 17 00:00:00 2001 From: emilylaguna Date: Wed, 1 Dec 2021 15:21:13 -0500 Subject: [PATCH 2/5] Add source when tapping on an Add Site button --- .../Blog/Add Site/AddSiteAlertFactory.swift | 3 +++ .../Blog/Blog List/BlogListViewController.m | 8 +++++--- .../Blog/My Site/MySiteViewController.swift | 15 ++++++++++----- .../System/Coordinators/MySitesCoordinator.swift | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Add Site/AddSiteAlertFactory.swift b/WordPress/Classes/ViewRelated/Blog/Add Site/AddSiteAlertFactory.swift index cb9200577da8..5b8c78d6e3d5 100644 --- a/WordPress/Classes/ViewRelated/Blog/Add Site/AddSiteAlertFactory.swift +++ b/WordPress/Classes/ViewRelated/Blog/Add Site/AddSiteAlertFactory.swift @@ -7,6 +7,7 @@ class AddSiteAlertFactory: NSObject { @objc func makeAddSiteAlert( + source: String?, canCreateWPComSite: Bool, createWPComSite: @escaping () -> Void, addSelfHostedSite: @escaping () -> Void) -> UIAlertController { @@ -20,6 +21,8 @@ class AddSiteAlertFactory: NSObject { alertController.addAction(addSelfHostedSiteAction(handler: addSelfHostedSite)) alertController.addAction(cancelAction()) + WPAnalytics.track(.addSiteAlertDisplayed, properties: ["source": source ?? "unknown"]) + return alertController } diff --git a/WordPress/Classes/ViewRelated/Blog/Blog List/BlogListViewController.m b/WordPress/Classes/ViewRelated/Blog/Blog List/BlogListViewController.m index 7ed90e295545..6ca0915fc2c6 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog List/BlogListViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/Blog List/BlogListViewController.m @@ -995,13 +995,15 @@ - (void)showAddSiteAlertFrom:(id)source [self setEditing:YES animated:YES]; } else { AddSiteAlertFactory *factory = [AddSiteAlertFactory new]; - UIAlertController *alertController = [factory makeAddSiteAlertWithCanCreateWPComSite:[self defaultWordPressComAccount] - createWPComSite:^{ + BOOL canCreateWPComSite = [self defaultWordPressComAccount] ? YES : NO; + UIAlertController *alertController = [factory makeAddSiteAlertWithSource:@"my_site" + canCreateWPComSite:canCreateWPComSite + createWPComSite:^{ [self launchSiteCreation]; } addSelfHostedSite:^{ [self showLoginControllerForAddingSelfHostedSite]; }]; - + if ([source isKindOfClass:[UIView class]]) { UIView *sourceView = (UIView *)source; alertController.popoverPresentationController.sourceView = sourceView; diff --git a/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift b/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift index f4c792f2aef3..6e0267c1b0d4 100644 --- a/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift @@ -78,7 +78,7 @@ class MySiteViewController: UIViewController, NoResultsViewHost { } private func subscribeToPostSignupNotifications() { - NotificationCenter.default.addObserver(self, selector: #selector(launchSiteCreation), name: .createSite, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(launchSiteCreationFromNotification), name: .createSite, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(showAddSelfHostedSite), name: .addSelfHosted, object: nil) } @@ -280,8 +280,9 @@ class MySiteViewController: UIViewController, NoResultsViewHost { @objc func presentInterfaceForAddingNewSite() { - let addSiteAlert = AddSiteAlertFactory().makeAddSiteAlert(canCreateWPComSite: defaultAccount() != nil) { [weak self] in - self?.launchSiteCreation() + + let addSiteAlert = AddSiteAlertFactory().makeAddSiteAlert(source: "my_site_no_sites", canCreateWPComSite: defaultAccount() != nil) { [weak self] in + self?.launchSiteCreation(source: "my_site_no_sites") } addSelfHostedSite: { WordPressAuthenticator.showLoginForSelfHostedSite(self) } @@ -298,13 +299,17 @@ class MySiteViewController: UIViewController, NoResultsViewHost { } @objc - func launchSiteCreation() { + func launchSiteCreationFromNotification() { + self.launchSiteCreation(source: "post_signup") + } + + func launchSiteCreation(source: String) { let wizardLauncher = SiteCreationWizardLauncher() guard let wizard = wizardLauncher.ui else { return } present(wizard, animated: true) - WPAnalytics.track(.enhancedSiteCreationAccessed) + WPAnalytics.track(.enhancedSiteCreationAccessed, withProperties: ["source": source]) } @objc diff --git a/WordPress/Classes/ViewRelated/System/Coordinators/MySitesCoordinator.swift b/WordPress/Classes/ViewRelated/System/Coordinators/MySitesCoordinator.swift index e88e76100374..87282fe690de 100644 --- a/WordPress/Classes/ViewRelated/System/Coordinators/MySitesCoordinator.swift +++ b/WordPress/Classes/ViewRelated/System/Coordinators/MySitesCoordinator.swift @@ -146,7 +146,7 @@ class MySitesCoordinator: NSObject { func showSiteCreation() { showRootViewController() - mySiteViewController.launchSiteCreation() + mySiteViewController.launchSiteCreation(source: "my_site") } @objc From 436f4e92b24ca3e0d103bc9140680ac0d11b93ec Mon Sep 17 00:00:00 2001 From: emilylaguna Date: Wed, 1 Dec 2021 15:21:33 -0500 Subject: [PATCH 3/5] Add a source when entering the WP.com site creation flow --- .../Blog/Blog List/BlogListViewController+SiteCreation.swift | 2 +- .../ViewRelated/NUX/WordPressAuthenticationManager.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Blog List/BlogListViewController+SiteCreation.swift b/WordPress/Classes/ViewRelated/Blog/Blog List/BlogListViewController+SiteCreation.swift index 9f976c760891..8f6e758c9a27 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog List/BlogListViewController+SiteCreation.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog List/BlogListViewController+SiteCreation.swift @@ -6,6 +6,6 @@ extension BlogListViewController { return } present(wizard, animated: true) - WPAnalytics.track(.enhancedSiteCreationAccessed) + WPAnalytics.track(.enhancedSiteCreationAccessed, withProperties: ["source": "my_sites"]) } } diff --git a/WordPress/Classes/ViewRelated/NUX/WordPressAuthenticationManager.swift b/WordPress/Classes/ViewRelated/NUX/WordPressAuthenticationManager.swift index 09a5f016ea99..9c9cd80cf2c8 100644 --- a/WordPress/Classes/ViewRelated/NUX/WordPressAuthenticationManager.swift +++ b/WordPress/Classes/ViewRelated/NUX/WordPressAuthenticationManager.swift @@ -389,6 +389,7 @@ extension WordPressAuthenticationManager: WordPressAuthenticatorDelegate { } navigationController.present(wizard, animated: true) + WPAnalytics.track(.enhancedSiteCreationAccessed, withProperties: ["source": "login_epilogue"]) } navigationController.pushViewController(epilogueViewController, animated: true) From 7f257738b32cce91ec927af6b95b34a7f8e17472 Mon Sep 17 00:00:00 2001 From: emilylaguna Date: Wed, 1 Dec 2021 15:50:54 -0500 Subject: [PATCH 4/5] Change post_signup to signup_epilogue --- .../Classes/ViewRelated/Blog/My Site/MySiteViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift b/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift index 6e0267c1b0d4..95ef2c06d46a 100644 --- a/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift @@ -300,7 +300,7 @@ class MySiteViewController: UIViewController, NoResultsViewHost { @objc func launchSiteCreationFromNotification() { - self.launchSiteCreation(source: "post_signup") + self.launchSiteCreation(source: "signup_epilogue") } func launchSiteCreation(source: String) { From db3f221a96f5e619a100f4886809017ec7109168 Mon Sep 17 00:00:00 2001 From: emilylaguna Date: Wed, 1 Dec 2021 15:59:29 -0500 Subject: [PATCH 5/5] Remove whitespace --- .../Classes/ViewRelated/Blog/My Site/MySiteViewController.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift b/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift index 95ef2c06d46a..b5ea641fe1ea 100644 --- a/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift @@ -280,7 +280,6 @@ class MySiteViewController: UIViewController, NoResultsViewHost { @objc func presentInterfaceForAddingNewSite() { - let addSiteAlert = AddSiteAlertFactory().makeAddSiteAlert(source: "my_site_no_sites", canCreateWPComSite: defaultAccount() != nil) { [weak self] in self?.launchSiteCreation(source: "my_site_no_sites") } addSelfHostedSite: {