Skip to content

Commit

Permalink
Merge pull request wordpress-mobile#21107 from wordpress-mobile/merge…
Browse files Browse the repository at this point in the history
…/22.8.0.1-to-trunk

Merge 22.8.0.1 and editorialized release notes to trunk
  • Loading branch information
oguzkocer authored Jul 14, 2023
2 parents f982845 + 65cc4ef commit e42868b
Show file tree
Hide file tree
Showing 39 changed files with 1,314 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ final class BlogDashboardViewController: UIViewController {
BlogDashboardViewModel(viewController: self, blog: blog)
}()

private var complianceCoordinator: CompliancePopoverCoordinator?

lazy var collectionView: DynamicHeightCollectionView = {
let collectionView = DynamicHeightCollectionView(frame: .zero, collectionViewLayout: createLayout())
Expand Down Expand Up @@ -81,9 +80,6 @@ final class BlogDashboardViewController: UIViewController {
startAlertTimer()

WPAnalytics.track(.mySiteDashboardShown)

complianceCoordinator = CompliancePopoverCoordinator(viewController: self)
complianceCoordinator?.presentIfNeeded()
}

override func viewWillDisappear(_ animated: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class MySiteViewController: UIViewController, NoResultsViewHost {
var willDisplayPostSignupFlow: Bool = false

private var createButtonCoordinator: CreateButtonCoordinator?
private var complianceCoordinator: CompliancePopoverCoordinator?

private let meScenePresenter: ScenePresenter
private let blogService: BlogService
Expand Down Expand Up @@ -208,6 +209,9 @@ class MySiteViewController: UIViewController, NoResultsViewHost {

createFABIfNeeded()
fetchPrompt(for: blog)

complianceCoordinator = CompliancePopoverCoordinator(viewController: self)
complianceCoordinator?.presentIfNeeded()
}

override func viewDidLayoutSubviews() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class CompliancePopoverCoordinator: CompliancePopoverCoordinatorProtocol {
}

func presentIfNeeded() {
guard FeatureFlag.compliancePopover.enabled else {
guard FeatureFlag.compliancePopover.enabled, !defaults.didShowCompliancePopup else {
return
}
complianceService.getIPCountryCode { [weak self] result in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import WordPressUI

final class CompliancePopoverViewController: UIViewController {

// MARK: - Dependencies

private let viewModel: CompliancePopoverViewModel

// MARK: - Views
private let hostingController: UIHostingController<CompliancePopover>

private var contentView: UIView {
return hostingController.view
}

private let viewModel: CompliancePopoverViewModel
private var bannerIntrinsicHeight: CGFloat = 0

init(viewModel: CompliancePopoverViewModel) {
Expand All @@ -35,6 +38,7 @@ final class CompliancePopoverViewController: UIViewController {
hostingController.rootView.saveAction = {
self.viewModel.didTapSave()
}
viewModel.didDisplayPopover()
}

override func viewDidLayoutSubviews() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,39 @@ import Foundation
import UIKit
import WordPressUI

final class CompliancePopoverViewModel: ObservableObject {
class CompliancePopoverViewModel: ObservableObject {

@Published
var isAnalyticsEnabled: Bool = !WPAppAnalytics.userHasOptedOut()

// MARK: - Dependencies

var coordinator: CompliancePopoverCoordinatorProtocol?

private let analyticsTracker: PrivacySettingsAnalyticsTracking
private let defaults: UserDefaults
private let contextManager: ContextManager

init(defaults: UserDefaults, contextManager: ContextManager) {
// MARK: - Init

init(defaults: UserDefaults,
contextManager: ContextManager,
analyticsTracker: PrivacySettingsAnalyticsTracking = PrivacySettingsAnalyticsTracker()) {
self.defaults = defaults
self.analyticsTracker = analyticsTracker
self.contextManager = contextManager
}

// MARK: - API

func didDisplayPopover() {
analyticsTracker.track(.privacyChoicesBannerPresented)
}

func didTapSettings() {
coordinator?.navigateToSettings()
defaults.didShowCompliancePopup = true
analyticsTracker.track(.privacyChoicesBannerSettingsButtonTapped)
}

func didTapSave() {
Expand All @@ -37,5 +54,6 @@ final class CompliancePopoverViewModel: ObservableObject {
AccountSettingsService(userID: accountID.intValue, api: restAPI).saveChange(change)
coordinator?.dismiss()
defaults.didShowCompliancePopup = true
analyticsTracker.trackPrivacyChoicesBannerSaveButtonTapped(analyticsEnabled: isAnalyticsEnabled)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ enum PrivacySettingsAnalytics: String {
// Privacy Settings
case privacySettingsOpened = "privacy_settings_opened"
case privacySettingsReportCrashesToggled = "privacy_settings_report_crashes_toggled"
case privacySettingsAnalyticsTrackingToggled = "privacy_settings_analytics_tracking_toggled"

// Privacy Choices Banner
case privacyChoicesBannerPresented = "privacy_choices_banner_presented"
case prviacyChoicesBannerSettingsButtonTapped = "privacy_choices_banner_settings_button_tapped"
case privacyChoicesBannerSettingsButtonTapped = "privacy_choices_banner_settings_button_tapped"
case privacyChoicesBannerSaveButtonTapped = "privacy_choices_banner_save_button_tapped"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,47 @@ import WordPressShared

protocol PrivacySettingsAnalyticsTracking {

func trackPrivacySettingsAnalyticsTrackingToggled(enabled: Bool)

func trackPrivacySettingsReportCrashesToggled(enabled: Bool)

func trackPrivacyChoicesBannerSaveButtonTapped(analyticsEnabled: Bool)
}

final class PrivacySettingsAnalyticsTracker: PrivacySettingsAnalyticsTracking {
func track(_ event: PrivacySettingsAnalytics, properties: [String: String])
}

private let tracker: AnalyticsEventTracking.Type
extension PrivacySettingsAnalyticsTracking {

init(tracker: AnalyticsEventTracking.Type = WPAnalytics.self) {
self.tracker = tracker
func trackPrivacySettingsAnalyticsTrackingToggled(enabled: Bool) {
let props = ["enabled": enabled.stringLiteral]
self.track(.privacySettingsAnalyticsTrackingToggled, properties: props)
}

// MARK: - API

func trackPrivacySettingsReportCrashesToggled(enabled: Bool) {
let props = ["enabled": enabled.stringLiteral]
self.track(.privacyChoicesBannerSaveButtonTapped, properties: props)
self.track(.privacySettingsReportCrashesToggled, properties: props)
}

func trackPrivacyChoicesBannerSaveButtonTapped(analyticsEnabled: Bool) {
let props = ["analytics_enabled": analyticsEnabled.stringLiteral]
self.track(.privacyChoicesBannerSaveButtonTapped, properties: props)
}

func track(_ event: PrivacySettingsAnalytics, properties: Properties = [:]) {
let event = AnalyticsEvent(name: event.rawValue, properties: properties)
tracker.track(event)
func track(_ event: PrivacySettingsAnalytics) {
self.track(event, properties: [:])
}
}

final class PrivacySettingsAnalyticsTracker: PrivacySettingsAnalyticsTracking {

// MARK: - Types
private let tracker: AnalyticsEventTracking.Type

typealias Properties = [String: String]
init(tracker: AnalyticsEventTracking.Type = WPAnalytics.self) {
self.tracker = tracker
}

func track(_ event: PrivacySettingsAnalytics, properties: [String: String]) {
let event = AnalyticsEvent(name: event.rawValue, properties: properties)
tracker.track(event)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,42 @@ class PrivacySettingsViewController: UITableViewController {
])
}

func usageTrackingChanged(_ enabled: Bool) {
/// A method that reacts to changes in the user's analytics tracking preference.
///
/// This method is invoked when a user enables or disables analytics tracking in their privacy settings. Its purpose is to update the user's preference locally and remotely, and to track the event if possible.
///
/// - If the user is enabling tracking, this method first turns tracking on, then sends an event to the analytics tracker. This ensures that the event of enabling tracking is tracked.
/// - If the user is disabling tracking, the event is sent to the analytics tracker before tracking is turned off. This ensures that the event of disabling tracking is tracked before tracking is fully turned off.
///
/// - Parameters:
/// - enabled: A boolean that indicates the user's preference. If `true`, analytics tracking is enabled. If `false`, analytics tracking is disabled.
///
private func usageTrackingChanged(_ enabled: Bool) {
analyticsTracker.trackPrivacySettingsAnalyticsTrackingToggled(enabled: enabled)
updateUserHasOptedOut(enabled)
analyticsTracker.trackPrivacySettingsAnalyticsTrackingToggled(enabled: enabled)
persistTrackingUpdateRemotely(enabled)
}

private func updateUserHasOptedOut(_ enabled: Bool) {
let appAnalytics = WordPressAppDelegate.shared?.analytics
appAnalytics?.setUserHasOptedOut(!enabled)
}

let context = ContextManager.shared.mainContext
guard let account = try? WPAccount.lookupDefaultWordPressComAccount(in: context) else {
return
private func persistTrackingUpdateRemotely(_ enabled: Bool) {
let result = ContextManager.shared.performQuery { context -> (NSNumber, WordPressComRestApi)? in
guard let account = try? WPAccount.lookupDefaultWordPressComAccount(in: context),
let wordPressComRestApi = account.wordPressComRestApi
else {
return nil
}
return (account.userID, wordPressComRestApi)
}

let change = AccountSettingsChange.tracksOptOut(!enabled)
AccountSettingsService(userID: account.userID.intValue, api: account.wordPressComRestApi).saveChange(change)
if let (accountID, wordPressComRestApi) = result {
let change = AccountSettingsChange.tracksOptOut(!enabled)
AccountSettingsService(userID: accountID.intValue, api: wordPressComRestApi).saveChange(change)
}
}

func openCookiePolicy() -> ImmuTableAction {
Expand Down
9 changes: 3 additions & 6 deletions WordPress/Jetpack/Resources/AppStoreStrings.po
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,11 @@ msgctxt "app_store_keywords"
msgid "social,notes,jetpack,writing,geotagging,media,blog,website,blogging,journal"
msgstr ""

msgctxt "v22.7-whats-new"
msgctxt "v22.8-whats-new"
msgid ""
"We fixed an issue with the home screen’s “Work on a draft post” card. The app will no longer crash when you access drafts while they’re in the middle of uploading.\n"
"We disabled blogging reminders for self-hosted sites that aren’t connected to Jetpack, since this feature is only available in the Jetpack app.\n"
"\n"
"We also solved a couple of problems in the block editor.\n"
"\n"
"- Right on—image blocks now display the correct aspect ratio, whether or not the image has a set width and height.\n"
"- When you’re dictating text, the cursor’s position will stay where it’s supposed to—no more jumping around. Keep calm and dictate on.\n"
"Reusable blocks are now known as synced patterns, the same as in the desktop editor.\n"
msgstr ""

#. translators: This is a promo message that will be attached on top of the first screenshot in the App Store.
Expand Down
9 changes: 2 additions & 7 deletions WordPress/Jetpack/Resources/release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
* [*] Blogging Reminders: Disabled prompt for self-hosted sites not connected to Jetpack. [#20970]
* [**] [internal] Do not save synced blogs if the app has signed out. [#20959]
* [**] [internal] Make sure synced posts are saved before calling completion block. [#20960]
* [**] [internal] Fix observing Quick Start notifications. [#20997]
* [**] [internal] Fixed an issue that was causing a memory leak in the domain selection flow. [#20813]
* [*] [Jetpack-only] Block editor: Rename "Reusable blocks" to "Synced patterns", aligning with the web editor. [https://github.com/wordpress-mobile/gutenberg-mobile/pull/5885]
* [**] [internal] Block editor: Fix a crash related to Reanimated when closing the editor [https://github.com/wordpress-mobile/gutenberg-mobile/pull/5938]
We disabled blogging reminders for self-hosted sites that aren’t connected to Jetpack, since this feature is only available in the Jetpack app.

Reusable blocks are now known as synced patterns, the same as in the desktop editor.
9 changes: 2 additions & 7 deletions WordPress/Resources/AppStoreStrings.po
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@ msgctxt "app_store_keywords"
msgid "blogger,writing,blogging,web,maker,online,store,business,make,create,write,blogs"
msgstr ""

msgctxt "v22.7-whats-new"
msgctxt "v22.8-whats-new"
msgid ""
"We fixed an issue with the home screen’s “Work on a draft post” card. The app will no longer crash when you access drafts while they’re in the middle of uploading.\n"
"\n"
"We also solved a couple of problems in the block editor.\n"
"\n"
"- Right on—image blocks now display the correct aspect ratio, whether or not the image has a set width and height.\n"
"- When you’re dictating text, the cursor’s position will stay where it’s supposed to—no more jumping around. Keep calm and dictate on.\n"
"We disabled blogging reminders for self-hosted sites that aren’t connected to Jetpack, since this feature is only available in the Jetpack app. Short and sweet.\n"
msgstr ""

#. translators: This is a standard chunk of text used to tell a user what's new with a release when nothing major has changed.
Expand Down
Loading

0 comments on commit e42868b

Please sign in to comment.