Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding white label event capture for sharing #27140

Merged
merged 8 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

@zlwaterfield zlwaterfield Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should still call onChange here so if we ever save this to the API the form state is updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide to save this to the API, i think we should be able to handle it in the sharingLogic which keeps track of the whitelabel state. I prefer not having onChange and setEmbedConfigValue together since they will be redundant. Let me know if I'm not understanding your suggestion correctly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setEmbedConfigValue is only calling eventUsageLogic.actions.reportDashboardWhitelabelToggled(value) so it is not updating the form state in kea.

)
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
Loading