: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(desktop): mobile list only enabled inbox sources in the filter (#86300)
Tom Owers743544226aa7
diff --git a/products/desktop/apps/mobile/src/features/inbox/components/FilterSheet.test.ts b/products/desktop/apps/mobile/src/features/inbox/components/FilterSheet.test.tsdeleted file mode 100644index 3a9749a7a40b..000000000000--- a/products/desktop/apps/mobile/src/features/inbox/components/FilterSheet.test.ts+++ /dev/null@@ -1,18 +0,0 @@-import { EXTERNAL_INBOX_SOURCES } from "@posthog/shared";-import { describe, expect, it } from "vitest";-import { SOURCE_PRODUCT_OPTIONS } from "./FilterSheet";--describe("SOURCE_PRODUCT_OPTIONS", () => {- it("includes every warehouse-backed source from the shared registry", () => {- const values = new Set(SOURCE_PRODUCT_OPTIONS.map((o) => o.value));- for (const source of EXTERNAL_INBOX_SOURCES) {- expect(values.has(source.product)).toBe(true);- }- });-- it("keeps the native products", () => {- const values = SOURCE_PRODUCT_OPTIONS.map((o) => o.value);- expect(values).toContain("session_replay");- expect(values).toContain("signals_scout");- });-});diff --git a/products/desktop/apps/mobile/src/features/inbox/components/FilterSheet.tsx b/products/desktop/apps/mobile/src/features/inbox/components/FilterSheet.tsxindex 47a22b36d88e..4fe00766277c 100644--- a/products/desktop/apps/mobile/src/features/inbox/components/FilterSheet.tsx+++ b/products/desktop/apps/mobile/src/features/inbox/components/FilterSheet.tsx@@ -1,12 +1,14 @@import { Text } from "@components/text";import { INBOX_PIPELINE_STATUSES } from "@posthog/core/inbox/reportFiltering";import { inboxStatusLabel } from "@posthog/core/inbox/reportPresentation";-import { EXTERNAL_INBOX_SOURCES, type SourceProduct } from "@posthog/shared";import type { SignalReportPriority } from "@posthog/shared/domain-types";import { Check } from "phosphor-react-native";+import { useMemo } from "react";import { Modal, Pressable, ScrollView, View } from "react-native";import { useScreenInsets } from "@/hooks/useScreenInsets";import { useThemeColors } from "@/lib/theme";+import { useSignalSourceConfigs } from "../hooks/useSignalSourceConfigs";+import { narrowSourceProductOptions } from "../sourceFilterOptions";import { useInboxFilterStore } from "../stores/inboxFilterStore";interface FilterSheetProps {@@ -58,22 +60,6 @@ function usePriorityDotColors(): Record<SignalReportPriority, string> {};}-export const SOURCE_PRODUCT_OPTIONS: { value: SourceProduct; label: string }[] =- [- { value: "session_replay", label: "Session replay" },- { value: "error_tracking", label: "Error tracking" },- { value: "llm_analytics", label: "AI observability" },- { value: "github", label: "GitHub" },- { value: "linear", label: "Linear" },- { value: "zendesk", label: "Zendesk" },- { value: "conversations", label: "Conversations" },- { value: "signals_scout", label: "Scout" },- ...EXTERNAL_INBOX_SOURCES.map((source) => ({- value: source.product,- label: source.label,- })),- ];-function SectionHeader({ title }: { title: string }) {return (<Text className="mb-1 font-semibold text-[12px] text-gray-10 uppercase tracking-wide">@@ -129,6 +115,12 @@ export function FilterSheet({ visible, onClose }: FilterSheetProps) {const setPriorityFilter = useInboxFilterStore((s) => s.setPriorityFilter);const resetFilters = useInboxFilterStore((s) => s.resetFilters);+ const { data: sourceConfigs } = useSignalSourceConfigs();+ const sourceOptions = useMemo(+ () => narrowSourceProductOptions(sourceConfigs, sourceProductFilter),+ [sourceConfigs, sourceProductFilter],+ );+const hasActiveFilters =sourceProductFilter.length > 0 ||priorityFilter.length > 0 ||@@ -241,7 +233,7 @@ export function FilterSheet({ visible, onClose }: FilterSheetProps) {selected={sourceProductFilter.length === 0}onPress={clearSourceProductFilter}/>- {SOURCE_PRODUCT_OPTIONS.map((option) => (+ {sourceOptions.map((option) => (<OptionRowkey={option.value}label={option.label}diff --git a/products/desktop/apps/mobile/src/features/inbox/hooks/useSignalSourceConfigs.ts b/products/desktop/apps/mobile/src/features/inbox/hooks/useSignalSourceConfigs.tsnew file mode 100644index 000000000000..f67188852662--- /dev/null+++ b/products/desktop/apps/mobile/src/features/inbox/hooks/useSignalSourceConfigs.ts@@ -0,0 +1,18 @@+import type { SignalSourceConfig } from "@posthog/api-client/posthog-client";+import { useQuery } from "@tanstack/react-query";+import { useAuthStore } from "@/features/auth";+import { getPostHogApiClient } from "@/lib/posthogApiClient";++export function useSignalSourceConfigs() {+ const { projectId, oauthAccessToken } = useAuthStore();++ return useQuery<SignalSourceConfig[]>({+ queryKey: ["inbox", "signal-source-configs", projectId],+ queryFn: () =>+ projectId+ ? getPostHogApiClient().listSignalSourceConfigs(projectId)+ : Promise.resolve([]),+ enabled: !!projectId && !!oauthAccessToken,+ staleTime: 30_000,+ });+}diff --git a/products/desktop/apps/mobile/src/features/inbox/sourceFilterOptions.test.ts b/products/desktop/apps/mobile/src/features/inbox/sourceFilterOptions.test.tsnew file mode 100644index 000000000000..1d9d3a7100c9--- /dev/null+++ b/products/desktop/apps/mobile/src/features/inbox/sourceFilterOptions.test.ts@@ -0,0 +1,69 @@+import type { SignalSourceConfig } from "@posthog/api-client/posthog-client";+import { EXTERNAL_INBOX_SOURCES, type SourceProduct } from "@posthog/shared";+import { describe, expect, it } from "vitest";+import {+ narrowSourceProductOptions,+ SOURCE_PRODUCT_OPTIONS,+} from "./sourceFilterOptions";++describe("SOURCE_PRODUCT_OPTIONS", () => {+ it("includes every warehouse-backed source from the shared registry", () => {+ const values = new Set(SOURCE_PRODUCT_OPTIONS.map((o) => o.value));+ for (const source of EXTERNAL_INBOX_SOURCES) {+ expect(values.has(source.product)).toBe(true);+ }+ });++ it("keeps the native products", () => {+ const values = SOURCE_PRODUCT_OPTIONS.map((o) => o.value);+ expect(values).toContain("session_replay");+ expect(values).toContain("signals_scout");+ });+});++function config(+ source_product: SourceProduct,+ enabled: boolean,+): SignalSourceConfig {+ return {+ id: source_product,+ source_product,+ source_type: "issue",+ enabled,+ config: {},+ created_at: "",+ updated_at: "",+ status: null,+ };+}++describe("narrowSourceProductOptions", () => {+ const values = (+ configs: SignalSourceConfig[] | undefined,+ selected: SourceProduct[] = [],+ ) => narrowSourceProductOptions(configs, selected).map((o) => o.value);++ it("shows an enabled warehouse source and hides a disabled one", () => {+ const result = values([config("github", true), config("sentry", false)]);+ expect(result).toContain("github");+ expect(result).not.toContain("sentry");+ });++ it("always keeps PostHog's own products", () => {+ const result = values([]);+ expect(result).toContain("session_replay");+ expect(result).toContain("signals_scout");+ expect(result).not.toContain("github");+ });++ it("keeps a disabled source while it is selected", () => {+ const result = values([config("sentry", false)], ["sentry"]);+ expect(result).toContain("sentry");+ });++ it("hides nothing while the source configs are unknown", () => {+ expect(values(undefined)).toEqual(+ SOURCE_PRODUCT_OPTIONS.map((o) => o.value),+ );+ });+});diff --git a/products/desktop/apps/mobile/src/features/inbox/sourceFilterOptions.ts b/products/desktop/apps/mobile/src/features/inbox/sourceFilterOptions.tsnew file mode 100644index 000000000000..3e3e9caee9ad--- /dev/null+++ b/products/desktop/apps/mobile/src/features/inbox/sourceFilterOptions.ts@@ -0,0 +1,29 @@+import type { SignalSourceConfig } from "@posthog/api-client/posthog-client";+import {+ EXTERNAL_INBOX_SOURCES,+ filterInboxSourceOptions,+ type SourceProduct,+} from "@posthog/shared";++export const SOURCE_PRODUCT_OPTIONS: { value: SourceProduct; label: string }[] =+ [+ { value: "session_replay", label: "Session replay" },+ { value: "error_tracking", label: "Error tracking" },+ { value: "llm_analytics", label: "AI observability" },+ { value: "conversations", label: "Conversations" },+ { value: "signals_scout", label: "Scout" },+ ...EXTERNAL_INBOX_SOURCES.map((source) => ({+ value: source.product,+ label: source.label,+ })),+ ];++export function narrowSourceProductOptions(+ configs: SignalSourceConfig[] | undefined,+ selected: SourceProduct[],+): { value: SourceProduct; label: string }[] {+ const enabled = configs+ ? new Set(configs.filter((c) => c.enabled).map((c) => c.source_product))+ : undefined;+ return filterInboxSourceOptions(SOURCE_PRODUCT_OPTIONS, enabled, selected);+}diff --git a/products/desktop/packages/shared/src/inbox-types.test.ts b/products/desktop/packages/shared/src/inbox-types.test.tsnew file mode 100644index 000000000000..a8ba04ce4af5--- /dev/null+++ b/products/desktop/packages/shared/src/inbox-types.test.ts@@ -0,0 +1,49 @@+import { describe, expect, it } from "vitest";+import type { SourceProduct } from "./inbox-types";+import { filterInboxSourceOptions } from "./inbox-types";++// A minimal mix of native products (session_replay, signals_scout) and+// warehouse-backed products (github, sentry) from the shared registry.+const OPTIONS: { value: SourceProduct }[] = [+ { value: "session_replay" },+ { value: "signals_scout" },+ { value: "github" },+ { value: "sentry" },+];++const values = (+ enabled: ReadonlySet<string> | undefined,+ selected: SourceProduct[] = [],+): SourceProduct[] =>+ filterInboxSourceOptions(OPTIONS, enabled, selected).map((o) => o.value);++describe("filterInboxSourceOptions", () => {+ it.each([+ {+ name: "shows an enabled warehouse source and hides a disabled one",+ enabled: new Set(["github"]),+ selected: [] as SourceProduct[],+ expected: ["session_replay", "signals_scout", "github"],+ },+ {+ name: "keeps PostHog's own products when nothing is enabled",+ enabled: new Set<string>(),+ selected: [] as SourceProduct[],+ expected: ["session_replay", "signals_scout"],+ },+ {+ name: "keeps a disabled source while it is selected",+ enabled: new Set<string>(),+ selected: ["sentry"] as SourceProduct[],+ expected: ["session_replay", "signals_scout", "sentry"],+ },+ {+ name: "hides nothing while the enabled set is unknown",+ enabled: undefined,+ selected: [] as SourceProduct[],+ expected: ["session_replay", "signals_scout", "github", "sentry"],+ },+ ])("$name", ({ enabled, selected, expected }) => {+ expect(values(enabled, selected)).toEqual(expected);+ });+});diff --git a/products/desktop/packages/shared/src/inbox-types.ts b/products/desktop/packages/shared/src/inbox-types.tsindex 58b3f7c547e2..0fe8df9d53d8 100644--- a/products/desktop/packages/shared/src/inbox-types.ts+++ b/products/desktop/packages/shared/src/inbox-types.ts@@ -456,3 +456,30 @@ export function sourceNeedsFullRefresh(recordKind: SignalRecordKind): boolean {export const EXTERNAL_INBOX_SOURCE_BY_PRODUCT: Partial<Record<SourceProduct, ExternalInboxSource>> = Object.fromEntries(EXTERNAL_INBOX_SOURCES.map((s) => [s.product, s]));++const WAREHOUSE_SOURCE_PRODUCTS = new Set<string>(+ EXTERNAL_INBOX_SOURCES.map((source) => source.product),+);++/**+ * Narrow a list of inbox source-filter options to what a project actually uses.+ *+ * The registry carries every warehouse-backed integration (~40) while a project+ * runs a handful, so a warehouse source is kept only when it is switched on, plus+ * anything currently selected so an active filter is never invisible. PostHog's+ * own products stay listed unconditionally. Pass `undefined` when the enabled set+ * is unknown (still loading, or the request failed) to hide nothing.+ */+export function filterInboxSourceOptions<T extends { value: SourceProduct }>(+ options: readonly T[],+ enabledSourceProducts: ReadonlySet<string> | undefined,+ selected: readonly SourceProduct[],+): T[] {+ if (!enabledSourceProducts) return [...options];+ return options.filter(+ (option) =>+ !WAREHOUSE_SOURCE_PRODUCTS.has(option.value) ||+ enabledSourceProducts.has(option.value) ||+ selected.includes(option.value),+ );+}diff --git a/products/desktop/packages/shared/src/index.ts b/products/desktop/packages/shared/src/index.tsindex b078e739c00e..724c2beb6c3c 100644--- a/products/desktop/packages/shared/src/index.ts+++ b/products/desktop/packages/shared/src/index.ts@@ -210,6 +210,7 @@ export type {export {EXTERNAL_INBOX_SOURCE_BY_PRODUCT,EXTERNAL_INBOX_SOURCES,+ filterInboxSourceOptions,sourceNeedsFullRefresh,} from "./inbox-types";export { EXTERNAL_LINKS } from "./links";diff --git a/products/desktop/packages/ui/src/features/inbox/filterOptions.test.ts b/products/desktop/packages/ui/src/features/inbox/filterOptions.test.tsindex 2809e83d2220..dd8b46a2ba1f 100644--- a/products/desktop/packages/ui/src/features/inbox/filterOptions.test.ts+++ b/products/desktop/packages/ui/src/features/inbox/filterOptions.test.ts@@ -1,8 +1,8 @@+import { filterInboxSourceOptions } from "@posthog/shared";import type { AvailableSuggestedReviewer } from "@posthog/shared/types";import { describe, expect, it } from "vitest";import {buildSuggestedReviewerFilterOptions,- filterInboxSourceOptions,getSuggestedReviewerDisplayName,INBOX_SOURCE_OPTIONS,} from "./filterOptions";@@ -65,7 +65,9 @@ describe("getSuggestedReviewerDisplayName", () => {describe("filterInboxSourceOptions", () => {const values = (enabled?: ReadonlySet<string>) =>- filterInboxSourceOptions(enabled, []).map((option) => option.value);+ filterInboxSourceOptions(INBOX_SOURCE_OPTIONS, enabled, []).map(+ (option) => option.value,+ );it("keeps only the warehouse sources that are switched on", () => {expect(values(new Set(["github", "zendesk"]))).toEqual([@@ -92,15 +94,15 @@ describe("filterInboxSourceOptions", () => {});it("keeps a selected source so an active filter stays visible", () => {- expect(filterInboxSourceOptions(new Set(), ["sentry"])).toContainEqual(- expect.objectContaining({ value: "sentry" }),- );+ expect(+ filterInboxSourceOptions(INBOX_SOURCE_OPTIONS, new Set(), ["sentry"]),+ ).toContainEqual(expect.objectContaining({ value: "sentry" }));});it("hides nothing while the enabled set is unknown", () => {- expect(filterInboxSourceOptions(undefined, [])).toEqual(- INBOX_SOURCE_OPTIONS,- );+ expect(+ filterInboxSourceOptions(INBOX_SOURCE_OPTIONS, undefined, []),+ ).toEqual(INBOX_SOURCE_OPTIONS);});});diff --git a/products/desktop/packages/ui/src/features/inbox/filterOptions.tsx b/products/desktop/packages/ui/src/features/inbox/filterOptions.tsxindex 77f591a34c64..4aa00a7375ef 100644--- a/products/desktop/packages/ui/src/features/inbox/filterOptions.tsx+++ b/products/desktop/packages/ui/src/features/inbox/filterOptions.tsx@@ -116,37 +116,6 @@ export const INBOX_SOURCE_OPTIONS: InboxSourceOption[] = [}),];-const EXTERNAL_SOURCE_PRODUCTS = new Set<string>(- EXTERNAL_INBOX_SOURCES.map((source) => source.product),-);--/**- * Narrow the source filter down to what a project actually uses.- *- * The registry carries every warehouse-backed integration we support (~40),- * while a project runs a handful — listing them all makes the filter taller than- * the screen. So warehouse sources are kept only when they are switched on, plus- * anything currently selected, so an active filter is never invisible. PostHog's- * own products stay listed unconditionally: they need no setup, and some- * (Scouts) emit reports without a `signal_source_config` row at all.- *- * Pass `undefined` when the enabled set is unknown (still loading, or the- * request failed) and nothing is hidden — better a long list than a filter that- * silently can't reach a source.- */-export function filterInboxSourceOptions(- enabledSourceProducts: ReadonlySet<string> | undefined,- selected: readonly SourceProduct[],-): InboxSourceOption[] {- if (!enabledSourceProducts) return INBOX_SOURCE_OPTIONS;- return INBOX_SOURCE_OPTIONS.filter(- (option) =>- !EXTERNAL_SOURCE_PRODUCTS.has(option.value) ||- enabledSourceProducts.has(option.value) ||- selected.includes(option.value),- );-}-export function inboxSortOptionKey(field: InboxSortField,direction: "asc" | "desc",diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.tsindex 093cf2d4ab9a..0a7fcda68ef4 100644--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.ts+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.ts@@ -1,6 +1,7 @@+import { filterInboxSourceOptions } from "@posthog/shared";import type { SourceProduct } from "@posthog/shared/types";import {- filterInboxSourceOptions,+ INBOX_SOURCE_OPTIONS,type InboxSourceOption,} from "@posthog/ui/features/inbox/filterOptions";import { useSignalSourceConfigs } from "@posthog/ui/features/inbox/hooks/useSignalSourceConfigs";@@ -17,11 +18,17 @@ export function useInboxSourceFilterOptions(const { data: configs } = useSignalSourceConfigs();return useMemo(() => {- if (!configs) return filterInboxSourceOptions(undefined, selected);+ if (!configs) {+ return filterInboxSourceOptions(+ INBOX_SOURCE_OPTIONS,+ undefined,+ selected,+ );+ }const enabled = new Set<string>();for (const config of configs) {if (config.enabled) enabled.add(config.source_product);}- return filterInboxSourceOptions(enabled, selected);+ return filterInboxSourceOptions(INBOX_SOURCE_OPTIONS, enabled, selected);}, [configs, selected]);}