Skip to content

Commit

Permalink
AI Assistant: add prompt show event on control and extension (#35256)
Browse files Browse the repository at this point in the history
* add menu show event on ai control and extension

* fixup versions
  • Loading branch information
CGastrell authored Jan 25, 2024
1 parent e4ec020 commit 7c1e5eb
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

AI Assistant: add menu show events on both control and extension (form)
2 changes: 1 addition & 1 deletion projects/plugins/jetpack/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"platform": {
"ext-intl": "0.0.0"
},
"autoloader-suffix": "f11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ13_1_a_7",
"autoloader-suffix": "f11009ded9fc4592b6a05b61ce272b3c_jetpackⓥ13_1_a_8",
"allow-plugins": {
"automattic/jetpack-autoloader": true,
"automattic/jetpack-composer-plugin": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ function AiAssistantDropdownContent( {
);

removeBlocks( otherBlocksIds );
tracks.recordEvent( 'jetpack_ai_assistant_prompt_show', { block_type: blockType } );
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import { useAiContext, AIControl, ERROR_QUOTA_EXCEEDED } from '@automattic/jetpack-ai-client';
import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
import { serialize } from '@wordpress/blocks';
import { KeyboardShortcuts } from '@wordpress/components';
import { useViewportMatch } from '@wordpress/compose';
Expand Down Expand Up @@ -79,6 +80,7 @@ export default function AiAssistantBar( {
} ) {
const wrapperRef = useRef< HTMLDivElement >( null );
const inputRef = useRef< HTMLInputElement >( null );
const { tracks } = useAnalytics();

const connected = isUserConnected();

Expand Down Expand Up @@ -201,6 +203,14 @@ export default function AiAssistantBar( {
};
}, [ isAssistantBarFixed, isVisible ] );

useEffect( () => {
if ( isVisible ) {
tracks.recordEvent( 'jetpack_ai_assistant_prompt_show', {
block_type: 'jetpack/contact-form',
} );
}
}, [ isVisible, tracks ] );

// focus input on first render only (for a11y reasons, toggling on/off should not focus the input)
useEffect( () => {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const jetpackFormEditWithAiComponents = createHigherOrderComponent( BlockEdit =>
* and close the event source.
*/
return () => {
// Only stop when the parent block is unmouted.
// Only stop when the parent block is unmounted.
if ( props?.name !== 'jetpack/contact-form' ) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions projects/plugins/jetpack/jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://jetpack.com
* Description: Security, performance, and marketing tools made by WordPress experts. Jetpack keeps your site protected so you can focus on more important things.
* Author: Automattic
* Version: 13.1-a.7
* Version: 13.1-a.8
* Author URI: https://jetpack.com
* License: GPL2+
* Text Domain: jetpack
Expand Down Expand Up @@ -34,7 +34,7 @@

define( 'JETPACK__MINIMUM_WP_VERSION', '6.3' );
define( 'JETPACK__MINIMUM_PHP_VERSION', '7.0' );
define( 'JETPACK__VERSION', '13.1-a.7' );
define( 'JETPACK__VERSION', '13.1-a.8' );

/**
* Constant used to fetch the connection owner token
Expand Down
2 changes: 1 addition & 1 deletion projects/plugins/jetpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Jetpack",
"version": "13.1.0-a.7",
"version": "13.1.0-a.8",
"private": true,
"description": "[Jetpack](https://jetpack.com/) is a WordPress plugin that supercharges your self-hosted WordPress site with the awesome cloud power of [WordPress.com](https://wordpress.com).",
"homepage": "https://jetpack.com",
Expand Down

0 comments on commit 7c1e5eb

Please sign in to comment.