Skip to content

Commit

Permalink
adding logic for dashboard white label
Browse files Browse the repository at this point in the history
  • Loading branch information
surbhi-posthog committed Dec 30, 2024
1 parent 3380872 commit 7ec7db3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 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, captureWhitelabelToggled } = useActions(sharingLogic(logicProps))
const { setIsEnabled, togglePreview, setIsWhitelabelEnabled } = useActions(sharingLogic(logicProps))
const { guardAvailableFeature } = useValues(upgradeModalLogic)

const [iframeLoaded, setIframeLoaded] = useState(false)
Expand Down Expand Up @@ -176,7 +176,7 @@ export function SharingModalContent({
onChange={() =>
guardAvailableFeature(AvailableFeature.WHITE_LABELLING, () => {
onChange(!value)
captureWhitelabelToggled(!value)
setIsWhitelabelEnabled(!value)
})
}
checked={!value}
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/lib/components/Sharing/sharingLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -58,7 +57,7 @@ export const sharingLogic = kea<sharingLogicType>([

actions({
togglePreview: true,
captureWhitelabelToggled: (enabled: boolean) => ({ enabled }),
setIsWhitelabelEnabled: (enabled: boolean) => ({ enabled }),
}),
reducers({
showPreview: [true, { togglePreview: (state) => !state }],
Expand Down Expand Up @@ -88,8 +87,10 @@ export const sharingLogic = kea<sharingLogicType>([
dashboardsModel.actions.loadDashboards()
}
},
captureWhitelabelToggled: ({ enabled }) => {
posthog.capture('sharing insight whitelabel toggled', { enabled })
setIsWhitelabelEnabled: (enabled) => {
if (props.dashboardId) {
eventUsageLogic.actions.reportDashboardWhitelabelToggled(enabled)

Check failure on line 92 in frontend/src/lib/components/Sharing/sharingLogic.ts

View workflow job for this annotation

GitHub Actions / Code quality checks

Argument of type '{ enabled: boolean; }' is not assignable to parameter of type 'boolean'.
}
},
})),

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: (isWhitelabelToggled: boolean) => ({ isWhitelabelToggled }),
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 ({ isWhitelabelToggled }) => {
posthog.capture(`dashboard whitelabel toggled`, { is_whitelabel_toggled: isWhitelabelToggled })
},
reportUpgradeModalShown: async (payload) => {
posthog.capture('upgrade modal shown', payload)
},
Expand Down

0 comments on commit 7ec7db3

Please sign in to comment.