Skip to content

Commit

Permalink
Help Center: Add editor type to tracking (#97010)
Browse files Browse the repository at this point in the history
  • Loading branch information
escapemanuele authored Dec 3, 2024
1 parent 08f6a66 commit 43e6df7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/help-center/help-center-gutenberg.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useCallback, useEffect, useState, useReducer } from '@wordpress/element
import { registerPlugin } from '@wordpress/plugins';
import ReactDOM from 'react-dom';
import { useCanvasMode } from './hooks/use-canvas-mode';
import { getEditorType } from './utils';
import './help-center.scss';

const queryClient = new QueryClient();
Expand All @@ -29,6 +30,7 @@ function HelpCenterContent() {
force_site_id: true,
location: 'help-center',
section: 'gutenberg-editor',
editor_type: getEditorType(),
canvas_mode: canvasMode,
} );

Expand Down
20 changes: 20 additions & 0 deletions apps/help-center/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,23 @@ export const getUnlock = () => {
return undefined;
}
};

export const getEditorType = () => {
if ( document.querySelector( '#editor .edit-post-layout' ) ) {
return 'post';
}

if ( document.querySelector( '#site-editor' ) ) {
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 43e6df7

Please sign in to comment.