{"id":23949899,"url":"https://github.com/jeroenvisser101/growthbook-elixir","last_synced_at":"2025-04-12T22:37:12.003Z","repository":{"id":57503625,"uuid":"453536847","full_name":"jeroenvisser101/growthbook-elixir","owner":"jeroenvisser101","description":"A GrowthBook SDK for Elixir","archived":false,"fork":false,"pushed_at":"2022-01-30T22:52:56.000Z","size":45,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T18:19:07.279Z","etag":null,"topics":["ab-testing","elixir","elixir-lang","feature-flags"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/growthbook","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeroenvisser101.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-29T22:47:24.000Z","updated_at":"2023-07-25T16:43:35.000Z","dependencies_parsed_at":"2022-08-29T20:21:44.625Z","dependency_job_id":null,"html_url":"https://github.com/jeroenvisser101/growthbook-elixir","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenvisser101%2Fgrowthbook-elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenvisser101%2Fgrowthbook-elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenvisser101%2Fgrowthbook-elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeroenvisser101%2Fgrowthbook-elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeroenvisser101","download_url":"https://codeload.github.com/jeroenvisser101/growthbook-elixir/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643006,"owners_count":21138353,"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":["ab-testing","elixir","elixir-lang","feature-flags"],"created_at":"2025-01-06T11:52:31.981Z","updated_at":"2025-04-12T22:37:11.983Z","avatar_url":"https://github.com/jeroenvisser101.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GrowthBook\n\n[Online documentation](https://hexdocs.pm/growthbook) | [Hex.pm](https://hex.pm/packages/growthbook)\n\n\u003e NOTE: This library is in active development, and the API may change.\n\n\u003c!-- MDOC !--\u003e\n\n`GrowthBook` is a [GrowthBook](https://growthbook.io) SDK for Elixir/OTP.\n\nThis SDK follows the guidelines set out in [GrowthBook's documentation](https://docs.growthbook.io/lib/build-your-own), and the API is tested on conformance with the test cases from the JS SDK.\n\nTo ensure an Elixir-friendly API, the implementation deviates from the official SDK in the following ways:\n\n- Instead of tuple-lists, this library uses actual tuples\n- Comparisons with `undefined` are implemented by using `:undefined`\n- Function names are converted to `snake_case`, and `is_` prefix is replaced with a `?` suffix\n- Instead of classes, a Context struct is used (similar to `%Plug.Conn{}` in `plug`)\n- There may be some discrepancies between handling of Truthy values between the JS and Elixir SDKs (if you notice this, a issue, or better, a PR is welcome)\n\n## What is GrowthBook?\n\n[GrowthBook](https://www.growthbook.io) is an open source A/B testing platform. The platform works\nsignificantly different from other A/B testing platforms, most notably: it is language agnostic.\n\nClients by default work offline, and manage their own data. This means that you are free to\nimplement A/B tests server-side, or client-side without worrying about things like \"anti-flicker\"\nscripts, or the added latency of JS embeds.\n\nFurthermore, GrowthBook supports both experiments (A/B tests and multivariate tests) and feature\nflags. Because all logic to run experiments and feature flags is contained in the library, there\nis virtually no added latency to running experiments or using feature flags.\n\n## Usage\n\n```elixir\n# Create a context, which can be reused for multiple users\nconfig = Jason.decode!(\"\"\"\n{\n  \"overrides\": {\n    \"checkout-v2\": {\n      \"status\": \"running\",\n      \"coverage\": 1,\n      \"weights\": [0.5, 0.5],\n      \"force\": 0\n    }\n  }\n}\n\"\"\")\n\nfeatures_config = Jason.decode!(\"\"\"\n{\n  \"features\": {\n    \"send-reminder\": {\n      \"defaultValue\": false,\n      \"rules\": [{ \"condition\": { \"browser\": \"chrome\" }, \"force\": true }]\n    },\n    \"add-to-cart-btn-color\": {\n      \"rules\": [{ \"variations\": [{ \"color\": \"red\" }, { \"color\": \"green\" }] }]\n    }\n  }\n}\n\"\"\")\n\noverrides = GrowthBook.Config.experiment_overrides_from_config(config)\nfeatures = GrowthBook.Config.features_from_config(features_config)\n\ncontext = %GrowthBook.Context{\n  enabled?: true,\n  features: features,\n  overrides: overrides,\n  attributes: %{\n    \"id\" =\u003e \"12345\",\n    \"country_code\" =\u003e \"NL\",\n    \"browser\" =\u003e \"chrome\"\n  }\n}\n\n# Use a feature toggle\nif GrowthBook.feature(context, \"send-reminder\").on? do\n  Logger.info(\"Sending reminder\")\nend\n\n# Use a feature's value\ncolor = GrowthBook.feature(context, \"add-to-cart-btn-color\").value[\"color\"]\nLogger.info(\"Color: \" \u003c\u003e color)\n\n# Run an inline experiment\nif GrowthBook.run(context, %GrowthBook.Experiment{\n  key: \"checkout-v2\",\n  coverage: 1,\n  variations: [1, 2]\n}).in_experiment? do\n  Logger.info(\"In experiment\")\nend\n```\n\n## Installation\n\nAdd `growthbook` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:growthbook, \"~\u003e 0.1\"}\n  ]\nend\n```\n\n## License\n\nThis library is MIT licensed. See the\n[LICENSE](https://raw.github.com/jeroenvisser101/growthbook-elixir/main/LICENSE)\nfile in this repository for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeroenvisser101%2Fgrowthbook-elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeroenvisser101%2Fgrowthbook-elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeroenvisser101%2Fgrowthbook-elixir/lists"}