From d0a77376a954e434c1d88802e80e952891a48d94 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Mon, 9 Mar 2020 16:14:14 +0100 Subject: [PATCH 1/3] Include editor startup time in EDITOR_SESSION_START --- .../wordpress/android/ui/posts/PostEditorAnalyticsSession.java | 3 +++ 1 file changed, 3 insertions(+) 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..573787933d20 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,7 @@ public void start(ArrayList unsupportedBlocksList) { Map properties = getCommonProperties(); properties.put(KEY_UNSUPPORTED_BLOCKS, unsupportedBlocksList != null ? unsupportedBlocksList : new ArrayList<>()); + properties.put(KEY_STARTUP_TIME, System.currentTimeMillis() - mStartTime); AnalyticsTracker.track(Stat.EDITOR_SESSION_START, properties); mStarted = true; } else { From 68c042b8daceeac18503d7918add170ed4e3e450 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Mon, 9 Mar 2020 16:41:38 +0100 Subject: [PATCH 2/3] Add explanation about assumptions for start method --- .../java/org/wordpress/android/ui/posts/EditPostActivity.java | 4 ++++ 1 file changed, 4 insertions(+) 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); } From 4baf2644554e248d92979957c92023699313d958 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Wed, 11 Mar 2020 15:06:03 +0100 Subject: [PATCH 3/3] Adds clarification on design choices for start time measurement --- .../android/ui/posts/PostEditorAnalyticsSession.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 573787933d20..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 @@ -94,6 +94,13 @@ 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;