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

Add editor session startup time #11411

Merged
merged 3 commits into from
Mar 11, 2020
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 @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// 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();
maxme marked this conversation as resolved.
Show resolved Hide resolved

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