Skip to content

Commit

Permalink
Jetpack AI: Add tracking to the thumbs up/down component, saving the …
Browse files Browse the repository at this point in the history
…component and rating to Tracks (#40553)

* Jetpack AI: Add tracking to the thumbs up/down component, saving the component and rating to Tracks

* changelog
  • Loading branch information
mwatson authored Dec 11, 2024
1 parent a5c8473 commit 4481373
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Jetpack AI: Add tracking to the thumbs up/down component, saving the component and rating to Tracks
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
import { Button, Tooltip } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { thumbsUp, thumbsDown } from '@wordpress/icons';
Expand All @@ -7,8 +8,14 @@ import { getFeatureAvailability } from '../../../../blocks/ai-assistant/lib/util

import './style.scss';

export default function AiFeedbackThumbs( { disabled = false, iconSize = 24, ratedItem } ) {
export default function AiFeedbackThumbs( {
disabled = false,
iconSize = 24,
ratedItem,
feature,
} ) {
const [ itemsRated, setItemsRated ] = useState( {} );
const { tracks } = useAnalytics();

const rateAI = ( isThumbsUp: boolean ) => {
const aiRating = isThumbsUp ? 'thumbs-up' : 'thumbs-down';
Expand All @@ -18,7 +25,10 @@ export default function AiFeedbackThumbs( { disabled = false, iconSize = 24, rat
[ ratedItem ]: aiRating,
} );

// calls to Tracks or whatever else can be made here
tracks.recordEvent( 'jetpack_ai_feedback', {
type: feature,
rating: aiRating,
} );
};

const checkThumb = ( thumbValue: string ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export default function Carrousel( {
disabled={ aiFeedbackDisabled( images[ current ] ) }
ratedItem={ images[ current ].libraryUrl || '' }
iconSize={ 20 }
feature="image-generator"
/>
</div>

Expand Down

0 comments on commit 4481373

Please sign in to comment.