Skip to content

Commit

Permalink
Editor Stats - add editor type tracking for block widgets editors (#…
Browse files Browse the repository at this point in the history
…53789)

* add widgets and customize-widgets as editor types

* fix header-inserter method
  • Loading branch information
Addison-Stavlo authored Jun 18, 2021
1 parent ed034c0 commit dfa7c86
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/wpcom-block-editor/src/wpcom/features/tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ const getBlockInserterUsed = ( originalBlockIds = [] ) => {
// (at least at the time of writing), which is why we can rely on this method.
if (
select( 'core/edit-post' )?.isInserterOpened() ||
select( 'core/edit-site' )?.isInserterOpened()
select( 'core/edit-site' )?.isInserterOpened() ||
select( 'core/edit-widgets' )?.isInserterOpened() ||
document
.querySelector( '.customize-widgets-layout__inserter-panel' )
?.contains( document.activeElement )
) {
return 'header-inserter';
}
Expand Down Expand Up @@ -306,7 +310,7 @@ const trackInnerBlocksReplacement = ( rootClientId, blocks ) => {
to update via `replaceInnerBlocks`.
3. Performing undo or redo related to template parts and reusable blocks
will update the instances via `replaceInnerBlocks`.
will update the instances via `replaceInnerBlocks`.
*/
const parentBlock = select( 'core/block-editor' ).getBlocksByClientId( rootClientId )?.[ 0 ];
if ( parentBlock ) {
Expand Down
8 changes: 8 additions & 0 deletions apps/wpcom-block-editor/src/wpcom/features/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@ export const getEditorType = () => {
return 'site';
}

if ( document.querySelector( '#widgets-editor' ) ) {
return 'widgets';
}

if ( document.querySelector( '#customize-controls .customize-widgets__sidebar-section.open' ) ) {
return 'customize-widgets';
}

return undefined;
};

0 comments on commit dfa7c86

Please sign in to comment.