: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): add Salesforce useful link to account details (#66063)
Arthur Moreira de Deuscdef985aa32a
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 30ccf2b7fb0c..b150e4363be4 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -4765,9 +4765,9 @@ snapshots:scenes-app-customer-analytics-accounts--row-expanded-empty--light:hash: v1.k794b7964.904bd5b939f99d43408ae3a8a814a3c299bd57bf13a0fd1d98ff6033fd66e343.K1Z16ICEF6-O9kIej8kGnYyarloq2oZH5rdtmx-8Hu0scenes-app-customer-analytics-accounts--row-expanded-links-disabled--dark:- hash: v1.k794b7964.f2d43867c031f539641e4c8f6fcf30bfe6140cc9e3aa596b65d767dd10fa4921.F1vyV__TE7gcuA85X8fUmey9KXhssurg6Rk65ETYcIM+ hash: v1.k794b7964.520e6455cfdd404a1af3d98f6c138a0b5ce57f94e66263f26b968418daebaa64.ACJbyDSyqXK4dZKV4TUemg4cKPIjpXZB008wOEI5D20scenes-app-customer-analytics-accounts--row-expanded-links-disabled--light:- hash: v1.k794b7964.7895f3c3ea4bd144f0fab73b065ed655f19e1726976d0fef0abfeb68d10743f6.1yXgRyhrdluQY4gaksbmnL5KmsTfBC51mFDrwuH-a8k+ hash: v1.k794b7964.b6d4fa4f4fe7f87fe5fea5c702fc4db8558f8b9f0904cb9659ae9aece845b3ac.QfMAWNJmI8DCp90AGyh4Ena5eXJqEtCc3OFG2onVXnIscenes-app-customer-analytics-accounts--row-expanded-usage-not-found--dark:hash: v1.k794b7964.53af994a2a4dfb2f883e27ed73be8d55e1177b97f5c8b622708dfcdbe5f33d2a.A7AJRK9hY-yytJMNPghuLYtOJIoj0VBJidseMubwZWsscenes-app-customer-analytics-accounts--row-expanded-usage-not-found--light:diff --git a/products/customer_analytics/frontend/components/Accounts/AccountNotebooksExpansion.tsx b/products/customer_analytics/frontend/components/Accounts/AccountNotebooksExpansion.tsxindex 06194ca540c5..f2ef551f6b04 100644--- a/products/customer_analytics/frontend/components/Accounts/AccountNotebooksExpansion.tsx+++ b/products/customer_analytics/frontend/components/Accounts/AccountNotebooksExpansion.tsx@@ -1,7 +1,7 @@import { useActions, useValues } from 'kea'import posthog from 'posthog-js'-import { IconGraph, IconPencil, IconPeople, IconPiggyBank, IconReceipt } from '@posthog/icons'+import { IconCloud, IconGraph, IconPencil, IconPeople, IconPiggyBank, IconReceipt } from '@posthog/icons'import {LemonButton,LemonInput,@@ -46,6 +46,7 @@ const LINK_ICONS: Record<string, JSX.Element> = {'usage-dashboard': <IconGraph />,slack: <IconSlack />,'billing-admin': <IconReceipt />,+ salesforce: <IconCloud />,}function UsefulLinks({ accountId }: { accountId: string }): JSX.Element {diff --git a/products/customer_analytics/frontend/components/Accounts/accountLinksLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountLinksLogic.test.tsindex 1e2816f16d9e..c686a7b0d70e 100644--- a/products/customer_analytics/frontend/components/Accounts/accountLinksLogic.test.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountLinksLogic.test.ts@@ -68,6 +68,7 @@ describe('accountLinksLogic', () => {billing_id: 'cus_1',slack_channel_id: 'C1',usage_dashboard_link: '',+ sfdc_id: '',})})@@ -87,6 +88,7 @@ describe('accountLinksLogic', () => {billing_id: 'new',slack_channel_id: 'C9',usage_dashboard_link: '',+ sfdc_id: '001abc',})logic.actions.saveLinks()await expectLogic(logic).toFinishAllListeners()@@ -98,6 +100,7 @@ describe('accountLinksLogic', () => {billing_id: 'new',slack_channel_id: 'C9',usage_dashboard_link: null,+ sfdc_id: '001abc',},})expect(logic.values.account).toEqual(updated)@@ -113,13 +116,14 @@ describe('accountLinksLogic', () => {billing_id: '',slack_channel_id: ' ',usage_dashboard_link: '',+ sfdc_id: '',})logic.actions.saveLinks()await expectLogic(logic).toFinishAllListeners()expect(mockAccountsPartialUpdate).toHaveBeenCalledWith(TEAM, 'acc-1', {external_id: null,- properties: { billing_id: null, slack_channel_id: null, usage_dashboard_link: null },+ properties: { billing_id: null, slack_channel_id: null, usage_dashboard_link: null, sfdc_id: null },})})diff --git a/products/customer_analytics/frontend/components/Accounts/accountLinksLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountLinksLogic.tsindex 0712c633838a..4d4d23a0b481 100644--- a/products/customer_analytics/frontend/components/Accounts/accountLinksLogic.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountLinksLogic.ts@@ -20,12 +20,13 @@ const ORGANIZATION_GROUP_TYPE_INDEX = 0const REVENUE_DASHBOARD_ID = 259114const BILLING_ADMIN_ORIGIN = 'https://billing.posthog.com'const SLACK_ARCHIVES_ORIGIN = 'https://posthog.slack.com/archives'+const SALESFORCE_ORIGIN = 'https://posthog.my.salesforce.com'export interface AccountLinksLogicProps {accountId: string}-export type AccountLinkFieldKey = 'external_id' | 'billing_id' | 'slack_channel_id' | 'usage_dashboard_link'+export type AccountLinkFieldKey = 'external_id' | 'billing_id' | 'slack_channel_id' | 'usage_dashboard_link' | 'sfdc_id'export interface AccountLinkFieldDef {key: AccountLinkFieldKey@@ -40,6 +41,7 @@ export const ACCOUNT_LINK_FIELDS: AccountLinkFieldDef[] = [{ key: 'billing_id', label: 'Billing ID', placeholder: 'e.g. cus_acme_123' },{ key: 'slack_channel_id', label: 'Slack channel ID', placeholder: 'e.g. C0123456789' },{ key: 'usage_dashboard_link', label: 'Usage dashboard link', placeholder: 'https://…' },+ { key: 'sfdc_id', label: 'Salesforce ID', placeholder: 'e.g. 0011t00000AbCdEfGhI' },]const EMPTY_FIELDS: AccountLinkFieldValues = {@@ -47,6 +49,7 @@ const EMPTY_FIELDS: AccountLinkFieldValues = {billing_id: '',slack_channel_id: '',usage_dashboard_link: '',+ sfdc_id: '',}export interface AccountLink {@@ -124,6 +127,7 @@ export const accountLinksLogic = kea<accountLinksLogicType>([billing_id: account?.properties?.billing_id ?? '',slack_channel_id: account?.properties?.slack_channel_id ?? '',usage_dashboard_link: account?.properties?.usage_dashboard_link ?? '',+ sfdc_id: account?.properties?.sfdc_id ?? '',}),],links: [@@ -133,6 +137,7 @@ export const accountLinksLogic = kea<accountLinksLogicType>([const billingId = account?.properties?.billing_id ?? nullconst slackChannelId = account?.properties?.slack_channel_id ?? nullconst usageDashboardLink = account?.properties?.usage_dashboard_link ?? null+ const sfdcId = account?.properties?.sfdc_id ?? nullconst backUrl =removeProjectIdIfPresent(currentLocation.pathname) + currentLocation.search + currentLocation.hashreturn [@@ -176,6 +181,13 @@ export const accountLinksLogic = kea<accountLinksLogicType>([targetBlank: true,disabledReason: billingId ? null : 'No billing ID set',},+ {+ key: 'salesforce',+ label: 'Salesforce',+ to: sfdcId ? `${SALESFORCE_ORIGIN}/${sfdcId}` : null,+ targetBlank: true,+ disabledReason: sfdcId ? null : 'No Salesforce ID set',+ },]},],@@ -201,6 +213,7 @@ export const accountLinksLogic = kea<accountLinksLogicType>([billing_id: orNull(form.billing_id),slack_channel_id: orNull(form.slack_channel_id),usage_dashboard_link: orNull(form.usage_dashboard_link),+ sfdc_id: orNull(form.sfdc_id),} as PatchedAccountApiProperties,})actions.loadAccountSuccess(updated)