Skip to content

Commit

Permalink
feat: Add Feature Flag to Redirect Users to /insights After Product A…
Browse files Browse the repository at this point in the history
…nalytics Onboarding (#19346)

* wire up feature flag for redirecting people to /insights after product analytics onboarding

* fix implementation

* update the insights redirect url to include onboarding_completed

---------

Co-authored-by: Bianca Yang <[email protected]>
  • Loading branch information
xrdt and Bianca Yang authored Dec 18, 2023
1 parent a4a694c commit b6d6a5c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions frontend/src/lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export const FEATURE_FLAGS = {
SESSION_REPLAY_IOS: 'session-replay-ios', // owner: #team-replay
YEAR_IN_HOG: 'year-in-hog', // owner: #team-replay
SESSION_REPLAY_EXPORT_MOBILE_DATA: 'session-replay-export-mobile-data', // owner: #team-replay
REDIRECT_INGESTION_PRODUCT_ANALYTICS_ONBOARDING: 'redirect-ingestion-product-analytics-onboarding', // owner: @biancayang
} as const
export type FeatureFlagKey = (typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS]

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/onboarding/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const OnboardingWrapper = ({ children }: { children: React.ReactNode }): JSX.Ele
const OtherProductsStep = <OnboardingOtherProductsStep stepKey={OnboardingStepKey.OTHER_PRODUCTS} />
steps = [...steps, OtherProductsStep]
}
if (featureFlags[FEATURE_FLAGS.INVITE_TEAM_MEMBER_ONBOARDING] == 'test') {
if (featureFlags[FEATURE_FLAGS.INVITE_TEAM_MEMBER_ONBOARDING] === 'test') {
const inviteTeammatesStep = <OnboardingInviteTeammates stepKey={OnboardingStepKey.INVITE_TEAMMATES} />
steps = [...steps, inviteTeammatesStep]
}
Expand Down
24 changes: 13 additions & 11 deletions frontend/src/scenes/onboarding/onboardingLogic.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { actions, connect, kea, listeners, path, props, reducers, selectors } from 'kea'
import { actionToUrl, combineUrl, router, urlToAction } from 'kea-router'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic, FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { billingLogic } from 'scenes/billing/billingLogic'
import { teamLogic } from 'scenes/teamLogic'
Expand Down Expand Up @@ -27,10 +29,12 @@ export enum OnboardingStepKey {
export type AllOnboardingSteps = OnboardingStep[]
export type OnboardingStep = JSX.Element

export const getProductUri = (productKey: ProductKey): string => {
export const getProductUri = (productKey: ProductKey, featureFlags: FeatureFlagsSet): string => {
switch (productKey) {
case ProductKey.PRODUCT_ANALYTICS:
return combineUrl(urls.events(), { onboarding_completed: true }).url
return featureFlags[FEATURE_FLAGS.REDIRECT_INGESTION_PRODUCT_ANALYTICS_ONBOARDING] === 'test'
? combineUrl(urls.insights(), { onboarding_completed: true }).url
: combineUrl(urls.events(), { onboarding_completed: true }).url
case ProductKey.SESSION_REPLAY:
return urls.replay()
case ProductKey.FEATURE_FLAGS:
Expand All @@ -46,7 +50,7 @@ export const onboardingLogic = kea<onboardingLogicType>([
props({} as OnboardingLogicProps),
path(['scenes', 'onboarding', 'onboardingLogic']),
connect({
values: [billingLogic, ['billing'], teamLogic, ['currentTeam']],
values: [billingLogic, ['billing'], teamLogic, ['currentTeam'], featureFlagLogic, ['featureFlags']],
actions: [billingLogic, ['loadBillingSuccess'], teamLogic, ['updateCurrentTeamSuccess']],
}),
actions({
Expand Down Expand Up @@ -85,14 +89,6 @@ export const onboardingLogic = kea<onboardingLogicType>([
setStepKey: (_, { stepKey }) => stepKey,
},
],
onCompleteOnboardingRedirectUrl: [
urls.default(),
{
setProductKey: (_, { productKey }) => {
return productKey ? getProductUri(productKey as ProductKey) : urls.default()
},
},
],
subscribedDuringOnboarding: [
false,
{
Expand All @@ -101,6 +97,12 @@ export const onboardingLogic = kea<onboardingLogicType>([
],
})),
selectors({
onCompleteOnboardingRedirectUrl: [
(s) => [s.featureFlags, s.productKey],
(featureFlags: FeatureFlagsSet, productKey: string | null) => {
return productKey ? getProductUri(productKey as ProductKey, featureFlags) : urls.default()
},
],
totalOnboardingSteps: [
(s) => [s.allOnboardingSteps],
(allOnboardingSteps: AllOnboardingSteps) => allOnboardingSteps.length,
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/scenes/products/Products.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useActions, useValues } from 'kea'
import { router } from 'kea-router'
import { LemonCard } from 'lib/lemon-ui/LemonCard/LemonCard'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { billingLogic } from 'scenes/billing/billingLogic'
import { getProductUri } from 'scenes/onboarding/onboardingLogic'
import { SceneExport } from 'scenes/sceneTypes'
Expand Down Expand Up @@ -93,6 +94,7 @@ export function ProductCard({
className?: string
}): JSX.Element {
const { currentTeam } = useValues(teamLogic)
const { featureFlags } = useValues(featureFlagLogic)
const onboardingCompleted = currentTeam?.has_completed_onboarding_for?.[product.type]
const vertical = orientation === 'vertical'

Expand All @@ -113,7 +115,7 @@ export function ProductCard({
<div className={`flex gap-x-2 flex-0 items-center ${!vertical && 'justify-end'}`}>
{onboardingCompleted ? (
<OnboardingCompletedButton
productUrl={getProductUri(product.type as ProductKey)}
productUrl={getProductUri(product.type as ProductKey, featureFlags)}
onboardingUrl={urls.onboarding(product.type)}
productKey={product.type as ProductKey}
/>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const urls = {
`/batch_exports/${id}` + (params ? `?${toParams(params)}` : ''),
batchExportEdit: (id: string): string => `/batch_exports/${id}/edit`,
ingestionWarnings: (): string => '/data-management/ingestion-warnings',
insights: (): string => '/insights',
insightNew: (filters?: AnyPartialFilterType, dashboardId?: DashboardType['id'] | null, query?: string): string =>
combineUrl('/insights/new', dashboardId ? { dashboard: dashboardId } : {}, {
...(filters ? { filters } : {}),
Expand Down

0 comments on commit b6d6a5c

Please sign in to comment.