: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
feat(user-interviews): show interview link on response page (#58867)
coryslater150813e12ae5
diff --git a/products/user_interviews/frontend/InterviewLinkCopyButton.tsx b/products/user_interviews/frontend/InterviewLinkCopyButton.tsxnew file mode 100644index 000000000000..6c506b31ee07--- /dev/null+++ b/products/user_interviews/frontend/InterviewLinkCopyButton.tsx@@ -0,0 +1,41 @@+import { useValues } from 'kea'++import { IconCopy } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { copyToClipboard } from 'lib/utils/copyToClipboard'++import { userInterviewLogic } from './userInterviewLogic'++export function InterviewLinkCopyButton({ identifier, topicId }: { identifier: string; topicId: string }): JSX.Element {+ const { linkForIdentifier, linksLoading, linksLoadFailed } = useValues(userInterviewLogic({ id: topicId }))+ const interviewUrl = linkForIdentifier(identifier)++ const handleCopy = (e: React.MouseEvent): void => {+ e.preventDefault()+ e.stopPropagation()+ if (!interviewUrl) {+ return+ }+ void copyToClipboard(interviewUrl, 'interview link')+ }++ const disabledReason = interviewUrl+ ? undefined+ : linksLoadFailed+ ? "Couldn't generate link — refresh to retry"+ : linksLoading+ ? 'Generating link…'+ : 'No link available'++ return (+ <LemonButton+ type="tertiary"+ size="xsmall"+ icon={<IconCopy />}+ onClick={handleCopy}+ disabledReason={disabledReason}+ tooltip="Copy interview link"+ />+ )+}diff --git a/products/user_interviews/frontend/UserInterview.tsx b/products/user_interviews/frontend/UserInterview.tsxindex fb3e015ffaf6..0a2b5c8ad699 100644--- a/products/user_interviews/frontend/UserInterview.tsx+++ b/products/user_interviews/frontend/UserInterview.tsx@@ -1,18 +1,18 @@import { useValues } from 'kea'-import { IconArrowLeft, IconCheck, IconChevronRight, IconClock, IconCopy } from '@posthog/icons'+import { IconArrowLeft, IconCheck, IconChevronRight, IconClock } from '@posthog/icons'import { LemonButton, LemonSkeleton, LemonTag, LemonWidget } from '@posthog/lemon-ui'import { NotFound } from 'lib/components/NotFound'import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'import { Link } from 'lib/lemon-ui/Link'-import { copyToClipboard } from 'lib/utils/copyToClipboard'import { SceneExport } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'import { SceneContent } from '~/layout/scenes/components/SceneContent'import type { UserInterviewTopicApi } from './generated/api.schemas'+import { InterviewLinkCopyButton } from './InterviewLinkCopyButton'import { UserInterviewLogicProps, userInterviewLogic } from './userInterviewLogic'export const scene: SceneExport<UserInterviewLogicProps> = {@@ -218,39 +218,6 @@ function DetailRow({ label, value }: { label: string; value: string }): JSX.Elem)}-function InterviewLinkCopyButton({ identifier, topicId }: { identifier: string; topicId: string }): JSX.Element {- const { linkForIdentifier, linksLoading, linksLoadFailed } = useValues(userInterviewLogic({ id: topicId }))- const interviewUrl = linkForIdentifier(identifier)-- const handleCopy = (e: React.MouseEvent): void => {- e.preventDefault()- e.stopPropagation()- if (!interviewUrl) {- return- }- void copyToClipboard(interviewUrl, 'interview link')- }-- const disabledReason = interviewUrl- ? undefined- : linksLoadFailed- ? "Couldn't generate link — refresh to retry"- : linksLoading- ? 'Generating link…'- : 'No link available'-- return (- <LemonButton- type="tertiary"- size="xsmall"- icon={<IconCopy />}- onClick={handleCopy}- disabledReason={disabledReason}- tooltip="Copy interview link"- />- )-}-function PersonRow({identifier,topicId,diff --git a/products/user_interviews/frontend/UserInterviewResponse.tsx b/products/user_interviews/frontend/UserInterviewResponse.tsxindex f03118fe2d9a..fabde1ff3ee0 100644--- a/products/user_interviews/frontend/UserInterviewResponse.tsx+++ b/products/user_interviews/frontend/UserInterviewResponse.tsx@@ -1,11 +1,13 @@+import { useValues } from 'kea'import { useEffect, useState } from 'react'-import { IconArrowLeft, IconCalendar, IconPerson, IconSend } from '@posthog/icons'+import { IconArrowLeft, IconCalendar, IconPerson, IconSend, IconShare } from '@posthog/icons'import { LemonButton, LemonSkeleton, LemonTag, LemonWidget } from '@posthog/lemon-ui'import api from 'lib/api'import { NotFound } from 'lib/components/NotFound'import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'+import { Link } from 'lib/lemon-ui/Link'import { PersonDisplay } from 'scenes/persons/PersonDisplay'import { SceneExport } from 'scenes/sceneTypes'import { teamLogic } from 'scenes/teamLogic'@@ -17,6 +19,8 @@ import { PersonType } from '~/types'import { userInterviewTopicsRetrieve, userInterviewTopicsIntervieweesList, userInterviewsList } from './generated/api'import type { UserInterviewTopicApi, IntervieweeContextApi, UserInterviewApi } from './generated/api.schemas'+import { InterviewLinkCopyButton } from './InterviewLinkCopyButton'+import { userInterviewLogic } from './userInterviewLogic'export interface UserInterviewResponseProps {topicId: string@@ -30,6 +34,8 @@ export const scene: SceneExport<UserInterviewResponseProps> = {export function UserInterviewResponse({ topicId, responseId }: UserInterviewResponseProps): JSX.Element {const identifier = decodeURIComponent(responseId)+ const { linkForIdentifier, linksLoading, linksLoadFailed } = useValues(userInterviewLogic({ id: topicId }))+ const interviewUrl = linkForIdentifier(identifier)const [loading, setLoading] = useState(true)const [topic, setTopic] = useState<UserInterviewTopicApi | null>(null)const [intervieweeContext, setIntervieweeContext] = useState<IntervieweeContextApi | null>(null)@@ -165,6 +171,30 @@ export function UserInterviewResponse({ topicId, responseId }: UserInterviewResp<span className="font-medium">{identifier}</span></div>)}+ <div className="space-y-1">+ <div className="flex items-center gap-2">+ <IconShare className="text-muted shrink-0" />+ <span className="text-sm">Interview link</span>+ <InterviewLinkCopyButton identifier={identifier} topicId={topicId} />+ </div>+ {interviewUrl ? (+ <Link+ to={interviewUrl}+ target="_blank"+ className="block text-xs font-mono break-all pl-6"+ >+ {interviewUrl}+ </Link>+ ) : (+ <span className="block text-xs text-muted pl-6">+ {linksLoadFailed+ ? "Couldn't generate link — refresh to retry"+ : linksLoading+ ? 'Generating link…'+ : 'No link available'}+ </span>+ )}+ </div><div><LemonTag type={hasResponse ? 'success' : 'default'}>{hasResponse ? 'Responded' : 'Awaiting response'}