: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(customer-analytics): Instrument notes tab analytics events (#68001)
Arthur Moreira de Deus9e4ce46a39aa
diff --git a/products/customer_analytics/frontend/components/AccountNotes/AccountNotesTabContent.tsx b/products/customer_analytics/frontend/components/AccountNotes/AccountNotesTabContent.tsxindex 63fd7279240e..2748e48cf3b7 100644--- a/products/customer_analytics/frontend/components/AccountNotes/AccountNotesTabContent.tsx+++ b/products/customer_analytics/frontend/components/AccountNotes/AccountNotesTabContent.tsx@@ -1,4 +1,5 @@import { useActions, useValues } from 'kea'+import posthog from 'posthog-js'import { LemonInput, LemonSkeleton } from '@posthog/lemon-ui'@@ -10,6 +11,7 @@ import { urls } from 'scenes/urls'import type { AccountNoteApi } from 'products/customer_analytics/frontend/generated/api.schemas'+import { AccountsEvents } from '../Accounts/constants'import { accountNotesLogic } from './accountNotesLogic'export function AccountNotesTabContent(): JSX.Element {@@ -32,6 +34,9 @@ export function AccountNotesTabContent(): JSX.Element {to={urls.notebook(note.short_id)}className="font-semibold"onClick={(event) => {+ posthog.capture(AccountsEvents.NotesTabNoteClicked, {+ notebook_short_id: note.short_id,+ })event.preventDefault()selectNotebook(note.short_id)}}@@ -50,6 +55,9 @@ export function AccountNotesTabContent(): JSX.Element {data-attr="account-note-account"to={urls.customerAnalyticsAccount(note.account_id)}className="whitespace-nowrap"+ onClick={() => {+ posthog.capture(AccountsEvents.NotesTabAccountClicked, { account_id: note.account_id })+ }}>{accountName}</Link>diff --git a/products/customer_analytics/frontend/components/AccountNotes/accountNotesLogic.ts b/products/customer_analytics/frontend/components/AccountNotes/accountNotesLogic.tsindex 3cb4ecd7debf..2962364fb8d9 100644--- a/products/customer_analytics/frontend/components/AccountNotes/accountNotesLogic.ts+++ b/products/customer_analytics/frontend/components/AccountNotes/accountNotesLogic.ts@@ -12,6 +12,7 @@ import type {PaginatedAccountNoteListApi,} from 'products/customer_analytics/frontend/generated/api.schemas'+import { AccountsEvents } from '../Accounts/constants'import type { accountNotesLogicType } from './accountNotesLogicType'const RESULTS_PER_PAGE = 50@@ -64,8 +65,17 @@ export const accountNotesLogic = kea<accountNotesLogicType>([}),],})),- listeners(({ actions }) => ({- setSearch: () => actions.loadAccountNotes(),+ listeners(({ actions, values }) => ({+ // Analytics capture is debounced so only the settled query reports, never per keystroke;+ // no raw search text is logged (PII convention).+ setSearch: async (_, breakpoint) => {+ actions.loadAccountNotes()+ await breakpoint(500)+ posthog.capture(AccountsEvents.NotesTabSearched, {+ has_query: !!values.search,+ query_length: values.search.length,+ })+ },setPage: () => actions.loadAccountNotes(),loadAccountNotesFailure: ({ error }) => {posthog.captureException(error)@@ -73,6 +83,7 @@ export const accountNotesLogic = kea<accountNotesLogicType>([},})),afterMount(({ actions }) => {+ posthog.capture(AccountsEvents.NotesTabViewed)actions.loadAccountNotes()}),])diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.mdindex a40b747724f4..f73b677caa23 100644--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md@@ -182,6 +182,10 @@ We track user actions on the Accounts list with `posthog.capture()`. Conventions| `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` |> **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.tsindex 1d69d0808dce..d45b68a07923 100644--- a/products/customer_analytics/frontend/components/Accounts/constants.ts+++ b/products/customer_analytics/frontend/components/Accounts/constants.ts@@ -48,4 +48,8 @@ export const AccountsEvents = {TabViewed: 'customer analytics account tab viewed',RelatedUserClicked: 'customer analytics account related user clicked',OpportunityClicked: 'customer analytics account opportunity clicked',+ NotesTabViewed: 'customer analytics notes tab viewed',+ NotesTabSearched: 'customer analytics notes tab searched',+ NotesTabNoteClicked: 'customer analytics notes tab note clicked',+ NotesTabAccountClicked: 'customer analytics notes tab account clicked',} as const