diff --git a/WordPress/Classes/Services/JetpackWebViewControllerFactory.swift b/WordPress/Classes/Services/JetpackWebViewControllerFactory.swift index 58bb214db064..e3d53f3d23b8 100644 --- a/WordPress/Classes/Services/JetpackWebViewControllerFactory.swift +++ b/WordPress/Classes/Services/JetpackWebViewControllerFactory.swift @@ -6,7 +6,7 @@ class JetpackWebViewControllerFactory { guard let url = URL(string: "https://wordpress.com/settings/jetpack/\(siteID)") else { return nil } - return WebViewControllerFactory.controller(url: url) + return WebViewControllerFactory.controller(url: url, source: "jetpack_web_settings") } } diff --git a/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift b/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift index 2fc4e0c225cf..a177adc60183 100644 --- a/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift +++ b/WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift @@ -264,10 +264,23 @@ import Foundation // People case peopleFilterChanged case peopleUserInvited + // Login: Epilogue case loginEpilogueChooseSiteTapped case loginEpilogueCreateNewSiteTapped + // WebKitView + case webKitViewDisplayed + case webKitViewDismissed + case webKitViewOpenInSafariTapped + case webKitViewReloadTapped + case webKitViewShareTapped + case webKitViewNavigatedBack + case webKitViewNavigatedForward + + // Preview WebKitView + case previewWebKitViewDeviceChanged + /// A String that represents the event var value: String { switch self { @@ -716,11 +729,32 @@ import Foundation return "people_management_filter_changed" case .peopleUserInvited: return "people_management_user_invited" + // Login: Epilogue case .loginEpilogueChooseSiteTapped: return "login_epilogue_choose_site_tapped" case .loginEpilogueCreateNewSiteTapped: return "login_epilogue_create_new_site_tapped" + + // WebKitView + case .webKitViewDisplayed: + return "webkitview_displayed" + case .webKitViewDismissed: + return "webkitview_dismissed" + case .webKitViewOpenInSafariTapped: + return "webkitview_open_in_safari_tapped" + case .webKitViewReloadTapped: + return "webkitview_reload_tapped" + case .webKitViewShareTapped: + return "webkitview_share_tapped" + case .webKitViewNavigatedBack: + return "webkitview_navigated_back" + case .webKitViewNavigatedForward: + return "webkitview_navigated_forward" + + case .previewWebKitViewDeviceChanged: + return "preview_webkitview_device_changed" + } // END OF SWITCH } diff --git a/WordPress/Classes/Utility/ContentCoordinator.swift b/WordPress/Classes/Utility/ContentCoordinator.swift index e8ca3f544e0c..abbc0917ad41 100644 --- a/WordPress/Classes/Utility/ContentCoordinator.swift +++ b/WordPress/Classes/Utility/ContentCoordinator.swift @@ -5,7 +5,7 @@ protocol ContentCoordinator { func displayStatsWithSiteID(_ siteID: NSNumber?, url: URL?) throws func displayFollowersWithSiteID(_ siteID: NSNumber?, expirationTime: TimeInterval) throws func displayStreamWithSiteID(_ siteID: NSNumber?) throws - func displayWebViewWithURL(_ url: URL) + func displayWebViewWithURL(_ url: URL, source: String) func displayFullscreenImage(_ image: UIImage) func displayPlugin(withSlug pluginSlug: String, on siteSlug: String) throws func displayBackupWithSiteID(_ siteID: NSNumber?) throws @@ -132,13 +132,13 @@ struct DefaultContentCoordinator: ContentCoordinator { controller?.navigationController?.pushViewController(browseViewController, animated: true) } - func displayWebViewWithURL(_ url: URL) { + func displayWebViewWithURL(_ url: URL, source: String) { if UniversalLinkRouter(routes: UniversalLinkRouter.readerRoutes).canHandle(url: url) { UniversalLinkRouter(routes: UniversalLinkRouter.readerRoutes).handle(url: url, source: .inApp(presenter: controller)) return } - let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url) + let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url, source: source) let navController = UINavigationController(rootViewController: webViewController) controller?.present(navController, animated: true) } diff --git a/WordPress/Classes/Utility/Spotlight/SearchManager.swift b/WordPress/Classes/Utility/Spotlight/SearchManager.swift index 7e7ea5b30ef4..d7a80568d9d1 100644 --- a/WordPress/Classes/Utility/Spotlight/SearchManager.swift +++ b/WordPress/Classes/Utility/Spotlight/SearchManager.swift @@ -452,7 +452,7 @@ fileprivate extension SearchManager { WPTabBarController.sharedInstance().showMySitesTab() closePreviewIfNeeded(for: apost) - let controller = PreviewWebKitViewController(post: apost) + let controller = PreviewWebKitViewController(post: apost, source: "spotlight_preview_post") controller.trackOpenEvent() let navWrapper = LightNavigationController(rootViewController: controller) if WPTabBarController.sharedInstance()?.traitCollection.userInterfaceIdiom == .pad { diff --git a/WordPress/Classes/Utility/WebKitViewController.swift b/WordPress/Classes/Utility/WebKitViewController.swift index ddeca82b0ebd..2024a1cb2ac0 100644 --- a/WordPress/Classes/Utility/WebKitViewController.swift +++ b/WordPress/Classes/Utility/WebKitViewController.swift @@ -2,6 +2,7 @@ import Foundation import Gridicons import UIKit import WebKit +import WordPressShared protocol WebKitAuthenticatable { var authenticator: RequestAuthenticator? { get } @@ -27,6 +28,7 @@ class WebKitViewController: UIViewController, WebKitAuthenticatable { @objc let webView: WKWebView @objc let progressView = WebProgressView() @objc let titleView = NavigationTitleView() + let analyticsSource: String? @objc lazy var backButton: UIBarButtonItem = { let button = UIBarButtonItem(image: UIImage.gridicon(.chevronLeft).imageFlippedForRightToLeftLayoutDirection(), @@ -120,12 +122,14 @@ class WebKitViewController: UIViewController, WebKitAuthenticatable { linkBehavior = configuration.linkBehavior opensNewInSafari = configuration.opensNewInSafari onClose = configuration.onClose + analyticsSource = configuration.analyticsSource + super.init(nibName: nil, bundle: nil) hidesBottomBarWhenPushed = true startObservingWebView() } - fileprivate init(url: URL, parent: WebKitViewController, configuration: WKWebViewConfiguration) { + fileprivate init(url: URL, parent: WebKitViewController, configuration: WKWebViewConfiguration, source: String? = nil) { webView = WKWebView(frame: .zero, configuration: configuration) self.url = url customOptionsButton = parent.customOptionsButton @@ -136,6 +140,7 @@ class WebKitViewController: UIViewController, WebKitAuthenticatable { navigationDelegate = parent.navigationDelegate linkBehavior = parent.linkBehavior opensNewInSafari = parent.opensNewInSafari + analyticsSource = source super.init(nibName: nil, bundle: nil) hidesBottomBarWhenPushed = true startObservingWebView() @@ -197,12 +202,16 @@ class WebKitViewController: UIViewController, WebKitAuthenticatable { webView.uiDelegate = self loadWebViewRequest() + + track(.webKitViewDisplayed) } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) stopWaitingForConnectionRestored() ReachabilityUtils.dismissNoInternetConnectionNotice() + + track(.webKitViewDismissed) } @objc func loadWebViewRequest() { @@ -387,7 +396,6 @@ class WebKitViewController: UIViewController, WebKitAuthenticatable { } // MARK: User Actions - @objc func close() { dismiss(animated: true, completion: onClose) } @@ -407,19 +415,22 @@ class WebKitViewController: UIViewController, WebKitAuthenticatable { } } present(activityViewController, animated: true) - + track(.webKitViewShareTapped) } @objc func refresh() { webView.reload() + track(.webKitViewReloadTapped) } @objc func goBack() { webView.goBack() + track(.webKitViewNavigatedBack) } @objc func goForward() { webView.goForward() + track(.webKitViewNavigatedForward) } @objc func openInSafari() { @@ -427,6 +438,7 @@ class WebKitViewController: UIViewController, WebKitAuthenticatable { return } UIApplication.shared.open(url) + track(.webKitViewOpenInSafariTapped) } ///location is used to present a document menu in tap location on iOS 13 @@ -472,6 +484,14 @@ class WebKitViewController: UIViewController, WebKitAuthenticatable { navigationItem.titleView?.accessibilityValue = titleView.titleLabel.text navigationItem.titleView?.accessibilityTraits = .updatesFrequently } + + private func track(_ event: WPAnalyticsEvent) { + let properties: [AnyHashable: Any] = [ + "source": analyticsSource ?? "unknown" + ] + + WPAnalytics.track(event, properties: properties) + } } extension WebKitViewController: WKNavigationDelegate { @@ -537,7 +557,7 @@ extension WebKitViewController: WKUIDelegate { if opensNewInSafari { UIApplication.shared.open(url, options: [:], completionHandler: nil) } else { - let controller = WebKitViewController(url: url, parent: self, configuration: configuration) + let controller = WebKitViewController(url: url, parent: self, configuration: configuration, source: analyticsSource) let navController = UINavigationController(rootViewController: controller) present(navController, animated: true) return controller.webView diff --git a/WordPress/Classes/Utility/WebViewControllerConfiguration.swift b/WordPress/Classes/Utility/WebViewControllerConfiguration.swift index d7da836760a8..bc386d2a4e1e 100644 --- a/WordPress/Classes/Utility/WebViewControllerConfiguration.swift +++ b/WordPress/Classes/Utility/WebViewControllerConfiguration.swift @@ -6,6 +6,7 @@ class WebViewControllerConfiguration: NSObject { @objc var optionsButton: UIBarButtonItem? @objc var secureInteraction = false @objc var addsWPComReferrer = false + @objc var analyticsSource: String? /// Opens any new pages in Safari. Otherwise, a new web view will be opened var opensNewInSafari = false diff --git a/WordPress/Classes/Utility/WebViewControllerFactory.swift b/WordPress/Classes/Utility/WebViewControllerFactory.swift index 528a2395fa90..7009839d4ceb 100644 --- a/WordPress/Classes/Utility/WebViewControllerFactory.swift +++ b/WordPress/Classes/Utility/WebViewControllerFactory.swift @@ -6,45 +6,48 @@ class WebViewControllerFactory: NSObject { override init() { } - @objc static func controller(configuration: WebViewControllerConfiguration) -> WebKitViewController { + @objc static func controller(configuration: WebViewControllerConfiguration, source: String) -> WebKitViewController { + configuration.analyticsSource = source + let controller = WebKitViewController(configuration: configuration) return controller } - @objc static func controller(url: URL) -> UIViewController { + @objc static func controller(url: URL, source: String) -> UIViewController { let configuration = WebViewControllerConfiguration(url: url) - return controller(configuration: configuration) + return controller(configuration: configuration, source: source) } - @objc static func controller(url: URL, title: String) -> UIViewController { + @objc static func controller(url: URL, title: String, source: String) -> UIViewController { let configuration = WebViewControllerConfiguration(url: url) configuration.customTitle = title - return controller(configuration: configuration) + return controller(configuration: configuration, source: source) } - @objc static func controller(url: URL, blog: Blog, withDeviceModes: Bool = false) -> UIViewController { + @objc static func controller(url: URL, blog: Blog, source: String, withDeviceModes: Bool = false) -> UIViewController { let configuration = WebViewControllerConfiguration(url: url) + configuration.analyticsSource = source configuration.authenticate(blog: blog) - return withDeviceModes ? PreviewWebKitViewController(configuration: configuration) : controller(configuration: configuration) + return withDeviceModes ? PreviewWebKitViewController(configuration: configuration) : controller(configuration: configuration, source: source) } - @objc static func controller(url: URL, account: WPAccount) -> UIViewController { + @objc static func controller(url: URL, account: WPAccount, source: String) -> UIViewController { let configuration = WebViewControllerConfiguration(url: url) configuration.authenticate(account: account) - return controller(configuration: configuration) + return controller(configuration: configuration, source: source) } - @objc static func controllerAuthenticatedWithDefaultAccount(url: URL) -> UIViewController { + @objc static func controllerAuthenticatedWithDefaultAccount(url: URL, source: String) -> UIViewController { let configuration = WebViewControllerConfiguration(url: url) configuration.authenticateWithDefaultAccount() - return controller(configuration: configuration) + return controller(configuration: configuration, source: source) } - static func controllerWithDefaultAccountAndSecureInteraction(url: URL) -> WebKitViewController { + static func controllerWithDefaultAccountAndSecureInteraction(url: URL, source: String) -> WebKitViewController { let configuration = WebViewControllerConfiguration(url: url) configuration.authenticateWithDefaultAccount() configuration.secureInteraction = true - return controller(configuration: configuration) + return controller(configuration: configuration, source: source) } } diff --git a/WordPress/Classes/ViewRelated/Activity/ActivityDetailViewController.swift b/WordPress/Classes/ViewRelated/Activity/ActivityDetailViewController.swift index 5553ee487f9c..45093459e7dc 100644 --- a/WordPress/Classes/ViewRelated/Activity/ActivityDetailViewController.swift +++ b/WordPress/Classes/ViewRelated/Activity/ActivityDetailViewController.swift @@ -86,7 +86,7 @@ class ActivityDetailViewController: UIViewController, StoryboardLoadable { return } - let navController = UINavigationController(rootViewController: WebViewControllerFactory.controller(url: url)) + let navController = UINavigationController(rootViewController: WebViewControllerFactory.controller(url: url, source: "activity_detail_warning")) present(navController, animated: true) } diff --git a/WordPress/Classes/ViewRelated/Activity/FormattableContent/ActivityContentRouter.swift b/WordPress/Classes/ViewRelated/Activity/FormattableContent/ActivityContentRouter.swift index 9b79505149f8..fdde5e488d34 100644 --- a/WordPress/Classes/ViewRelated/Activity/FormattableContent/ActivityContentRouter.swift +++ b/WordPress/Classes/ViewRelated/Activity/FormattableContent/ActivityContentRouter.swift @@ -40,7 +40,7 @@ struct ActivityContentRouter: ContentRouter { let pluginSlug = pluginRange.pluginSlug try? coordinator.displayPlugin(withSlug: pluginSlug, on: siteSlug) default: - coordinator.displayWebViewWithURL(url) + coordinator.displayWebViewWithURL(url, source: "activity_detail_route") } } diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m index 8a71596d6835..43fba919b50f 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m @@ -1865,7 +1865,7 @@ - (void)showViewSiteFromSource:(BlogDetailsNavigationSource)source NSURL *targetURL = [NSURL URLWithString:self.blog.homeURL]; - UIViewController *webViewController = [WebViewControllerFactory controllerWithUrl:targetURL blog:self.blog withDeviceModes:true]; + UIViewController *webViewController = [WebViewControllerFactory controllerWithUrl:targetURL blog:self.blog source:@"my_site_view_site" withDeviceModes:true]; LightNavigationController *navController = [[LightNavigationController alloc] initWithRootViewController:webViewController]; if (self.traitCollection.userInterfaceIdiom == UIUserInterfaceIdiomPad) { navController.modalPresentationStyle = UIModalPresentationFullScreen; diff --git a/WordPress/Classes/ViewRelated/Blog/Site Management/SiteSettingsViewController+SiteManagement.swift b/WordPress/Classes/ViewRelated/Blog/Site Management/SiteSettingsViewController+SiteManagement.swift index dd1ff9466e73..a31c2f6ac696 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Management/SiteSettingsViewController+SiteManagement.swift +++ b/WordPress/Classes/ViewRelated/Blog/Site Management/SiteSettingsViewController+SiteManagement.swift @@ -138,7 +138,7 @@ public extension SiteSettingsViewController { let configuration = WebViewControllerConfiguration(url: url) configuration.secureInteraction = true configuration.authenticate(blog: blog) - let controller = WebViewControllerFactory.controller(configuration: configuration) + let controller = WebViewControllerFactory.controller(configuration: configuration, source: "site_settings_show_purchases") controller.loadViewIfNeeded() controller.navigationItem.titleView = nil controller.title = NSLocalizedString("Purchases", comment: "Title of screen showing site purchases") diff --git a/WordPress/Classes/ViewRelated/Blog/Site Settings/DateAndTimeFormatSettingsViewController.swift b/WordPress/Classes/ViewRelated/Blog/Site Settings/DateAndTimeFormatSettingsViewController.swift index 3e94841d3586..fc0e3676b478 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Settings/DateAndTimeFormatSettingsViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/Site Settings/DateAndTimeFormatSettingsViewController.swift @@ -206,7 +206,7 @@ open class DateAndTimeFormatSettingsViewController: UITableViewController { guard let url = URL(string: DateAndTimeFormatSettingsViewController.learnMoreUrl) else { return } - let webViewController = WebViewControllerFactory.controller(url: url) + let webViewController = WebViewControllerFactory.controller(url: url, source: "site_settings_date_time_format_learn_more") if presentingViewController != nil { navigationController?.pushViewController(webViewController, animated: true) diff --git a/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController+Swift.swift b/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController+Swift.swift index 665e69a4f48d..55fab46c25da 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController+Swift.swift +++ b/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController+Swift.swift @@ -150,7 +150,7 @@ extension SiteSettingsViewController { guard let url = URL(string: self.ampSupportURL) else { return } - let webViewController = WebViewControllerFactory.controller(url: url) + let webViewController = WebViewControllerFactory.controller(url: url, source: "site_settings_amp_footer") if presentingViewController != nil { navigationController?.pushViewController(webViewController, animated: true) diff --git a/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m b/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m index 89186be40a23..fb107b3820cd 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsViewController.m @@ -919,7 +919,8 @@ - (void)showStartOverForBlog:(Blog *)blog [self.navigationController pushViewController:viewController animated:YES]; } else { NSURL *targetURL = [NSURL URLWithString:EmptySiteSupportURL]; - UIViewController *webViewController = [WebViewControllerFactory controllerWithUrl:targetURL]; + + UIViewController *webViewController = [WebViewControllerFactory controllerWithUrl:targetURL source:@"site_settings_start_over"]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:webViewController]; [self presentViewController:navController animated:YES completion:nil]; } diff --git a/WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift b/WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift index f94993934e64..a862854b04ff 100644 --- a/WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift +++ b/WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift @@ -508,7 +508,7 @@ private extension CommentDetailViewController { return } - let viewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url) + let viewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url, source: "comment_detail") let navigationControllerToPresent = UINavigationController(rootViewController: viewController) present(navigationControllerToPresent, animated: true, completion: nil) diff --git a/WordPress/Classes/ViewRelated/Comments/CommentViewController.m b/WordPress/Classes/ViewRelated/Comments/CommentViewController.m index 6b0d0ddcee4e..fbe1dd3f481c 100644 --- a/WordPress/Classes/ViewRelated/Comments/CommentViewController.m +++ b/WordPress/Classes/ViewRelated/Comments/CommentViewController.m @@ -466,7 +466,7 @@ - (void)openWebViewWithURL:(NSURL *)url return; } - UIViewController *webViewController = [WebViewControllerFactory controllerAuthenticatedWithDefaultAccountWithUrl:url]; + UIViewController *webViewController = [WebViewControllerFactory controllerAuthenticatedWithDefaultAccountWithUrl:url source:@"comments"]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:webViewController]; [self presentViewController:navController animated:YES completion:nil]; } diff --git a/WordPress/Classes/ViewRelated/Domains/Domain registration/RegisterDomainSuggestions/RegisterDomainSuggestionsViewController.swift b/WordPress/Classes/ViewRelated/Domains/Domain registration/RegisterDomainSuggestions/RegisterDomainSuggestionsViewController.swift index 86c4409ba614..16e2d0890dd2 100644 --- a/WordPress/Classes/ViewRelated/Domains/Domain registration/RegisterDomainSuggestions/RegisterDomainSuggestionsViewController.swift +++ b/WordPress/Classes/ViewRelated/Domains/Domain registration/RegisterDomainSuggestions/RegisterDomainSuggestionsViewController.swift @@ -309,7 +309,7 @@ extension RegisterDomainSuggestionsViewController: NUXButtonViewControllerDelega return } - let webViewController = WebViewControllerFactory.controllerWithDefaultAccountAndSecureInteraction(url: url) + let webViewController = WebViewControllerFactory.controllerWithDefaultAccountAndSecureInteraction(url: url, source: "domains_register") let navController = LightNavigationController(rootViewController: webViewController) // WORKAROUND: The reason why we have to use this mechanism to detect success and failure conditions diff --git a/WordPress/Classes/ViewRelated/Jetpack/Jetpack Restore/Restore Complete/JetpackRestoreCompleteViewController.swift b/WordPress/Classes/ViewRelated/Jetpack/Jetpack Restore/Restore Complete/JetpackRestoreCompleteViewController.swift index 93afe71cb55f..600d89b528eb 100644 --- a/WordPress/Classes/ViewRelated/Jetpack/Jetpack Restore/Restore Complete/JetpackRestoreCompleteViewController.swift +++ b/WordPress/Classes/ViewRelated/Jetpack/Jetpack Restore/Restore Complete/JetpackRestoreCompleteViewController.swift @@ -54,7 +54,7 @@ class JetpackRestoreCompleteViewController: BaseRestoreCompleteViewController { return } - let webVC = WebViewControllerFactory.controller(url: homeURL) + let webVC = WebViewControllerFactory.controller(url: homeURL, source: "jetpack_restore_complete") let navigationVC = LightNavigationController(rootViewController: webVC) self.present(navigationVC, animated: true) diff --git a/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSettingsViewController.swift b/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSettingsViewController.swift index 1acdeff4aaf0..489c6cb2d890 100644 --- a/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSettingsViewController.swift +++ b/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSettingsViewController.swift @@ -322,7 +322,7 @@ open class JetpackSettingsViewController: UITableViewController { guard let url = URL(string: JetpackSettingsViewController.learnMoreUrl) else { return } - let webViewController = WebViewControllerFactory.controller(url: url) + let webViewController = WebViewControllerFactory.controller(url: url, source: "jetpack_settings_learn_more") if presentingViewController != nil { navigationController?.pushViewController(webViewController, animated: true) diff --git a/WordPress/Classes/ViewRelated/Jetpack/Login/JetpackLoginViewController.swift b/WordPress/Classes/ViewRelated/Jetpack/Login/JetpackLoginViewController.swift index cb53d936dbe1..dbb2adc45ad3 100644 --- a/WordPress/Classes/ViewRelated/Jetpack/Login/JetpackLoginViewController.swift +++ b/WordPress/Classes/ViewRelated/Jetpack/Login/JetpackLoginViewController.swift @@ -202,7 +202,7 @@ class JetpackLoginViewController: UIViewController { return } - let webviewViewController = WebViewControllerFactory.controller(url: url) + let webviewViewController = WebViewControllerFactory.controller(url: url, source: "jetpack_login") let navigationViewController = UINavigationController(rootViewController: webviewViewController) present(navigationViewController, animated: true, completion: nil) } diff --git a/WordPress/Classes/ViewRelated/Me/App Settings/About/AboutViewController.swift b/WordPress/Classes/ViewRelated/Me/App Settings/About/AboutViewController.swift index bf35504217bc..54bd3ef8e123 100644 --- a/WordPress/Classes/ViewRelated/Me/App Settings/About/AboutViewController.swift +++ b/WordPress/Classes/ViewRelated/Me/App Settings/About/AboutViewController.swift @@ -170,10 +170,10 @@ open class AboutViewController: UITableViewController { } if let title = title { - present(webViewController: WebViewControllerFactory.controller(url: url, title: title)) + present(webViewController: WebViewControllerFactory.controller(url: url, title: title, source: "about")) } else { - present(webViewController: WebViewControllerFactory.controller(url: url)) + present(webViewController: WebViewControllerFactory.controller(url: url, source: "about")) } } diff --git a/WordPress/Classes/ViewRelated/Me/App Settings/About/AppAboutScreenConfiguration.swift b/WordPress/Classes/ViewRelated/Me/App Settings/About/AppAboutScreenConfiguration.swift index 7a22661502dd..1ab44599b999 100644 --- a/WordPress/Classes/ViewRelated/Me/App Settings/About/AppAboutScreenConfiguration.swift +++ b/WordPress/Classes/ViewRelated/Me/App Settings/About/AppAboutScreenConfiguration.swift @@ -5,7 +5,7 @@ import WordPressShared struct WebViewPresenter { func present(for url: URL, context: AboutItemActionContext) { - let webViewController = WebViewControllerFactory.controller(url: url) + let webViewController = WebViewControllerFactory.controller(url: url, source: "about") let navigationController = UINavigationController(rootViewController: webViewController) context.viewController.present(navigationController, animated: true, completion: nil) } diff --git a/WordPress/Classes/ViewRelated/Me/App Settings/PrivacySettingsViewController.swift b/WordPress/Classes/ViewRelated/Me/App Settings/PrivacySettingsViewController.swift index fc03124b9aba..a76678bdaa50 100644 --- a/WordPress/Classes/ViewRelated/Me/App Settings/PrivacySettingsViewController.swift +++ b/WordPress/Classes/ViewRelated/Me/App Settings/PrivacySettingsViewController.swift @@ -153,7 +153,7 @@ class PrivacySettingsViewController: UITableViewController { guard let url = URL(string: urlString) else { return } - let webViewController = WebViewControllerFactory.controller(url: url) + let webViewController = WebViewControllerFactory.controller(url: url, source: "privacy_settings") let navigation = UINavigationController(rootViewController: webViewController) present(navigation, animated: true) } diff --git a/WordPress/Classes/ViewRelated/Media/MediaItemViewController.swift b/WordPress/Classes/ViewRelated/Media/MediaItemViewController.swift index 27eddda49fb0..d235fc32379e 100644 --- a/WordPress/Classes/ViewRelated/Media/MediaItemViewController.swift +++ b/WordPress/Classes/ViewRelated/Media/MediaItemViewController.swift @@ -225,7 +225,7 @@ class MediaItemViewController: UITableViewController { guard let remoteURL = media.remoteURL, let url = URL(string: remoteURL) else { return } - let controller = WebViewControllerFactory.controller(url: url, blog: media.blog) + let controller = WebViewControllerFactory.controller(url: url, blog: media.blog, source: "media_item") controller.loadViewIfNeeded() controller.navigationItem.titleView = nil controller.title = media.title ?? "" diff --git a/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationContentRouter.swift b/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationContentRouter.swift index ed1f7a1d8897..16cff0c8d900 100644 --- a/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationContentRouter.swift +++ b/WordPress/Classes/ViewRelated/Notifications/Controllers/NotificationContentRouter.swift @@ -16,7 +16,7 @@ struct NotificationContentRouter { do { try displayContent(of: range, with: url) } catch { - coordinator.displayWebViewWithURL(url) + coordinator.displayWebViewWithURL(url, source: "notifications") } } @@ -31,7 +31,7 @@ struct NotificationContentRouter { do { try displayNotificationSource() } catch { - coordinator.displayWebViewWithURL(fallbackURL) + coordinator.displayWebViewWithURL(fallbackURL, source: "notifications") } } diff --git a/WordPress/Classes/ViewRelated/People/InvitePersonViewController.swift b/WordPress/Classes/ViewRelated/People/InvitePersonViewController.swift index 822f5882efcd..919402709259 100644 --- a/WordPress/Classes/ViewRelated/People/InvitePersonViewController.swift +++ b/WordPress/Classes/ViewRelated/People/InvitePersonViewController.swift @@ -489,7 +489,7 @@ extension InvitePersonViewController { return } - let webViewController = WebViewControllerFactory.controller(url: url) + let webViewController = WebViewControllerFactory.controller(url: url, source: "invite_person_role_learn_more") let navController = UINavigationController(rootViewController: webViewController) present(navController, animated: true) } diff --git a/WordPress/Classes/ViewRelated/Plugins/PluginViewModel.swift b/WordPress/Classes/ViewRelated/Plugins/PluginViewModel.swift index 29887f57ebc8..b3bcbf37c3da 100644 --- a/WordPress/Classes/ViewRelated/Plugins/PluginViewModel.swift +++ b/WordPress/Classes/ViewRelated/Plugins/PluginViewModel.swift @@ -555,7 +555,7 @@ class PluginViewModel: Observable { } private func presentBrowser(`for` url: URL) { - let controller = WebViewControllerFactory.controller(url: url) + let controller = WebViewControllerFactory.controller(url: url, source: "plugins") let navigationController = UINavigationController(rootViewController: controller) self.present?(navigationController) } diff --git a/WordPress/Classes/ViewRelated/Post/AbstractPostListViewController.swift b/WordPress/Classes/ViewRelated/Post/AbstractPostListViewController.swift index 9f518e269133..f22ec257633b 100644 --- a/WordPress/Classes/ViewRelated/Post/AbstractPostListViewController.swift +++ b/WordPress/Classes/ViewRelated/Post/AbstractPostListViewController.swift @@ -928,7 +928,7 @@ class AbstractPostListViewController: UIViewController, let post = apost.hasRevision() ? apost.revision! : apost - let controller = PreviewWebKitViewController(post: post) + let controller = PreviewWebKitViewController(post: post, source: "posts_pages_view_post") controller.trackOpenEvent() // NOTE: We'll set the title to match the title of the View action button. // If the button title changes we should also update the title here. diff --git a/WordPress/Classes/ViewRelated/Post/EditPostViewController.swift b/WordPress/Classes/ViewRelated/Post/EditPostViewController.swift index 6640335a80a0..f45ef0316035 100644 --- a/WordPress/Classes/ViewRelated/Post/EditPostViewController.swift +++ b/WordPress/Classes/ViewRelated/Post/EditPostViewController.swift @@ -240,7 +240,7 @@ class EditPostViewController: UIViewController { return } - let controller = PreviewWebKitViewController(post: post) + let controller = PreviewWebKitViewController(post: post, source: "edit_post_preview") controller.trackOpenEvent() let navWrapper = LightNavigationController(rootViewController: controller) if postPost.traitCollection.userInterfaceIdiom == .pad { diff --git a/WordPress/Classes/ViewRelated/Post/PostEditor+MoreOptions.swift b/WordPress/Classes/ViewRelated/Post/PostEditor+MoreOptions.swift index c66dda512fd0..ed3352f5bdd8 100644 --- a/WordPress/Classes/ViewRelated/Post/PostEditor+MoreOptions.swift +++ b/WordPress/Classes/ViewRelated/Post/PostEditor+MoreOptions.swift @@ -92,14 +92,14 @@ extension PostEditor { let previewController: PreviewWebKitViewController if let previewURLString = previewURLString, let previewURL = URL(string: previewURLString) { - previewController = PreviewWebKitViewController(post: self.post, previewURL: previewURL) + previewController = PreviewWebKitViewController(post: self.post, previewURL: previewURL, source: "edit_post_more_preview") } else { if self.post.permaLink == nil { DDLogError("displayPreview: Post permalink is unexpectedly nil") self.displayPreviewNotAvailable(title: NSLocalizedString("Preview Unavailable", comment: "Title on display preview error" )) return } - previewController = PreviewWebKitViewController(post: self.post) + previewController = PreviewWebKitViewController(post: self.post, source: "edit_post_more_preview") } previewController.trackOpenEvent() let navWrapper = LightNavigationController(rootViewController: previewController) diff --git a/WordPress/Classes/ViewRelated/Post/PostNoticeNavigationCoordinator.swift b/WordPress/Classes/ViewRelated/Post/PostNoticeNavigationCoordinator.swift index 9e08827a6bd0..6b91ed91e1b5 100644 --- a/WordPress/Classes/ViewRelated/Post/PostNoticeNavigationCoordinator.swift +++ b/WordPress/Classes/ViewRelated/Post/PostNoticeNavigationCoordinator.swift @@ -23,7 +23,7 @@ class PostNoticeNavigationCoordinator { return } - let controller = PreviewWebKitViewController(post: page) + let controller = PreviewWebKitViewController(post: page, source: "post_notice_preview") controller.trackOpenEvent() controller.navigationItem.title = NSLocalizedString("View", comment: "Verb. The screen title shown when viewing a post inside the app.") diff --git a/WordPress/Classes/ViewRelated/Post/Preview/PreviewWebKitViewController.swift b/WordPress/Classes/ViewRelated/Post/Preview/PreviewWebKitViewController.swift index 726a406433db..e1d33d87f686 100644 --- a/WordPress/Classes/ViewRelated/Post/Preview/PreviewWebKitViewController.swift +++ b/WordPress/Classes/ViewRelated/Post/Preview/PreviewWebKitViewController.swift @@ -1,5 +1,6 @@ import Gridicons import WebKit +import WordPressShared /// An augmentation of WebKitViewController to provide Previewing for different devices class PreviewWebKitViewController: WebKitViewController { @@ -47,7 +48,7 @@ class PreviewWebKitViewController: WebKitViewController { /// - Parameters: /// - post: The post to use for generating the preview URL and authenticating to the blog. **NOTE**: `previewURL` will be used as the URL instead, when available. /// - previewURL: The URL to display in the preview web view. - init(post: AbstractPost, previewURL: URL? = nil) { + init(post: AbstractPost, previewURL: URL? = nil, source: String) { self.post = post @@ -67,6 +68,7 @@ class PreviewWebKitViewController: WebKitViewController { configuration.linkBehavior = isPage ? .hostOnly(url) : .urlOnly(url) configuration.opensNewInSafari = true configuration.authenticate(blog: post.blog) + configuration.analyticsSource = source super.init(configuration: configuration) } @@ -190,6 +192,12 @@ class PreviewWebKitViewController: WebKitViewController { popoverContentController.selectedOption = selectedDevice popoverContentController.onDeviceChange = { [weak self] option in self?.selectedDevice = option + + let properties: [AnyHashable: Any] = [ + "source": self?.analyticsSource ?? "unknown", + "option": option.rawValue + ] + WPAnalytics.track(.previewWebKitViewDeviceChanged, properties: properties) } popoverContentController.modalPresentationStyle = .popover diff --git a/WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailCoordinator.swift b/WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailCoordinator.swift index b43d95aa1cd2..1b58346c71c8 100644 --- a/WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailCoordinator.swift +++ b/WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailCoordinator.swift @@ -572,7 +572,7 @@ class ReaderDetailCoordinator { let configuration = WebViewControllerConfiguration(url: url) configuration.authenticateWithDefaultAccount() configuration.addsWPComReferrer = true - let controller = WebViewControllerFactory.controller(configuration: configuration) + let controller = WebViewControllerFactory.controller(configuration: configuration, source: "reader_detail") let navController = LightNavigationController(rootViewController: controller) viewController?.present(navController, animated: true) } diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.m b/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.m index 5536591e7b4b..6fb202c2d326 100644 --- a/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.m +++ b/WordPress/Classes/ViewRelated/Reader/ReaderCommentsViewController.m @@ -1296,7 +1296,7 @@ - (void)cell:(ReaderCommentCell *)cell didTapAuthor:(Comment *)comment WebViewControllerConfiguration *configuration = [[WebViewControllerConfiguration alloc] initWithUrl:url]; [configuration authenticateWithDefaultAccount]; [configuration setAddsWPComReferrer:YES]; - UIViewController *webViewController = [WebViewControllerFactory controllerWithConfiguration:configuration]; + UIViewController *webViewController = [WebViewControllerFactory controllerWithConfiguration:configuration source:@"reader_comments_author"]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:webViewController]; [self presentViewController:navController animated:YES completion:nil]; } @@ -1414,7 +1414,7 @@ - (void)presentWebViewControllerWithURL:(NSURL *)URL WebViewControllerConfiguration *configuration = [[WebViewControllerConfiguration alloc] initWithUrl:linkURL]; [configuration authenticateWithDefaultAccount]; [configuration setAddsWPComReferrer:YES]; - UIViewController *webViewController = [WebViewControllerFactory controllerWithConfiguration:configuration]; + UIViewController *webViewController = [WebViewControllerFactory controllerWithConfiguration:configuration source:@"reader_comments"]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:webViewController]; [self presentViewController:navController animated:YES completion:nil]; } diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderReportPostAction.swift b/WordPress/Classes/ViewRelated/Reader/ReaderReportPostAction.swift index 8764f25cbeb5..cc7d5fcccb42 100644 --- a/WordPress/Classes/ViewRelated/Reader/ReaderReportPostAction.swift +++ b/WordPress/Classes/ViewRelated/Reader/ReaderReportPostAction.swift @@ -16,7 +16,7 @@ final class ReaderReportPostAction { configuration.authenticate(account: account) } - let controller = WebViewControllerFactory.controller(configuration: configuration) + let controller = WebViewControllerFactory.controller(configuration: configuration, source: "reader_report") let navController = UINavigationController(rootViewController: controller) origin.present(navController, animated: true) diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderShowAttributionAction.swift b/WordPress/Classes/ViewRelated/Reader/ReaderShowAttributionAction.swift index 6dfa83783772..11a80cfd82cb 100644 --- a/WordPress/Classes/ViewRelated/Reader/ReaderShowAttributionAction.swift +++ b/WordPress/Classes/ViewRelated/Reader/ReaderShowAttributionAction.swift @@ -22,7 +22,7 @@ final class ReaderShowAttributionAction { } let configuration = WebViewControllerConfiguration(url: linkURL) configuration.addsWPComReferrer = true - let controller = WebViewControllerFactory.controller(configuration: configuration) + let controller = WebViewControllerFactory.controller(configuration: configuration, source: "reader_attribution") let navController = UINavigationController(rootViewController: controller) origin.present(navController, animated: true) } diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderVisitSiteAction.swift b/WordPress/Classes/ViewRelated/Reader/ReaderVisitSiteAction.swift index 83eb39e569ba..61b477950d35 100644 --- a/WordPress/Classes/ViewRelated/Reader/ReaderVisitSiteAction.swift +++ b/WordPress/Classes/ViewRelated/Reader/ReaderVisitSiteAction.swift @@ -13,7 +13,7 @@ final class ReaderVisitSiteAction { if let account = service.defaultWordPressComAccount() { configuration.authenticate(account: account) } - let controller = WebViewControllerFactory.controller(configuration: configuration) + let controller = WebViewControllerFactory.controller(configuration: configuration, source: "reader_visit_site") let navController = LightNavigationController(rootViewController: controller) origin.present(navController, animated: true) WPAnalytics.trackReader(.readerArticleVisited) diff --git a/WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsInsightsTableViewController.swift b/WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsInsightsTableViewController.swift index 267553b41f4e..0be5d380a10c 100644 --- a/WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsInsightsTableViewController.swift +++ b/WordPress/Classes/ViewRelated/Stats/Insights/SiteStatsInsightsTableViewController.swift @@ -379,7 +379,7 @@ private extension SiteStatsInsightsTableViewController { extension SiteStatsInsightsTableViewController: SiteStatsInsightsDelegate { func displayWebViewWithURL(_ url: URL) { - let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url) + let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url, source: "site_stats_insights") let navController = UINavigationController.init(rootViewController: webViewController) present(navController, animated: true) } diff --git a/WordPress/Classes/ViewRelated/Stats/Period Stats/SiteStatsPeriodTableViewController.swift b/WordPress/Classes/ViewRelated/Stats/Period Stats/SiteStatsPeriodTableViewController.swift index 516cafa7e7ad..460b64b08f50 100644 --- a/WordPress/Classes/ViewRelated/Stats/Period Stats/SiteStatsPeriodTableViewController.swift +++ b/WordPress/Classes/ViewRelated/Stats/Period Stats/SiteStatsPeriodTableViewController.swift @@ -251,7 +251,7 @@ extension SiteStatsPeriodTableViewController: NoResultsViewControllerDelegate { extension SiteStatsPeriodTableViewController: SiteStatsPeriodDelegate { func displayWebViewWithURL(_ url: URL) { - let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url) + let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url, source: "site_stats_period") let navController = UINavigationController.init(rootViewController: webViewController) present(navController, animated: true) } diff --git a/WordPress/Classes/ViewRelated/Stats/Referrer Details/ReferrerDetailsTableViewController.swift b/WordPress/Classes/ViewRelated/Stats/Referrer Details/ReferrerDetailsTableViewController.swift index 240a1194c8f4..184e78d5dc0f 100644 --- a/WordPress/Classes/ViewRelated/Stats/Referrer Details/ReferrerDetailsTableViewController.swift +++ b/WordPress/Classes/ViewRelated/Stats/Referrer Details/ReferrerDetailsTableViewController.swift @@ -51,7 +51,7 @@ extension ReferrerDetailsTableViewController { // MARK: - ReferrerDetailsViewModelDelegate extension ReferrerDetailsTableViewController: ReferrerDetailsViewModelDelegate { func displayWebViewWithURL(_ url: URL) { - let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url) + let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url, source: "stats_referrer_details") let navController = UINavigationController(rootViewController: webViewController) present(navController, animated: true) } diff --git a/WordPress/Classes/ViewRelated/Stats/Shared Views/Post Stats/PostStatsTableViewController.swift b/WordPress/Classes/ViewRelated/Stats/Shared Views/Post Stats/PostStatsTableViewController.swift index 570736314473..0dfcca952453 100644 --- a/WordPress/Classes/ViewRelated/Stats/Shared Views/Post Stats/PostStatsTableViewController.swift +++ b/WordPress/Classes/ViewRelated/Stats/Shared Views/Post Stats/PostStatsTableViewController.swift @@ -184,7 +184,7 @@ private extension PostStatsTableViewController { extension PostStatsTableViewController: PostStatsDelegate { func displayWebViewWithURL(_ url: URL) { - let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url) + let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url, source: "stats_post_stats") let navController = UINavigationController.init(rootViewController: webViewController) present(navController, animated: true) } diff --git a/WordPress/Classes/ViewRelated/Stats/Shared Views/Stats Detail/SiteStatsDetailTableViewController.swift b/WordPress/Classes/ViewRelated/Stats/Shared Views/Stats Detail/SiteStatsDetailTableViewController.swift index 708d28507e38..e3175aeb74dc 100644 --- a/WordPress/Classes/ViewRelated/Stats/Shared Views/Stats Detail/SiteStatsDetailTableViewController.swift +++ b/WordPress/Classes/ViewRelated/Stats/Shared Views/Stats Detail/SiteStatsDetailTableViewController.swift @@ -278,7 +278,7 @@ extension SiteStatsDetailTableViewController: SiteStatsDetailsDelegate { } func displayWebViewWithURL(_ url: URL) { - let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url) + let webViewController = WebViewControllerFactory.controllerAuthenticatedWithDefaultAccount(url: url, source: "site_stats_detail") let navController = UINavigationController.init(rootViewController: webViewController) present(navController, animated: true) } diff --git a/WordPress/Classes/ViewRelated/System/WPTabBarController+ShowTab.swift b/WordPress/Classes/ViewRelated/System/WPTabBarController+ShowTab.swift index 9d91418312e2..bebe6436a78e 100644 --- a/WordPress/Classes/ViewRelated/System/WPTabBarController+ShowTab.swift +++ b/WordPress/Classes/ViewRelated/System/WPTabBarController+ShowTab.swift @@ -59,7 +59,7 @@ extension WPTabBarController { UserDefaults.standard.storiesIntroWasAcknowledged = true self?.showStoryEditor() }, openURL: { [weak self] url in - let webViewController = WebViewControllerFactory.controller(url: url) + let webViewController = WebViewControllerFactory.controller(url: url, source: "show_story_example") let navController = UINavigationController(rootViewController: webViewController) self?.presentedViewController?.present(navController, animated: true) }) diff --git a/WordPress/Classes/ViewRelated/Themes/ThemeBrowserViewController.swift b/WordPress/Classes/ViewRelated/Themes/ThemeBrowserViewController.swift index 643c12fc7637..7c4cd0a6ef0f 100644 --- a/WordPress/Classes/ViewRelated/Themes/ThemeBrowserViewController.swift +++ b/WordPress/Classes/ViewRelated/Themes/ThemeBrowserViewController.swift @@ -894,7 +894,7 @@ public protocol ThemePresenter: AnyObject { activateButton = UIBarButtonItem(title: title, style: .plain, target: self, action: #selector(ThemeBrowserViewController.activatePresentingTheme)) activateButton?.isEnabled = !theme.isCurrentTheme() - let webViewController = WebViewControllerFactory.controller(configuration: configuration) + let webViewController = WebViewControllerFactory.controller(configuration: configuration, source: "theme_browser") webViewController.navigationItem.rightBarButtonItem = activateButton let navigation = UINavigationController(rootViewController: webViewController) navigation.modalPresentationStyle = modalStyle diff --git a/WordPress/Classes/ViewRelated/User Profile Sheet/UserProfileSheetViewController.swift b/WordPress/Classes/ViewRelated/User Profile Sheet/UserProfileSheetViewController.swift index 83ebd159fa79..d34175dba76c 100644 --- a/WordPress/Classes/ViewRelated/User Profile Sheet/UserProfileSheetViewController.swift +++ b/WordPress/Classes/ViewRelated/User Profile Sheet/UserProfileSheetViewController.swift @@ -168,7 +168,7 @@ private extension UserProfileSheetViewController { } WPAnalytics.track(.blogUrlPreviewed, properties: ["source": blogUrlPreviewedSource as Any]) - contentCoordinator.displayWebViewWithURL(siteURL) + contentCoordinator.displayWebViewWithURL(siteURL, source: blogUrlPreviewedSource ?? "user_profile_sheet") } func configureTable() { diff --git a/WordPress/Jetpack/Classes/ViewRelated/Login Error/View Models/JetpackNoSitesErrorViewModel.swift b/WordPress/Jetpack/Classes/ViewRelated/Login Error/View Models/JetpackNoSitesErrorViewModel.swift index 9df350efeefb..da3485dd61be 100644 --- a/WordPress/Jetpack/Classes/ViewRelated/Login Error/View Models/JetpackNoSitesErrorViewModel.swift +++ b/WordPress/Jetpack/Classes/ViewRelated/Login Error/View Models/JetpackNoSitesErrorViewModel.swift @@ -12,7 +12,7 @@ struct JetpackNoSitesErrorViewModel: JetpackErrorViewModel { return } - let controller = WebViewControllerFactory.controller(url: url) + let controller = WebViewControllerFactory.controller(url: url, source: "jetpack_no_sites") let navController = UINavigationController(rootViewController: controller) viewController?.present(navController, animated: true) diff --git a/WordPress/Jetpack/Classes/ViewRelated/Login Error/View Models/JetpackNotFoundErrorViewModel.swift b/WordPress/Jetpack/Classes/ViewRelated/Login Error/View Models/JetpackNotFoundErrorViewModel.swift index db98a837133b..5aac59c8d6c4 100644 --- a/WordPress/Jetpack/Classes/ViewRelated/Login Error/View Models/JetpackNotFoundErrorViewModel.swift +++ b/WordPress/Jetpack/Classes/ViewRelated/Login Error/View Models/JetpackNotFoundErrorViewModel.swift @@ -28,7 +28,7 @@ struct JetpackNotFoundErrorViewModel: JetpackErrorViewModel { return } - let controller = WebViewControllerFactory.controller(url: url) + let controller = WebViewControllerFactory.controller(url: url, source: "jetpack_not_found") let navController = UINavigationController(rootViewController: controller) viewController?.present(navController, animated: true) diff --git a/WordPress/WordPressTest/MockContentCoordinator.swift b/WordPress/WordPressTest/MockContentCoordinator.swift index 62d814d3ba82..74a947b168cf 100644 --- a/WordPress/WordPressTest/MockContentCoordinator.swift +++ b/WordPress/WordPressTest/MockContentCoordinator.swift @@ -44,7 +44,7 @@ class MockContentCoordinator: ContentCoordinator { streamSiteID = siteID } - func displayWebViewWithURL(_ url: URL) { + func displayWebViewWithURL(_ url: URL, source: String) { } diff --git a/WordPress/WordPressTest/ViewRelated/Post/Controllers/PreviewWebKitViewControllerTests.swift b/WordPress/WordPressTest/ViewRelated/Post/Controllers/PreviewWebKitViewControllerTests.swift index 831ffd0b2658..979fa7ca6b41 100644 --- a/WordPress/WordPressTest/ViewRelated/Post/Controllers/PreviewWebKitViewControllerTests.swift +++ b/WordPress/WordPressTest/ViewRelated/Post/Controllers/PreviewWebKitViewControllerTests.swift @@ -25,7 +25,7 @@ class PreviewWebKitViewControllerTests: XCTestCase { func testMissingPermalink() { let post = PostBuilder(context).drafted().build() - let vc = PreviewWebKitViewController(post: post, previewURL: nil) + let vc = PreviewWebKitViewController(post: post, previewURL: nil, source: "test_missing_permalink") XCTAssertEqual(vc.url!.absoluteString, "about:blank", "Should load blank page when no permalink is available") } @@ -34,7 +34,7 @@ class PreviewWebKitViewControllerTests: XCTestCase { let post = PostBuilder(context).drafted().build() post.permaLink = "http://example.com/" - let vc = PreviewWebKitViewController(post: post, previewURL: nil) + let vc = PreviewWebKitViewController(post: post, previewURL: nil, source: "test_draft_toolbar") let items = vc.toolbarItems(linkBehavior: vc.linkBehavior) XCTAssertTrue(items.contains(vc.publishButton), "Preview toolbar for draft should contain publish button.") @@ -50,7 +50,7 @@ class PreviewWebKitViewControllerTests: XCTestCase { let post = PostBuilder(context).published().build() post.permaLink = "http://example.com/" - let vc = PreviewWebKitViewController(post: post, previewURL: nil) + let vc = PreviewWebKitViewController(post: post, previewURL: nil, source: "test_published_toolbar") let items = vc.toolbarItems(linkBehavior: vc.linkBehavior) XCTAssertTrue(items.contains(vc.shareButton), "Preview toolbar for post should contain share button.") @@ -65,7 +65,7 @@ class PreviewWebKitViewControllerTests: XCTestCase { let page = PageBuilder(context).build() page.permaLink = "http://example.com/" - let vc = PreviewWebKitViewController(post: page, previewURL: nil) + let vc = PreviewWebKitViewController(post: page, previewURL: nil, source: "test_site_page") let items = vc.toolbarItems(linkBehavior: vc.linkBehavior) XCTAssertFalse(items.contains(vc.publishButton), "Preview toolbar for page should not contain publish button.")