Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -894,11 +894,13 @@ extension GutenbergViewController: GutenbergBridgeDelegate {

func gutenbergDidMount(unsupportedBlockNames: [String]) {
if !editorSession.started {
let galleryWithImageBlocks = gutenbergEditorSettings()?.galleryWithImageBlocks

// Note that this method is also used to track startup performance
// 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())
editorSession.start(unsupportedBlocks: unsupportedBlockNames, canViewEditorOnboarding: canViewEditorOnboarding(), galleryWithImageBlocks: galleryWithImageBlocks)
}
}

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

mutating func start(unsupportedBlocks: [String] = [], canViewEditorOnboarding: Bool = false) {
mutating func start(unsupportedBlocks: [String] = [], canViewEditorOnboarding: Bool = false, 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)
let properties = startEventProperties(with: unsupportedBlocks, canViewEditorOnboarding: canViewEditorOnboarding, galleryWithImageBlocks: galleryWithImageBlocks)

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

private func startEventProperties(with unsupportedBlocks: [String], canViewEditorOnboarding: Bool) -> [String: Any] {
private func startEventProperties(with unsupportedBlocks: [String], canViewEditorOnboarding: Bool, 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,6 +43,12 @@ struct PostEditorAnalyticsSession {

properties[Property.canViewEditorOnboarding] = canViewEditorOnboarding

if let galleryWithImageBlocks = galleryWithImageBlocks {
properties[Property.unstableGalleryWithImageBlocks] = "\(galleryWithImageBlocks)"
} else {
properties[Property.unstableGalleryWithImageBlocks] = "unknown"
}

return properties.merging(commonProperties, uniquingKeysWith: { $1 })
}

Expand Down Expand Up @@ -87,6 +93,7 @@ private extension PostEditorAnalyticsSession {
static let template = "template"
static let startupTime = "startup_time_ms"
static let canViewEditorOnboarding = "can_view_editor_onboarding"
static let unstableGalleryWithImageBlocks = "unstableGalleryWithImageBlocks"
}

var commonProperties: [String: String] {
Expand Down