:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(user-interviews): address qa-swarm findings on copy-link button (#58698)
Paul D'Ambrac206fa4c0a47
diff --git a/products/user_interviews/frontend/UserInterview.tsx b/products/user_interviews/frontend/UserInterview.tsxindex a00c4da8b81f..fb3e015ffaf6 100644--- a/products/user_interviews/frontend/UserInterview.tsx+++ b/products/user_interviews/frontend/UserInterview.tsx@@ -219,7 +219,7 @@ function DetailRow({ label, value }: { label: string; value: string }): JSX.Elem}function InterviewLinkCopyButton({ identifier, topicId }: { identifier: string; topicId: string }): JSX.Element {- const { linkForIdentifier, linksLoading } = useValues(userInterviewLogic({ id: topicId }))+ const { linkForIdentifier, linksLoading, linksLoadFailed } = useValues(userInterviewLogic({ id: topicId }))const interviewUrl = linkForIdentifier(identifier)const handleCopy = (e: React.MouseEvent): void => {@@ -231,7 +231,13 @@ function InterviewLinkCopyButton({ identifier, topicId }: { identifier: string;void copyToClipboard(interviewUrl, 'interview link')}- const disabledReason = interviewUrl ? undefined : linksLoading ? 'Generating link…' : 'No link available'+ const disabledReason = interviewUrl+ ? undefined+ : linksLoadFailed+ ? "Couldn't generate link — refresh to retry"+ : linksLoading+ ? 'Generating link…'+ : 'No link available'return (<LemonButtondiff --git a/products/user_interviews/frontend/userInterviewLogic.ts b/products/user_interviews/frontend/userInterviewLogic.tsindex 275a713f33ae..718d302b8134 100644--- a/products/user_interviews/frontend/userInterviewLogic.ts+++ b/products/user_interviews/frontend/userInterviewLogic.ts@@ -1,4 +1,4 @@-import { afterMount, kea, key, path, props, selectors } from 'kea'+import { afterMount, kea, key, path, props, reducers, selectors } from 'kea'import { loaders } from 'kea-loaders'import { teamLogic } from 'scenes/teamLogic'@@ -24,6 +24,13 @@ export interface UserInterviewLogicProps {id: string}+function unwrapPaginatedOrArray<T>(response: T[] | { results?: T[] }): T[] {+ if (Array.isArray(response)) {+ return response+ }+ return response.results ?? []+}+export const userInterviewLogic = kea<userInterviewLogicType>([path(['products', 'user_interviews', 'frontend', 'userInterviewLogic']),props({} as UserInterviewLogicProps),@@ -71,13 +78,19 @@ export const userInterviewLogic = kea<userInterviewLogicType>([const response = (await userInterviewTopicsGenerateLinksCreate(projectId, props.id)) as unknown as| InterviewLinkApi[]| { results?: InterviewLinkApi[] }- if (Array.isArray(response)) {- return response- }- return response.results ?? []+ return unwrapPaginatedOrArray(response)},},})),+ reducers({+ linksLoadFailed: [+ false,+ {+ loadLinks: () => false,+ loadLinksFailure: () => true,+ },+ ],+ }),selectors(({ props }) => ({topicInterviews: [(s) => [s.interviews],