diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.ts index 1649fe5a211df..009e4cdb77e1f 100644 --- a/frontend/src/lib/utils/eventUsageLogic.ts +++ b/frontend/src/lib/utils/eventUsageLogic.ts @@ -491,7 +491,13 @@ export const eventUsageLogic = kea([ 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 @@ -1200,9 +1206,14 @@ export const eventUsageLogic = kea([ }) }, // 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 }) => { diff --git a/frontend/src/scenes/products/productsLogic.tsx b/frontend/src/scenes/products/productsLogic.tsx index 313e26ea70a1c..4b5a7611e5e5c 100644 --- a/frontend/src/scenes/products/productsLogic.tsx +++ b/frontend/src/scenes/products/productsLogic.tsx @@ -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' @@ -11,13 +12,20 @@ export const productsLogic = kea([ 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: