: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(signals): let people scope the inbox to themselves for a shareable link (#95631)
Andrew Maguirefcf3d956f7da
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex b4b8584cae4a..d0a773147c74 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6339,7 +6339,7 @@ snapshots:scenes-app-customer-analytics-dashboard--customer-tasks--dark:hash: v1.k794b7964.bf4411a8550fe620b82da8dbf7db11efbe3915634ecdcf3baa8b2bffc0aad593.frezJ_q91GKzahZb8GfRbUeRbERSv-ReB2HIBNJN6Owscenes-app-customer-analytics-dashboard--customer-tasks--light:- hash: v1.k794b7964.acedcb03c7c39d27c2b9f0ed3f1b1ac44fe3fdc58f68a0ed0d0b9e475e70ca96.nKLpWDvqLrHFG2HwFEAexR8rc63-OmxYQogH_Utdg9I+ hash: v1.k794b7964.60a97139d05e6353174d50bce8ad84e23d4ea39806dcbde6d81b4d259356a1c8.YTy9rPEtfJxKbOKmMJxP_wLyhtlalHtNLi0HqnPKfe0scenes-app-customer-analytics-dashboard--feature-request-details--dark:hash: v1.k794b7964.dd76e36d821568ab1a8ea103274a39792a5916586913dcc54d4b8c6022aed968.ofepc5cJ-e3ysJbDmjbn2yyefm6X7NwNtnjOfyB4WmAscenes-app-customer-analytics-dashboard--feature-request-details--light:diff --git a/products/signals/frontend/inbox/components/shell/InboxScopeFilter.test.tsx b/products/signals/frontend/inbox/components/shell/InboxScopeFilter.test.tsxindex a21368859b79..9b6c90199c75 100644--- a/products/signals/frontend/inbox/components/shell/InboxScopeFilter.test.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxScopeFilter.test.tsx@@ -1,3 +1,5 @@+import { MOCK_DEFAULT_USER } from 'lib/api.mock'+import '@testing-library/jest-dom'import { cleanup, render, screen, waitFor } from '@testing-library/react'@@ -7,11 +9,23 @@ import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'import { inboxFiltersLogic } from '../../logics/inboxFiltersLogic'+import type { InboxPerson } from './InboxPeoplePicker'import { InboxScopeFilter } from './InboxScopeFilter'jest.mock('posthog-js')-// The people picker isn't needed to exercise the trigger label, and it pulls in a popover + avatars.-jest.mock('./InboxPeoplePicker', () => ({ InboxPeoplePicker: () => null }))+// The real picker pulls in a popover and avatars. This stand-in lists the roster rows as plain text,+// which is all these tests read from it.+jest.mock('./InboxPeoplePicker', () => ({+ InboxPeoplePicker: ({ people }: { people: InboxPerson[] }) => (+ <ul>+ {people.map((person) => (+ <li key={person.uuid}>+ {person.name} {person.trailing}+ </li>+ ))}+ </ul>+ ),+}))describe('InboxScopeFilter', () => {beforeEach(() => {@@ -21,6 +35,7 @@ describe('InboxScopeFilter', () => {get: {'/api/projects/:team_id/signals/reports/available_reviewers': {'uuid-ada': { name: 'Ada', email: '[email protected]' },+ [MOCK_DEFAULT_USER.uuid]: { name: MOCK_DEFAULT_USER.first_name, email: MOCK_DEFAULT_USER.email },},},})@@ -46,10 +61,20 @@ describe('InboxScopeFilter', () => {render(<InboxScopeFilter />)inboxFiltersLogic.actions.setScope('teammate:uuid-ada')- await waitFor(() => expect(screen.getByText('Ada')).toBeInTheDocument())+ await waitFor(() => expect(screen.getByLabelText('Report scope: Ada')).toBeInTheDocument())inboxFiltersLogic.actions.setScope('teammate:uuid-off-roster')- await waitFor(() => expect(screen.getByText('Teammate')).toBeInTheDocument())- expect(screen.queryByText('Ada')).toBeNull()+ await waitFor(() => expect(screen.getByLabelText('Report scope: Teammate')).toBeInTheDocument())+ expect(screen.queryByLabelText('Report scope: Ada')).toBeNull()+ })++ // "For you" resolves to whoever opens the link, so a URL that opens to *your* reports for a+ // teammate can only come from your own roster row. Hiding that row as a duplicate of "For you"+ // makes your view the one scope nobody can share.+ it('keeps the signed-in user in the roster so their scope can be shared by URL', async () => {+ inboxFiltersLogic.mount()+ render(<InboxScopeFilter />)++ await waitFor(() => expect(screen.getByText(`${MOCK_DEFAULT_USER.first_name} (you)`)).toBeInTheDocument())})})diff --git a/products/signals/frontend/inbox/components/shell/InboxScopeFilter.tsx b/products/signals/frontend/inbox/components/shell/InboxScopeFilter.tsxindex 815ae9fb99c6..2876fa68a5a5 100644--- a/products/signals/frontend/inbox/components/shell/InboxScopeFilter.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxScopeFilter.tsx@@ -92,15 +92,16 @@ export function InboxScopeFilter(): JSX.Element {setSearch(value)searchAvailableReviewers(value)}}- // The pinned "For you" row already stands for the signed-in user, so their own- // roster row would be a second control writing a different scope for the same view.- people={reviewers- .filter((reviewer) => reviewer.user_uuid !== user?.uuid)- .map((reviewer) => ({- uuid: reviewer.user_uuid,- name: reviewer.name,- email: reviewer.email,- }))}+ // The signed-in user keeps their own roster row next to the pinned "For you" row. Both+ // show the same reports, but only the roster row writes `scope=teammate:<uuid>` to the+ // URL. "For you" is the default, so it leaves the URL bare and resolves to whoever opens+ // the link. The roster row is the only way to share a link that opens to your reports.+ people={reviewers.map((reviewer) => ({+ uuid: reviewer.user_uuid,+ name: reviewer.name,+ email: reviewer.email,+ trailing: reviewer.user_uuid === user?.uuid ? '(you)' : undefined,+ }))}loading={availableReviewersLoading}selectedUuid={scope === INBOX_SCOPE_ENTIRE_PROJECT ? null : (selectedTeammateUuid ?? undefined)}forYou={{ active: isForYou, onPick: () => pick(INBOX_SCOPE_FOR_YOU) }}