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 for all of the site settings areas #17545

Merged
merged 32 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4c2d73c
Add new settings track names
Nov 23, 2021
e09e06b
Add a fieldName property to EditableTextRow to help in tracking which…
Nov 23, 2021
08b10e9
Add a trackingKey property to the SettingsController's
Nov 23, 2021
b91b7e5
Add a helper method to track when a SettingsController's text field i…
Nov 23, 2021
5c7d7ed
Add fieldName's to the Account Settings view
Nov 23, 2021
a70a60d
Track when the primary site is changed
Nov 23, 2021
b9aadf8
Add fieldName's to the My Profile settings view
Nov 23, 2021
fd9079f
Remove account_close_cancel event
Nov 23, 2021
68650ca
Add tracking when the user closes their account
Nov 23, 2021
0475b8b
Track when the clear media cache button is tapped
Nov 23, 2021
15e1ac6
Track when the app settings clear spotlight index button is tapped
Nov 23, 2021
586aed3
Track when the clear app settings siri suggestions button is tapped
Nov 23, 2021
608518a
Track the app icon name when the app icon is changed
Nov 23, 2021
12f18a7
Add track name for the privacy settings
Nov 23, 2021
ceb2a5a
Track when the privacy settings is opened and the report crashes opti…
Nov 23, 2021
9836eec
Add tracking when the open device settings button is tapped
Nov 23, 2021
b1803c0
Add tracking to the site settings view
Nov 23, 2021
a4ab116
Track homepage settings change
Nov 23, 2021
20791b1
Track default category change
Nov 23, 2021
adefc8b
Add a helper method for tracking settings changes
Nov 23, 2021
c8f76d2
Update existing references to use new helper method
Nov 23, 2021
9ae9a13
Add edit/add tag tracking to site settings
Nov 23, 2021
379397d
Add objc support to the trackSettingsChange helper method
Nov 23, 2021
d92e54f
Add tracking to the date and time format settings view
Nov 23, 2021
bc2a272
Add tracking to the related posts settings view
Nov 23, 2021
1b80969
Add default post format tracking
Nov 23, 2021
2f6b230
Add speed up your site tracking
Nov 23, 2021
575f438
Add discussion settings tracking
Nov 23, 2021
87a15d9
Add tracking to jetpack settings
Nov 23, 2021
8eac109
Adds tracking for the amp, privacy, and language fields in site settings
Nov 24, 2021
36af41c
Swap send and receive pingbacks tracking
Nov 24, 2021
77a67d8
Refactor the discussion settings tracking
Nov 24, 2021
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
58 changes: 58 additions & 0 deletions WordPress/Classes/Utility/Analytics/WPAnalyticsEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,23 @@ import Foundation
case readerManageViewDisplayed
case readerManageViewDismissed

// App Settings
case settingsDidChange

// Account Close
case accountCloseTapped
case accountCloseCompleted

// App Settings
case appSettingsClearMediaCacheTapped
case appSettingsClearSpotlightIndexTapped
case appSettingsClearSiriSuggestionsTapped
case appSettingsOpenDeviceSettingsTapped

// Privacy Settings
case privacySettingsOpened
case privacySettingsReportCrashesToggled

/// A String that represents the event
var value: String {
switch self {
Expand Down Expand Up @@ -628,6 +645,7 @@ import Foundation
case .postListShareAction:
return "post_list_button_pressed"

// Reader: Filter Sheet
case .readerFilterSheetDisplayed:
return "reader_filter_sheet_displayed"
case .readerFilterSheetDismissed:
Expand All @@ -636,10 +654,36 @@ import Foundation
return "reader_filter_sheet_item_selected"
case .readerFilterSheetCleared:
return "reader_filter_sheet_cleared"

// Reader: Manage View
case .readerManageViewDisplayed:
return "reader_manage_view_displayed"
case .readerManageViewDismissed:
return "reader_manage_view_dismissed"

// App Settings
case .settingsDidChange:
return "settings_did_change"
case .appSettingsClearMediaCacheTapped:
return "app_settings_clear_media_cache_tapped"
case .appSettingsClearSpotlightIndexTapped:
return "app_settings_clear_spotlight_index_tapped"
case .appSettingsClearSiriSuggestionsTapped:
return "app_settings_clear_siri_suggestions_tapped"
case .appSettingsOpenDeviceSettingsTapped:
return "app_settings_open_device_settings_tapped"

// Privacy Settings
case .privacySettingsOpened:
return "privacy_settings_opened"
case .privacySettingsReportCrashesToggled:
return "privacy_settings_report_crashes_toggled"

// Account Close
case .accountCloseTapped:
return "account_close_tapped"
case .accountCloseCompleted:
return "account_close_completed"
} // END OF SWITCH
}

