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.

feat(signals): recommend external sources under the roster (#120322)

Georgiy Tarasov0371749d6711
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f6e5c3f84012..377f42cfdec1 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -11803,9 +11803,9 @@ snapshots:
scenes-app-inbox-scene--self-driving-verdict-pending--light:
hash: v1.k794b7964.96cdbec6c78e8daedb06be4a0134093efcd5838af69e6e7d1722a3892cf561b5.iJ2K0zNhOVgGAPY6JvduyhDBODMwk-CN7_mAdB8scOg
scenes-app-inbox-scene--settings--dark:
- hash: v1.k794b7964.612c957c2cd6be3aacf8474108905309288515d8b9df4b55349af9cc46bd8db1.a8ySvmj0vf7FuB26LbmFYbJAm9h7B_6MDAM1pDxLKBQ
+ hash: v1.k794b7964.29c22df959c46eea8ed7aca17ae08ed2baa06434debacc36dbc8fde60463a546.5tR2C3x_gzXCnAXzxIV0bVzkIZ3SCAKy7ZoVCWvINR0
scenes-app-inbox-scene--settings--light:
- hash: v1.k794b7964.8f37c5b61160f9dff684aa6a1118005f609297319e926ab1d6adac8ffa811a1d.vX6fnQvxLtMMrSAm-dDjuRRwN2AL-nZQdw1J5UXzbnE
+ hash: v1.k794b7964.d1bc08b77d8d3d6c1a9c199ddf804dbed27ed4a41ffb6acac1510c1215f1ab02.0jNsBlhNTXyiOP7lSAxBBLBsEF3vzoXQl71PHtEr1o0
scenes-app-inbox-scene--triage--dark:
hash: v1.k794b7964.77e43b36fdcd81befecf4de80e489050f525840924ec6ddef37c23a9179dbe8a.B3qkZFYBncFaPn2EBg4cBoYu_LIwW29imNwBdLXF5eo
scenes-app-inbox-scene--triage--light:
@@ -12391,57 +12391,57 @@ snapshots:
scenes-app-inbox-signal-cards--ticket-without-number--light:
hash: v1.k794b7964.015ae3204d23d033c3a0b131e352122cbc3cfa019f66f8f230f059b100f8f2cc.ZMT3pKT2QFcOr116n_hOXdGWTMc0uwzvvfj8DVcWurM
scenes-app-inbox-signalsourcespanel--armed-but-products-off--dark:
- hash: v1.k794b7964.d9e1c2afb6f581f8b4c52431419f301a9ede3ace72af3c68833446a82e60a878.19TmWp9UJVMxXizkSUzcHxmGrFkTyXBwEmkxgs_rtPA
+ hash: v1.k794b7964.3fca5271769b28e9dd438daea15374c0eaeb48fb0c410837abe14cd49405113c.AQNxOcFjiI12qmNuT8XFUa8lLcDw-0M90ek6Yfrq0nA
scenes-app-inbox-signalsourcespanel--armed-but-products-off--light:
- hash: v1.k794b7964.c58c22bdf4320e2f5f5745ad2748bd8ee5f44a64ad9ad11dd59f4eb53ded1155.WtmvAHN3f0h7s6wBQeoeku7KZX1E9qtZOV5nRwSwaOI
+ hash: v1.k794b7964.9e0c4247b06eb6f81795eebf17fabcf97eb6a43de695fa832a06a14b08ddfd36.0IpgpcQMhel6LYGGrgvzzphI-_0LbilwfvFOHwjRE5Q
scenes-app-inbox-signalsourcespanel--arming-blocked--dark:
- hash: v1.k794b7964.1940ec0e00f18c0d9f69897f9653c85d4d91e8cb0529f0d01383adf4eaaef1fc.mmO8Ex3cycW_9Yuec9rKYO6VcCcuJM_hTGzY0VIActU
+ hash: v1.k794b7964.27bdcfc55aeed00e5e9897f803173dd5e400774320ec1af848c1c3c795c3189b.RP0oJQScotluRcqlgjHQGuKCD6mT21sCrxsbWnZu4Lo
scenes-app-inbox-signalsourcespanel--arming-blocked--light:
- hash: v1.k794b7964.44f5e8776f4772718f5e48859612f5b3755bb2d983b683faadc4663b8f699862.NMhn6QkLpktRDDw3BQB_RiAMbxRhp6bZjoWdqeferb0
+ hash: v1.k794b7964.784faabfcb8007037d6799b7d2dae91943fef74763ad810ff71befff7ff6bf48.D5eqByskPTPE8q2iVo2Z8ACgAMqzstlgfGsstwAVrvU
scenes-app-inbox-signalsourcespanel--error-tracking-expanded--dark:
- hash: v1.k794b7964.7dde345e874d3bdbebe9771dafea12cd7e864725a82dcc3c0f316795d12c9d50.K9IoHt3jSnBEahbNFu0N2tZywxb1C5pof73cNr8l3UE
+ hash: v1.k794b7964.a0839fa0fb26c8a0581dd68ca484bc8643e2af6114da7e07347868739ed52f21.AdN3N9h810sVQw-h-zf3ro4Yhn8HDX88vQ68aRyfEhk
scenes-app-inbox-signalsourcespanel--error-tracking-expanded--light:
- hash: v1.k794b7964.bc2f68514bc26966b8b79cd8a31d7258099dee2b591ec8837b081395c5c5d0ef.QQbW6kVDyzyuE1fYGYHsG0s-09hNK_qyzpa35jScxYM
+ hash: v1.k794b7964.44fae06ba16b10327c6d038a633dda3127bbb7ba118e81890b98333b04789059.GM1N_dUTzLnkvJVZJ4ClWPavvzaPb104BOLC38GFVcY
scenes-app-inbox-signalsourcespanel--event-definitions-unavailable--dark:
- hash: v1.k794b7964.b98d54eded5a8ed6ac21341da9a289bea6a0271dedd4c1c73561a970b434896e.P0rfnaWExtCCXG3N9pmVfUIQqhw19hCFK9iVd_KrRoI
+ hash: v1.k794b7964.13e6f7e5b4951e8ecf59eda646bca88f6754cf74c03618a61f762838c78ee377.J1WX3OFzITVT4oMxD5ZwQ9EBfjiEff2KsbGwDt6NaQQ
scenes-app-inbox-signalsourcespanel--event-definitions-unavailable--light:
- hash: v1.k794b7964.72e096179ea9a037671e0cdbf8cc12b35c0ca67d9080b7a7b4a3c8f58392770c.I-GXCnNUh2ZRmBJvnGYuMa7FqhTe0t8sD4vqghYN_mc
+ hash: v1.k794b7964.738f49cf8a3fbde67ad7a5a778f00a5eb5b0f31c7d16b5bc8ba4ec0e69aa6aaa.mWWVP3af5YfB9iD6YYbaZBz5Tl2s6iDT_ovanI9Rft4
scenes-app-inbox-signalsourcespanel--everything-healthy--dark:
- hash: v1.k794b7964.c34f61a0c04f89820537b1bf5498a7f238a113506efc75ce33a88f4fa941ae81.mX71hzhWonRB1u71FX2hrkU4rJ8l3bnZo07w3NAaWbc
+ hash: v1.k794b7964.721e76e08aea0742286b822d3a5946bcc6f79f18325ad8fd34d4cdd76b837512.Np9JRKRWMTLZVNT7QCug-DxEeyQxk7SZJyrSKF6Yv5A
scenes-app-inbox-signalsourcespanel--everything-healthy--light:
- hash: v1.k794b7964.4295ef3035ff47a0427900b19b3dfd7d9cdc7742eb59ba9a6e4c26fd25396df4.3UQqYdePooSWMuZG10Kj8Zjuc-hQLUSCn68St2BHNfY
+ hash: v1.k794b7964.b0173ec379ef4ae25fb5b7e76cc71e902226b924f7c32aeb310f4bf9b5a22eed.qrMcTRSwE1vZ2WHdNxcWTPROEQ4_VvbsDGGYZmoWBaY
scenes-app-inbox-signalsourcespanel--external-sources-connected--dark:
- hash: v1.k794b7964.8484a7ec658e1b397c8289a1b3f5c2e30d188b534274fc36b2f7e24bc0cf338b.LafX61fiDOHPQKLwS2KV6DSJeVa4TRHBRWe3ql530xU
+ hash: v1.k794b7964.5ba434ed18fab56f3a359137663e711abd9bf381430a4f0ad89787b2eddaa4b4.MQrcKwjwMM2lT9ipaepSWS0vAZV011-oVWkmiJMknmY
scenes-app-inbox-signalsourcespanel--external-sources-connected--light:
- hash: v1.k794b7964.0dd2ea8c18149d0034f469c4a7213c42e5b11f5e113fd82e5e144a1270462df9.d7yUMu-2-FeG6QV6fyB9aX7QFFeaHbdVL0wZWzuPM2c
+ hash: v1.k794b7964.a926c58ef67a5e74ed94130ad3f601746fa833b02766286836f20dacbba393ab.dAtaLvOklsZDoZ2TCDeqoISYFhCQS9bOCKxZmhPaIoI
scenes-app-inbox-signalsourcespanel--playground--dark:
- hash: v1.k794b7964.105ae0aa2757615d0382ed469bf144c50cddd7ce4a3cda18f30a0722b371e6fe.M73GXlC31bXcY0KxKIMmUoxXb9NgzYTKwUBpS_kxdMU
+ hash: v1.k794b7964.bf110bfc524865eeca246465b9d77b2c459ef174adc30467846eb4da336e7d34.7c-aS8AlUPb7I6Kl0UZUMyTLlHb6RCAApiFNs0Hm2y4
scenes-app-inbox-signalsourcespanel--playground--light:
- hash: v1.k794b7964.b17a619d4c5f4991ac6c39de9a7058181f2c6b1dbd1a08d72282fc196d0b1643.aFOD39BqPd7z2E0o5LcO0QuH-u_y5Eo9eC5vXHRt6J8
+ hash: v1.k794b7964.94f72a200e5f1bb4473a4898e797cb9204c09312c013115b4b9a6b0a26963c84.5SaEJhSjL_XmMORB0BEOCv8Ev0-agnQ4ihWFkkri9zk
scenes-app-inbox-signalsourcespanel--products-on-no-recent-data--dark:
- hash: v1.k794b7964.f7e2b82fc929c83d24de2615c4c5fee6ba4f1588a95fd2c59258b452029222b7.tjwKh7VLzhwMkw9qNTl5DowACTnugEW2xTr8cTxqT0c
+ hash: v1.k794b7964.52659244c3ef80d5c33a16a7d65e8421905f58de01727344317bb30229db837d.7AFDHv1nJGkdXqIf0nYNdAflka5_U70A91xEtoIVqgY
scenes-app-inbox-signalsourcespanel--products-on-no-recent-data--light:
- hash: v1.k794b7964.1b9f6d3818076c1c4e4ad45d61af019739d80a4d2abd09d3f0c7b30485b1e114.OADuXVe7AHjh2hpmzW04hqOO5s0QPDlP7Jy_CdxVSZ8
+ hash: v1.k794b7964.72cbd2e313fc35be228cc8d59c35a8523ddec78d5aee442ef81acfd9204e88b5.CZwszynRpltH9_1D-WNG352VoCdEI4NG-XDL0HGp6WM
scenes-app-inbox-signalsourcespanel--replay-vision-expanded--dark:
- hash: v1.k794b7964.511e08623fcced57d221aefdae525351f176705e7fb05c7055ccb0c9a4e8cbbf.EdKWKqrddDSF9D5I-GchSL46n37W2YgsosAmidGN1Z8
+ hash: v1.k794b7964.ba0d4a995c904ca03cbb6dad663d6ba1e2abd4095b1a1f836d58fd75794e6fb0.KGmccMtnWXoZRmpecPVaEkIx0tPzenYRz6Il3KoJiQ8
scenes-app-inbox-signalsourcespanel--replay-vision-expanded--light:
- hash: v1.k794b7964.492798d45d4b94b51562e0a1387ff4a4722046dcdf3079ad1b252e85aa31f217.Yh9JG6ocJT9Nsvl01aT1xWuBm2KQoedqk5UfYuedYSQ
+ hash: v1.k794b7964.02fe2dffc5449a718f2c1c42e1e8e6a4abd22794e26e62097843ebc115603646.8NKMbqb5bpr-AFMdyC-kc9IsJVZIN32FuH8fYXN25lA
scenes-app-inbox-signalsourcespanel--server-side-exceptions-only--dark:
- hash: v1.k794b7964.105ae0aa2757615d0382ed469bf144c50cddd7ce4a3cda18f30a0722b371e6fe.rW1i1pQTYXfhcI4jbV4L1SwTnDrV0dKRKIA9CpbKAH0
+ hash: v1.k794b7964.bf110bfc524865eeca246465b9d77b2c459ef174adc30467846eb4da336e7d34.ZW_phUEs0NjXeJs57usDCZmho0FEu_uiUPmP9bxD1Jw
scenes-app-inbox-signalsourcespanel--server-side-exceptions-only--light:
- hash: v1.k794b7964.b17a619d4c5f4991ac6c39de9a7058181f2c6b1dbd1a08d72282fc196d0b1643.iiyP7ijQDhrG7Lhzf5qnyzBL1NZ846qpyVx-N1umb3U
+ hash: v1.k794b7964.94f72a200e5f1bb4473a4898e797cb9204c09312c013115b4b9a6b0a26963c84.h3aFSiKjy360WInAdpsftUNOxF9T_IFbYEyYslw0-Os
scenes-app-inbox-signalsourcespanel--source-catalog-connect-step--dark:
- hash: v1.k794b7964.a2450493dcc246c5364fadecbc076f8a6431fa3cb54a24ce8a43f0035755b3ee.-SefbiFHh2vb_iXB1G3qGt44u-4xuonKH1IKJTLRakg
+ hash: v1.k794b7964.be0afcd2c78ebbcf5e9be1936f2afa60b104a521c37673792d7b1c2763c70eeb.9D-GQZ4BdzLnqkH-sfZqQjBQoleqJM4dhL1lgafAFnI
scenes-app-inbox-signalsourcespanel--source-catalog-connect-step--light:
- hash: v1.k794b7964.28e1842012dfa855088912c8bed000371f0f09b715e9262140d07cd8e881abc4.2oNwX1CeRfidWC1ENlOQQRvuM_6cBG6R5ALLO_gYJc4
+ hash: v1.k794b7964.306fb23c439334374b9ceae47f242edb0ba2cbf9313d255a6f0aac54fd038d16.829n9nWezXS75jPieMDpWOhWmkDuY5xq5I0OD4Mu5zA
scenes-app-inbox-signalsourcespanel--source-catalog-open--dark:
- hash: v1.k794b7964.2d397ce4347aadd97b4e2baad327b921c7c2010cc88dc4e11508806a405c5d78.wyrvp4I9i9p7m_VrTSj3TZdRouB8Zmp9q9mrgq1u4dw
+ hash: v1.k794b7964.efdda8fab343620e712a4a3a175f9edba29bca8d357b782a1e1314d4d415b72d.ovnA51MpkfwdYND0NKTR_eqT5eRBinJbDgYZOEJ51SE
scenes-app-inbox-signalsourcespanel--source-catalog-open--light:
- hash: v1.k794b7964.6e91eac66df908a8a883f0dc2d26050f2f3f7e79ecd712a21127d86075275255.IHGjK77PkD_0Xlg1WNkBwLfqnR5MLpDn-04Coq5yNM8
+ hash: v1.k794b7964.fa6bcc0a684aaa46bfc102ea0a879c0af8f183b9206a6ef27f0f2d53a72d5519.uZKA01NAcf5kZObXT0QW0LNbRtD7eFhoeXVHR3Po2Hc
scenes-app-inbox-signalsourcespanel--source-configs-unavailable--dark:
- hash: v1.k794b7964.92b8f268a6960dcae3191f35a90160ae2170c0f03e004fdc28952c0a904cc7fa.79B_OJa_MZq3NEfccSPuVfy1vWDdhkgqZ5tikDAJGwM
+ hash: v1.k794b7964.db9d51d553a1b00cc491773f3eb1f200e8aed4c380649d5bf536ff424ab97d2d.SQ7oPEEK3Ndguww2v2PCgeBbURlHxtKheOjR0BQs_us
scenes-app-inbox-signalsourcespanel--source-configs-unavailable--light:
- hash: v1.k794b7964.676f807c36752746f961938e31ba18b296067a6987b9adc2e9f91e4d94402ccf.jmRK6LLUX-xyeplh2X3mdIcJJCflVuLr41fhAER3uI0
+ hash: v1.k794b7964.2c21e1c09151d0120c47387c405b130974fc7748614f5a6133953af502e6ffca.ASXnJaUcEqHGXTiflpitXSGM3P_CLT9cberwhmxnwlI
scenes-app-inbox-slacknotificationssection--awaiting-target--dark:
hash: v1.k794b7964.45b41fad1dd8b6146ff7465279bf86d9e32f5447d189a1c54f687a6d729ee1fc._HO_rqQTGcO42B-T57VXA3yJ8kNYSWXBP-VFz8iS690
scenes-app-inbox-slacknotificationssection--awaiting-target--light:
diff --git a/products/signals/frontend/inbox/components/config/AgentsRoster.test.tsx b/products/signals/frontend/inbox/components/config/AgentsRoster.test.tsx
index af546a42911d..ca49fffd0fbd 100644
--- a/products/signals/frontend/inbox/components/config/AgentsRoster.test.tsx
+++ b/products/signals/frontend/inbox/components/config/AgentsRoster.test.tsx
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom'
-import { cleanup, render, screen, waitFor } from '@testing-library/react'
+import { cleanup, render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { FEATURE_FLAGS } from 'lib/constants'
@@ -54,6 +54,7 @@ describe('AgentsRoster', () => {
],
'/api/projects/:team_id/event_definitions/': () => [200, EMPTY_LIST],
'/api/environments/:team_id/external_data_sources/': () => [200, EMPTY_LIST],
+ '/api/environments/:team_id/integrations/': () => [200, EMPTY_LIST],
'/api/projects/:team_id/external_data_sources/wizard/': () => [200, { GitLab: GITLAB_WIZARD_CONFIG }],
},
})
@@ -82,6 +83,9 @@ describe('AgentsRoster', () => {
const jiraToggle = await screen.findByLabelText('Turn on Jira')
expect(jiraToggle.closest('[data-attr="signal-source-row"]')).toHaveAttribute('data-source', 'jira')
expect(document.querySelector('[data-attr="signal-source-row"][data-source="github"]')).toBeNull()
+ const recommendations = await screen.findByTestId('signal-source-recommendations')
+ expect(within(recommendations).getByText('Jira')).toBeInTheDocument()
+ expect(within(recommendations).getByText('Turn on')).toBeInTheDocument()
await userEvent.click(screen.getByText('Add source'))
expect(await screen.findByText('Add a source')).toBeInTheDocument()
@@ -157,6 +161,7 @@ describe('AgentsRoster', () => {
expect(await screen.findByText(/Couldn't load your signal sources/)).toBeInTheDocument()
expect(screen.getByLabelText('Arm Support')).toBeDisabled()
+ expect(screen.queryByTestId('signal-source-recommendations')).not.toBeInTheDocument()
await userEvent.click(screen.getByText('Add source'))
await screen.findByText('Add a source')
await userEvent.type(screen.getByLabelText('Search sources'), 'GitHub issues')
diff --git a/products/signals/frontend/inbox/components/config/AgentsRoster.tsx b/products/signals/frontend/inbox/components/config/AgentsRoster.tsx
index d2031250e8e7..3805620c0bdd 100644
--- a/products/signals/frontend/inbox/components/config/AgentsRoster.tsx
+++ b/products/signals/frontend/inbox/components/config/AgentsRoster.tsx
@@ -26,6 +26,7 @@ import { AGENT_ROSTER_GROUPS, AgentRosterDefinition, AgentRosterGroup, AgentRost
import { LinearTeamsModal } from './LinearTeamsModal'
import { SourceAgentIcon } from './SourceAgentIcon'
import { SourceCatalogModal } from './SourceCatalogModal'
+import { SourceRecommendations } from './SourceRecommendations'
import { SourceSteeringModal } from './SourceSteeringModal'
type AgentRosterStatus = 'standby' | 'watching' | 'syncing' | 'sync_failed'
@@ -612,6 +613,7 @@ export function AgentsRoster(): JSX.Element {
const {
externalSourceStates,
rosterGroups,
+ visibleSourceRecommendations,
sourcesLoadError,
dataWarehouseSourcesLoading,
conversationsConfig,
@@ -642,6 +644,7 @@ export function AgentsRoster(): JSX.Element {
} = useValues(signalSourcesLogic)
const {
openSourceCatalog,
+ hideSourceRecommendations,
loadSources,
openLinearTeamsPicker,
closeLinearTeamsPicker,
@@ -967,28 +970,49 @@ export function AgentsRoster(): JSX.Element {
{rosterGroups.map((group) => (
<div key={group.label} className="flex flex-col gap-2 pt-2">
- <div className="flex items-center justify-between gap-2">
+ <div className="flex flex-wrap items-center justify-between gap-2">
<AgentRosterGroupHeader group={group} />
{group.id === 'external' && (
+ <div className="flex flex-wrap items-center gap-1">
+ {group.agents.length === 0 && visibleSourceRecommendations.length > 0 && (
+ <LemonButton
+ type="tertiary"
+ size="xsmall"
+ onClick={hideSourceRecommendations}
+ data-attr="signal-source-recommendations-hide"
+ >
+ Hide recommendations
+ </LemonButton>
+ )}
+ <LemonButton
+ type="secondary"
+ size="xsmall"
+ icon={<IconPlus />}
+ onClick={openSourceCatalog}
+ data-attr="signal-source-catalog-open"
+ >
+ Add source
+ </LemonButton>
+ </div>
+ )}
+ </div>
+ {group.agents.length > 0 && (
+ <div className="-mx-2 divide-y divide-primary">{group.agents.map(renderAgent)}</div>
+ )}
+ {group.id === 'external' && group.agents.length > 0 && visibleSourceRecommendations.length > 0 && (
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <h4 className="m-0 text-sm font-semibold">Recommended for you</h4>
<LemonButton
- type="secondary"
+ type="tertiary"
size="xsmall"
- icon={<IconPlus />}
- onClick={openSourceCatalog}
- data-attr="signal-source-catalog-open"
+ onClick={hideSourceRecommendations}
+ data-attr="signal-source-recommendations-hide"
>
- Add source
+ Hide recommendations
</LemonButton>
- )}
- </div>
- {group.id === 'external' && group.agents.length === 0 ? (
- <p className="mb-0 rounded border border-dashed border-primary px-3 py-2.5 text-xs text-secondary">
- No external sources yet. Add one to let agents read the issues, tickets, and feedback in the
- tools you already use.
- </p>
- ) : (
- <div className="-mx-2 divide-y divide-primary">{group.agents.map(renderAgent)}</div>
+ </div>
)}
+ {group.id === 'external' && <SourceRecommendations />}
</div>
))}
diff --git a/products/signals/frontend/inbox/components/config/SignalSourcesPanel.stories.tsx b/products/signals/frontend/inbox/components/config/SignalSourcesPanel.stories.tsx
index 8698e064c9ba..af757fe58dfa 100644
--- a/products/signals/frontend/inbox/components/config/SignalSourcesPanel.stories.tsx
+++ b/products/signals/frontend/inbox/components/config/SignalSourcesPanel.stories.tsx
@@ -440,7 +440,7 @@ export const ErrorTrackingExpanded: Story = {
},
}
-/** Connected tools in the roster: GitHub on, Sentry failing, Jira synced but off. */
+/** Connected tools in the roster, with Jira (synced but off) and two category gaps recommended under it. */
export const ExternalSourcesConnected: Story = {
args: { externalConnections: true },
}
diff --git a/products/signals/frontend/inbox/components/config/SourceRecommendations.tsx b/products/signals/frontend/inbox/components/config/SourceRecommendations.tsx
new file mode 100644
index 000000000000..4bb941044174
--- /dev/null
+++ b/products/signals/frontend/inbox/components/config/SourceRecommendations.tsx
@@ -0,0 +1,75 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonButton, LemonTag } from '@posthog/lemon-ui'
+
+import { isExternalSignalSource } from '../../externalSignalSources'
+import { WarehouseBackedSource, signalSourcesLogic } from '../../signalSourcesLogic'
+import { SourceRecommendation } from '../../sourceRecommendations'
+import { SourceAgentIcon } from './SourceAgentIcon'
+
+function recommendationDescription({ agent, reason, description }: SourceRecommendation): string {
+ switch (reason) {
+ case 'synced':
+ return 'Already syncing to your warehouse, so watching turns on with one click.'
+ case 'integration':
+ return 'Already connected to PostHog. Agents can start reading it right away.'
+ case 'default':
+ return description ?? agent.watches
+ }
+}
+
+export function SourceRecommendations(): JSX.Element | null {
+ const { visibleSourceRecommendations, externalSourceStates, isCiSignalsToggling } = useValues(signalSourcesLogic)
+ const { selectCatalogSource } = useActions(signalSourcesLogic)
+
+ if (visibleSourceRecommendations.length === 0) {
+ return null
+ }
+
+ return (
+ <div
+ className="grid grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] gap-2"
+ data-attr="signal-source-recommendations"
+ >
+ {/* auto-fill keeps the empty tracks, so one or two cards stay card-sized rather than stretching across the row. */}
+ {visibleSourceRecommendations.map((recommendation) => {
+ const { agent, reason } = recommendation
+ const source = agent.source as WarehouseBackedSource
+ const state = isExternalSignalSource(source) ? externalSourceStates[source] : null
+ const loading = state ? state.loading : isCiSignalsToggling
+ return (
+ <div
+ key={agent.source}
+ className="flex flex-col gap-2 rounded border border-primary bg-surface-secondary p-3"
+ data-attr="signal-source-recommendation"
+ data-source={agent.source}
+ >
+ <div className="flex items-center gap-2">
+ <SourceAgentIcon agent={agent} />
+ <span className="truncate text-sm font-medium">{agent.label}</span>
+ {agent.alpha && (
+ <LemonTag type="completion" size="small">
+ Alpha
+ </LemonTag>
+ )}
+ </div>
+ <p className="mb-0 flex-1 text-xs leading-4 text-secondary">
+ {recommendationDescription(recommendation)}
+ </p>
+ <LemonButton
+ type="secondary"
+ size="xsmall"
+ className="self-start"
+ loading={loading}
+ disabledReason={state?.blockedReason}
+ onClick={() => selectCatalogSource(source, 'recommendation')}
+ data-attr="signal-source-recommendation-action"
+ >
+ {reason === 'synced' ? 'Turn on' : 'Connect'}
+ </LemonButton>
+ </div>
+ )
+ })}
+ </div>
+ )
+}
diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.ts
index 3087368d71ab..567e9dff599a 100644
--- a/products/signals/frontend/inbox/inboxAnalytics.ts
+++ b/products/signals/frontend/inbox/inboxAnalytics.ts
@@ -830,18 +830,29 @@ export function captureSignalSourceInterest(source: string): void {
captureInboxEvent(INBOX_EVENTS.SOURCE_INTEREST, { source })
}
-export type SignalSourceCatalogOrigin = 'catalog'
+export type SignalSourceCatalogOrigin = 'catalog' | 'recommendation'
/** The add-source catalog opened. Pairs with {@link captureSignalSourceConnected} to show how many opens end in a connection. */
-export function captureSignalSourceCatalogOpened(params: { connectedCount: number }): void {
- captureInboxEvent(INBOX_EVENTS.SOURCE_CATALOG_OPENED, { connected_count: params.connectedCount })
+export function captureSignalSourceCatalogOpened(params: {
+ recommendationCount: number
+ connectedCount: number
+}): void {
+ captureInboxEvent(INBOX_EVENTS.SOURCE_CATALOG_OPENED, {
+ recommendation_count: params.recommendationCount,
+ connected_count: params.connectedCount,
+ })
}
export function captureSignalSourceCatalogSourceSelected(params: {
source: string
origin: SignalSourceCatalogOrigin
+ reason: string | null
}): void {
- captureInboxEvent(INBOX_EVENTS.SOURCE_CATALOG_SOURCE_SELECTED, { source: params.source, origin: params.origin })
+ captureInboxEvent(INBOX_EVENTS.SOURCE_CATALOG_SOURCE_SELECTED, {
+ source: params.source,
+ origin: params.origin,
+ recommendation_reason: params.reason,
+ })
}
/**
diff --git a/products/signals/frontend/inbox/signalSourcesLogic.test.ts b/products/signals/frontend/inbox/signalSourcesLogic.test.ts
index febefec752e8..2cf47068e3f6 100644
--- a/products/signals/frontend/inbox/signalSourcesLogic.test.ts
+++ b/products/signals/frontend/inbox/signalSourcesLogic.test.ts
@@ -7,15 +7,23 @@ import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
import { FEATURE_FLAGS } from 'lib/constants'
+import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { teamLogic } from 'scenes/teamLogic'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { AccessControlLevel, ExternalDataJobStatus, ExternalDataSource, ExternalDataSourceSchema } from '~/types'
+import {
+ AccessControlLevel,
+ ExternalDataJobStatus,
+ ExternalDataSource,
+ ExternalDataSourceSchema,
+ IntegrationType,
+} from '~/types'
import { sourcesDataLogic } from 'products/data_warehouse/frontend/shared/logics/sourcesDataLogic'
+import type { InboxOnboardingDraftApi, InboxOnboardingStateApi } from '../generated/api.schemas'
import { signalSourcesLogic } from './signalSourcesLogic'
import { SignalSourceProduct, SignalSourceType } from './types'
@@ -67,6 +75,15 @@ const githubIssuesConfig = {
status: null,
}
+const declinedJiraDraft: InboxOnboardingDraftApi = {
+ step: 'github',
+ sources: [{ source_product: 'jira', source_type: 'issue', enabled: false }],
+ scanner_ids: [],
+ suggestions: [],
+ automatic_implementation: false,
+ implementation_priority: 'P1',
+}
+
function deferred<T>(): { promise: Promise<T>; resolve: (value: T) => void } {
let resolvePromise!: (value: T) => void
const promise = new Promise<T>((resolve) => {
@@ -78,11 +95,14 @@ function deferred<T>(): { promise: Promise<T>; resolve: (value: T) => void } {
describe('signalSourcesLogic', () => {
let logic: ReturnType<typeof signalSourcesLogic.build>
let warehouseSources: ExternalDataSource[]
+ let onboardingState: InboxOnboardingStateApi
beforeEach(() => {
warehouseSources = []
+ onboardingState = { draft: null, completed_at: null, variant: null }
useMocks({
get: {
+ '/api/projects/:team_id/signals/onboarding/': () => [200, onboardingState],
'/api/environments/:team_id/external_data_sources/': () => [
200,
{ results: warehouseSources, count: warehouseSources.length, next: null, previous: null },
@@ -282,23 +302,99 @@ describe('signalSourcesLogic', () => {
createConfig.mockRestore()
})
- // The roster shows what runs and the catalog shows the rest. A regression that lists the whole
- // registry in the roster again, or filters the catalog wrong, fails here.
- it('rosters connected sources and filters the catalog', () => {
+ it.each([
+ { status: 200, reason: 'integration' },
+ { status: 500, reason: 'default' },
+ ])('waits for integrations before recommending sources, with a $status response', async ({ status, reason }) => {
+ await expectLogic(logic).toFinishAllListeners()
+ const response = deferred<void>()
+ useMocks({
+ get: {
+ '/api/environments/:team_id/integrations/': async () => {
+ await response.promise
+ return status === 200
+ ? [200, { results: [{ id: 1, kind: 'github' }], next: null }]
+ : [500, { detail: 'Server error' }]
+ },
+ },
+ })
+ integrationsLogic.actions.clearIntegrations()
+ integrationsLogic.actions.loadIntegrations()
logic.actions.loadSourceConfigsSuccess([])
+ sourcesDataLogic.actions.loadSourcesSuccess({ results: [], next: null, previous: null })
+
+ expect(logic.values.visibleSourceRecommendations).toEqual([])
+
+ response.resolve()
+ await expectLogic(integrationsLogic).toFinishAllListeners()
+ expect(logic.values.visibleSourceRecommendations.find(({ agent }) => agent.source === 'github')).toMatchObject({
+ reason,
+ })
+ })
+
+ // The roster shows what runs and the catalog shows the rest, with the recommendations built only
+ // once both the configs and the connections are known. A recommendation computed from a half-loaded
+ // picture would tell someone to connect a tool they already sync.
+ it('rosters connected sources, filters the catalog, and recommends by effort once everything has loaded', () => {
+ integrationsLogic.actions.loadIntegrationsSuccess([{ id: 1, kind: 'github' } as IntegrationType])
+ logic.actions.loadSourceConfigsSuccess([
+ {
+ ...githubIssuesConfig,
+ id: 'conversations_ticket',
+ source_product: SignalSourceProduct.Conversations,
+ source_type: SignalSourceType.Ticket,
+ enabled: true,
+ },
+ ])
+ expect(logic.values.recommendedSources).toEqual([])
+
+ const recommended = (): string[][] =>
+ logic.values.visibleSourceRecommendations.map(({ agent, reason }) => [agent.source, reason])
+ sourcesDataLogic.actions.loadSourcesSuccess({ results: [], next: null, previous: null })
+ expect(recommended()).toEqual([
+ ['github', 'integration'],
+ ['linear', 'default'],
+ ])
+
+ logic.actions.loadOnboardingStateSuccess({
+ draft: declinedJiraDraft,
+ completed_at: '2024-03-10T00:00:00Z',
+ variant: 'test-ui',
+ })
sourcesDataLogic.actions.loadSourcesSuccess({
results: [
- { ...githubSource, source_type: 'Jira' },
- { ...githubSource, id: 'source-gitea', source_type: 'Gitea' },
+ { ...githubSource, source_type: 'Jira', created_at: '2024-03-01T00:00:00Z' },
+ { ...githubSource, id: 'source-gitea', source_type: 'Gitea', created_at: '2024-03-20T00:00:00Z' },
],
next: null,
previous: null,
})
- expect(
- logic.values.rosterGroups.find((group) => group.id === 'external')?.agents.map((agent) => agent.source)
- ).toEqual(['jira', 'gitea'])
+ const external = (): string[] =>
+ logic.values.rosterGroups.find((group) => group.id === 'external')?.agents.map((agent) => agent.source) ??
+ []
+ expect(external()).toEqual(['jira', 'gitea'])
expect(logic.values.externalSourceStates.jira).toMatchObject({ connected: true, requiresSetup: false })
expect(logic.values.externalSourceStates.sentry).toMatchObject({ connected: false, requiresSetup: true })
+ expect(recommended()).toEqual([
+ ['gitea', 'synced'],
+ ['github', 'integration'],
+ ])
+
+ const connectedSources = (['Gitea', 'Bugsnag', 'Honeybadger', 'Raygun'] as const).map((source_type) => ({
+ ...githubSource,
+ id: source_type,
+ source_type,
+ }))
+ sourcesDataLogic.actions.loadSourcesSuccess({ results: connectedSources, next: null, previous: null })
+ expect(recommended()).toHaveLength(4)
+ logic.actions.hideSourceRecommendations()
+ expect(recommended()).toEqual([])
+ sourcesDataLogic.actions.loadSourcesSuccess({
+ results: [...connectedSources, { ...githubSource, id: 'rollbar', source_type: 'Rollbar' }],
+ next: null,
+ previous: null,
+ })
+ expect(recommended()).toEqual([['rollbar', 'synced']])
featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.ENGINEERING_ANALYTICS]: true })
expect(logic.values.sourceCategoryOptions).toContainEqual({ label: 'Engineering', value: 'Engineering' })
@@ -320,6 +416,55 @@ describe('signalSourcesLogic', () => {
expect(logic.values.rosterGroups.find((group) => group.id === 'posthog')?.agents.length).toBeGreaterThan(0)
})
+ it.each([
+ { name: 'control completion', variant: 'control' as const, draft: null, expected: ['jira'] },
+ {
+ name: 'completion without a source choice',
+ variant: 'test-ui' as const,
+ draft: { ...declinedJiraDraft, sources: [] },
+ expected: ['jira'],
+ },
+ { name: 'an explicit source rejection', variant: 'test-ui' as const, draft: declinedJiraDraft, expected: [] },
+ ])('refreshes recommendations after $name', async (state) => {
+ warehouseSources = [{ ...githubSource, source_type: 'Jira', created_at: '2024-03-01T00:00:00Z' }]
+ onboardingState = { variant: state.variant, draft: state.draft, completed_at: null }
+ sourcesDataLogic.actions.loadSourcesSuccess({ results: warehouseSources, next: null, previous: null })
+ await expectLogic(logic, () => logic.actions.loadSourceConfigs()).toFinishAllListeners()
+ expect(logic.values.visibleSourceRecommendations.map(({ agent }) => agent.source)).toEqual(['jira'])
+
+ onboardingState = { ...onboardingState, completed_at: '2024-03-10T00:00:00Z' }
+ await expectLogic(logic, () => logic.actions.loadSourceConfigs()).toFinishAllListeners()
+ expect(logic.values.visibleSourceRecommendations.map(({ agent }) => agent.source)).toEqual(state.expected)
+ })
+
+ it.each(['project', 'user'])('isolates recommendation dismissals by %s across reloads', (scope) => {
+ const originalContext = window.POSTHOG_APP_CONTEXT!
+ logic.actions.hideSourceRecommendations()
+ expect(logic.values.sourceRecommendationsDismissal).toEqual([])
+ logic.unmount()
+
+ const otherTeam =
+ scope === 'project' ? { ...MOCK_DEFAULT_TEAM, id: MOCK_DEFAULT_TEAM.id + 1 } : MOCK_DEFAULT_TEAM
+ window.POSTHOG_APP_CONTEXT = {
+ ...originalContext,
+ current_user: { ...originalContext.current_user!, uuid: 'another-user' },
+ }
+ if (scope === 'project') {
+ window.POSTHOG_APP_CONTEXT.current_user = originalContext.current_user
+ }
+ initKeaTests(true, otherTeam)
+ logic = signalSourcesLogic()
+ logic.mount()
+ expect(logic.values.sourceRecommendationsDismissal).toBeNull()
+ logic.unmount()
+
+ window.POSTHOG_APP_CONTEXT = originalContext
+ initKeaTests()
+ logic = signalSourcesLogic()
+ logic.mount()
+ expect(logic.values.sourceRecommendationsDismissal).toEqual([])
+ })
+
it('carries the card guidance onto an error tracking signal type turned on later', async () => {
// Error tracking is one guidance box over three rows. A row created after the guidance was
// written would otherwise start empty, so that one trigger would report everything while the
diff --git a/products/signals/frontend/inbox/signalSourcesLogic.ts b/products/signals/frontend/inbox/signalSourcesLogic.ts
index 8b5d033530f2..c8813eb2b2ce 100644
--- a/products/signals/frontend/inbox/signalSourcesLogic.ts
+++ b/products/signals/frontend/inbox/signalSourcesLogic.ts
@@ -8,12 +8,14 @@ import api from 'lib/api'
import { ApiConfig } from 'lib/api'
import type { PaginatedResponse } from 'lib/api'
import { FEATURE_FLAGS } from 'lib/constants'
+import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import type { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
+import { buildUserScopedPersistenceConfig } from 'lib/logic/persistence'
import { teamLogic } from 'scenes/teamLogic'
import { productEnablementCreate } from '~/generated/core/api'
-import { ExternalDataSource, ExternalDataSourceSchema, TeamPublicType, TeamType } from '~/types'
+import { ExternalDataSource, ExternalDataSourceSchema, IntegrationType, TeamPublicType, TeamType } from '~/types'
import { sourcesDataLogic } from 'products/data_warehouse/frontend/shared/logics/sourcesDataLogic'
import {
@@ -29,7 +31,12 @@ import { SignalSourceProduct, SignalSourceType } from 'products/signals/frontend
import { externalDataSchemasPartialUpdate } from 'products/warehouse_sources/frontend/generated/api'
import { ExternalDataSourceTypeEnumApi } from 'products/warehouse_sources/frontend/generated/api.schemas'
-import type { SignalSourceTypeApi, SignalSourceConfigSourceTypeEnumApi } from '../generated/api.schemas'
+import { signalsOnboardingList } from '../generated/api'
+import type {
+ InboxOnboardingStateApi,
+ SignalSourceTypeApi,
+ SignalSourceConfigSourceTypeEnumApi,
+} from '../generated/api.schemas'
import {
AGENT_ROSTER_GROUPS,
AgentRosterDefinition,
@@ -47,6 +54,12 @@ import {
captureSignalSourceDisabled,
captureSignalSourceToggleFailed,
} from './inboxAnalytics'
+import {
+ MAX_SOURCE_RECOMMENDATIONS,
+ SourceRecommendation,
+ SourceRecommendationInput,
+ recommendSources,
+} from './sourceRecommendations'
import { SOURCE_STEERING_KEY, SignalSourceConfig, SignalSourceConfigStatus, ToggleSignalSourceParams } from './types'
/** product_enablement recipe names for products that back a signal source. */
@@ -92,6 +105,8 @@ function inheritedErrorTrackingConfig(configs: SignalSourceConfig[]): Record<str
/** Warehouse-backed signal sources, keyed by roster source id. */
export type WarehouseBackedSource = ExternalSignalSource | 'engineering_analytics'
+export const SOURCE_RECOMMENDATIONS_DISMISSAL_STORAGE_KEY = 'inbox-source-recommendations-dismissed'
+
const PINNED_SOURCE_ORDER: Partial<Record<AgentRosterSource, number>> = {
github: 0,
linear: 1,
@@ -267,6 +282,8 @@ function toggleSourceConfigState(
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface signalSourcesLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
+ integrations: IntegrationType[] | null // integrationsLogic
+ integrationsLoading: boolean // integrationsLogic
dataWarehouseSources: PaginatedResponse<ExternalDataSource> | null // sourcesDataLogic
dataWarehouseSourcesLoading: boolean // sourcesDataLogic
sourcesLoadError: boolean // sourcesDataLogic
@@ -307,11 +324,14 @@ export interface signalSourcesLogicValues {
isZendeskTicketsToggling: boolean
linearIssuesConfig: SignalSourceConfig | null
linearTeamsPicker: LinearTeamsPickerState | null
+ onboardingState: InboxOnboardingStateApi | null
+ onboardingStateLoading: boolean
pgAnalyzeIssuesConfig: SignalSourceConfig | null
productDataEvents: Set<string> | null
productDataEventsFailed: boolean
productDataEventsLoading: boolean
productStatusBySource: Partial<Record<AgentRosterSource, SourceProductStatus>>
+ recommendedSources: SourceRecommendation[]
rosterGroups: AgentRosterGroup[]
scannerInventoryKnown: boolean
sourceCatalog: SourceCatalogGroup[]
@@ -324,9 +344,11 @@ export interface signalSourcesLogicValues {
sourceConfigs: SignalSourceConfig[] | null
sourceConfigsLoadFailed: boolean
sourceConfigsLoading: boolean
+ sourceRecommendationsDismissal: string[] | null
sourceSearchQuery: string
sourcesModalOpen: boolean
togglingSourceKeys: Set<string>
+ visibleSourceRecommendations: SourceRecommendation[]
visionScanners: ReplayScannerApi[] | null
visionScannersLoading: boolean
zendeskTicketsConfig: SignalSourceConfig | null
@@ -358,6 +380,9 @@ export interface signalSourcesLogicActions {
enableSourceProductComplete: () => {
value: true
}
+ hideSourceRecommendations: () => {
+ value: true
+ }
initiateDataWarehouseSourceToggle: (source: WarehouseBackedSource) => {
source: WarehouseBackedSource
}
@@ -376,6 +401,21 @@ export interface signalSourcesLogicActions {
ciSignalsConfig: CISignalsConfigApi
payload?: any
}
+ loadOnboardingState: () => any
+ loadOnboardingStateFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadOnboardingStateSuccess: (
+ onboardingState: InboxOnboardingStateApi,
+ payload?: any
+ ) => {
+ onboardingState: InboxOnboardingStateApi
+ payload?: any
+ }
loadProductDataEvents: () => any
loadProductDataEventsFailure: (
error: string,
@@ -441,7 +481,7 @@ export interface signalSourcesLogicActions {
source: WarehouseBackedSource,
origin: SignalSourceCatalogOrigin
) => {
- origin: 'catalog'
+ origin: SignalSourceCatalogOrigin
source: WarehouseBackedSource
}
setAllScannerSignals: (enabled: boolean) => {
@@ -481,6 +521,9 @@ export interface signalSourcesLogicActions {
setSourceCategory: (category: string) => {
category: string
}
+ setSourceRecommendationsDismissed: (syncedSources: string[]) => {
+ syncedSources: string[]
+ }
setSourceSearchQuery: (query: string) => {
query: string
}
@@ -666,6 +709,68 @@ export interface signalSourcesLogicMeta {
>,
ciSignalsConfig: CISignalsConfigApi | null
) => AgentRosterGroup[]
+ recommendedSources: (
+ externalAgents: AgentRosterDefinition[],
+ externalSourceStates: Record<
+ | 'aha'
+ | 'appfigures'
+ | 'appfollow'
+ | 'asknicely'
+ | 'bugsnag'
+ | 'canny'
+ | 'dixa'
+ | 'featurebase'
+ | 'freshdesk'
+ | 'freshservice'
+ | 'frill'
+ | 'front'
+ | 'gitea'
+ | 'github'
+ | 'gitlab'
+ | 'google_search_console'
+ | 'gorgias'
+ | 'honeybadger'
+ | 'hubspot'
+ | 'intercom'
+ | 'jira'
+ | 'judgeme_reviews'
+ | 'kustomer'
+ | 'linear'
+ | 'pganalyze'
+ | 'plain'
+ | 'productboard'
+ | 'rapid7_insightvm'
+ | 'raygun'
+ | 'retently'
+ | 'rollbar'
+ | 'semgrep'
+ | 'sentry'
+ | 'shortcut'
+ | 'snyk'
+ | 'sonarqube'
+ | 'uservoice'
+ | 'zendesk',
+ ExternalSignalSourceState
+ >,
+ ciSignalsConfig: CISignalsConfigApi | null,
+ ciSignalsIsFullyEnabled: boolean,
+ integrations: IntegrationType[] | null,
+ integrationsLoading: boolean,
+ sourceConfigs: SignalSourceConfig[] | null,
+ dataWarehouseSources: PaginatedResponse<ExternalDataSource> | null,
+ sourcesLoadError: boolean,
+ errorTrackingTypeStates: {
+ enabled: boolean
+ sourceType: SignalSourceType
+ }[],
+ conversationsConfig: SignalSourceConfig | null,
+ onboardingState: InboxOnboardingStateApi | null,
+ onboardingStateLoading: boolean
+ ) => SourceRecommendation[]
+ visibleSourceRecommendations: (
+ recommendedSources: SourceRecommendation[],
+ sourceRecommendationsDismissal: string[] | null
+ ) => SourceRecommendation[]
githubIssuesConfig: (sourceConfigs: SignalSourceConfig[] | null) => SignalSourceConfig | null
linearIssuesConfig: (sourceConfigs: SignalSourceConfig[] | null) => SignalSourceConfig | null
zendeskTicketsConfig: (sourceConfigs: SignalSourceConfig[] | null) => SignalSourceConfig | null
@@ -722,6 +827,8 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
['featureFlags'],
teamLogic,
['currentTeam'],
+ integrationsLogic,
+ ['integrations', 'integrationsLoading'],
],
actions: [sourcesDataLogic, ['loadSources']],
})),
@@ -736,6 +843,8 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
source,
origin,
}),
+ hideSourceRecommendations: true,
+ setSourceRecommendationsDismissed: (syncedSources: string[]) => ({ syncedSources }),
openSourcesModal: true,
closeSourcesModal: true,
initiateDataWarehouseSourceToggle: (source: WarehouseBackedSource) => ({ source }),
@@ -783,6 +892,15 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
engineeringAnalyticsCiSignalsConfigRetrieve(String(teamLogic.values.currentTeamId)),
},
],
+ // Read here rather than from inboxSetupLogic: that logic depends on this one and drags the whole
+ // setup flow in with it, and the recommendations only need the completion time.
+ onboardingState: [
+ null as InboxOnboardingStateApi | null,
+ {
+ loadOnboardingState: async (): Promise<InboxOnboardingStateApi> =>
+ signalsOnboardingList(String(ApiConfig.getCurrentProjectId())),
+ },
+ ],
productDataEvents: [
null as Set<string> | null,
{
@@ -863,7 +981,7 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
],
})),
- reducers({
+ reducers(() => ({
scannerInventoryKnown: [false, { setScannerInventoryKnown: (_, { known }) => known }],
errorTrackingHasIssues: [
null as boolean | null,
@@ -883,6 +1001,12 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
closeSourcesModal: () => false,
},
],
+ // Remember existing synced sources so only a new connection can undo a dismissal.
+ sourceRecommendationsDismissal: [
+ null as string[] | null,
+ { ...buildUserScopedPersistenceConfig(), storageKey: SOURCE_RECOMMENDATIONS_DISMISSAL_STORAGE_KEY },
+ { setSourceRecommendationsDismissed: (_, { syncedSources }) => syncedSources },
+ ],
sourcesModalOpen: [
false,
{
@@ -1002,7 +1126,7 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
},
},
],
- }),
+ })),
selectors({
dataSourceSetupOAuthRedirectUrl: [
@@ -1165,6 +1289,98 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
: group.agents.filter((agent) => !agent.flag || featureFlags[agent.flag]),
})),
],
+ // A recommendation built before configs, connections, and integrations finish loading can
+ // tell someone to connect a tool they already use.
+ recommendedSources: [
+ (s) => [
+ s.externalAgents,
+ s.externalSourceStates,
+ s.ciSignalsConfig,
+ s.ciSignalsIsFullyEnabled,
+ s.integrations,
+ s.integrationsLoading,
+ s.sourceConfigs,
+ s.dataWarehouseSources,
+ s.sourcesLoadError,
+ s.errorTrackingTypeStates,
+ s.conversationsConfig,
+ s.onboardingState,
+ s.onboardingStateLoading,
+ ],
+ (
+ agents: AgentRosterDefinition[],
+ externalStates: Record<ExternalSignalSource, ExternalSignalSourceState>,
+ ciConfig: CISignalsConfigApi | null,
+ ciEnabled: boolean,
+ integrations: IntegrationType[] | null,
+ integrationsLoading: boolean,
+ sourceConfigs: SignalSourceConfig[] | null,
+ dataWarehouseSources: PaginatedResponse<ExternalDataSource> | null,
+ sourcesLoadError: boolean,
+ errorTrackingTypeStates: { enabled: boolean; sourceType: SignalSourceType }[],
+ conversationsConfig: SignalSourceConfig | null,
+ onboardingState: InboxOnboardingStateApi | null,
+ onboardingStateLoading: boolean
+ ): SourceRecommendation[] => {
+ if (
+ sourceConfigs === null ||
+ (integrations === null && integrationsLoading) ||
+ (dataWarehouseSources === null && !sourcesLoadError) ||
+ (onboardingState === null && onboardingStateLoading)
+ ) {
+ return []
+ }
+ const completedChoices = onboardingState?.completed_at ? (onboardingState.draft?.sources ?? []) : []
+ const declinedInOnboarding = (source: WarehouseBackedSource): boolean => {
+ const choices = completedChoices.filter((choice) => choice.source_product === source)
+ return choices.length > 0 && choices.every((choice) => !choice.enabled)
+ }
+ const states: SourceRecommendationInput[] = [
+ {
+ source: 'error_tracking',
+ connected: false,
+ enabled: errorTrackingTypeStates.some(({ enabled }) => enabled),
+ },
+ { source: 'conversations', connected: false, enabled: !!conversationsConfig?.enabled },
+ ...agents.map((agent): SourceRecommendationInput => {
+ if (isExternalSignalSource(agent.source)) {
+ const state = externalStates[agent.source]
+ return {
+ source: agent.source,
+ connected: state.connected,
+ enabled: !!state.config?.enabled,
+ declinedInOnboarding: state.connected && declinedInOnboarding(agent.source),
+ }
+ }
+ return {
+ source: agent.source,
+ connected: !!ciConfig?.configured,
+ enabled: ciEnabled,
+ declinedInOnboarding:
+ !!ciConfig?.configured && declinedInOnboarding(agent.source as WarehouseBackedSource),
+ }
+ }),
+ ]
+ return recommendSources(
+ agents,
+ states,
+ (integrations ?? []).map((integration) => integration.kind)
+ )
+ },
+ ],
+ // Hidden means hidden, except for a tool synced after the person hid the strip: a fresh
+ // warehouse connection is the strongest hint the strip ever has.
+ visibleSourceRecommendations: [
+ (s) => [s.recommendedSources, s.sourceRecommendationsDismissal],
+ (recommendations: SourceRecommendation[], dismissal: string[] | null): SourceRecommendation[] =>
+ (dismissal === null
+ ? recommendations
+ : recommendations.filter(
+ (recommendation) =>
+ recommendation.reason === 'synced' && !dismissal.includes(recommendation.agent.source)
+ )
+ ).slice(0, MAX_SOURCE_RECOMMENDATIONS),
+ ],
githubIssuesConfig: [
(s) => [s.sourceConfigs],
(sourceConfigs: SignalSourceConfig[] | null): SignalSourceConfig | null =>
@@ -1514,11 +1730,22 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
closeSourceCatalog: forgetResumedSetup,
openSourceCatalog: () => {
captureSignalSourceCatalogOpened({
+ recommendationCount: values.visibleSourceRecommendations.length,
connectedCount: values.rosterGroups.find((group) => group.id === 'external')?.agents.length ?? 0,
})
},
+ hideSourceRecommendations: () => {
+ actions.setSourceRecommendationsDismissed(
+ values.recommendedSources
+ .filter((recommendation) => recommendation.reason === 'synced')
+ .map((recommendation) => recommendation.agent.source)
+ )
+ },
selectCatalogSource: ({ source, origin }) => {
- captureSignalSourceCatalogSourceSelected({ source, origin })
+ const reason = values.recommendedSources.find(
+ (recommendation) => recommendation.agent.source === source
+ )?.reason
+ captureSignalSourceCatalogSourceSelected({ source, origin, reason: reason ?? null })
if (isExternalSignalSource(source)) {
actions.initiateDataWarehouseSourceToggle(source)
} else {
@@ -1537,6 +1764,11 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
actions.closeSourceCatalog()
}
},
+ loadSourceConfigs: () => {
+ if (!values.onboardingStateLoading) {
+ actions.loadOnboardingState()
+ }
+ },
loadSourceConfigsFailure: ({ error, errorObject }) => {
captureSignalSourceConfigsLoadFailed(errorObject?.detail || error || 'Failed to load signal sources')
},
diff --git a/products/signals/frontend/inbox/sourceRecommendations.ts b/products/signals/frontend/inbox/sourceRecommendations.ts
new file mode 100644
index 000000000000..6ef608456c5e
--- /dev/null
+++ b/products/signals/frontend/inbox/sourceRecommendations.ts
@@ -0,0 +1,101 @@
+import type { AgentRosterDefinition, AgentRosterSource } from './components/config/agentRosterMeta'
+import type { ExternalSignalSource } from './externalSignalSources'
+
+export type SourceRecommendationReason = 'synced' | 'integration' | 'default'
+
+export interface SourceRecommendation {
+ agent: AgentRosterDefinition
+ reason: SourceRecommendationReason
+ description?: string
+}
+
+export interface SourceRecommendationInput {
+ source: AgentRosterSource
+ connected: boolean
+ enabled: boolean
+ /** An explicit saved rejection should not become a recommendation. */
+ declinedInOnboarding?: boolean
+}
+
+export const DEFAULT_RECOMMENDATIONS: readonly { source: AgentRosterSource; description: string }[] = [
+ { source: 'github', description: 'Issues filed in GitHub' },
+ { source: 'engineering_analytics', description: 'Flaky checks and slowing GitHub Actions workflows' },
+ { source: 'linear', description: 'Issues tracked in Linear' },
+ { source: 'zendesk', description: 'Incoming Zendesk tickets' },
+]
+
+/**
+ * A PostHog product that covers a catalog category. While it is on, external tools in that category
+ * are not suggested: a team watching Error tracking does not need to hear about Sentry.
+ */
+export const POSTHOG_SOURCE_CATEGORIES: Partial<Record<AgentRosterSource, string>> = {
+ error_tracking: 'Error tracking',
+ conversations: 'Support',
+}
+
+export const INTEGRATION_KIND_SOURCES: Readonly<Record<string, ExternalSignalSource>> = {
+ github: 'github',
+ gitlab: 'gitlab',
+ intercom: 'intercom',
+ jira: 'jira',
+ linear: 'linear',
+ hubspot: 'hubspot',
+ 'google-search-console': 'google_search_console',
+}
+
+export const MAX_SOURCE_RECOMMENDATIONS = 4
+
+export function recommendSources(
+ agents: AgentRosterDefinition[],
+ states: SourceRecommendationInput[],
+ integrationKinds: readonly string[]
+): SourceRecommendation[] {
+ const stateBySource = new Map(states.map((state) => [state.source, state]))
+ const agentBySource = new Map(agents.map((agent) => [agent.source, agent]))
+ const coveredCategories = new Set(
+ states
+ .filter((state) => state.enabled)
+ .map((state) => POSTHOG_SOURCE_CATEGORIES[state.source])
+ .filter((category): category is string => !!category)
+ )
+ const recommendations: SourceRecommendation[] = []
+ const add = (source: AgentRosterSource, reason: SourceRecommendationReason, description?: string): void => {
+ const agent = agentBySource.get(source)
+ const state = stateBySource.get(source)
+ if (
+ !agent ||
+ !state ||
+ state.enabled ||
+ state.declinedInOnboarding ||
+ (agent.category && coveredCategories.has(agent.category)) ||
+ recommendations.some((existing) => existing.agent.source === source)
+ ) {
+ return
+ }
+ recommendations.push({ agent, reason, description })
+ }
+
+ for (const state of states) {
+ if (state.connected) {
+ add(state.source, 'synced')
+ }
+ }
+ for (const kind of integrationKinds) {
+ const source = INTEGRATION_KIND_SOURCES[kind]
+ if (source && !stateBySource.get(source)?.connected) {
+ add(source, 'integration')
+ }
+ }
+ // Adding one external tool proves the person found the catalog, so the generic defaults have done
+ // their job. The two project-specific reasons above stay: they are cheap and about this project.
+ const hasExternalSource = agents.some((agent) => {
+ const state = stateBySource.get(agent.source)
+ return !!state && (state.connected || state.enabled)
+ })
+ if (!hasExternalSource) {
+ for (const { source, description } of DEFAULT_RECOMMENDATIONS) {
+ add(source, 'default', description)
+ }
+ }
+ return recommendations
+}