Skip to content

Commit

Permalink
Merge branch 'trunk' into Odie/restrict-escalation-until-enough-context
Browse files Browse the repository at this point in the history
  • Loading branch information
AllTerrainDeveloper authored Jan 17, 2025
2 parents 0aa5cf0 + 10b1979 commit 070e314
Show file tree
Hide file tree
Showing 187 changed files with 3,671 additions and 4,042 deletions.
28 changes: 27 additions & 1 deletion apps/wpcom-block-editor/src/wpcom/features/tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,32 @@ const maybeTrackPatternInsertion = ( actionData, additionalData ) => {
return null;
};

/**
* Track block drag and drop events.
* @param {Array} clientIds - Array of client IDs of the blocks being dragged.
* @param {string} fromRootClientId - Root client ID from where the blocks are dragged.
* @param {string} toRootClientId - Root client ID to where the blocks are dropped.
* @returns {void}
*/
const trackBlockDragDrop = ( clientIds, fromRootClientId, toRootClientId ) => {
const isDragging = select( 'core/block-editor' ).isDraggingBlocks();

// moveBlocksToPosition action is called when moving given blocks
// to a new position. This could be used in various scenarios such
// as mover arrows in the block toolbar, drag and drop, etc.
// Therefore this tracking ignore actions that are not related to
// dragging blocks.
if ( ! isDragging ) {
return;
}

getBlocksTracker( 'wpcom_block_moved_via_dragging' )(
clientIds,
fromRootClientId,
toRootClientId
);
};

/**
* Track block insertion.
* @param {Object | Array} blocks block instance object or an array of such objects
Expand Down Expand Up @@ -906,7 +932,7 @@ const REDUX_TRACKING = {
moveBlocksDown: getBlocksTracker( 'wpcom_block_moved_down' ),
removeBlocks: trackBlockRemoval,
removeBlock: trackBlockRemoval,
moveBlockToPosition: getBlocksTracker( 'wpcom_block_moved_via_dragging' ),
moveBlocksToPosition: trackBlockDragDrop,
insertBlock: trackBlockInsertion,
insertBlocks: trackBlockInsertion,
replaceBlock: trackBlockReplacement,
Expand Down
Loading

0 comments on commit 070e314

Please sign in to comment.