# Feature Flags

## Developer usage

If you want to introduce something behind a feature flag you can follow these steps:

1. Ask someone from DevOps for invite to ConfigCat.
2. Once you're in (<https://app.configcat.com/>) you can add your feature flag. The initial values should always be "On" in Dev and (probably always to start with) "Off" in Production and Staging.
3. Make sure that the CONFIGCAT\_SDK\_KEY environment variable is `export`ed in `.env.secret` in the root of the repository. You can fetch it by calling for example `yarn get-secrets service-portal`.
4. Start using your flag by using the package `@island.is/feature-flags`.

## Naming convention

When creating your feature flag, please try to have both the "Key for humans" and "key for programs" descriptive. If the feature flag will be used by a single service, make sure that at least the human key contains the service name. Adding a clear description will also help others knowing what your new flag does.

Example: Your service name is "my-awesome-service" and you're introducing a feature flag called "show-content". The key for humans could be "My awesome service: Show content" and the key for programs could be "myAwesomeServiceShowContent" (Hint: The UI generates the program key automatically from the human key)

## Feature flag lifecycle

After a feature flag has been flipped on for all environments be mindful to clean it up. That involves removing all mentions of that flag in the source code and deleting it from ConfigCat. You will need to contact an administrator to delete the flag.

## Feature flag for applications

You can introduce feature flags to applications. The flag determines whether the applications is accessible for users. See readme [here](https://docs.devland.is/libs/application/core#feature-flags) on further details on how to implement.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.devland.is/development/feature-flags.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
