-
+
{contentPrefix}
{getContent()}{' '}
{displayShowMoreLink() && (
diff --git a/packages/shared/src/components/post/smartPrompts/PromptButtons.tsx b/packages/shared/src/components/post/smartPrompts/PromptButtons.tsx
index 8493e0bf47..f355ed59b6 100644
--- a/packages/shared/src/components/post/smartPrompts/PromptButtons.tsx
+++ b/packages/shared/src/components/post/smartPrompts/PromptButtons.tsx
@@ -72,7 +72,7 @@ export const PromptButtons = ({
const { openModal } = useLazyModal();
const { data, isLoading } = usePromptsQuery();
const { flags: settingFlags } = useSettingsContext();
- const { prompt: promptFlags } = settingFlags;
+ const { prompt: promptFlags } = settingFlags || {};
const prompts = useMemo(() => {
return data?.filter((prompt) => promptFlags?.[prompt.id] !== false);
}, [data, promptFlags]);
diff --git a/packages/shared/src/hooks/chat/types.ts b/packages/shared/src/hooks/chat/types.ts
index 2a23632031..d285de10d9 100644
--- a/packages/shared/src/hooks/chat/types.ts
+++ b/packages/shared/src/hooks/chat/types.ts
@@ -31,7 +31,7 @@ export interface UseChat {
queryKey: QueryKey;
data: Search;
isLoading: boolean;
- handleSubmit(prompt: string): Promise;
+ handleSubmit(prompt: string, event?: MouseEvent): Promise;
}
export interface CreatePayload {
diff --git a/packages/webapp/__tests__/PostPage.tsx b/packages/webapp/__tests__/PostPage.tsx
index 2453025ddd..9f5a1b540c 100644
--- a/packages/webapp/__tests__/PostPage.tsx
+++ b/packages/webapp/__tests__/PostPage.tsx
@@ -652,8 +652,9 @@ it('should show TLDR when there is a summary', async () => {
createPostMock({ summary: 'test summary' }),
completeActionMock({ action: ActionType.BookmarkPost }),
]);
- const el = await screen.findByText('TLDR');
+ const el = await screen.findByTestId('tldr-container');
expect(el).toBeInTheDocument();
+ expect(el).toHaveTextContent('test summary');
// eslint-disable-next-line testing-library/no-node-access, testing-library/prefer-screen-queries
const link = queryByText(el.parentElement, 'Show more');
expect(link).not.toBeInTheDocument();
@@ -667,7 +668,7 @@ it('should toggle TLDR on click', async () => {
}),
completeActionMock({ action: ActionType.BookmarkPost }),
]);
- const el = await screen.findByText('TLDR');
+ const el = await screen.findByTestId('tldr-container');
expect(el).toBeInTheDocument();
// eslint-disable-next-line testing-library/no-node-access, testing-library/prefer-screen-queries
const showMoreLink = queryByText(el.parentElement, 'Show more');
@@ -684,7 +685,7 @@ it('should not show Show more link when there is a summary without reaching thre
'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores',
}),
]);
- const el = await screen.findByText('TLDR');
+ const el = await screen.findByTestId('tldr-container');
expect(el).toBeInTheDocument();
// eslint-disable-next-line testing-library/no-node-access, testing-library/prefer-screen-queries
const link = queryByText(el.parentElement, 'Show more');
@@ -699,7 +700,7 @@ it('should not cut summary when there is a summary without reaching threshold',
summary: summaryText,
}),
]);
- const el = await screen.findByText('TLDR');
+ const el = await screen.findByTestId('tldr-container');
expect(el).toBeInTheDocument();
const fullSummary = await screen.findByText(summaryText);
expect(fullSummary).toBeInTheDocument();
From 0d933329208eecc07d4096aa1392b00b909ad685 Mon Sep 17 00:00:00 2001
From: Chris Bongers
Date: Wed, 5 Feb 2025 15:52:37 +0200
Subject: [PATCH 26/28] fix: modify tracking needs
---
.../FeedSettings/components/SmartPrompts.tsx | 1 +
.../components/post/smartPrompts/SmartPrompt.tsx | 16 +++++++++++++---
packages/shared/src/lib/log.ts | 1 +
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/packages/shared/src/components/feeds/FeedSettings/components/SmartPrompts.tsx b/packages/shared/src/components/feeds/FeedSettings/components/SmartPrompts.tsx
index 6911927c77..13c55350a4 100644
--- a/packages/shared/src/components/feeds/FeedSettings/components/SmartPrompts.tsx
+++ b/packages/shared/src/components/feeds/FeedSettings/components/SmartPrompts.tsx
@@ -86,6 +86,7 @@ export const SmartPrompts = (): ReactElement => {
logEvent({
event_name: LogEvent.ToggleSmartPrompts,
+ target_type: label,
target_id: newState ? TargetId.On : TargetId.Off,
extra: JSON.stringify({
origin: Origin.Settings,
diff --git a/packages/shared/src/components/post/smartPrompts/SmartPrompt.tsx b/packages/shared/src/components/post/smartPrompts/SmartPrompt.tsx
index 43bb99350c..e07c65917a 100644
--- a/packages/shared/src/components/post/smartPrompts/SmartPrompt.tsx
+++ b/packages/shared/src/components/post/smartPrompts/SmartPrompt.tsx
@@ -6,13 +6,16 @@ import { useActions, usePlusSubscription } from '../../../hooks';
import { PromptButtons } from './PromptButtons';
import { PromptDisplay } from '../../../graphql/prompt';
import { PostUpgradeToPlus } from '../../plus/PostUpgradeToPlus';
-import { TargetId } from '../../../lib/log';
+import { LogEvent, TargetId } from '../../../lib/log';
import ShowMoreContent from '../../cards/common/ShowMoreContent';
import { SmartPromptResponse } from './SmartPromptResponse';
import { CustomPrompt } from './CustomPrompt';
import { ActionType } from '../../../graphql/actions';
+import { postLogEvent } from '../../../lib/feed';
+import { useLogContext } from '../../../contexts/LogContext';
export const SmartPrompt = ({ post }: { post: Post }): ReactElement => {
+ const { logEvent } = useLogContext();
const { isPlus } = usePlusSubscription();
const { completeAction, checkHasCompleted } = useActions();
const [activeDisplay, setActiveDisplay] = useState(
@@ -31,8 +34,15 @@ export const SmartPrompt = ({ post }: { post: Post }): ReactElement => {
return;
}
- if (!triedSmartPrompts && prompt !== PromptDisplay.TLDR) {
- completeAction(ActionType.SmartPrompt);
+ if (prompt !== PromptDisplay.TLDR) {
+ if (!triedSmartPrompts) {
+ completeAction(ActionType.SmartPrompt);
+ }
+ logEvent(
+ postLogEvent(LogEvent.SmartPrompt, post, {
+ extra: { prompt },
+ }),
+ );
}
switch (prompt) {
diff --git a/packages/shared/src/lib/log.ts b/packages/shared/src/lib/log.ts
index 71e20ca130..754a95870a 100644
--- a/packages/shared/src/lib/log.ts
+++ b/packages/shared/src/lib/log.ts
@@ -238,6 +238,7 @@ export enum LogEvent {
ShareTag = 'share tag',
// End Share
// Start Smart Prompts
+ SmartPrompt = 'smart prompt',
ToggleSmartPrompts = 'toggle smart prompts',
// End Smart Prompts
}
From 04336aa91739af82d3a386d0fb61afc0f45512dc Mon Sep 17 00:00:00 2001
From: Chris Bongers
Date: Wed, 5 Feb 2025 16:19:47 +0200
Subject: [PATCH 27/28] fix: last item feedback
---
.../FeedSettings/components/SmartPrompts.tsx | 50 ++++++++++---------
.../post/smartPrompts/CustomPrompt.tsx | 11 +++-
.../post/smartPrompts/PromptButtons.tsx | 2 +-
.../post/smartPrompts/SmartPrompt.tsx | 3 ++
4 files changed, 40 insertions(+), 26 deletions(-)
diff --git a/packages/shared/src/components/feeds/FeedSettings/components/SmartPrompts.tsx b/packages/shared/src/components/feeds/FeedSettings/components/SmartPrompts.tsx
index 13c55350a4..e909a194cd 100644
--- a/packages/shared/src/components/feeds/FeedSettings/components/SmartPrompts.tsx
+++ b/packages/shared/src/components/feeds/FeedSettings/components/SmartPrompts.tsx
@@ -7,8 +7,6 @@ import {
TypographyType,
} from '../../../typography/Typography';
import { PlusUser } from '../../../PlusUser';
-import ConditionalWrapper from '../../../ConditionalWrapper';
-import { SimpleTooltip } from '../../../tooltips';
import { LogEvent, Origin, TargetId } from '../../../../lib/log';
import { Button, ButtonSize, ButtonVariant } from '../../../buttons/Button';
import { plusUrl } from '../../../../lib/constants';
@@ -20,6 +18,8 @@ import { useSettingsContext } from '../../../../contexts/SettingsContext';
import { labels } from '../../../../lib';
import { useLogContext } from '../../../../contexts/LogContext';
import { useFeedSettingsEditContext } from '../FeedSettingsEditContext';
+import { SimpleTooltip } from '../../../tooltips';
+import ConditionalWrapper from '../../../ConditionalWrapper';
export const SmartPrompts = (): ReactElement => {
const { editFeedSettings } = useFeedSettingsEditContext();
@@ -54,23 +54,25 @@ export const SmartPrompts = (): ReactElement => {
of every post in one click.
-