From 0212fb26c5732e7a02e0e1a7ea24ddc366614995 Mon Sep 17 00:00:00 2001 From: Raquel Smith Date: Wed, 18 Sep 2024 14:09:49 -0700 Subject: [PATCH] feat(onboarding-templates): add template request form (#25062) --- .../DashboardTemplateSelectStep.tsx | 80 ++++++++++++++++--- .../onboardingTemplateConfigLogic.ts | 36 ++++++++- 2 files changed, 102 insertions(+), 14 deletions(-) diff --git a/frontend/src/scenes/onboarding/productAnalyticsSteps/DashboardTemplateSelectStep.tsx b/frontend/src/scenes/onboarding/productAnalyticsSteps/DashboardTemplateSelectStep.tsx index 0c437a6594e83..dde443fea3a4a 100644 --- a/frontend/src/scenes/onboarding/productAnalyticsSteps/DashboardTemplateSelectStep.tsx +++ b/frontend/src/scenes/onboarding/productAnalyticsSteps/DashboardTemplateSelectStep.tsx @@ -1,5 +1,7 @@ -import { LemonButton } from '@posthog/lemon-ui' -import { useActions } from 'kea' +import { LemonButton, LemonInput, LemonModal } from '@posthog/lemon-ui' +import { useActions, useValues } from 'kea' +import { Form } from 'kea-forms' +import { LemonField } from 'lib/lemon-ui/LemonField' import { useEffect } from 'react' import { DashboardTemplateChooser } from 'scenes/dashboard/DashboardTemplateChooser' import { newDashboardLogic } from 'scenes/dashboard/newDashboardLogic' @@ -17,7 +19,13 @@ export const OnboardingDashboardTemplateSelectStep = ({ }): JSX.Element => { const { goToNextStep } = useActions(onboardingLogic) const { clearActiveDashboardTemplate } = useActions(newDashboardLogic) - const { setDashboardCreatedDuringOnboarding, reportTemplateSelected } = useActions(onboardingTemplateConfigLogic) + const { + setDashboardCreatedDuringOnboarding, + reportTemplateSelected, + showTemplateRequestModal, + hideTemplateRequestModal, + } = useActions(onboardingTemplateConfigLogic) + const { isTemplateRequestModalOpen, isTemplateRequestFormSubmitting } = useValues(onboardingTemplateConfigLogic) // TODO: this is hacky, find a better way to clear the active template when coming back to this screen useEffect(() => { @@ -29,15 +37,27 @@ export const OnboardingDashboardTemplateSelectStep = ({ title="Start with a dashboard template" stepKey={stepKey} continueOverride={ - { - goToNextStep(2) - }} - data-attr="onboarding-skip-button" - > - Skip for now - +
+ { + showTemplateRequestModal() + }} + data-attr="onboarding-skip-button" + > + I need a different template + + { + goToNextStep(2) + }} + data-attr="onboarding-skip-button" + > + Skip for now + +
} >

@@ -56,6 +76,42 @@ export const OnboardingDashboardTemplateSelectStep = ({ redirectAfterCreation={false} availabilityContexts={[TemplateAvailabilityContext.ONBOARDING]} /> + +

+

+ PostHog can collect and visualize data from anywhere. We're still adding more templates to this + onboarding flow for different use-cases and business types. +

+

Let us know what kind of template you'd like to see and we'll work on adding one.

+
+ + + + + Continue + +
+
+ ) } diff --git a/frontend/src/scenes/onboarding/productAnalyticsSteps/onboardingTemplateConfigLogic.ts b/frontend/src/scenes/onboarding/productAnalyticsSteps/onboardingTemplateConfigLogic.ts index 6dffe47f5f3bc..bb1080cd0c41a 100644 --- a/frontend/src/scenes/onboarding/productAnalyticsSteps/onboardingTemplateConfigLogic.ts +++ b/frontend/src/scenes/onboarding/productAnalyticsSteps/onboardingTemplateConfigLogic.ts @@ -1,4 +1,5 @@ import { actions, connect, kea, listeners, path, reducers } from 'kea' +import { forms } from 'kea-forms' import { urlToAction } from 'kea-router' import posthog from 'posthog-js' import { dashboardTemplateVariablesLogic } from 'scenes/dashboard/dashboardTemplateVariablesLogic' @@ -28,7 +29,7 @@ export const onboardingTemplateConfigLogic = kea ({ template }), + showTemplateRequestModal: true, + hideTemplateRequestModal: true, }), reducers({ dashboardCreatedDuringOnboarding: [ @@ -47,13 +50,42 @@ export const onboardingTemplateConfigLogic = kea true, hideCustomEventField: () => false, }, ], + isTemplateRequestModalOpen: [ + false as boolean, + { + showTemplateRequestModal: () => true, + hideTemplateRequestModal: () => false, + }, + ], }), + forms(({ actions, values }) => ({ + templateRequestForm: { + alwaysShowErrors: true, + showErrorsOnTouch: true, + defaults: { + templateRequest: '', + }, + errors: ({ templateRequest }) => ({ + templateRequest: !templateRequest + ? "Please enter a template you'd like us to add to continue" + : undefined, + }), + submit: async () => { + posthog.capture('template requested during onboarding', { + template_request: values.templateRequestForm.templateRequest, + }) + actions.hideTemplateRequestModal() + actions.resetTemplateRequestForm() + actions.goToNextStep(2) + }, + }, + })), listeners(({ actions, values }) => ({ submitNewDashboardSuccessWithResult: ({ result, variables }) => { if (result && variables?.length == 0) {