{"id":20556457,"url":"https://github.com/flagsmith/flagsmith-elixir-flag-engine","last_synced_at":"2025-10-12T22:13:45.140Z","repository":{"id":40752600,"uuid":"467929243","full_name":"Flagsmith/flagsmith-elixir-flag-engine","owner":"Flagsmith","description":"Flag Engine implementation in Elixir","archived":false,"fork":false,"pushed_at":"2022-06-24T20:16:11.000Z","size":79,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-16T18:26:13.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Flagsmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-09T13:02:36.000Z","updated_at":"2022-04-28T10:16:25.000Z","dependencies_parsed_at":"2022-07-29T08:19:08.007Z","dependency_job_id":null,"html_url":"https://github.com/Flagsmith/flagsmith-elixir-flag-engine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagsmith%2Fflagsmith-elixir-flag-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagsmith%2Fflagsmith-elixir-flag-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagsmith%2Fflagsmith-elixir-flag-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagsmith%2Fflagsmith-elixir-flag-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flagsmith","download_url":"https://codeload.github.com/Flagsmith/flagsmith-elixir-flag-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242163854,"owners_count":20082224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T03:27:56.936Z","updated_at":"2025-10-12T22:13:43.997Z","avatar_url":"https://github.com/Flagsmith.png","language":"Elixir","readme":"# FlagsmithEngine\n\nDocumentation: [https://hexdocs.pm/flagsmith_engine](https://hexdocs.pm/flagsmith_engine)\n\n\u003cdiv align=\"center\"\u003e\n     \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003cspan\u003e\u0026nbsp; |\u003c/span\u003e\n     \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003cspan\u003e\u0026nbsp; |\u003c/span\u003e\n     \u003ca href=\"#options\"\u003eOptions\u003c/a\u003e\u003cspan\u003e\u0026nbsp; |\u003c/span\u003e\n     \u003ca href=\"#internals\"\u003eInternals\u003c/a\u003e\u003cspan\u003e\u0026nbsp; |\u003c/span\u003e\n\u003c/div\u003e\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `flagsmith_engine` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:flagsmith_engine, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n## Usage\n\nYou can configure this library by setting on the relevant config file:\n\n```elixir\nconfig :flagsmith_engine, :configuration,\n       environment_key: \"\u003cYOUR SDK KEY\u003e\",\n       api_url: \"https://api.flagsmith.com/api/v1\u003e\",\n       default_flag_handler: function_defaults_to_not_found,\n       custom_headers: [{\"to add to\", \"the requests\"}],\n       request_timeout_milliseconds: 5000,\n       enabled_local_evaluation: false,\n       environment_refresh_interval_milliseconds: 60_000,\n       retries: 0,\n       enable_analytics: false\n```\n\nAny field `t:Flagsmith.Configuration.t/0` has can be set at the app level configuration.\nWhen set at the app level you don't need to generate clients when using `Flagsmith.Client` module functions, unless you want or need different options.\n\n## Options\n\n- `environment_key` -\u003e a server side sdk key (required)\n\n- `api_url` -\u003e the base url to which requests against the Flagsmith API will be made (defaults to: \"https://api.flagsmith.com/api/v1\u003e\")\n\n- `default_flag_handler` -\u003e a 1 arity function that receives a feature name (String.t()) and is called when calling feature related functions and the given feature isn't found -\u003e defaults to returning `:not_found`\n\n- `custom_headers` -\u003e additional headers to include in the calls to the Flagsmith API, defaults to an empty list (no additional headers)\n\n- `request_timeout_milliseconds` -\u003e the timeout for the HTTP adapter when doing calls to the Flagsmith API (defaults to 5_000 milliseconds)\n\n- `enable_local_evaluation` -\u003e starts a poller cache for each sdk key in use, on their first invocation and keeps a local auto-refreshing cache with the environment document for each. This allows you to keep Flagsmith API calls to a minimum as the environment can be fetched locally and used for any other related functionality in the client.\n\n- `environment_refresh_interval_milliseconds` -\u003e the time to wait between polling the Flagsmith API for a new environment document, only relevant if `enable_local_evaluation` is set to true.\n\n- `retries` -\u003e the number of times the http adapter is allowed to retry failed calls to the Flagsmith API before deeming the response failed. Keep in mind that with local_evaluation and analytics, even if the requests fail after whatever number of retries you set here, they will keep being retried as their time-cycle resets (for the poller whatever is the environment_refresh_interval_milliseconds, for the analytics they're batched, and a dump is tried every 1 minute)\n\n- `enable_analytics` -\u003e track feature queries by reporting automatically to the Flagsmith API analytics endpoint queries and lookups to features. This only works when using the `Flagsmith.Client` module functions such as `is_feature_enabled`, `get_feature_value` and `get_flag`. \n\n\nTo use the client library without application level configuration (or to override it) whenever a configuration is expected you can pass either a `t:Flagsmith.Configuration.t/0` struct or a keyword list with the options as elements. For instance:\n\n```elixir\n{:ok, environment} = Flagsmith.Client.get_environment(environment_key: \"MY_SDK_KEY\", enable_local_evaluation: true)\n```\n\nOr by passing a `t:Flagsmith.Configuration.t/0` to it:\n\n```elixir\nconfig = Flagsmith.Client.new(environment_key: \"MY_SDK_KEY\", enable_analytics: true, api_url: \"https://my-own-api-endpoint.com\")\n\n{:ok, environment} = Flagsmith.Client.get_environment(config)\n```\n\nIf you configured the `Flagsmith.Client` at the application level, with at least an `:environment_key`, you can simply call:\n\n```elixir\n{:ok, environment} = Flagsmith.Client.get_environment()\n```\n\nThe precedence for the configuration values  is `Options \u003e Application config \u003e Defaults`.\n\n\nTo enable analytics or local evaluation, besides setting the configuration keys `enable_local_evaluation` and/or `enable_analytics`, you need to make sure `Flagsmith.Supervisor` is started before calling the client module, usually by placing it in your application supervision tree:\n\n```elixir\ndefmodule YourAppWeb.Application do\n\n   # ...\n   \n   def start(_type, _args) do\n     children = [\n       Flagsmith.Supervisor,\n       # ... other stuff\n     ]\n\n     opts = [strategy: :one_for_one, name: YourAppWeb.Supervisor]\n     Supervisor.start_link(children, opts)\n   end\n  \n   # ...\n```\n\nIf you only use API evaluation without tracking any analytics you don't need to to start the supervisor.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflagsmith%2Fflagsmith-elixir-flag-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflagsmith%2Fflagsmith-elixir-flag-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflagsmith%2Fflagsmith-elixir-flag-engine/lists"}