-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tracking when opening or searching in the Command Palette (#41838)
* Add tracking when opening or searching in the Command Palette * Add changefile(s) from automation for the following project(s): woocommerce * Add 'origin' property to all Command Palette events --------- Co-authored-by: github-actions <github-actions@github.com>
- Loading branch information
Showing
5 changed files
with
97 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
plugins/woocommerce-admin/client/wp-admin-scripts/command-palette/use-edited-post-type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
|
||
export const useEditedPostType = () => { | ||
// This will return 'post' or 'page' when in the post/page editor. | ||
const { currentPostType } = useSelect( ( select ) => { | ||
const store = select( 'core/editor' ); | ||
if ( ! store ) { | ||
return { | ||
currentPostType: null, | ||
}; | ||
} | ||
const { getCurrentPostType } = store; | ||
return { | ||
currentPostType: getCurrentPostType(), | ||
}; | ||
} ); | ||
// This will return 'wp_template' or 'wp_template_part' when in the Site Editor. | ||
const { editedPostType } = useSelect( ( select ) => { | ||
const store = select( 'core/edit-site' ); | ||
if ( ! store ) { | ||
return { | ||
editedPostType: null, | ||
}; | ||
} | ||
const { getEditedPostType } = store; | ||
return { | ||
editedPostType: getEditedPostType(), | ||
}; | ||
} ); | ||
|
||
return { editedPostType: editedPostType || currentPostType }; | ||
}; |
4 changes: 4 additions & 0 deletions
4
plugins/woocommerce/changelog/41838-update-41837-command-palette-tracking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: update | ||
Comment: Add tracking when opening or searching in the Command Palette | ||
|