Skip to content

Commit

Permalink
FET-1721: feature flag example
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Lysak committed Dec 13, 2024
1 parent 82b9cea commit d7e13eb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/pages/profile/[name]/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Head from 'next/head'
import { useFeatureFlagVariantKey } from 'posthog-js/react'
import { useEffect, useMemo } from 'react'
import { Trans, useTranslation } from 'react-i18next'
import styled, { css } from 'styled-components'
Expand Down Expand Up @@ -229,6 +230,18 @@ const ProfileContent = ({ isSelf, isLoading: parentIsLoading, name }: Props) =>

const chainName = useChainName()

// posthog.featureFlags.override({ 'ab-test-1': 'test' })s
const key = useFeatureFlagVariantKey('ab-test-1')
// or user posthog.getFeatureFlag('ab-test-1') import from posthog-js

if (key === 'test') {
console.log(`feature flag: ${key}`)
// Do something differently for this user
} else {
// It's a good idea to let control variant always be the default behaviour,
// so if something goes wrong with flag evaluation, you don't break your app.
}

return (
<>
<Head>
Expand Down

0 comments on commit d7e13eb

Please sign in to comment.