Skip to content

Commit

Permalink
feat: capture on user the first product they selected to onboard into (
Browse files Browse the repository at this point in the history
…#19687)

* capture on user the first product they selected to onboard into

* only capture this for new users
  • Loading branch information
raquelmsmith authored Jan 12, 2024
1 parent a45aef4 commit 5c8b912
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
15 changes: 13 additions & 2 deletions frontend/src/lib/utils/eventUsageLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,13 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
reportSurveyTemplateClicked: (template: SurveyTemplateType) => ({ template }),
reportProductUnsubscribed: (product: string) => ({ product }),
// onboarding
reportOnboardingProductSelected: (productKey: string) => ({ productKey }),
reportOnboardingProductSelected: (
productKey: string,
includeFirstOnboardingProductOnUserProperties: boolean
) => ({
productKey,
includeFirstOnboardingProductOnUserProperties,
}),
reportOnboardingCompleted: (productKey: string) => ({ productKey }),
reportSubscribedDuringOnboarding: (productKey: string) => ({ productKey }),
// command bar
Expand Down Expand Up @@ -1200,9 +1206,14 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
})
},
// onboarding
reportOnboardingProductSelected: ({ productKey }) => {
reportOnboardingProductSelected: ({ productKey, includeFirstOnboardingProductOnUserProperties }) => {
posthog.capture('onboarding product selected', {
product_key: productKey,
$set_once: {
first_onboarding_product_selected: includeFirstOnboardingProductOnUserProperties
? productKey
: undefined,
},
})
},
reportOnboardingCompleted: ({ productKey }) => {
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/scenes/products/productsLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { actions, connect, kea, listeners, path } from 'kea'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { onboardingLogic } from 'scenes/onboarding/onboardingLogic'
import { teamLogic } from 'scenes/teamLogic'
import { userLogic } from 'scenes/userLogic'

import { ProductKey } from '~/types'

Expand All @@ -11,13 +12,20 @@ export const productsLogic = kea<productsLogicType>([
path(() => ['scenes', 'products', 'productsLogic']),
connect({
actions: [teamLogic, ['updateCurrentTeam'], onboardingLogic, ['setProduct']],
values: [userLogic, ['user']],
}),
actions(() => ({
onSelectProduct: (product: ProductKey) => ({ product }),
})),
listeners(({ actions }) => ({
listeners(({ actions, values }) => ({
onSelectProduct: ({ product }) => {
eventUsageLogic.actions.reportOnboardingProductSelected(product)
const includeFirstOnboardingProductOnUserProperties = values.user?.date_joined
? new Date(values.user?.date_joined) > new Date('2024-01-10T00:00:00Z')
: false
eventUsageLogic.actions.reportOnboardingProductSelected(
product,
includeFirstOnboardingProductOnUserProperties
)

switch (product) {
case ProductKey.PRODUCT_ANALYTICS:
Expand Down

0 comments on commit 5c8b912

Please sign in to comment.