Feature flags

Feature flags are the switches your code checks, and you can connect PostHog or LaunchDarkly so Cactus can count the flags your code checks and read their state when it writes a page that checks one. You connect a flag tool in the Flag tools panel on the Sources page of the web app.

On this page

Connect PostHog

  1. In Settings › Sources, select Connect PostHog on the PostHog row under Flag tools.

  2. Sign in to PostHog. Cactus asks PostHog for read access to feature flags, projects and group types only.

  3. You come back to Settings › Sources, where the PostHog row names the project it is connected to.

Connect LaunchDarkly

  1. In Settings › Sources, select Connect LaunchDarkly on the LaunchDarkly row under Flag tools.

  2. Paste a LaunchDarkly access token into Reader token. The token needs the Reader role, and Cactus only reads with it. Select Find projects, which stays off until a token is pasted.

  3. Pick the Project and the Environment the token can see, then select Save.

What the rows say

Each row says how many flags your code checks with that tool, counting each flag name once. A check whose flag name Cactus cannot work out is not counted.

  • "No PostHog flag checks found in your code" means your code checks no flag with PostHog.
  • "Your code checks _the number_ flags with PostHog" gives how many flags your code checks with it, in the singular for one.

Cactus reads a flag's state each time it writes a page that checks that flag. After a flag changes, ask Cactus to republish those pages, which is what a build does.

Disconnect a tool

In Settings › Sources, select Disconnect on the tool's row under Flag tools.

Disconnecting deletes the token and the project from Cactus. Nothing the tool answered is kept, so nothing else is removed.

If Cactus can't tell the PostHog project

Until a teammate chooses one, the PostHog connection reads no flags for this product.

When your PostHog sign-in sees several projects, Cactus picks one by the flags your code checks.

  • The sign-in sees one project, and Cactus connects it.
  • Several projects, and one defines more of the flags your code checks than any other, so Cactus connects that one.
  • Otherwise it waits for a choice: no project is visible, two or more tie for the most, or none defines a flag your code checks.

If a tool turns Cactus away

What you see

What it means

What to do

"PostHog turned down Cactus' access. Connect again to fix it."

What it means

PostHog refused the saved token, so the PostHog row offers Connect again in place of Disconnect.

What to do

Select Connect again on the PostHog row.

"LaunchDarkly turned down this token. Disconnect, then connect with a new Reader token."

What it means

LaunchDarkly refused the saved token.

What to do

Select Disconnect on the LaunchDarkly row, then connect again with a new token.

"PostHog connection was cancelled."

What it means

You stopped the PostHog sign-in before it finished.

What to do

Select Connect PostHog again.

"PostHog could not complete that connection."

What it means

Cactus could not finish the PostHog connection.

What to do

Select Connect PostHog again.

"That PostHog connection expired. Connect again."

What it means

The PostHog sign-in took longer than 10 minutes to finish.

What to do

Select Connect PostHog again.

"LaunchDarkly refused the token."

What it means

The Reader token was refused when Cactus looked for its projects.

What to do

Paste a token that can see your projects, then select Find projects.

"LaunchDarkly could not be reached."

What it means

Cactus could not reach LaunchDarkly to read its projects.

What to do

Select Find projects again.

"That token can see no project."

What it means

The token reads no project at all.

What to do

Paste a different token.

"That project and environment are not ones the token can see."

What it means

The project or environment picked is not one the token reads.

What to do

Pick a project and environment the token can see, then select Save.

Sources

Related pages