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

Enable native editor onboarding features globally #17268

Merged
merged 8 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ abstract_target 'Apps' do
## Gutenberg (React Native)
## =====================
##
gutenberg :tag => 'v1.63.0'
gutenberg :commit => '02decec115e08b0ea60fde774bbc052d38a373ef'

## Third party libraries
## =====================
Expand Down
186 changes: 93 additions & 93 deletions Podfile.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
18.5
-----
* [**] Block editor: Block inserter indicates newly available block types [https://github.com/wordpress-mobile/gutenberg-mobile/pull/4047]


18.4
Expand Down
26 changes: 0 additions & 26 deletions WordPress/Classes/Utility/Editor/GutenbergOnboardingRollout.swift

This file was deleted.

17 changes: 0 additions & 17 deletions WordPress/Classes/Utility/Editor/GutenbergSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ class GutenbergSettings {
static let hasLaunchedGutenbergEditor = "kHasLaunchedGutenbergEditor"
static let blockTypeImpressions = "kBlockTypeImpressions"

// Only generated and saved for non-WPcom logins
static let editorOnboardingAnonID = "kEditorOnboardingAnonID"

private static func urlStringFrom(_ blog: Blog) -> String {
return (blog.url ?? "")
// New sites will add a slash at the end of URL.
Expand Down Expand Up @@ -173,20 +170,6 @@ class GutenbergSettings {
}
}

func canViewEditorOnboarding() -> Bool {
let uniqueRolloutId = getUniqueRolloutId()
let rollout = GutenbergOnboardingRollout()
return rollout.isRolloutIdInPhaseRolloutPercentage(uniqueRolloutId)
}

/// Temporary for the staged Editor Onboarding tooltip project. Generates a unique rollout ID for use in
/// determining if the user is in the percentage group that should see the Editor Onboarding Tooltip.
func getUniqueRolloutId() -> Int {
let anonId = database.object(forKey: Key.editorOnboardingAnonID) as? Int ?? UUID().hashValue
database.set(anonId, forKey: Key.editorOnboardingAnonID)
return anonId
}

/// True if the Gutenberg editor has previously launched from this app installation
var hasLaunchedGutenbergEditor: Bool {
get {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ extension GutenbergViewController {
ActionDispatcher.dispatch(NoticeAction.unlock)
}

if canViewEditorOnboarding() {
alert.addDefaultActionWithTitle(MoreSheetAlert.editorHelpTitle) { [weak self] _ in
self?.showEditorHelp()
ActionDispatcher.dispatch(NoticeAction.unlock)
}
alert.addDefaultActionWithTitle(MoreSheetAlert.editorHelpTitle) { [weak self] _ in
self?.showEditorHelp()
ActionDispatcher.dispatch(NoticeAction.unlock)
}

if #available(iOS 14.0, *),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
// It assumes this is being called when the editor has finished loading
// If you need to refactor this, please ensure that the startup_time_ms property
// is still reflecting the actual startup time of the editor
editorSession.start(unsupportedBlocks: unsupportedBlockNames, canViewEditorOnboarding: canViewEditorOnboarding(), galleryWithImageBlocks: galleryWithImageBlocks)
editorSession.start(unsupportedBlocks: unsupportedBlockNames, galleryWithImageBlocks: galleryWithImageBlocks)
}
}

Expand Down Expand Up @@ -1151,15 +1151,10 @@ extension GutenbergViewController: GutenbergBridgeDataSource {
// Only enable reusable block in WP.com sites until the issue
// (https://github.com/wordpress-mobile/gutenberg-mobile/issues/3457) in self-hosted sites is fixed
.reusableBlock: isWPComSite,
.editorOnboarding: canViewEditorOnboarding(),
.firstGutenbergEditorSession: !gutenbergSettings.hasLaunchedGutenbergEditor
]
}

func canViewEditorOnboarding() -> Bool {
gutenbergSettings.canViewEditorOnboarding()
}

private var isUnsupportedBlockEditorEnabled: Bool {
// The Unsupported Block Editor is disabled for all self-hosted non-jetpack sites.
// This is because they can have their web editor to be set to classic and then the fallback will not work.
Expand Down
14 changes: 4 additions & 10 deletions WordPress/Classes/ViewRelated/Post/PostEditor+Publish.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,12 @@ protocol PublishingEditor where Self: UIViewController {
var debouncer: Debouncer { get }

var prepublishingIdentifiers: [PrepublishingIdentifier] { get }

func canViewEditorOnboarding() -> Bool
}

var postPublishedReceipt: Receipt?

extension PublishingEditor {

func canViewEditorOnboarding() -> Bool {
return false
}

func publishingDismissed() {

}
Expand Down Expand Up @@ -170,7 +164,7 @@ extension PublishingEditor {
}

if dismissWhenDone {
self.editorSession.end(outcome: action.analyticsEndOutcome, canViewEditorOnboarding: self.canViewEditorOnboarding())
self.editorSession.end(outcome: action.analyticsEndOutcome)
} else {
self.editorSession.forceOutcome(action.analyticsEndOutcome)
}
Expand Down Expand Up @@ -316,7 +310,7 @@ extension PublishingEditor {
/// had been already confirmed by the user. In this case, we just close the editor.
/// Otherwise, we'll show an Action Sheet with options.
if post.shouldAttemptAutoUpload && post.canSave() {
editorSession.end(outcome: .cancel, canViewEditorOnboarding: canViewEditorOnboarding())
editorSession.end(outcome: .cancel)
/// If there are ongoing media uploads, save with completion processing
if MediaCoordinator.shared.isUploadingMedia(for: post) {
resumeSaving()
Expand All @@ -326,7 +320,7 @@ extension PublishingEditor {
} else if post.canSave() {
showPostHasChangesAlert()
} else {
editorSession.end(outcome: .cancel, canViewEditorOnboarding: canViewEditorOnboarding())
editorSession.end(outcome: .cancel)
discardUnsavedChangesAndUpdateGUI()
}
}
Expand Down Expand Up @@ -431,7 +425,7 @@ extension PublishingEditor {

// Button: Discard
alertController.addDestructiveActionWithTitle(discardTitle) { _ in
self.editorSession.end(outcome: .discard, canViewEditorOnboarding: self.canViewEditorOnboarding())
self.editorSession.end(outcome: .discard)
self.discardUnsavedChangesAndUpdateGUI()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ struct PostEditorAnalyticsSession {
contentType = ContentType(post: post).rawValue
}

mutating func start(unsupportedBlocks: [String] = [], canViewEditorOnboarding: Bool = false, galleryWithImageBlocks: Bool? = nil) {
mutating func start(unsupportedBlocks: [String] = [], galleryWithImageBlocks: Bool? = nil) {
assert(!started, "An editor session was attempted to start more than once")
hasUnsupportedBlocks = !unsupportedBlocks.isEmpty

let properties = startEventProperties(with: unsupportedBlocks, canViewEditorOnboarding: canViewEditorOnboarding, galleryWithImageBlocks: galleryWithImageBlocks)
let properties = startEventProperties(with: unsupportedBlocks, galleryWithImageBlocks: galleryWithImageBlocks)

WPAppAnalytics.track(.editorSessionStart, withProperties: properties)
started = true
}

private func startEventProperties(with unsupportedBlocks: [String], canViewEditorOnboarding: Bool, galleryWithImageBlocks: Bool?) -> [String: Any] {
private func startEventProperties(with unsupportedBlocks: [String], galleryWithImageBlocks: Bool?) -> [String: Any] {
// On Android, we are tracking this in milliseconds, which seems like a good enough time scale
// Let's make sure to round the value and send an integer for consistency
let startupTimeNanoseconds = DispatchTime.now().uptimeNanoseconds - startTime
Expand All @@ -43,8 +43,6 @@ struct PostEditorAnalyticsSession {
properties[Property.unsupportedBlocks] = blocksJSON
}

properties[Property.canViewEditorOnboarding] = canViewEditorOnboarding

if let galleryWithImageBlocks = galleryWithImageBlocks {
properties[Property.unstableGalleryWithImageBlocks] = "\(galleryWithImageBlocks)"
} else {
Expand Down Expand Up @@ -72,11 +70,9 @@ struct PostEditorAnalyticsSession {
}
}

func end(outcome endOutcome: Outcome, canViewEditorOnboarding: Bool = false) {
func end(outcome endOutcome: Outcome) {
let outcome = self.outcome ?? endOutcome
var properties: [String: Any] = [ Property.outcome: outcome.rawValue ].merging(commonProperties, uniquingKeysWith: { $1 })

properties[Property.canViewEditorOnboarding] = canViewEditorOnboarding
let properties: [String: Any] = [ Property.outcome: outcome.rawValue ].merging(commonProperties, uniquingKeysWith: { $1 })

WPAppAnalytics.track(.editorSessionEnd, withProperties: properties)
}
Expand All @@ -95,7 +91,6 @@ private extension PostEditorAnalyticsSession {
static let sessionId = "session_id"
static let template = "template"
static let startupTime = "startup_time_ms"
static let canViewEditorOnboarding = "can_view_editor_onboarding"
static let unstableGalleryWithImageBlocks = "unstable_gallery_with_image_blocks"
}

Expand Down
6 changes: 0 additions & 6 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,6 @@
2F08ECFC2283A4FB000F8E11 /* PostService+UnattachedMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F08ECFB2283A4FB000F8E11 /* PostService+UnattachedMedia.swift */; };
2F09D134245223D300956257 /* HeaderDetailsContentStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F09D133245223D300956257 /* HeaderDetailsContentStyles.swift */; };
2F161B0622CC2DC70066A5C5 /* LoadingStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F161B0522CC2DC70066A5C5 /* LoadingStatusView.swift */; };
2F54D0A52633424E0045F409 /* GutenbergOnboardingRollout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F54D0A42633424E0045F409 /* GutenbergOnboardingRollout.swift */; };
2F54D0A62633424E0045F409 /* GutenbergOnboardingRollout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F54D0A42633424E0045F409 /* GutenbergOnboardingRollout.swift */; };
2F605FA8251430C200F99544 /* PostCategoriesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F605FA7251430C200F99544 /* PostCategoriesViewController.swift */; };
2F605FAA25145F7200F99544 /* WPCategoryTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F605FA925145F7200F99544 /* WPCategoryTree.swift */; };
2F668B61255DD11400D0038A /* JetpackSpeedUpSiteSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F668B5E255DD11400D0038A /* JetpackSpeedUpSiteSettingsViewController.swift */; };
Expand Down Expand Up @@ -4979,7 +4977,6 @@
2F08ECFB2283A4FB000F8E11 /* PostService+UnattachedMedia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PostService+UnattachedMedia.swift"; sourceTree = "<group>"; };
2F09D133245223D300956257 /* HeaderDetailsContentStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderDetailsContentStyles.swift; sourceTree = "<group>"; };
2F161B0522CC2DC70066A5C5 /* LoadingStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingStatusView.swift; sourceTree = "<group>"; };
2F54D0A42633424E0045F409 /* GutenbergOnboardingRollout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GutenbergOnboardingRollout.swift; sourceTree = "<group>"; };
2F605FA7251430C200F99544 /* PostCategoriesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCategoriesViewController.swift; sourceTree = "<group>"; };
2F605FA925145F7200F99544 /* WPCategoryTree.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WPCategoryTree.swift; sourceTree = "<group>"; };
2F668B5E255DD11400D0038A /* JetpackSpeedUpSiteSettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JetpackSpeedUpSiteSettingsViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -14093,7 +14090,6 @@
F115308021B17E65002F1D65 /* EditorFactory.swift */,
FF54D4631D6F3FA900A0DC4D /* GutenbergSettings.swift */,
1E9D544C23C4C56300F6A9E0 /* GutenbergRollout.swift */,
2F54D0A42633424E0045F409 /* GutenbergOnboardingRollout.swift */,
);
path = Editor;
sourceTree = "<group>";
Expand Down Expand Up @@ -17920,7 +17916,6 @@
B5DBE4FE1D21A700002E81D3 /* NotificationsViewController.swift in Sources */,
E1B84F001E02E94D00BF6434 /* PingHubManager.swift in Sources */,
086103961EE09C91004D7C01 /* MediaVideoExporter.swift in Sources */,
2F54D0A52633424E0045F409 /* GutenbergOnboardingRollout.swift in Sources */,
E126C81F1F95FC1B00A5F464 /* PluginViewController.swift in Sources */,
E61084C11B9B47BA008050C5 /* ReaderSiteTopic.swift in Sources */,
FAB8004925AEDC2300D5D54A /* JetpackBackupCompleteViewController.swift in Sources */,
Expand Down Expand Up @@ -19728,7 +19723,6 @@
FABB23172602FC2C00C8785C /* ShadowView.swift in Sources */,
FABB23182602FC2C00C8785C /* Wizard.swift in Sources */,
FABB23192602FC2C00C8785C /* Media+WPMediaAsset.m in Sources */,
2F54D0A62633424E0045F409 /* GutenbergOnboardingRollout.swift in Sources */,
FABB231A2602FC2C00C8785C /* GutenbergImgUploadProcessor.swift in Sources */,
FABB231B2602FC2C00C8785C /* PluginListViewModel.swift in Sources */,
FABB231C2602FC2C00C8785C /* WPStyleGuide+People.swift in Sources */,
Expand Down