Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions docs/docs/best-practices/common-anti-patterns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: Common Anti-patterns
sidebar_label: Common Anti-patterns
sidebar_position: 10
---

# Common Anti-patterns

A flag works best when it answers one small question. The patterns below add work without making that question easier to
answer. Each section names the problem and gives a different way to handle it.

## Expecting real-time updates to change the screen

A real-time event tells your app that a flag changed. It does not change what the user sees. Your app still has to
refetch flags, handle requests already in flight, and decide what happens to a screen that is partway through a render.
Teams often add real-time updates first and write that code later.

Fetch flags when the session starts. That is enough for most applications. If a feature needs updates during a session,
use [real-time flags](/performance/real-time-flags) and plan for the refetch logic. Internal dashboards, kiosks,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Real-time flag updates require an Enterprise subscription, but this recommendation omits that restriction. State the plan requirement so readers do not plan around an unavailable feature.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/docs/best-practices/common-anti-patterns.md, line 19:

<comment>Real-time flag updates require an Enterprise subscription, but this recommendation omits that restriction. State the plan requirement so readers do not plan around an unavailable feature.</comment>

<file context>
@@ -0,0 +1,78 @@
+Teams often add real-time updates first and write that code later.
+
+Fetch flags when the session starts. That is enough for most applications. If a feature needs updates during a session,
+use [real-time flags](/performance/real-time-flags) and plan for the refetch logic. Internal dashboards, kiosks,
+monitoring screens, and emergency kill switches justify the extra code.
+
</file context>
Suggested change
use [real-time flags](/performance/real-time-flags) and plan for the refetch logic. Internal dashboards, kiosks,
+use [real-time flags](/performance/real-time-flags), available with an Enterprise subscription, and plan for the refetch logic. Internal dashboards, kiosks,

monitoring screens, and emergency kill switches justify the extra code.

## Chaining flags

Flagsmith supports [flag dependencies](/managing-flags/flag-dependencies), so one flag can depend on another. A long
chain is hard to reason about. Each extra link adds a state you have to simulate before you know what a user will see. A
Comment on lines +24 to +25

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This describes long dependency chains as a Flagsmith anti-pattern, but Flagsmith limits dependency nesting to one level. State the actual limit so readers do not look for unsupported configurations.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/docs/best-practices/common-anti-patterns.md, line 24:

<comment>This describes long dependency chains as a Flagsmith anti-pattern, but Flagsmith limits dependency nesting to one level. State the actual limit so readers do not look for unsupported configurations.</comment>

<file context>
@@ -0,0 +1,78 @@
+
+## Chaining flags
+
+Flagsmith supports [flag dependencies](/managing-flags/flag-dependencies), so one flag can depend on another. A long
+chain is hard to reason about. Each extra link adds a state you have to simulate before you know what a user will see. A
+broken prerequisite can also turn off a feature that looks unrelated.
</file context>
Suggested change
Flagsmith supports [flag dependencies](/managing-flags/flag-dependencies), so one flag can depend on another. A long
chain is hard to reason about. Each extra link adds a state you have to simulate before you know what a user will see. A
Flagsmith supports [flag dependencies](/managing-flags/flag-dependencies), but nesting is limited to one level. Even
one prerequisite adds a state you must simulate before you know what a user will see. A

broken prerequisite can also turn off a feature that looks unrelated.

Put the condition in one flag and use segments and traits to describe who should see it. Use dependencies for a short,
explicit prerequisite, such as a shared platform service that must exist before a feature can run.

## Storing HTML in remote config

HTML in a flag value couples your content to a release switch. Editors cannot preview it, translators cannot work with
it, and a small change can break the page layout. The flag then becomes a publishing tool that nobody maintains.

Store the markup in a content management system. Keep the flag for the decision to show or hide that content.

## Storing translated strings in flags

A flag value is not a translation system. Each new language adds another value to edit, and the copy drifts away from
the rest of your interface. Product teams also have to know where the strings live before they can change them.

Use your content management system or localisation tooling for text. Use the flag to turn the translated feature on for
a group of users.

## Adding Edge Proxy before you need it

[Edge Proxy](/performance/edge-proxy) puts evaluation close to your users. It also adds a service to deploy, monitor,
and debug. If your users are in one region and the API already meets your latency target, the extra service buys little.

Measure the problem first. Record where requests come from and how long the API takes. Adopt Edge Proxy when you have a
geographic spread or a measured latency need.

## Using PII as a trait or identifier

Client-side SDK endpoints are public. An email address or phone number stored as a persistent trait can be read by
anyone who guesses the identity. Using personal data as the identity makes that worse, since the identifier travels with
every flag request.

Use a GUID or another unguessable value as the identity. See [Identities](/flagsmith-concepts/identities). When you need
personal data for a targeting decision, send it as a [transient trait](/flagsmith-concepts/identities#transient-traits)
so Flagsmith evaluates it without storing it.

## Wrapping the SDK for portability

A wrapper around one SDK does not make your code portable to another flag provider. You still call provider-specific
methods, and you own the wrapper when the SDK changes.

Use [OpenFeature](/integrating-with-flagsmith/openfeature) when portability is the goal. It gives you one interface
across providers. If you want shorter names or project-specific helpers, wrap OpenFeature instead.

## Changing flags in production without review

One person can turn on a flag in production and change what every user sees. No second check stands between the click
and the release.

Enable [Change Requests](/administration-and-security/governance-and-compliance/change-requests) for production
environments. Reviewers see the exact change before it goes live. Keep direct edits for development environments.
Comment on lines +77 to +78

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Change Requests are available only on Scale-Up and Enterprise plans, but this recommendation omits that restriction. Name the required plans so readers know whether they can enable this workflow.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/docs/best-practices/common-anti-patterns.md, line 77:

<comment>Change Requests are available only on Scale-Up and Enterprise plans, but this recommendation omits that restriction. Name the required plans so readers know whether they can enable this workflow.</comment>

<file context>
@@ -0,0 +1,78 @@
+One person can turn on a flag in production and change what every user sees. No second check stands between the click
+and the release.
+
+Enable [Change Requests](/administration-and-security/governance-and-compliance/change-requests) for production
+environments. Reviewers see the exact change before it goes live. Keep direct edits for development environments.
</file context>
Suggested change
Enable [Change Requests](/administration-and-security/governance-and-compliance/change-requests) for production
environments. Reviewers see the exact change before it goes live. Keep direct edits for development environments.
+Enable [Change Requests](/administration-and-security/governance-and-compliance/change-requests) (available on Scale-Up and Enterprise plans) for production
environments. Reviewers see the exact change before it goes live. Keep direct edits for development environments.

Loading