Expand Down Expand Up @@ -803,4 +847,18 @@ extension WPAnalytics {
}
}

@objc static func trackSettingsChange(_ page: String, fieldName: String) {
Self.trackSettingsChange(page, fieldName: fieldName, value: nil)
}

@objc static func trackSettingsChange(_ page: String, fieldName: String, value: Any?) {
var properties: [AnyHashable: Any] = ["page": page, "field_name": fieldName]

if let value = value {
let additionalProperties: [AnyHashable: Any] = ["value": value]
properties.merge(additionalProperties) { (_, new) in new }
}

WPAnalytics.track(.settingsDidChange, properties: properties)
}
}
4 changes: 3 additions & 1 deletion WordPress/Classes/Utility/WPImmuTableRows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ struct EditableTextRow: ImmuTableRow {
let value: String
let accessoryImage: UIImage?
let action: ImmuTableAction?
let fieldName: String?

init(title: String, value: String, accessoryImage: UIImage? = nil, action: ImmuTableAction?) {
init(title: String, value: String, accessoryImage: UIImage? = nil, action: ImmuTableAction?, fieldName: String? = nil) {
self.title = title
self.value = value
self.accessoryImage = accessoryImage
self.action = action
self.fieldName = fieldName
}

func configureCell(_ cell: UITableViewCell) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UIKit
import Gridicons
import WordPressShared

final class SiteTagsViewController: UITableViewController {
private struct TableConstants {
Expand Down Expand Up @@ -309,6 +310,7 @@ extension SiteTagsViewController {
newTag.tagDescription = data.subtitle

save(newTag)
WPAnalytics.trackSettingsChange("site_tags", fieldName: "add_tag")
}

private func updateTag(_ tag: PostTag, updatedData: SettingsTitleSubtitleController.Content) {
Expand All @@ -323,6 +325,7 @@ extension SiteTagsViewController {
tag.tagDescription = updatedData.subtitle

save(tag)
WPAnalytics.trackSettingsChange("site_tags", fieldName: "edit_tag")
}

private func existingTagForData(_ data: SettingsTitleSubtitleController.Content) -> PostTag? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ open class DateAndTimeFormatSettingsViewController: UITableViewController {
if let newDateFormat = selected as? String {
self?.settings.dateFormat = newDateFormat
self?.saveSettings()
WPAnalytics.trackSettingsChange("date_format", fieldName: "date_format")
}
}

Expand Down Expand Up @@ -168,6 +169,8 @@ open class DateAndTimeFormatSettingsViewController: UITableViewController {
if let newTimeFormat = selected as? String {
self?.settings.timeFormat = newTimeFormat
self?.saveSettings()
WPAnalytics.trackSettingsChange("date_format", fieldName: "time_format")

}
}

Expand All @@ -187,6 +190,9 @@ open class DateAndTimeFormatSettingsViewController: UITableViewController {
if let newStartOfWeek = selected as? String {
self?.settings.startOfWeek = newStartOfWeek
self?.saveSettings()
WPAnalytics.trackSettingsChange("date_format",
fieldName: "start_of_week",
value: newStartOfWeek as Any)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import WordPressShared
/// allow the user to tune those settings, as required.
///
open class DiscussionSettingsViewController: UITableViewController {
private let tracksDiscussionSettingsKey = "site_settings_discussion"

// MARK: - Initializers / Deinitializers
@objc public convenience init(blog: Blog) {
self.init(style: .grouped)
Expand Down Expand Up @@ -183,6 +185,7 @@ open class DiscussionSettingsViewController: UITableViewController {
return
}

trackSettingsChange(fieldName: "allow_comments", value: enabled as Any)
settings.commentsAllowed = enabled
}

Expand All @@ -191,6 +194,7 @@ open class DiscussionSettingsViewController: UITableViewController {
return
}

trackSettingsChange(fieldName: "receive_pingbacks", value: enabled as Any)
settings.pingbackInboundEnabled = enabled
}

Expand All @@ -199,6 +203,7 @@ open class DiscussionSettingsViewController: UITableViewController {
return
}

trackSettingsChange(fieldName: "send_pingbacks", value: enabled as Any)
settings.pingbackOutboundEnabled = enabled
}

Expand All @@ -207,6 +212,7 @@ open class DiscussionSettingsViewController: UITableViewController {
return
}

trackSettingsChange(fieldName: "require_name_and_email", value: enabled as Any)
settings.commentsRequireNameAndEmail = enabled
}

Expand All @@ -215,6 +221,7 @@ open class DiscussionSettingsViewController: UITableViewController {
return
}

trackSettingsChange(fieldName: "require_registration", value: enabled as Any)
settings.commentsRequireRegistration = enabled
}

Expand All @@ -234,6 +241,9 @@ open class DiscussionSettingsViewController: UITableViewController {
pickerViewController.onChange = { [weak self] (enabled: Bool, newValue: Int) in
self?.settings.commentsCloseAutomatically = enabled
self?.settings.commentsCloseAutomaticallyAfterDays = newValue as NSNumber

let value: Any = enabled ? newValue : "disabled"
self?.trackSettingsChange(fieldName: "close_commenting", value: value)
}

navigationController?.pushViewController(pickerViewController, animated: true)
Expand All @@ -250,6 +260,7 @@ open class DiscussionSettingsViewController: UITableViewController {
return
}

self?.trackSettingsChange(fieldName: "comments_sort_by", value: selected as Any)
self?.settings.commentsSorting = newSortOrder
}

Expand All @@ -268,6 +279,7 @@ open class DiscussionSettingsViewController: UITableViewController {
}

self?.settings.commentsThreading = newThreadingDepth
self?.trackSettingsChange(fieldName: "comments_threading", value: selected as Any)
}

navigationController?.pushViewController(settingsViewController, animated: true)
Expand All @@ -287,6 +299,9 @@ open class DiscussionSettingsViewController: UITableViewController {
pickerViewController.onChange = { [weak self] (enabled: Bool, newValue: Int) in
self?.settings.commentsPagingEnabled = enabled
self?.settings.commentsPageSize = newValue as NSNumber

let value: Any = enabled ? newValue : "disabled"
self?.trackSettingsChange(fieldName: "comments_paging", value: value)
}

navigationController?.pushViewController(pickerViewController, animated: true)
Expand All @@ -305,6 +320,7 @@ open class DiscussionSettingsViewController: UITableViewController {
}

self?.settings.commentsAutoapproval = newApprovalStatus
self?.trackSettingsChange(fieldName: "comments_automatically_approve", value: selected as Any)
}

navigationController?.pushViewController(settingsViewController, animated: true)
Expand All @@ -321,6 +337,7 @@ open class DiscussionSettingsViewController: UITableViewController {
pickerViewController.pickerSelectedValue = settings.commentsMaximumLinks as? Int
pickerViewController.onChange = { [weak self] (enabled: Bool, newValue: Int) in
self?.settings.commentsMaximumLinks = newValue as NSNumber
self?.trackSettingsChange(fieldName: "comments_links", value: newValue as Any)
}

navigationController?.pushViewController(pickerViewController, animated: true)
Expand All @@ -336,6 +353,7 @@ open class DiscussionSettingsViewController: UITableViewController {
comment: "Text rendered at the bottom of the Discussion Moderation Keys editor")
settingsViewController.onChange = { [weak self] (updated: Set<String>) in
self?.settings.commentsModerationKeys = updated
self?.trackSettingsChange(fieldName: "comments_hold_for_moderation", value: updated.count as Any)
}

navigationController?.pushViewController(settingsViewController, animated: true)
Expand All @@ -351,12 +369,18 @@ open class DiscussionSettingsViewController: UITableViewController {
comment: "Text rendered at the bottom of the Discussion Blocklist Keys editor")
settingsViewController.onChange = { [weak self] (updated: Set<String>) in
self?.settings.commentsBlocklistKeys = updated
self?.trackSettingsChange(fieldName: "comments_block_list", value: updated.count as Any)
}

navigationController?.pushViewController(settingsViewController, animated: true)
}

private func trackSettingsChange(fieldName: String, value: Any?) {
WPAnalytics.trackSettingsChange(tracksDiscussionSettingsKey,
fieldName: fieldName,
value: value)

}

// MARK: - Computed Properties
fileprivate var sections: [Section] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ import WordPressShared
/// If there is already an in progress change (i.e. bad network), don't push the view controller and deselect the selection immediately.
tableView.allowsSelection = false

WPAnalytics.trackSettingsChange("homepage_settings",
fieldName: "homepage_type",
value: (homepageType == .page) ? "page" : "posts")

/// Send the remove service call
let service = HomepageSettingsService(blog: blog, context: blog.managedObjectContext!)
service?.setHomepageType(homepageType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ - (SwitchTableViewCell *)relatedPostsEnabledCell
_relatedPostsEnabledCell.name = NSLocalizedString(@"Show Related Posts", @"Label for configuration switch to enable/disable related posts");
__weak RelatedPostsSettingsViewController *weakSelf = self;
_relatedPostsEnabledCell.onChange = ^(BOOL value){
[WPAnalytics trackSettingsChange:@"related_posts" fieldName:@"show_related_posts" value:@(value)];

[weakSelf updateRelatedPostsSettings:nil];
};
}
Expand All @@ -203,6 +205,7 @@ - (SwitchTableViewCell *)relatedPostsShowHeaderCell
_relatedPostsShowHeaderCell.name = NSLocalizedString(@"Show Header", @"Label for configuration switch to show/hide the header for the related posts section");
__weak RelatedPostsSettingsViewController *weakSelf = self;
_relatedPostsShowHeaderCell.onChange = ^(BOOL value){
[WPAnalytics trackSettingsChange:@"related_posts" fieldName:@"show_related_posts_header" value:@(value)];
[weakSelf updateRelatedPostsSettings:nil];
};
}
Expand All @@ -217,6 +220,8 @@ - (SwitchTableViewCell *)relatedPostsShowThumbnailsCell
_relatedPostsShowThumbnailsCell.name = NSLocalizedString(@"Show Images", @"Label for configuration switch to show/hide images thumbnail for the related posts");
__weak RelatedPostsSettingsViewController *weakSelf = self;
_relatedPostsShowThumbnailsCell.onChange = ^(BOOL value){
[WPAnalytics trackSettingsChange:@"related_posts" fieldName:@"show_related_posts_thumbnail" value:@(value)];

[weakSelf updateRelatedPostsSettings:nil];
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ extension SiteSettingsViewController {
self?.blog.settings?.gmtOffset = newValue.gmtOffset as NSNumber?
self?.blog.settings?.timezoneString = newValue.timezoneString
self?.saveSettings()
self?.trackSettingsChange(fieldName: "timezone",
value: newValue.value as Any)
}
navigationController?.pushViewController(controller, animated: true)
}
Expand All @@ -105,6 +107,7 @@ extension SiteSettingsViewController {
pickerViewController.onChange = { [weak self] (enabled: Bool, newValue: Int) in
self?.blog.settings?.postsPerPage = newValue as NSNumber?
self?.saveSettings()
self?.trackSettingsChange(fieldName: "posts_per_page", value: newValue as Any)
}

navigationController?.pushViewController(pickerViewController, animated: true)
Expand Down Expand Up @@ -355,6 +358,8 @@ extension SiteSettingsViewController {
if value != self.blog.settings?.name {
self.blog.settings?.name = value
self.saveSettings()

self.trackSettingsChange(fieldName: "site_title")
}
}

Expand Down Expand Up @@ -385,6 +390,8 @@ extension SiteSettingsViewController {
if normalizedTagline != self.blog.settings?.tagline {
self.blog.settings?.tagline = normalizedTagline
self.saveSettings()

self.trackSettingsChange(fieldName: "tagline")
}
}

Expand All @@ -403,4 +410,10 @@ extension SiteSettingsViewController {

tableView.deselectRow(at: indexPath, animated: true)
}

func trackSettingsChange(fieldName: String, value: Any? = nil) {
WPAnalytics.trackSettingsChange("site_settings",
fieldName: fieldName,
value: value)
}
}
Loading