Skip to content

Commit

Permalink
feat: surveys onboarding (#18053)
Browse files Browse the repository at this point in the history
* first pass

* update sdks

* add stepkey

* fix typo

* use correct number of sig figs
  • Loading branch information
raquelmsmith authored Oct 18, 2023
1 parent 7b8072d commit 3fe9dc2
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 2 deletions.
5 changes: 4 additions & 1 deletion frontend/src/scenes/billing/PlanComparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const getProductTiers = (
): JSX.Element => {
const tiers = plan?.tiers

const allTierPrices = tiers?.map((tier) => parseFloat(tier.unit_amount_usd))
const sigFigs = allTierPrices?.map((price) => price?.toString().split('.')[1]?.length).sort((a, b) => b - a)[0]

return (
<>
{tiers ? (
Expand All @@ -63,7 +66,7 @@ const getProductTiers = (
<span className="font-bold">
{i === 0 && parseFloat(tier.unit_amount_usd) === 0
? 'Free'
: `$${parseFloat(tier.unit_amount_usd).toFixed(6)}`}
: `$${parseFloat(tier.unit_amount_usd).toFixed(sigFigs)}`}
</span>
</div>
))
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/scenes/onboarding/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { OnboardingBillingStep } from './OnboardingBillingStep'
import { OnboardingOtherProductsStep } from './OnboardingOtherProductsStep'
import { OnboardingVerificationStep } from './OnboardingVerificationStep'
import { FeatureFlagsSDKInstructions } from './sdks/feature-flags/FeatureFlagsSDKInstructions'
import { SurveysSDKInstructions } from './sdks/surveys/SurveysSDKInstructions'

export const scene: SceneExport = {
component: Onboarding,
Expand Down Expand Up @@ -105,6 +106,19 @@ const FeatureFlagsOnboarding = (): JSX.Element => {
)
}

const SurveysOnboarding = (): JSX.Element => {
return (
<OnboardingWrapper>
<SDKs
usersAction="taking surveys"
sdkInstructionMap={SurveysSDKInstructions}
subtitle="Choose the framework your frontend is built on, or use our all-purpose JavaScript library. If you already have the snippet installed, you can skip this step!"
stepKey={OnboardingStepKey.SDKS}
/>
</OnboardingWrapper>
)
}

export function Onboarding(): JSX.Element | null {
const { featureFlags } = useValues(featureFlagLogic)
const { product } = useValues(onboardingLogic)
Expand All @@ -122,6 +136,7 @@ export function Onboarding(): JSX.Element | null {
[ProductKey.PRODUCT_ANALYTICS]: ProductAnalyticsOnboarding,
[ProductKey.SESSION_REPLAY]: SessionReplayOnboarding,
[ProductKey.FEATURE_FLAGS]: FeatureFlagsOnboarding,
[ProductKey.SURVEYS]: SurveysOnboarding,
}
const OnboardingView = onboardingViews[product.type]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const OnboardingOtherProductsStep = ({
return (
<OnboardingStep
title={`${product?.name} pairs with...`}
subtitle="The magic in PostHog is having everyting all in one place. Get started with our other products to unlock your product and data superpowers."
subtitle="The magic in PostHog is having everything all in one place. Get started with our other products to unlock your product and data superpowers."
showSkip
continueOverride={<></>}
stepKey={stepKey}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const SurveysFinalSteps = (): JSX.Element => {
return (
<>
<h3>Next up: Create a survey</h3>
<p>Complete this onboarding flow, then create a survey from one of our templates or from scratch.</p>
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SDKInstructionsMap, SDKKey } from '~/types'
import { JSWebInstructions, NextJSInstructions, ReactInstructions } from '.'

export const SurveysSDKInstructions: SDKInstructionsMap = {
[SDKKey.JS_WEB]: JSWebInstructions,
[SDKKey.NEXT_JS]: NextJSInstructions,
[SDKKey.REACT]: ReactInstructions,
}
3 changes: 3 additions & 0 deletions frontend/src/scenes/onboarding/sdks/surveys/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './js-web'
export * from './next-js'
export * from './react'
13 changes: 13 additions & 0 deletions frontend/src/scenes/onboarding/sdks/surveys/js-web.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
import { SDKInstallJSWebInstructions } from '../sdk-install-instructions'
import { SurveysFinalSteps } from './SurveysFinalSteps'

export function JSWebInstructions(): JSX.Element {
return (
<>
<SDKInstallJSWebInstructions />
<LemonDivider thick dashed className="my-4" />
<SurveysFinalSteps />
</>
)
}
11 changes: 11 additions & 0 deletions frontend/src/scenes/onboarding/sdks/surveys/next-js.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SDKInstallNextJSInstructions } from '../sdk-install-instructions/next-js'
import { SurveysFinalSteps } from './SurveysFinalSteps'

export function NextJSInstructions(): JSX.Element {
return (
<>
<SDKInstallNextJSInstructions />
<SurveysFinalSteps />
</>
)
}
11 changes: 11 additions & 0 deletions frontend/src/scenes/onboarding/sdks/surveys/react.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SDKInstallReactInstructions } from '../sdk-install-instructions/react'
import { SurveysFinalSteps } from './SurveysFinalSteps'

export function ReactInstructions(): JSX.Element {
return (
<>
<SDKInstallReactInstructions />
<SurveysFinalSteps />
</>
)
}

0 comments on commit 3fe9dc2

Please sign in to comment.