From fc2b8db8cfaa85357a303ff1db1143e973ff5c4b Mon Sep 17 00:00:00 2001 From: Mihaela Ogrezeanu Date: Tue, 10 Sep 2019 06:54:37 -0700 Subject: [PATCH] Show full event name in sidebar Summary: Show info about the event which triggered a new changeset generation; in case of a state update, also show the name of the method which triggered the state update. Reviewed By: pasqualeanatriello Differential Revision: D17162202 fbshipit-source-id: ebf218f8ce71799e4dd452f54b1621af7f83cc51 --- .../plugins/sections/ChangesetDebug.java | 10 +++++++-- .../sections/SectionsFlipperPlugin.java | 22 ++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/android/src/main/java/com/facebook/flipper/plugins/sections/ChangesetDebug.java b/android/src/main/java/com/facebook/flipper/plugins/sections/ChangesetDebug.java index 4bdb18f01..ae84e3de8 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/sections/ChangesetDebug.java +++ b/android/src/main/java/com/facebook/flipper/plugins/sections/ChangesetDebug.java @@ -32,7 +32,9 @@ public class ChangesetDebug implements ChangesetDebugListener { public interface ChangesetListener { void onChangesetApplied( - String name, + String eventName, + String eventSource, + String updateStateMethodName, boolean isAsync, String surfaceId, String id, @@ -90,8 +92,12 @@ public class ChangesetDebug implements ChangesetDebugListener { eventSourceSection = updatedStateSection == null ? "" : updatedStateSection.getSimpleName(); } + final String stateUpdateMethodName = stateUpdateAttribution == null ? null : attribution; + sSectionsFlipperPlugin.onChangesetApplied( - eventSourceName + " " + eventSourceSection, + eventSourceName, + eventSourceSection, + stateUpdateMethodName, isEventAsync(eventSource), surfaceId, sChangesetIdGenerator.incrementAndGet() + "-" + surfaceId, diff --git a/android/src/main/java/com/facebook/flipper/plugins/sections/SectionsFlipperPlugin.java b/android/src/main/java/com/facebook/flipper/plugins/sections/SectionsFlipperPlugin.java index ebff3082e..c38d59aaf 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/sections/SectionsFlipperPlugin.java +++ b/android/src/main/java/com/facebook/flipper/plugins/sections/SectionsFlipperPlugin.java @@ -45,7 +45,7 @@ public class SectionsFlipperPlugin implements FlipperPlugin, ChangesetListener { } /** - * @param name Name of event + * @param eventName Name of event * @param isAsync Whether the event was sync or async * @param surfaceId SectionTree tag * @param id Changeset generation unique id @@ -54,7 +54,9 @@ public class SectionsFlipperPlugin implements FlipperPlugin, ChangesetListener { */ @Override public void onChangesetApplied( - String name, + String eventName, + String eventSource, + String updateStateMethodName, boolean isAsync, String surfaceId, String id, @@ -63,16 +65,26 @@ public class SectionsFlipperPlugin implements FlipperPlugin, ChangesetListener { if (mConnection == null) { return; } + + final String reason = eventName + " " + eventSource; + final FlipperObject.Builder eventPayloadBuilder = new FlipperObject.Builder(); + eventPayloadBuilder.put("Event", eventName); + eventPayloadBuilder.put("Async", isAsync); + eventPayloadBuilder.put("Section", eventSource); + if (updateStateMethodName != null) { + eventPayloadBuilder.put("Update state method", updateStateMethodName); + } + mConnection.send( "addEvent", new FlipperObject.Builder() .put("id", id) .put("update_mode", isAsync ? 0 : 1) - .put("reason", name) + .put("reason", reason) .put("surface_key", surfaceId) .put("tree_generation_timestamp", 10000) // TODO .put("stack_trace", new FlipperArray.Builder().build()) - .put("payload", new FlipperObject.Builder().build()) + .put("payload", eventPayloadBuilder.build()) .build()); mConnection.send( @@ -82,7 +94,7 @@ public class SectionsFlipperPlugin implements FlipperPlugin, ChangesetListener { .put("hierarchy_generation_timestamp", 10000) // TODO .put("hierarchy_generation_duration", 0) // TODO .put("tree", tree) - .put("reason", name) + .put("reason", eventName) .build()); // Not sure both CHANGESET_GENERATED and CHANGESET_APPLIED need to sent here, need