PluginProbe
Extendify / trunk
Extendify vtrunk
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
← All changes | src/Agent/components/ChatSuggestions.jsx +16 -2 3.1.3 → trunk View file →
@@ -1,8 +1,9 @@
1 1 import { sparkle } from '@agent/icons';
2 2 import { useDomainActivities } from '@agent/state/domain-activities';
3 3 import { useSuggestionsStore } from '@agent/state/suggestions';
4 -import { useState } from '@wordpress/element';
4 +import { track } from '@shared/lib/track';
5 +import { useEffect, useState } from '@wordpress/element';
5 6 import { __ } from '@wordpress/i18n';
6 7 import {
7 8 chevronRight,
8 9 drafts,
@@ -36,9 +37,11 @@
36 37 const [allSuggestions, setAllSuggestions] = useState(suggestions);
37 38
38 39 const handleSelect = (suggestion) => {
39 40 markAsClicked(suggestion);
40 - if (suggestion.tracking) {
41 + if (suggestion.telemetry) {
42 + track(suggestion.telemetry.key, suggestion.telemetry.payload);
43 + } else if (suggestion.tracking) {
41 44 setDomainActivity({ ...suggestion.tracking, action: 'clicked' });
42 45 }
43 46 // External-link suggestions are plain links: the anchor opens the new tab.
44 47 // They don't trigger a workflow or post a message in the chat.
@@ -75,9 +78,20 @@
75 78 );
76 79 };
77 80
78 81 const SuggestionButton = ({ suggestion, onSelect }) => {
82 + const { setDomainActivity } = useDomainActivities();
79 83 const icon = icons[suggestion?.icon] ?? icons.sparkle;
84 +
85 + useEffect(() => {
86 + if (suggestion.viewTelemetry) {
87 + track(suggestion.viewTelemetry.key, suggestion.viewTelemetry.payload);
88 + }
89 + if (suggestion.tracking) {
90 + setDomainActivity({ ...suggestion.tracking, action: 'viewed' });
91 + }
92 + }, [suggestion, setDomainActivity]);
93 +
80 94 const className =
81 95 'group flex items-center justify-between rounded-sm bg-transparent px-1 py-1 text-left text-sm not-italic text-gray-900 transition-colors duration-100 hover:bg-gray-100 focus:outline-hidden focus:ring-2 focus:ring-design-main';
82 96 const content = (
83 97 <>