-
Notifications
You must be signed in to change notification settings - Fork 58
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
Track block movement actions #4833
Conversation
a6a67e3
to
9de6a6c
Compare
Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing job @geriux 🏅 !
I confirm that the editor is sending editor_block_moved
events for both actions of tapping on up/down arrows and drag & drop 🎊 .
However, I noticed that moving a block by long-pressing over the up/down arrows and tapping on "Move to Top" or "Move to bottom" is not generating an event. Not sure if these options are heavily used by users, but it might lead to receiving fewer moving block events. Probably not a critical issue but before approving the PR I'd like to double-check this with you @geriux.
/** | ||
* Helper function to track block movement events. | ||
* | ||
* @param {string} action Type of movement (arrows/drag & drop) | ||
* @return {void} | ||
*/ | ||
function trackBlockMoved( action ) { | ||
const eventProperties = { | ||
action_source: action, | ||
}; | ||
|
||
sendEventToHost( 'editor_block_moved', eventProperties ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be interesting to collect more information like the type of block being moved or if it has inner blocks, similar to what we do in the above trackBlocksHandler
function. For the purpose of measuring the drag & drop blocks feature this information is enough, so we could apply this suggestion in the future and create a follow-up issue for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice suggestion, I ended up adding it here c213399#diff-b264ddd07fecd2f9655557832fb8f89baa62f7f89c387e80df664c26ceb36084R98-R99
Nice catch! I think we should track those as well, should we include them in the action |
Good question, I'd lean towards the option that collects more information (i.e. tracking them separately). However, this makes me think if we should track the up and down movements separately too, wdyt? Potential sources of block movement action:
|
I agree! I'll update them. Thank you! |
Hey @fluiddot 👋 this is ready for another review 😃, the Android build is ready. The iOS build is still in progress. |
Unfortunately, there are some issues with the CI job that creates an installable build, since it might take a while, would you be able to test it using a local build? |
Sure thing, I'll test it locally 👍. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the latest changes and look great to me, however, I noticed that the drag_and_drop
event is being only sent in some cases when dragging and dropping the block in its original location (see attached video capture). Upon further investigation, I see that depending on if the block is dropped before and after, it sends the event:
- Dropped before - Doesn't send the event.
- Dropped after - Sends the event.
ios-drag-and-drop-track-events.mp4
Thanks for spotting the issue, when dragging the block right above and staying in the same position doesn't call I feel it'd be an issue if we want to know if drag & drop was enabled in all cases, regardless if a block was actually moved. With the current approach, it will only be tracked if the block was actually moved. I think in this case, a "bug" would make sense but let me know if we should still track it anyways 😄 |
Ok, I see, so in this case, the block is actually being moved but to the same origin position.
Right, probably the issue here is more related to the fact that the block is being moved than actually sending the event. Hence, the event logic is behaving as expected. Regarding the issue related to preventing the block to be moved if the target location is the same as the origin, I think we could open a new issue as a follow-up. |
Well, currently it is intended to not move a block if it's in the same position, as you can see here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎊 ! Awesome work @geriux 🙇 !
NOTE: Following this note from the PR's description, before merging we should revert the Gutenberg reference update and JS bundle.
The bundle and Gutenberg reference changes are included to be able to test the drag & drop event, those will not be included once this is approved and ready to be merged.
64337fa
to
1d6316a
Compare
Fixes #4831
WordPress iOS PR
-> [Gutenberg] Analytics - Add editor block moved event WordPress-iOS#18530WordPress Android PR
-> [Gutenberg] Analytics - Add editor block moved event WordPress-Android#16485Note: The bundle and Gutenberg reference changes are included to be able to test the drag & drop event, those will not be included once this is approved and ready to be merged.
This PR adds a new event
editor_block_moved
that is triggered when a block is moved by either:The event has the following properties:
action_source
which can be:move_arrows_up
when a block is moved using the up arrow button.move_arrows_down
when a block is moved using the down arrow button.move_arrows_to_top
when a block is moved to the top by long-pressing on the up arrow button.move_arrows_to_bottom
when a block is moved to the bottom by long-pressing on the down arrow button.drag_and_drop
when a block is moved using the drag & drop blocks feature.block_name
name of the block that is being moved.inner_block
if it has inner blocks or not.Once this is merged, it will only track when a block is moved using the up/down arrow buttons, since the drag & drop blocks feature is not merged yet.
To test
Builds:
Move a block by tapping on the up/down arrow buttons
wp(ios|android)_editor_block_moved
to arrive successfully with the propertiesaction_source
containing:move_arrows_(up|down)
,inner_block
and,block_name
.Move a block by long-pressing on the up/down arrow buttons
Move to the top
orMove to the bottom
.wp(ios|android)_editor_block_moved
to arrive successfully with the propertiesaction_source
containing:move_arrows_to_(top|bottom)
,inner_block
and,block_name
.Move a block using the drag & drop blocks feature
wp(ios|android)_editor_block_moved
to arrive successfully with the propertiesaction_source
containing:drag_and_drop,
inner_blockand,
block_name`.PR submission checklist: