Skip to content

About

Chrome extension to flip Flagsmith flags for just yourself (server-side identity overrides) on a self-hosted Flagsmith

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Flagsmith DevTools

A Chrome extension for self-hosted Flagsmith. See the flags for the current user and flip them for just yourself, without opening the dashboard and without touching anyone else's flags.

Every change is stored as a server-side identity override on your identity, never on the shared environment. Teammates, testers and production traffic are unaffected, and "Reset" (or the auto-reset timer) deletes the override so you fall back to the shared state.

Panel with an override

Alice flips dark_mode for herself. Bob, and everyone else, still see the shared value.

Alice (overridden) Bob (unchanged)
Alice Bob

Contents

  1. The problem
  2. Try it in 3 commands
  3. What it does
  4. How it works
  5. Why this approach
  6. Project layout
  7. Security and permissions
  8. Testing
  9. Limitations
  10. Troubleshooting
  11. Roadmap

The problem

When you need to see a feature behind a flag in your local build or on staging, the usual routes are all bad:

  • Open the Flagsmith dashboard, find the flag, flip it. Slow, a context switch every time, and it changes the flag for everyone using that environment. Teammates and QA suddenly see your experiment, or a half-finished feature.
  • Edit code or local config. Doesn't reproduce what the real Flagsmith server returns, and has to be undone before you commit.
  • Add a dev toolbar library to the app. Needs code changes in every app, and usually keeps overrides only in that one browser.

Flagsmith already has the right primitive: an identity override (a feature state attached to one identity). The missing piece is a fast, safe way to use it from the browser. That is this tool.

Try it in 3 commands

Requires Docker and Node 18+ (Chrome for the extension).

git clone https://github.com/NambertJones/flagsmith-devtools && cd flagsmith-devtools
docker compose up -d          # Flagsmith on :8000, demo app on :8080
node scripts/seed.mjs         # creates admin, project and demo flags, prints your keys

Then load the extension:

  1. Open chrome://extensions, enable Developer mode, click Load unpacked, pick extension/.
  2. Click the toolbar icon (or open DevTools → Flagsmith tab) and paste the four values the seed script printed (also saved in devtools.config.json). Approve the host permission prompt.
  3. Open the demo URL the seed script printed, tick dark_mode in the panel, and the page reloads with your override. Open the demo with &identity=bob to see that Bob is unaffected.

Dashboard login: admin@example.com / DevTools-demo-1234 (demo values only, change for real use).

scripts/seed.mjs is idempotent: it registers (or logs in as) the admin user, creates an organisation, a project named Demo App, a Development environment (some versions don't create one automatically), and four flags: new_checkout, dark_mode, welcome_banner (with a text value) and max_items_per_page (with a numeric-looking value). It then writes the connection details to devtools.config.json, which is git-ignored because it contains an admin token.

What it does

Panel (toolbar popup, and a Flagsmith tab inside Chrome DevTools)

  • Lists every flag as evaluated for your identity (overrides applied), filterable by name.
  • Toggle a flag, or edit its value, and the change is saved as an override for your identity only.
  • Overridden flags are highlighted with an overridden badge and a per-flag Reset button.
  • Reset all my overrides removes every override for your identity in one click.
  • Optionally reloads the active tab after each change so the page picks up the new state.

Auto-reset (so you never forget an override)

  • Choose 15 min / 1 hour / 8 hours / never (default 1 hour). Each override you create is scheduled for removal, and a background service worker deletes it on the server when the time comes.
  • If the panel is open when that happens, it refreshes itself so it never shows stale state.

Auto-detect (no copy-pasting keys)

  • With the DevTools Flagsmith tab open, the extension watches the page's own Flagsmith SDK requests and offers the API URL, environment key and identity it saw, with one click to fill them in. You only add your admin token.

How it works

Two kinds of credentials

Credential Used for Where it goes
Environment key (client-side SDK key, safe to ship in a browser) Reading flags X-Environment-Key header
Admin API token (a Flagsmith user's token) Creating and deleting overrides Authorization: Token … header

Endpoints used

Action Endpoint
Flags as evaluated for you GET /api/v1/identities/?identifier=<you> (environment key)
Shared baseline (no overrides) GET /api/v1/flags/ (environment key)
Environment id GET /api/v1/environments/<key>/ (admin token)
Find your identity GET /api/v1/environments/<key>/identities/?q=<you> (admin token)
Create your identity if missing POST /api/v1/environments/<key>/identities/ (admin token)
List your overrides GET …/identities/<id>/featurestates/ (admin token)
Create / update an override POST / PUT …/identities/<id>/featurestates/[<fs-id>/] (admin token)
Remove an override DELETE …/identities/<id>/featurestates/<fs-id>/ (admin token)

Writes only ever target …/identities/<id>/featurestates/, never the environment-level feature states. A unit test asserts this.

What happens when you open the panel

  1. Look up your identity row (without creating it).
  2. In parallel: fetch the shared baseline, the flags evaluated for you, and your existing overrides.
  3. Merge them into rows: each flag shows its evaluated state, whether it is overridden, and the baseline it differs from.

What happens when you flip a flag

  1. Make sure your identity exists (create it on first use, since overrides need a stored identity).
  2. POST a new override, or PUT the existing one, with the feature id, enabled flag, value, the environment id and your identity id. An empty value is sent as null.
  3. Schedule its auto-reset (see below), then refresh the panel and optionally reload the tab.

Flagsmith's evaluation order puts identity overrides above segment overrides above the environment default, so your override wins for you and nobody else.

Auto-reset internals

  • Expiry entries (overrideId, identityId, due time) live in chrome.storage.local.
  • The panel adds an entry when you create an override and removes it on reset, then pings the background service worker.
  • The worker (background.js) uses chrome.alarms to wake up at the next due time, deletes every due override via the API, and re-arms the alarm for the next one.
  • An override that is already gone (HTTP 404) counts as done. Any other failure is retried after a minute. The worker also sweeps on browser start-up and extension install.

Auto-detect internals

  • devtools.js listens to chrome.devtools.network.onRequestFinished for the inspected page, which needs no extra permissions.
  • detect.js recognises /api/v1/identities/ and /api/v1/flags/ calls that carry an X-Environment-Key header, keeps any path prefix of a self-hosted install (for example https://host/flagsmith), and reads the identity from the identifier query parameter or the JSON body. A later anonymous request never overwrites an identity that was already seen.

Why this approach

In-app toolbars Flagsmith DevTools
Needs code changes in the app Yes No
Works on any site using Flagsmith (staging, a teammate's branch) No Yes
Override visible to your backend, mobile app and other browsers No (local only) Yes (stored on your identity)
Affects other users No No
Finds API URL, key and identity from the page's own traffic No Yes (DevTools tab)
Overrides auto-expire so you never forget one No Yes (default 1 hour)

Because the override lives on the server, your backend services, mobile builds and other browsers that evaluate flags for the same identity see it too, which a local-only override can't do.

Project layout

extension/            Chrome Manifest V3 extension (no build step, no dependencies)
  manifest.json       permissions: storage, tabs, alarms; optional host access
  panel.html/js/css   the UI (toolbar popup and DevTools tab share it)
  api.js              Flagsmith client: reads, identity lookup, override CRUD
  expiry.js           pure auto-reset bookkeeping
  background.js       service worker that removes expired overrides
  detect.js           infers API URL / key / identity from page requests
  devtools.html/js    registers the DevTools tab and runs auto-detect
docker-compose.yml    self-hosted Flagsmith (Postgres) + a static demo app
scripts/seed.mjs      bootstraps the local Flagsmith and writes devtools.config.json
demo/index.html       tiny app that renders flags for an identity
test/                 unit, live and real-Chrome end-to-end tests
.github/workflows/    CI: tests, manifest check, extension zip

Security and permissions

  • Host access is requested only for the API origin you configure, at runtime (optional_host_permissions), not for every site.
  • Other permissions: storage (settings and the expiry list), alarms (auto-reset), tabs (reload the tab after a change).
  • The admin token is stored in chrome.storage.local of your browser profile, unencrypted, like most extension settings. Use a token for a user who only has access to your dev/staging environment, not production.
  • docker-compose.yml uses demo secrets (database password, Django secret key). Change them before exposing the stack anywhere.
  • Nothing is sent anywhere except to the Flagsmith API URL you configure.

Testing

npm test            # unit tests: API client, detection, expiry (in-memory fake Flagsmith)
npm run test:live   # the API client against your running local Flagsmith
npm run test:e2e    # loads the real extension in Chrome and drives it against live Flagsmith
npm run icons       # regenerate extension icons
  • Unit tests check that an override affects only the chosen identity, that updating uses PUT instead of creating a duplicate, that reset removes it, that writes never touch environment-level state, and that detection and expiry logic behave.
  • Live test repeats those checks against the real API.
  • End-to-end test installs the actual extension into Chrome through the DevTools Protocol and checks that the panel renders the flags, that a UI toggle creates a server-side override and an expiry entry, that the background service worker removes an expired override, and that the open panel refreshes afterwards. It needs Chrome installed and the compose stack running.

CI runs the unit tests, validates the manifest and builds a zip of the extension on every push.

Limitations

  • Targets the default (core / Postgres) Flagsmith API. Edge-API deployments use different override endpoints and are not supported yet.
  • Your identity must match the identifier your app passes to the Flagsmith SDK.
  • Editing a flag sets its on/off state and its single value. Multivariate weights are not edited.
  • Auto-reset runs from the browser, so it needs Chrome to be running when the timer fires. Overrides still expire later (or can be reset by hand) if it wasn't.
  • Auto-detect needs the DevTools Flagsmith tab open while the page makes its Flagsmith calls.
  • Local-evaluation SDKs that don't fetch identity overrides from the server won't see them.

Troubleshooting

Symptom Likely cause
"Permission to reach … was denied" Approve the host permission prompt for your API URL, or press Save again.
401 in the panel Wrong or expired admin token. Copy it again from the seed output or your Flagsmith profile.
Flags don't change on the page The page's identity doesn't match the one in the panel, or the app caches flags. Check "Viewing as …".
Seed script can't connect The stack isn't up yet. Check docker compose ps and docker compose logs flagsmith.
Flagsmith image fails to start Make sure Docker has enough memory and ports 8000 and 8080 are free.

Roadmap

  • Edge-API (DynamoDB) identity overrides.
  • Multivariate options and JSON value editing.
  • "View as" other identities, with traits, to test segments.
  • Publish to the Chrome Web Store.

License

MIT

About

Chrome extension to flip Flagsmith flags for just yourself (server-side identity overrides) on a self-hosted Flagsmith

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages