Skip to content

Commit

Permalink
feat: adding white label event capture for sharing (#27140)
Browse files Browse the repository at this point in the history
  • Loading branch information
surbhi-posthog authored Jan 7, 2025
1 parent 8e0fabf commit 4e1e75e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
11 changes: 6 additions & 5 deletions frontend/src/lib/components/Sharing/SharingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function SharingModalContent({
iframeProperties,
shareLink,
} = useValues(sharingLogic(logicProps))
const { setIsEnabled, togglePreview } = useActions(sharingLogic(logicProps))
const { setIsEnabled, togglePreview, setEmbedConfigValue } = useActions(sharingLogic(logicProps))
const { guardAvailableFeature } = useValues(upgradeModalLogic)

const [iframeLoaded, setIframeLoaded] = useState(false)
Expand Down Expand Up @@ -159,7 +159,7 @@ export function SharingModalContent({
</LemonField>
)}
<LemonField name="whitelabel">
{({ value, onChange }) => (
{({ value }) => (
<LemonSwitch
fullWidth
bordered
Expand All @@ -174,9 +174,10 @@ export function SharingModalContent({
</div>
}
onChange={() =>
guardAvailableFeature(AvailableFeature.WHITE_LABELLING, () =>
onChange(!value)
)
guardAvailableFeature(AvailableFeature.WHITE_LABELLING, () => {
// setEmbedConfigValue is used to update the form state and call the reportDashboardWhitelabelToggled event
setEmbedConfigValue('whitelabel', !value)
})
}
checked={!value}
/>
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/lib/components/Sharing/sharingLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ export const sharingLogic = kea<sharingLogicType>([
dashboardsModel.actions.loadDashboards()
}
},
setEmbedConfigValue: ({ name, value }) => {
if (name === 'whitelabel' && props.dashboardId) {
eventUsageLogic.actions.reportDashboardWhitelabelToggled(value)
}
},
})),

forms({
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/lib/utils/eventUsageLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
newLength: number
) => ({ attribute, originalLength, newLength }),
reportDashboardShareToggled: (isShared: boolean) => ({ isShared }),
reportDashboardWhitelabelToggled: (isWhiteLabelled: boolean) => ({ isWhiteLabelled }),
reportUpgradeModalShown: (featureName: string) => ({ featureName }),
reportTimezoneComponentViewed: (
component: 'label' | 'indicator',
Expand Down Expand Up @@ -791,6 +792,9 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
reportDashboardShareToggled: async ({ isShared }) => {
posthog.capture(`dashboard share toggled`, { is_shared: isShared })
},
reportDashboardWhitelabelToggled: async ({ isWhiteLabelled }) => {
posthog.capture(`dashboard whitelabel toggled`, { is_whitelabelled: isWhiteLabelled })
},
reportUpgradeModalShown: async (payload) => {
posthog.capture('upgrade modal shown', payload)
},
Expand Down

0 comments on commit 4e1e75e

Please sign in to comment.