diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index a59d9881ecce..eead47256b5e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -2669,6 +2669,10 @@ private void onEditorFinalTouchesBeforeShowing() { @Override public void onEditorFragmentContentReady(ArrayList unsupportedBlocksList) { + // 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 mPostEditorAnalyticsSession.start(unsupportedBlocksList); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostEditorAnalyticsSession.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostEditorAnalyticsSession.java index 8c1d7b8d3b59..7874be72f9ea 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostEditorAnalyticsSession.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostEditorAnalyticsSession.java @@ -26,6 +26,7 @@ public class PostEditorAnalyticsSession implements Serializable { private static final String KEY_POST_TYPE = "post_type"; private static final String KEY_OUTCOME = "outcome"; private static final String KEY_SESSION_ID = "session_id"; + private static final String KEY_STARTUP_TIME = "startup_time_ms"; private static final String KEY_TEMPLATE = "template"; private String mSessionId = UUID.randomUUID().toString(); @@ -38,6 +39,7 @@ public class PostEditorAnalyticsSession implements Serializable { private Outcome mOutcome = null; private String mTemplate; private boolean mHWAccOff = false; + private long mStartTime = System.currentTimeMillis(); enum Editor { GUTENBERG, @@ -92,6 +94,14 @@ public void start(ArrayList unsupportedBlocksList) { Map properties = getCommonProperties(); properties.put(KEY_UNSUPPORTED_BLOCKS, unsupportedBlocksList != null ? unsupportedBlocksList : new ArrayList<>()); + // Note that start time only counts when the analytics session was created and not when the editor + // activity started. We are mostly interested in measuring the loading times for the block editor, + // where the main bottleneck seems to be initializing React Native and doing the initial load of Gutenberg. + // + // Measuring the full editor activity initialization would be more accurate, but we don't expect the + // difference to be significant enough, and doing that would add more complexity to how we are initializing + // the session. + properties.put(KEY_STARTUP_TIME, System.currentTimeMillis() - mStartTime); AnalyticsTracker.track(Stat.EDITOR_SESSION_START, properties); mStarted = true; } else {