Skip to content

: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.

fix(desktop): mobile link conversations ticket evidence (#100063)

Tom Owersb16c182aa65d
diff --git a/products/desktop/apps/mobile/src/features/inbox/components/SignalCard.tsx b/products/desktop/apps/mobile/src/features/inbox/components/SignalCard.tsx
index fa78c6e217e4..cc9b7b16cc83 100644
--- a/products/desktop/apps/mobile/src/features/inbox/components/SignalCard.tsx
+++ b/products/desktop/apps/mobile/src/features/inbox/components/SignalCard.tsx
@@ -34,7 +34,12 @@ import { MarkdownText } from "@/features/chat/components/MarkdownText";
import { formatRelativeTime } from "@/lib/format";
import { openExternalUrl } from "@/lib/openExternalUrl";
import { getPostHogApiClient } from "@/lib/posthogApiClient";
-import { useThemeColors } from "@/lib/theme";
+import { type ThemeColors, useThemeColors } from "@/lib/theme";
+import {
+ type ConversationsTicketExtra,
+ conversationsTicketRef,
+ supportTicketUrl,
+} from "../conversationsTicket";
import {
colonOffsetFromSeconds,
colonOffsetToSeconds,
@@ -62,6 +67,7 @@ function SourceIcon({
return <ChatCircle size={size} color={color} />;
case "llm_analytics":
return <Robot size={size} color={color} />;
+ case "conversations":
case "zendesk":
return <ChatCircle size={size} color={color} />;
case "linear":
@@ -334,6 +340,56 @@ function WatchRecordingAction({ evidence }: { evidence: RecordingEvidence }) {
);
}
+function ConversationsTicketFooter({
+ signal,
+ extra,
+ themeColors,
+}: {
+ signal: Signal;
+ extra: ConversationsTicketExtra;
+ themeColors: ThemeColors;
+}) {
+ const { projectId, cloudRegion } = useAuthStore();
+ const ticketRef = conversationsTicketRef(signal, extra);
+ const ticketUrl =
+ ticketRef !== null
+ ? supportTicketUrl(ticketRef, { projectId, cloudRegion })
+ : null;
+
+ return (
+ <View className="mt-2 flex-row flex-wrap items-center gap-x-3 gap-y-1">
+ {extra.ticket_number != null && (
+ <Text className="font-mono text-[11px] text-gray-10">
+ #{extra.ticket_number}
+ </Text>
+ )}
+ {extra.status && (
+ <Text className="text-[11px] text-gray-10">Status: {extra.status}</Text>
+ )}
+ {extra.priority && (
+ <Text className="text-[11px] text-gray-10">
+ Priority: {extra.priority}
+ </Text>
+ )}
+ <View className="flex-1" />
+ {ticketUrl ? (
+ <Pressable
+ onPress={() => openExternalUrl(ticketUrl)}
+ hitSlop={6}
+ className="flex-row items-center gap-1 active:opacity-60"
+ >
+ <Text className="text-[11px] text-gray-10">Open ticket</Text>
+ <ArrowSquareOut size={12} color={themeColors.gray[10]} />
+ </Pressable>
+ ) : (
+ <Text className="text-[11px] text-gray-10">
+ Source ticket unavailable
+ </Text>
+ )}
+ </View>
+ );
+}
+
interface SignalCardProps {
signal: Signal;
finding?: SignalFindingContent;
@@ -352,6 +408,11 @@ export function SignalCard({ signal, finding }: SignalCardProps) {
const ticketUrl =
typeof extra.url === "string" ? (extra.url as string) : null;
+ const conversationsExtra =
+ signal.source_product === "conversations" && signal.source_type === "ticket"
+ ? (extra as ConversationsTicketExtra)
+ : null;
+
const externalUrl = issueUrl ?? ticketUrl ?? null;
const recordingEvidence = extractRecordingEvidence(signal);
@@ -381,6 +442,15 @@ export function SignalCard({ signal, finding }: SignalCardProps) {
{verified !== undefined && <VerifiedBadge verified={verified} />}
</View>
+ {conversationsExtra?.email_subject && (
+ <Text
+ className="mb-1 font-medium text-[13px] text-gray-12"
+ numberOfLines={2}
+ >
+ {conversationsExtra.email_subject}
+ </Text>
+ )}
+
{/* Body */}
<CollapsibleBody body={signal.content} />
@@ -388,26 +458,33 @@ export function SignalCard({ signal, finding }: SignalCardProps) {
<WatchRecordingAction evidence={recordingEvidence} />
)}
- {/* Footer meta (lightweight, no source-specific extras for v1) */}
- {(issueNumber !== null || externalUrl) && (
- <View className="mt-2 flex-row items-center gap-3">
- {issueNumber !== null && (
- <Text className="font-medium text-[11px] text-gray-10">
- #{issueNumber}
- </Text>
- )}
- <View className="flex-1" />
- {externalUrl && (
- <Pressable
- onPress={() => openExternalUrl(externalUrl)}
- hitSlop={6}
- className="flex-row items-center gap-1 active:opacity-60"
- >
- <Text className="text-[11px] text-gray-10">Open</Text>
- <ArrowSquareOut size={12} color={themeColors.gray[10]} />
- </Pressable>
- )}
- </View>
+ {conversationsExtra ? (
+ <ConversationsTicketFooter
+ signal={signal}
+ extra={conversationsExtra}
+ themeColors={themeColors}
+ />
+ ) : (
+ (issueNumber !== null || externalUrl) && (
+ <View className="mt-2 flex-row items-center gap-3">
+ {issueNumber !== null && (
+ <Text className="font-medium text-[11px] text-gray-10">
+ #{issueNumber}
+ </Text>
+ )}
+ <View className="flex-1" />
+ {externalUrl && (
+ <Pressable
+ onPress={() => openExternalUrl(externalUrl)}
+ hitSlop={6}
+ className="flex-row items-center gap-1 active:opacity-60"
+ >
+ <Text className="text-[11px] text-gray-10">Open</Text>
+ <ArrowSquareOut size={12} color={themeColors.gray[10]} />
+ </Pressable>
+ )}
+ </View>
+ )
)}
<CodePathsDisclosure paths={codePaths} />
diff --git a/products/desktop/apps/mobile/src/features/inbox/conversationsTicket.test.ts b/products/desktop/apps/mobile/src/features/inbox/conversationsTicket.test.ts
new file mode 100644
index 000000000000..e4f30f181524
--- /dev/null
+++ b/products/desktop/apps/mobile/src/features/inbox/conversationsTicket.test.ts
@@ -0,0 +1,92 @@
+import type { Signal } from "@posthog/shared/domain-types";
+import { describe, expect, it } from "vitest";
+import {
+ conversationsTicketRef,
+ supportTicketUrl,
+} from "./conversationsTicket";
+
+function makeSignal(overrides: Partial<Signal> = {}): Signal {
+ return {
+ signal_id: "s1",
+ content: "",
+ source_product: "conversations",
+ source_type: "ticket",
+ source_id: "0197-ticket-uuid",
+ weight: 1,
+ timestamp: "",
+ extra: {},
+ ...overrides,
+ };
+}
+
+describe("conversationsTicketRef", () => {
+ it.each([
+ [
+ "the ticket number when the emitter stored one",
+ { ticket_number: 4821 },
+ 4821,
+ ],
+ [
+ "the ticket uuid for evidence stored without a number",
+ {},
+ "0197-ticket-uuid",
+ ],
+ ])("resolves to %s", (_label, extra, expected) => {
+ expect(conversationsTicketRef(makeSignal(), extra)).toBe(expected);
+ });
+
+ it.each([
+ ["a non-positive integer", 0],
+ ["a non-integer", 12.5],
+ ])(
+ "falls back to source_id when ticket_number is %s",
+ (_label, ticket_number) => {
+ expect(conversationsTicketRef(makeSignal(), { ticket_number })).toBe(
+ "0197-ticket-uuid",
+ );
+ },
+ );
+
+ it("returns null when neither identifier resolves", () => {
+ expect(
+ conversationsTicketRef(makeSignal({ source_id: "" }), {}),
+ ).toBeNull();
+ });
+});
+
+describe("supportTicketUrl", () => {
+ it.each([
+ [
+ "a ticket number",
+ 4821,
+ "https://us.posthog.com/project/123/support/tickets/4821",
+ ],
+ [
+ "a ticket uuid",
+ "0197-uuid",
+ "https://us.posthog.com/project/123/support/tickets/0197-uuid",
+ ],
+ [
+ "an unsafe ticket ref",
+ "a/b?c",
+ "https://us.posthog.com/project/123/support/tickets/a%2Fb%3Fc",
+ ],
+ ])(
+ "links the source project's ticket page by %s",
+ (_label, ref, expected) => {
+ expect(supportTicketUrl(ref, { projectId: 123, cloudRegion: "us" })).toBe(
+ expected,
+ );
+ },
+ );
+
+ it.each([
+ ["project", { projectId: null, cloudRegion: "us" as const }],
+ ["region", { projectId: 123, cloudRegion: null }],
+ ])(
+ "has no destination without a %s to resolve against",
+ (_label, options) => {
+ expect(supportTicketUrl(4821, options)).toBeNull();
+ },
+ );
+});
diff --git a/products/desktop/apps/mobile/src/features/inbox/conversationsTicket.ts b/products/desktop/apps/mobile/src/features/inbox/conversationsTicket.ts
new file mode 100644
index 000000000000..cd0b214b14f6
--- /dev/null
+++ b/products/desktop/apps/mobile/src/features/inbox/conversationsTicket.ts
@@ -0,0 +1,36 @@
+import type { Signal } from "@posthog/shared/domain-types";
+import { getCloudUrlFromRegion } from "@/features/auth/lib/constants";
+import type { CloudRegion } from "@/features/auth/types";
+
+export interface ConversationsTicketExtra {
+ ticket_number?: number;
+ status?: string;
+ priority?: string;
+ email_subject?: string;
+}
+
+export function conversationsTicketRef(
+ signal: Signal,
+ extra: ConversationsTicketExtra,
+): string | number | null {
+ if (
+ typeof extra.ticket_number === "number" &&
+ Number.isInteger(extra.ticket_number) &&
+ extra.ticket_number > 0
+ ) {
+ return extra.ticket_number;
+ }
+ return signal.source_id || null;
+}
+
+export function supportTicketUrl(
+ ticketRef: string | number,
+ options: {
+ projectId: number | null;
+ cloudRegion: CloudRegion | null;
+ },
+): string | null {
+ const { projectId, cloudRegion } = options;
+ if (projectId === null || cloudRegion === null) return null;
+ return `${getCloudUrlFromRegion(cloudRegion)}/project/${projectId}/support/tickets/${encodeURIComponent(String(ticketRef))}`;
+}
diff --git a/products/desktop/apps/mobile/src/features/inbox/utils.test.ts b/products/desktop/apps/mobile/src/features/inbox/utils.test.ts
index bbdcb62fa8dd..8433219dd09c 100644
--- a/products/desktop/apps/mobile/src/features/inbox/utils.test.ts
+++ b/products/desktop/apps/mobile/src/features/inbox/utils.test.ts
@@ -328,6 +328,11 @@ describe("sourceLine", () => {
expected: "Error tracking · New issue",
},
{ product: "sentry", type: "issue", expected: "Sentry · issue" },
+ {
+ product: "conversations",
+ type: "ticket",
+ expected: "Conversations · Ticket",
+ },
{
product: "mystery_source",
type: "thing",
diff --git a/products/desktop/apps/mobile/src/features/inbox/utils.ts b/products/desktop/apps/mobile/src/features/inbox/utils.ts
index 912bcd710458..be66132ebb29 100644
--- a/products/desktop/apps/mobile/src/features/inbox/utils.ts
+++ b/products/desktop/apps/mobile/src/features/inbox/utils.ts
@@ -22,6 +22,8 @@ export function sourceLine(signal: Signal): string {
return "Session replay · Session problem";
if (source_product === "llm_analytics" && source_type === "evaluation")
return "AI observability · Evaluation";
+ if (source_product === "conversations" && source_type === "ticket")
+ return "Conversations · Ticket";
if (source_product === "zendesk" && source_type === "ticket")
return "Zendesk · Ticket";
if (source_product === "github" && source_type === "issue")