Skip to content

Commit

Permalink
Merge pull request #11411 from wordpress-mobile/add/editor_session_st…
Browse files Browse the repository at this point in the history
…artup_time

Add editor session startup time
  • Loading branch information
koke authored Mar 11, 2020
2 parents 725bbab + 4baf264 commit 2f1c87b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2669,6 +2669,10 @@ private void onEditorFinalTouchesBeforeShowing() {

@Override
public void onEditorFragmentContentReady(ArrayList<Object> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,
Expand Down Expand Up @@ -92,6 +94,14 @@ public void start(ArrayList<Object> unsupportedBlocksList) {
Map<String, Object> 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 {
Expand Down

0 comments on commit 2f1c87b

Please sign in to comment.