: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(customer-analytics): link searched feature requests (#104691)
Arthur Moreira de Deus44e941753c7f
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.mdindex 1b49f1ea4eaf..85a97e9940ef 100644--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md@@ -51,7 +51,7 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_TABLE_DATA_NODE_KEY, acc| `accountNotebooksLogic` | Notes/notebooks linked to one account (keyed by `accountId`): server-side pagination (`page`/`notebooksCount`), debounced title+content search (`searchTerm`), sort (`sorting` by created date/author), and `createNote` (creates an internal account notebook and opens it in the side panel). || `accountRelatedUsersLogic` | Group members / related users for one account (keyed by `externalId`). It debounces name and email searches, and owns the table's sort (`sorting`, on `level` or `last_login`) and access-level filter (`levels`); both reset to page 1 and reload. US-region orgs use the org-members endpoint, which takes `search`, `levels` and a whitelisted `ordering`. When it returns no members, the logic falls back to the `eu_org_members` data warehouse view (a materialized pre-join of the EU postgres sync, prod-only), fetched once per expansion then searched, filtered, sorted and paginated in pages of 20 client-side (mirroring the backend's ordering, "never logged in" at the far end). Once a US request has returned members the org is remembered as US-hosted and an empty filtered page is treated as "no match"; until then an empty US page falls back to the EU view, so a filter set before the first load finishes still applies. Both reads supply the member's organization access level and last-login data. EU values refresh daily. The EU view also includes the source Django user ID. Each member carries its source region so staff admin links open the correct user's detail page in the correct cloud. A missing view (local dev) degrades to the normal empty state. || `accountRelationshipsLogic` | Relationship assignments for one account (keyed by `accountId`): fetches the full timeline once (`include_history=true` on the nested relationships endpoint) — the `displayedRelationships` selector (current assignments first, newest first, optionally narrowed by `definitionFilter`) feeds the (paginated) history tab, the `activeRelationships` selector feeds the sidebar summary. Also owns the tab's mutations: `assignRelationship` (definition picker + `MemberSelect`, POSTs the assign endpoint), `endRelationship` (per active row, POSTs the end endpoint), and `deleteRelationship` (admin-only, confirmation-gated hard delete). All mutations share the `relationshipSaving` guard, reload the timeline, and force-refresh the list's data nodes so relationship columns stay in sync. |-| `accountFeatureRequestsLogic` | Feature requests for one account (keyed by `accountId`): loads linked requests in server pages of five with debounced search, then searches a bounded server page of accessible, editable active requests for the link picker. Request links carry the account's Feature requests deep link as their origin, so the detail breadcrumb returns to the same account tab. The picker exposes load failures with retry guidance and refreshes stale options after optimistic-concurrency conflicts. |+| `accountFeatureRequestsLogic` | Feature requests for one account (keyed by `accountId`): loads linked requests in server pages of five with debounced search, then searches a bounded server page of accessible, editable active requests for the link picker. The picker keeps a selected search result available when the select clears its input, so requests outside the default page remain linkable. Request links carry the account's Feature requests deep link as their origin, so the detail breadcrumb returns to the same account tab. The picker exposes load failures with retry guidance and refreshes stale options after optimistic-concurrency conflicts. || `accountBillingLogic` | Billing data behind the Usage and Spend tabs (keyed by `accountId:kind`); injects the account's org + date range into saved billing insights' SQL variables, preloads each insight result when the account expands, and owns the per-view hidden-series state (`ephemeralHiddenSeriesKeysByShortId`) behind the chart chips. || `accountOpportunitiesLogic` | Salesforce opportunities behind the Opportunities tab (keyed by `accountId`): fetches the account's `sfdc_id`, then queries the data-warehouse `salesforce.opportunity` table via HogQL. Degrades to an empty state (not an error) when the table is absent — it's production-only. || `accountSummariesLogic` | The Summaries tab (keyed by `accountId`): fetches the account (for its linked `slack_channel_id` and `slack_summary_cadence`) plus the first page of the `accountsSummariesList` endpoint, navigates server pages via `loadSummariesPage` (5 per page, `page` reducer; each page replaces the last), holds per-summary collapse state (`expandedSummaryIds` / `toggleSummaryExpanded`), and owns the cadence opt-in (`setCadence` PATCHes the account through `accountsPartialUpdate`, guarded by a `cadenceSaving` flag). Turning the cadence on with no summaries yet starts `generatingFirstSummary` polling (`startFirstSummaryPolling` / `stopFirstSummaryPolling`, two `cache.disposables` keys) so the backfill the backend kicks off appears without a refresh; the poll deadline lives in a module-level map keyed by account id, because this logic unmounts whenever its row collapses while the backfill keeps running. Distinguishes not-loaded / no-channel-linked / generating / loaded-empty / load-failed; captures unexpected failures. |diff --git a/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.test.tsindex 516ee40accd2..1c4d4b39d2e1 100644--- a/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.test.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.test.ts@@ -52,19 +52,28 @@ describe('accountFeatureRequestsLogic', () => {jest.restoreAllMocks()})- it('links an existing request without replacing its current accounts', async () => {+ it('links a searched request without replacing its current accounts', async () => {const listSpy = jest.spyOn(generatedApi, 'featureRequestsList').mockResolvedValueOnce(emptyPage)+ .mockResolvedValueOnce(emptyPage).mockResolvedValueOnce({ ...emptyPage, count: 1, results: [existingRequest] })- .mockResolvedValueOnce({ ...emptyPage, count: 1, results: [existingRequest] })+ .mockResolvedValueOnce(emptyPage)const updateSpy = jest.spyOn(generatedApi, 'featureRequestsUpdate').mockResolvedValue(existingRequest)const logic = accountFeatureRequestsLogic({ accountId: 'account-2' })logic.mount()await expectLogic(logic).toFinishAllListeners()await expectLogic(logic, () => logic.actions.openRequestPicker()).toFinishAllListeners()- logic.actions.setSelectedRequestId(existingRequest.id)+ await expectLogic(logic, () => logic.actions.setRequestSearch('scheduled')).toFinishAllListeners()+ await expectLogic(logic, () => {+ logic.actions.setRequestSearch('')+ logic.actions.setSelectedRequestId(existingRequest.id)+ }).toFinishAllListeners()++ expect(logic.values.selectedRequestId).toBe(existingRequest.id)+ expect(logic.values.availableRequests).toEqual([existingRequest])+await expectLogic(logic, () => logic.actions.linkSelectedRequest()).toFinishAllListeners()expect(updateSpy).toHaveBeenCalledWith(String(MOCK_DEFAULT_TEAM.id), existingRequest.id, {diff --git a/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.tsindex c02ebfa8c7db..aa29ab892b8e 100644--- a/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountFeatureRequestsLogic.ts@@ -176,7 +176,7 @@ export const accountFeatureRequestsLogic = kea<accountFeatureRequestsLogicType>(null as string | null,{setSelectedRequestId: (_, { selectedRequestId }) => selectedRequestId,- setRequestSearch: () => null,+ setRequestSearch: (selectedRequestId, { search }) => (search ? null : selectedRequestId),openRequestPicker: () => null,closeRequestPicker: () => null,},@@ -232,7 +232,9 @@ export const accountFeatureRequestsLogic = kea<accountFeatureRequestsLogicType>(},setRequestSearch: async (_, breakpoint) => {await breakpoint(300)- actions.loadAvailableRequests()+ if (!values.selectedRequestId) {+ actions.loadAvailableRequests()+ }},linkSelectedRequest: async () => {if (!values.selectedRequestId || values.linkingRequest) {