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(customer-analytics): show note creator and filter notes list (#68247)

Arthur Moreira de Deuse2e554645663
diff --git a/products/customer_analytics/frontend/components/AccountNotes/AccountNotesTabContent.tsx b/products/customer_analytics/frontend/components/AccountNotes/AccountNotesTabContent.tsx
index a2f742160536..ef7d436a63c2 100644
--- a/products/customer_analytics/frontend/components/AccountNotes/AccountNotesTabContent.tsx
+++ b/products/customer_analytics/frontend/components/AccountNotes/AccountNotesTabContent.tsx
@@ -1,11 +1,15 @@
import { useActions, useValues } from 'kea'
import posthog from 'posthog-js'
+import { useState } from 'react'
-import { LemonInput, LemonSkeleton } from '@posthog/lemon-ui'
+import { IconChevronDown, IconX } from '@posthog/icons'
+import { LemonButton, LemonCheckbox, LemonDropdown, LemonInput, LemonSkeleton, ProfilePicture } from '@posthog/lemon-ui'
+import { MemberSelectMultiple } from 'lib/components/MemberSelectMultiple'
import { LemonTable, LemonTableColumn, LemonTableColumns } from 'lib/lemon-ui/LemonTable'
import { atColumn } from 'lib/lemon-ui/LemonTable/columnUtils'
import { Link } from 'lib/lemon-ui/Link'
+import { fullName } from 'lib/utils/strings'
import { notebookPanelLogic } from 'scenes/notebooks/NotebookPanel/notebookPanelLogic'
import { urls } from 'scenes/urls'
@@ -15,11 +19,21 @@ import { AccountsEvents } from '../Accounts/constants'
import { accountNotesLogic } from './accountNotesLogic'
export function AccountNotesTabContent(): JSX.Element {
- const { accountNotes, accountNotesResponse, accountNotesResponseLoading, search, pagination } =
- useValues(accountNotesLogic)
- const { setSearch } = useActions(accountNotesLogic)
+ const {
+ accountNotes,
+ accountNotesResponse,
+ accountNotesResponseLoading,
+ search,
+ createdByFilter,
+ createdByCurrentUser,
+ accountFilter,
+ pagination,
+ } = useValues(accountNotesLogic)
+ const { setSearch, setCreatedByFilter, setCreatedByCurrentUser, reportFilterChange } = useActions(accountNotesLogic)
const { selectNotebook } = useActions(notebookPanelLogic)
+ const hasFilters = !!search || createdByFilter.length > 0 || accountFilter !== null
+
const columns: LemonTableColumns<AccountNoteApi> = [
{
title: 'Title',
@@ -64,6 +78,25 @@ export function AccountNotesTabContent(): JSX.Element {
)
},
},
+ {
+ title: 'Created by',
+ key: 'created_by',
+ render: function Render(_, note) {
+ const user = note.created_by
+ if (!user) {
+ return <span className="text-muted">—</span>
+ }
+ return (
+ <div className="flex items-center gap-2">
+ <ProfilePicture
+ user={{ email: user.email, first_name: user.first_name, last_name: user.last_name }}
+ size="sm"
+ />
+ <span className="whitespace-nowrap">{fullName(user) || user.email}</span>
+ </div>
+ )
+ },
+ },
atColumn<AccountNoteApi>('created_at', 'Created') as LemonTableColumn<
AccountNoteApi,
keyof AccountNoteApi | undefined
@@ -76,15 +109,35 @@ export function AccountNotesTabContent(): JSX.Element {
return (
<div className="space-y-4">
- <LemonInput
- type="search"
- placeholder="Search notes"
- onChange={setSearch}
- value={search}
- size="small"
- className="min-w-64"
- data-attr="account-notes-search"
- />
+ <div className="flex flex-wrap gap-2 items-center">
+ <LemonInput
+ type="search"
+ placeholder="Search notes"
+ onChange={setSearch}
+ value={search}
+ size="small"
+ className="min-w-64"
+ data-attr="account-notes-search"
+ />
+ <AccountPicker />
+ <CreatedByPicker
+ value={createdByFilter}
+ onChange={(userIds) => {
+ setCreatedByFilter(userIds)
+ reportFilterChange('created_by')
+ }}
+ />
+ <LemonCheckbox
+ checked={createdByCurrentUser}
+ onChange={(value) => {
+ setCreatedByCurrentUser(value)
+ reportFilterChange('my_notes')
+ }}
+ label="My notes"
+ info="Shortcut for Created by: you — notes you created"
+ data-attr="account-notes-my-notes-filter"
+ />
+ </div>
{accountNotesResponse === null ? (
// Dedicated initial-load state (mirrors AccountOpportunitiesExpansion); the
// table's own loading overlay covers subsequent search/pagination fetches.
@@ -98,8 +151,8 @@ export function AccountNotesTabContent(): JSX.Element {
loading={accountNotesResponseLoading}
pagination={pagination}
emptyState={
- search
- ? 'No notes matching your search'
+ hasFilters
+ ? 'No notes matching your filters'
: "No account notes yet. Create notes from an account's Notes tab."
}
nouns={['note', 'notes']}
@@ -108,3 +161,128 @@ export function AccountNotesTabContent(): JSX.Element {
</div>
)
}
+
+function CreatedByPicker({ value, onChange }: { value: number[]; onChange: (userIds: number[]) => void }): JSX.Element {
+ const buttonLabel =
+ value.length === 0
+ ? 'Created by anyone'
+ : value.length === 1
+ ? 'Created by 1 person'
+ : `Created by ${value.length} people`
+ return (
+ <div className="flex gap-1 items-center" data-attr="account-notes-created-by-filter">
+ <LemonDropdown
+ closeOnClickInside={false}
+ overlay={
+ <div className="p-2 min-w-64">
+ <MemberSelectMultiple
+ idKey="id"
+ value={value}
+ onChange={(users) => onChange(users.map((user) => user.id))}
+ />
+ </div>
+ }
+ >
+ <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />}>
+ {buttonLabel}
+ </LemonButton>
+ </LemonDropdown>
+ {value.length > 0 && (
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconX />}
+ onClick={() => onChange([])}
+ tooltip="Clear created-by filter"
+ />
+ )}
+ </div>
+ )
+}
+
+function AccountPicker(): JSX.Element {
+ const { accountFilter, accountSearch, accountOptions, accountOptionsResponseLoading } = useValues(accountNotesLogic)
+ const { setAccountFilter, setAccountSearch, reportFilterChange } = useActions(accountNotesLogic)
+ const [showPopover, setShowPopover] = useState(false)
+
+ const selectAccount = (account: { id: string; name: string } | null): void => {
+ setShowPopover(false)
+ setAccountFilter(account)
+ reportFilterChange('account')
+ }
+
+ return (
+ <div className="flex gap-1 items-center" data-attr="account-notes-account-filter">
+ <LemonDropdown
+ closeOnClickInside={false}
+ visible={showPopover}
+ placement="bottom-start"
+ actionable
+ onVisibilityChange={(visible) => {
+ setShowPopover(visible)
+ if (!visible && accountSearch) {
+ setAccountSearch('')
+ }
+ }}
+ overlay={
+ <div className="max-w-100 space-y-2">
+ <LemonInput
+ type="search"
+ placeholder="Search accounts"
+ autoFocus
+ value={accountSearch}
+ onChange={setAccountSearch}
+ fullWidth
+ />
+ <ul className="space-y-px max-h-80 overflow-y-auto">
+ <li>
+ <LemonButton
+ fullWidth
+ role="menuitem"
+ size="small"
+ active={accountFilter === null}
+ onClick={() => selectAccount(null)}
+ >
+ All accounts
+ </LemonButton>
+ </li>
+ {accountOptions.map((option) => (
+ <li key={option.key}>
+ <LemonButton
+ fullWidth
+ role="menuitem"
+ size="small"
+ active={accountFilter?.id === option.key}
+ onClick={() => selectAccount({ id: option.key, name: option.label })}
+ >
+ {option.label}
+ </LemonButton>
+ </li>
+ ))}
+ {accountOptionsResponseLoading ? (
+ <div className="p-2 text-secondary italic truncate border-t">Loading...</div>
+ ) : accountOptions.length === 0 ? (
+ <div className="p-2 text-secondary italic truncate border-t">
+ {accountSearch ? 'No matches' : 'No accounts'}
+ </div>
+ ) : null}
+ </ul>
+ </div>
+ }
+ >
+ <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />}>
+ {accountFilter ? accountFilter.name : 'All accounts'}
+ </LemonButton>
+ </LemonDropdown>
+ {accountFilter !== null && (
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconX />}
+ onClick={() => selectAccount(null)}
+ tooltip="Clear account filter"
+ />
+ )}
+ </div>
+ )
+}
diff --git a/products/customer_analytics/frontend/components/AccountNotes/accountNotesLogic.ts b/products/customer_analytics/frontend/components/AccountNotes/accountNotesLogic.ts
index 2962364fb8d9..b2a61a7d900d 100644
--- a/products/customer_analytics/frontend/components/AccountNotes/accountNotesLogic.ts
+++ b/products/customer_analytics/frontend/components/AccountNotes/accountNotesLogic.ts
@@ -5,27 +5,37 @@ import posthog from 'posthog-js'
import { PaginationManual, lemonToast } from '@posthog/lemon-ui'
import { teamLogic } from 'scenes/teamLogic'
+import { userLogic } from 'scenes/userLogic'
-import { accountNotesList } from 'products/customer_analytics/frontend/generated/api'
+import { accountNotesList, accountsList } from 'products/customer_analytics/frontend/generated/api'
import type {
AccountNoteApi,
+ PaginatedAccountListApi,
PaginatedAccountNoteListApi,
} from 'products/customer_analytics/frontend/generated/api.schemas'
-import { AccountsEvents } from '../Accounts/constants'
+import { AccountsEvents, type NotesTabFilterType } from '../Accounts/constants'
import type { accountNotesLogicType } from './accountNotesLogicType'
const RESULTS_PER_PAGE = 50
+const ACCOUNT_OPTIONS_LIMIT = 50
+
+export type AccountFilterOption = { id: string; name: string }
export const accountNotesLogic = kea<accountNotesLogicType>([
path(['products', 'customer_analytics', 'frontend', 'components', 'AccountNotes', 'accountNotesLogic']),
connect(() => ({
- values: [teamLogic, ['currentTeamId']],
+ values: [teamLogic, ['currentTeamId'], userLogic, ['user']],
})),
actions({
loadAccountNotes: true,
setSearch: (search: string) => ({ search }),
setPage: (page: number) => ({ page }),
+ setCreatedByFilter: (userIds: number[]) => ({ userIds }),
+ setCreatedByCurrentUser: (value: boolean) => ({ value }),
+ setAccountFilter: (account: AccountFilterOption | null) => ({ account }),
+ setAccountSearch: (query: string) => ({ query }),
+ reportFilterChange: (filterType: NotesTabFilterType) => ({ filterType }),
}),
loaders(({ values }) => ({
accountNotesResponse: [
@@ -35,6 +45,8 @@ export const accountNotesLogic = kea<accountNotesLogicType>([
await breakpoint(100)
const response = await accountNotesList(String(values.currentTeamId), {
search: values.search || undefined,
+ account_id: values.accountFilter?.id,
+ created_by: values.createdByFilter.length ? values.createdByFilter : undefined,
limit: RESULTS_PER_PAGE,
offset: (values.page - 1) * RESULTS_PER_PAGE,
})
@@ -43,16 +55,48 @@ export const accountNotesLogic = kea<accountNotesLogicType>([
},
},
],
+ accountOptionsResponse: [
+ null as PaginatedAccountListApi | null,
+ {
+ loadAccountOptions: async ({ query }: { query: string }, breakpoint) => {
+ await breakpoint(300)
+ const response = await accountsList(String(values.currentTeamId), {
+ search: query || undefined,
+ limit: ACCOUNT_OPTIONS_LIMIT,
+ })
+ breakpoint()
+ return response
+ },
+ },
+ ],
})),
reducers({
search: ['', { setSearch: (_, { search }) => search }],
- page: [1, { setPage: (_, { page }) => page, setSearch: () => 1 }],
+ createdByFilter: [[] as number[], { setCreatedByFilter: (_, { userIds }) => userIds }],
+ accountFilter: [null as AccountFilterOption | null, { setAccountFilter: (_, { account }) => account }],
+ accountSearch: ['', { setAccountSearch: (_, { query }) => query }],
+ page: [
+ 1,
+ {
+ setPage: (_, { page }) => page,
+ setSearch: () => 1,
+ setCreatedByFilter: () => 1,
+ setAccountFilter: () => 1,
+ },
+ ],
}),
selectors(({ actions }) => ({
accountNotes: [
(s) => [s.accountNotesResponse],
(response: PaginatedAccountNoteListApi | null): AccountNoteApi[] => response?.results ?? [],
],
+ currentUserId: [(s) => [s.user], (user): number | null => user?.id ?? null],
+ // "My notes" is a shorthand, not separate state: checked iff the created-by filter is exactly [me].
+ createdByCurrentUser: [
+ (s) => [s.createdByFilter, s.currentUserId],
+ (createdByFilter: number[], currentUserId: number | null): boolean =>
+ currentUserId !== null && createdByFilter.length === 1 && createdByFilter[0] === currentUserId,
+ ],
pagination: [
(s) => [s.page, s.accountNotesResponse],
(page: number, response: PaginatedAccountNoteListApi | null): PaginationManual => ({
@@ -64,6 +108,23 @@ export const accountNotesLogic = kea<accountNotesLogicType>([
onForward: () => actions.setPage(page + 1),
}),
],
+ accountOptions: [
+ (s) => [s.accountOptionsResponse, s.accountFilter],
+ (
+ response: PaginatedAccountListApi | null,
+ accountFilter: AccountFilterOption | null
+ ): { key: string; label: string }[] => {
+ const options = (response?.results ?? []).map((account) => ({
+ key: account.id,
+ label: account.name,
+ }))
+ // Keep the selected account visible even when it's outside the current search page.
+ if (accountFilter && !options.some((option) => option.key === accountFilter.id)) {
+ options.unshift({ key: accountFilter.id, label: accountFilter.name })
+ }
+ return options
+ },
+ ],
})),
listeners(({ actions, values }) => ({
// Analytics capture is debounced so only the settled query reports, never per keystroke;
@@ -77,13 +138,38 @@ export const accountNotesLogic = kea<accountNotesLogicType>([
})
},
setPage: () => actions.loadAccountNotes(),
+ setCreatedByFilter: () => actions.loadAccountNotes(),
+ setCreatedByCurrentUser: ({ value }) => {
+ actions.setCreatedByFilter(value && values.currentUserId !== null ? [values.currentUserId] : [])
+ },
+ setAccountFilter: () => actions.loadAccountNotes(),
+ setAccountSearch: ({ query }) => actions.loadAccountOptions({ query }),
+ // Captures live in a dedicated report action (dispatched by the controls only) so the
+ // "My notes" shortcut cascading into setCreatedByFilter doesn't double-fire events.
+ reportFilterChange: ({ filterType }) => {
+ const properties: Record<string, string | number | boolean> = { filter_type: filterType }
+ if (filterType === 'created_by') {
+ properties.is_cleared = values.createdByFilter.length === 0
+ properties.user_count = values.createdByFilter.length
+ } else if (filterType === 'account') {
+ properties.is_cleared = values.accountFilter === null
+ } else {
+ properties.value = values.createdByCurrentUser
+ properties.is_cleared = !values.createdByCurrentUser
+ }
+ posthog.capture(AccountsEvents.NotesTabFiltered, properties)
+ },
loadAccountNotesFailure: ({ error }) => {
posthog.captureException(error)
lemonToast.error('Failed to load account notes')
},
+ loadAccountOptionsFailure: ({ error }) => {
+ posthog.captureException(error)
+ },
})),
afterMount(({ actions }) => {
posthog.capture(AccountsEvents.NotesTabViewed)
actions.loadAccountNotes()
+ actions.loadAccountOptions({ query: '' })
}),
])
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index f73b677caa23..ba421f27732c 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -159,33 +159,34 @@ We track user actions on the Accounts list with `posthog.capture()`. Conventions
### Tracked events
-| Event | Fires from | Properties |
-| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `customer analytics accounts list viewed` | `accountsLogic` `afterMount` | _(none — funnel anchor; account count and saved-config aren't loaded at mount)_ |
-| `customer analytics accounts filter changed` | `accountsLogic` `reportFilterChange` listener (dispatched by the filter controls) | `filter_type` (`tag` \| `unassigned_only` \| `my_accounts` \| `assigned_to`), `value`, `is_cleared`, `active_filter_count`; for `tag` also `tag_count`; for `assigned_to` also `role_count` |
-| `customer analytics accounts searched` | `accountsLogic` `setSearchInput` listener (post-debounce) | `query_length`, `has_query`, `active_filter_count` |
-| `customer analytics accounts refreshed` | `accountsLogic` `refresh` | `has_search`, `active_filter_count`, `sort_column` |
-| `customer analytics accounts sorted` | `accountsLogic` `toggleSort` | `column`, `direction` (`asc` \| `desc` \| `cleared`) |
-| ~~`customer analytics accounts columns saved`~~ | _Deprecated — no longer emitted. Column changes are now saved as part of a view (see view events below)._ | _n/a_ |
-| `customer analytics accounts overview tiles edited` | `accountsOverviewTilesLogic` editor close (diffed vs open snapshot, only when changed) | `tiles_added`, `tiles_removed`, `tiles_updated`, `reordered`, `tile_count_before`, `tile_count_after` |
-| `customer analytics accounts overview tiles localstorage read` | `accountsOverviewTilesLogic` `afterMount` (only when a legacy custom value exists) | `tile_count` — **tombstone**: a legacy localStorage tiles value was read; once this stops firing, no browser still carries one and the read path can be removed |
-| `customer analytics accounts view saved` | `accountsViewsLogic` `submitNewViewForm` listener (success) | `visibility` (`private` \| `shared`) |
-| `customer analytics accounts view updated` | `accountsViewsLogic` `updateViewSuccess` listener | _(none)_ |
-| `customer analytics accounts view selected` | `accountsViewsLogic` `applyView` listener | `visibility` |
-| `customer analytics accounts view deleted` | `accountsViewsLogic` `deleteViewSuccess` listener | _(none)_ |
-| `customer analytics account role assigned` | `accountsLogic` `updateAccountRole` | `role` (`csm` \| `account_executive` \| `account_owner`), `is_assigned`, `assigned_user_id`, `source` (always `list_row` today) |
-| `customer analytics account link clicked` | `AccountNotebooksExpansion.tsx` useful-link `onClick` | `link_key`, `has_destination` |
-| `customer analytics account note clicked` | `AccountNotebooksExpansion.tsx` note `<Link>` `onClick` | `notebook_short_id` |
-| `customer analytics accounts note created` | `accountNotebooksLogic` `createNoteSuccess` listener | `notebook_short_id` |
-| `customer analytics accounts notes searched` | `accountNotebooksLogic` `setSearchTerm` listener (post-debounce) | `has_query`, `query_length` (no raw text) |
-| `customer analytics accounts notes sorted` | `accountNotebooksLogic` `setSorting` listener | `column` (`created_at` \| `created_by` \| null), `direction` (`asc` \| `desc` \| `cleared`) |
-| `customer analytics account tab viewed` | `accountsExpansionLogic` `setActiveTab` listener (genuine tab clicks only; programmatic `openAccountTab` navigation does not fire it) | `tab` (`notes` \| `users` \| `usage` \| `spend` \| `opportunities`) |
-| `customer analytics account related user clicked` | `AccountRelatedUsersExpansion.tsx` user `<Link>` `onClick` | _(none — customer end-user PII kept out)_ |
-| `customer analytics account opportunity clicked` | `AccountOpportunitiesExpansion.tsx` opportunity name `<Link>` `onClick` | _(none — CRM record id/url kept out)_ |
-| `customer analytics notes tab viewed` | `accountNotesLogic` (`../AccountNotes/`) `afterMount` — the top-level Notes tab, not the per-account expansion | _(none — funnel anchor)_ |
-| `customer analytics notes tab searched` | `accountNotesLogic` `setSearch` listener (post-debounce) | `has_query`, `query_length` (no raw text) |
-| `customer analytics notes tab note clicked` | `AccountNotesTabContent.tsx` note title `<Link>` `onClick` (opens side panel) | `notebook_short_id` |
-| `customer analytics notes tab account clicked` | `AccountNotesTabContent.tsx` account `<Link>` `onClick` | `account_id` |
+| Event | Fires from | Properties |
+| -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `customer analytics accounts list viewed` | `accountsLogic` `afterMount` | _(none — funnel anchor; account count and saved-config aren't loaded at mount)_ |
+| `customer analytics accounts filter changed` | `accountsLogic` `reportFilterChange` listener (dispatched by the filter controls) | `filter_type` (`tag` \| `unassigned_only` \| `my_accounts` \| `assigned_to`), `value`, `is_cleared`, `active_filter_count`; for `tag` also `tag_count`; for `assigned_to` also `role_count` |
+| `customer analytics accounts searched` | `accountsLogic` `setSearchInput` listener (post-debounce) | `query_length`, `has_query`, `active_filter_count` |
+| `customer analytics accounts refreshed` | `accountsLogic` `refresh` | `has_search`, `active_filter_count`, `sort_column` |
+| `customer analytics accounts sorted` | `accountsLogic` `toggleSort` | `column`, `direction` (`asc` \| `desc` \| `cleared`) |
+| ~~`customer analytics accounts columns saved`~~ | _Deprecated — no longer emitted. Column changes are now saved as part of a view (see view events below)._ | _n/a_ |
+| `customer analytics accounts overview tiles edited` | `accountsOverviewTilesLogic` editor close (diffed vs open snapshot, only when changed) | `tiles_added`, `tiles_removed`, `tiles_updated`, `reordered`, `tile_count_before`, `tile_count_after` |
+| `customer analytics accounts overview tiles localstorage read` | `accountsOverviewTilesLogic` `afterMount` (only when a legacy custom value exists) | `tile_count` — **tombstone**: a legacy localStorage tiles value was read; once this stops firing, no browser still carries one and the read path can be removed |
+| `customer analytics accounts view saved` | `accountsViewsLogic` `submitNewViewForm` listener (success) | `visibility` (`private` \| `shared`) |
+| `customer analytics accounts view updated` | `accountsViewsLogic` `updateViewSuccess` listener | _(none)_ |
+| `customer analytics accounts view selected` | `accountsViewsLogic` `applyView` listener | `visibility` |
+| `customer analytics accounts view deleted` | `accountsViewsLogic` `deleteViewSuccess` listener | _(none)_ |
+| `customer analytics account role assigned` | `accountsLogic` `updateAccountRole` | `role` (`csm` \| `account_executive` \| `account_owner`), `is_assigned`, `assigned_user_id`, `source` (always `list_row` today) |
+| `customer analytics account link clicked` | `AccountNotebooksExpansion.tsx` useful-link `onClick` | `link_key`, `has_destination` |
+| `customer analytics account note clicked` | `AccountNotebooksExpansion.tsx` note `<Link>` `onClick` | `notebook_short_id` |
+| `customer analytics accounts note created` | `accountNotebooksLogic` `createNoteSuccess` listener | `notebook_short_id` |
+| `customer analytics accounts notes searched` | `accountNotebooksLogic` `setSearchTerm` listener (post-debounce) | `has_query`, `query_length` (no raw text) |
+| `customer analytics accounts notes sorted` | `accountNotebooksLogic` `setSorting` listener | `column` (`created_at` \| `created_by` \| null), `direction` (`asc` \| `desc` \| `cleared`) |
+| `customer analytics account tab viewed` | `accountsExpansionLogic` `setActiveTab` listener (genuine tab clicks only; programmatic `openAccountTab` navigation does not fire it) | `tab` (`notes` \| `users` \| `usage` \| `spend` \| `opportunities`) |
+| `customer analytics account related user clicked` | `AccountRelatedUsersExpansion.tsx` user `<Link>` `onClick` | _(none — customer end-user PII kept out)_ |
+| `customer analytics account opportunity clicked` | `AccountOpportunitiesExpansion.tsx` opportunity name `<Link>` `onClick` | _(none — CRM record id/url kept out)_ |
+| `customer analytics notes tab viewed` | `accountNotesLogic` (`../AccountNotes/`) `afterMount` — the top-level Notes tab, not the per-account expansion | _(none — funnel anchor)_ |
+| `customer analytics notes tab searched` | `accountNotesLogic` `setSearch` listener (post-debounce) | `has_query`, `query_length` (no raw text) |
+| `customer analytics notes tab filtered` | `accountNotesLogic` `reportFilterChange` listener (dispatched by the filter controls only, so the "My notes" cascade doesn't double-fire) | `filter_type` (`created_by` \| `account` \| `my_notes`), `is_cleared`; for `created_by` also `user_count`; for `my_notes` also `value` (no account id/name logged) |
+| `customer analytics notes tab note clicked` | `AccountNotesTabContent.tsx` note title `<Link>` `onClick` (opens side panel) | `notebook_short_id` |
+| `customer analytics notes tab account clicked` | `AccountNotesTabContent.tsx` account `<Link>` `onClick` | `account_id` |
> **Keep this table up to date.** Whenever you add, rename, or remove a `posthog.capture()` event in the Accounts area — or change its properties — update this table in the same change. An agent reading this file should be able to trust it as the source of truth for what the Accounts list reports.
diff --git a/products/customer_analytics/frontend/components/Accounts/constants.ts b/products/customer_analytics/frontend/components/Accounts/constants.ts
index d45b68a07923..cebd171f17e8 100644
--- a/products/customer_analytics/frontend/components/Accounts/constants.ts
+++ b/products/customer_analytics/frontend/components/Accounts/constants.ts
@@ -50,6 +50,9 @@ export const AccountsEvents = {
OpportunityClicked: 'customer analytics account opportunity clicked',
NotesTabViewed: 'customer analytics notes tab viewed',
NotesTabSearched: 'customer analytics notes tab searched',
+ NotesTabFiltered: 'customer analytics notes tab filtered',
NotesTabNoteClicked: 'customer analytics notes tab note clicked',
NotesTabAccountClicked: 'customer analytics notes tab account clicked',
} as const
+
+export type NotesTabFilterType = 'created_by' | 'account' | 'my_notes'