Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Added logging statements for 'Edit Prompt' and 'Preview' buttons #219

Merged
merged 4 commits into from Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions web-src/src/components/PromptEditor.js
Expand Up @@ -20,13 +20,14 @@ import { useRecoilState, useRecoilValue } from 'recoil';
import { css, injectGlobal } from '@emotion/css';
import { Global } from '@emotion/react';
import { motion, AnimatePresence } from 'framer-motion';

import Close from '@spectrum-icons/workflow/Close';
import { NO_VALUE_STRING, renderPrompt } from '../helpers/PromptRenderer.js';
import PreviewIcon from '../icons/PreviewIcon.js';

import { parametersState } from '../state/ParametersState.js';
import { promptState } from '../state/PromptState.js';
import { NO_VALUE_STRING, renderPrompt } from '../helpers/PromptRenderer.js';
import { log } from '../helpers/Tracking.js';

import PreviewIcon from '../icons/PreviewIcon.js';

languages.custom = {
function: /{{[^@#]([^{}]+)}}/,
Expand Down Expand Up @@ -107,6 +108,12 @@ function PromptEditor({ isOpen, onClose, ...props }) {
}
}, [viewSource]);

useEffect(() => {
if (!viewSource) {
log('prompt:editor:previewed');
}
}, [viewSource]);

const handleKeyDown = useCallback((event) => {
if (event.key === 'Escape') {
onClose();
Expand Down
9 changes: 8 additions & 1 deletion web-src/src/components/PromptSessionPanel.js
Expand Up @@ -10,16 +10,23 @@
* governing permissions and limitations under the License.
*/
import { Flex, Grid } from '@adobe/react-spectrum';
import React from 'react';
import React, { useEffect } from 'react';
import { useRecoilState } from 'recoil';
import { PromptSessionSideView } from './PromptSessionSideView.js';
import { PromptResultListView } from './PromptResultListView.js';
import PromptEditor from './PromptEditor.js';
import { promptEditorState } from '../state/PromptEditorState.js';
import { log } from '../helpers/Tracking.js';

export function PromptSessionPanel() {
const [isOpenPromptEditor, setIsOpenPromptEditor] = useRecoilState(promptEditorState);

useEffect(() => {
if (isOpenPromptEditor) {
log('prompt:editor:opened');
}
}, [isOpenPromptEditor]);

return (
<Grid
columns={['1fr', '2fr']}
Expand Down
1 change: 0 additions & 1 deletion web-src/src/components/PromptSessionSideView.js
Expand Up @@ -92,7 +92,6 @@ export function PromptSessionSideView({ isOpenPromptEditor, onTogglePrompt, ...p
<ActionButton
isQuiet
UNSAFE_className="hover-cursor-pointer"
// width={'size-1500'}
onPress={onTogglePrompt}
UNSAFE_style={isOpenPromptEditor ? { background: 'var(--spectrum-gray-200)' } : undefined}
>
Expand Down