diff --git a/frontend/src/lib/components/Sharing/SharingModal.tsx b/frontend/src/lib/components/Sharing/SharingModal.tsx index e699d2f82f828..0f5a47b2bfe6b 100644 --- a/frontend/src/lib/components/Sharing/SharingModal.tsx +++ b/frontend/src/lib/components/Sharing/SharingModal.tsx @@ -65,7 +65,7 @@ export function SharingModalContent({ iframeProperties, shareLink, } = useValues(sharingLogic(logicProps)) - const { setIsEnabled, togglePreview, captureWhitelabelToggled } = useActions(sharingLogic(logicProps)) + const { setIsEnabled, togglePreview, setIsWhitelabelEnabled } = useActions(sharingLogic(logicProps)) const { guardAvailableFeature } = useValues(upgradeModalLogic) const [iframeLoaded, setIframeLoaded] = useState(false) @@ -176,7 +176,7 @@ export function SharingModalContent({ onChange={() => guardAvailableFeature(AvailableFeature.WHITE_LABELLING, () => { onChange(!value) - captureWhitelabelToggled(!value) + setIsWhitelabelEnabled(!value) }) } checked={!value} diff --git a/frontend/src/lib/components/Sharing/sharingLogic.ts b/frontend/src/lib/components/Sharing/sharingLogic.ts index be3e668ae11a0..6d03bf3040505 100644 --- a/frontend/src/lib/components/Sharing/sharingLogic.ts +++ b/frontend/src/lib/components/Sharing/sharingLogic.ts @@ -3,7 +3,6 @@ import { forms } from 'kea-forms' import { loaders } from 'kea-loaders' import api from 'lib/api' import { eventUsageLogic } from 'lib/utils/eventUsageLogic' -import posthog from 'posthog-js' import { getInsightId } from 'scenes/insights/utils' import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic' import { urls } from 'scenes/urls' @@ -58,7 +57,7 @@ export const sharingLogic = kea([ actions({ togglePreview: true, - captureWhitelabelToggled: (enabled: boolean) => ({ enabled }), + setIsWhitelabelEnabled: (enabled: boolean) => ({ enabled }), }), reducers({ showPreview: [true, { togglePreview: (state) => !state }], @@ -88,8 +87,10 @@ export const sharingLogic = kea([ dashboardsModel.actions.loadDashboards() } }, - captureWhitelabelToggled: ({ enabled }) => { - posthog.capture('sharing insight whitelabel toggled', { enabled }) + setIsWhitelabelEnabled: (enabled) => { + if (props.dashboardId) { + eventUsageLogic.actions.reportDashboardWhitelabelToggled(enabled) + } }, })), diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.ts index 39487ede8f5e0..d2746e7614336 100644 --- a/frontend/src/lib/utils/eventUsageLogic.ts +++ b/frontend/src/lib/utils/eventUsageLogic.ts @@ -399,6 +399,7 @@ export const eventUsageLogic = kea([ newLength: number ) => ({ attribute, originalLength, newLength }), reportDashboardShareToggled: (isShared: boolean) => ({ isShared }), + reportDashboardWhitelabelToggled: (isWhitelabelToggled: boolean) => ({ isWhitelabelToggled }), reportUpgradeModalShown: (featureName: string) => ({ featureName }), reportTimezoneComponentViewed: ( component: 'label' | 'indicator', @@ -791,6 +792,9 @@ export const eventUsageLogic = kea([ reportDashboardShareToggled: async ({ isShared }) => { posthog.capture(`dashboard share toggled`, { is_shared: isShared }) }, + reportDashboardWhitelabelToggled: async ({ isWhitelabelToggled }) => { + posthog.capture(`dashboard whitelabel toggled`, { is_whitelabel_toggled: isWhitelabelToggled }) + }, reportUpgradeModalShown: async (payload) => { posthog.capture('upgrade modal shown', payload) },