From d7e13eb6851ba69e8923db5131e73b966f843c63 Mon Sep 17 00:00:00 2001 From: Stanislav Lysak Date: Fri, 13 Dec 2024 14:04:28 +0200 Subject: [PATCH] FET-1721: feature flag example --- src/components/pages/profile/[name]/Profile.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/pages/profile/[name]/Profile.tsx b/src/components/pages/profile/[name]/Profile.tsx index 5f67940be..05efbd2e5 100644 --- a/src/components/pages/profile/[name]/Profile.tsx +++ b/src/components/pages/profile/[name]/Profile.tsx @@ -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' @@ -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 ( <>