Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds tracking to the Add Site buttons #17612

Merged
merged 5 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ import Foundation
// Preview WebKitView
case previewWebKitViewDeviceChanged

case addSiteAlertDisplayed

/// A String that represents the event
var value: String {
switch self {
Expand Down Expand Up @@ -778,6 +780,9 @@ import Foundation
case .previewWebKitViewDeviceChanged:
return "preview_webkitview_device_changed"

case .addSiteAlertDisplayed:
return "add_site_alert_displayed"

} // END OF SWITCH
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class AddSiteAlertFactory: NSObject {

@objc
func makeAddSiteAlert(
source: String?,
canCreateWPComSite: Bool,
createWPComSite: @escaping () -> Void,
addSelfHostedSite: @escaping () -> Void) -> UIAlertController {
Expand All @@ -20,6 +21,8 @@ class AddSiteAlertFactory: NSObject {
alertController.addAction(addSelfHostedSiteAction(handler: addSelfHostedSite))
alertController.addAction(cancelAction())

WPAnalytics.track(.addSiteAlertDisplayed, properties: ["source": source ?? "unknown"])

return alertController
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ extension BlogListViewController {
return
}
present(wizard, animated: true)
WPAnalytics.track(.enhancedSiteCreationAccessed)
WPAnalytics.track(.enhancedSiteCreationAccessed, withProperties: ["source": "my_sites"])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -280,8 +280,8 @@ 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)
}
Expand All @@ -298,13 +298,17 @@ class MySiteViewController: UIViewController, NoResultsViewHost {
}

@objc
func launchSiteCreation() {
func launchSiteCreationFromNotification() {
self.launchSiteCreation(source: "signup_epilogue")
}

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ extension WordPressAuthenticationManager: WordPressAuthenticatorDelegate {
}

navigationController.present(wizard, animated: true)
WPAnalytics.track(.enhancedSiteCreationAccessed, withProperties: ["source": "login_epilogue"])
}

navigationController.pushViewController(epilogueViewController, animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class MySitesCoordinator: NSObject {

func showSiteCreation() {
showRootViewController()
mySiteViewController.launchSiteCreation()
mySiteViewController.launchSiteCreation(source: "my_site")
}

@objc
Expand Down