{"id":24542752,"url":"https://github.com/molassesapp/molasses-ruby","last_synced_at":"2025-04-15T11:12:27.121Z","repository":{"id":46888183,"uuid":"299774742","full_name":"molassesapp/molasses-ruby","owner":"molassesapp","description":"A Ruby SDK for Molasses. It allows you to evaluate user's status for a feature. It also helps simplify logging events for A/B testing.","archived":false,"fork":false,"pushed_at":"2021-09-22T01:34:43.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T11:12:09.123Z","etag":null,"topics":["feature-flags","feature-toggle","feature-toggles","hacktoberfest"],"latest_commit_sha":null,"homepage":"https://www.molasses.app","language":"Ruby","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/molassesapp.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":"2020-09-30T01:01:03.000Z","updated_at":"2021-09-22T01:34:37.000Z","dependencies_parsed_at":"2022-08-20T22:31:03.457Z","dependency_job_id":null,"html_url":"https://github.com/molassesapp/molasses-ruby","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/molassesapp%2Fmolasses-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molassesapp%2Fmolasses-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molassesapp%2Fmolasses-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molassesapp%2Fmolasses-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/molassesapp","download_url":"https://codeload.github.com/molassesapp/molasses-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249058384,"owners_count":21205911,"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":["feature-flags","feature-toggle","feature-toggles","hacktoberfest"],"created_at":"2025-01-22T19:17:34.626Z","updated_at":"2025-04-15T11:12:27.104Z","avatar_url":"https://github.com/molassesapp.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/molassesapp/molasses-go/main/logo.png\" style=\"margin: 0px auto;\" width=\"200\"/\u003e\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eMolasses-Ruby\u003c/h1\u003e\n\nA Ruby SDK for Molasses. It allows you to evaluate user's status for a feature. It also helps simplify logging events for A/B testing.\n\nMolasses uses polling to check if you have updated features. Once initialized, it takes microseconds to evaluate if a user is active.\n\n## Install\n\n```\ngem install molasses\n\nbundle add molasses\n```\n\n## Usage\n\n### Initialization\n\nStart by initializing the client with an `APIKey`. This begins the polling for any feature updates. The updates happen every 15 seconds.\n\n```ruby\nrequire 'molasses'\n\nclient = Molasses::Client.new(\"test_api_key\")\n\n```\n\nIf you decide you want to auto track experiments being viewed (experiment started events) you can turn that on by setting the `:auto_send_events` field to `true`\n\n```go\nclient = Molasses::Client.new(\"test_api_key\", {\n  :auto_send_events =\u003e true\n})\n\n```\n\n### Check if feature is active\n\nYou can call `is_active` with the key name and optionally a user's information. The `id` field is used to determine whether a user is part of a percentage of users. If you have other constraints based on user params you can pass those in the `params` field.\n\n```ruby\n client.is_active(\"FOO_TEST\", {\n   \"id\"=\u003e\"foo\",\n   \"params\"=\u003e{\n     \"isBetaUser\"=\u003e\"false\",\n     \"isScaredUser\"=\u003e\"false\"\n    }\n })\n\n```\n\nYou can check if a feature is active for a user who is anonymous by just calling `isActive` with the key. You won't be able to do percentage roll outs or track that user's behavior.\n\n```ruby\nclient.is_active(\"TEST_FEATURE_FOR_USER\")\n```\n\n### Tracking and Experiments\n\nTo track any analytics event you can call `track`. experiment_success takes the event's name,the user, and any additional parameters for the event.\n\n```ruby\nclient.track(\"Button Clicked\", {\n   \"id\"=\u003e\"foo\",\n   \"params\"=\u003e{\n     \"isBetaUser\"=\u003e\"false\",\n     \"isScaredUser\"=\u003e\"false\"\n    }\n }, {\n\t\t\"version\": \"v2.3.0\"\n\t},)\n```\n\nTo track whether an experiment was started you can call `experiment_started`. experiment_started takes the feature's name,the user, and any additional parameters for the event.\n\n```ruby\nclient.experiment_started(\"GOOGLE_SSO\", {\n   \"id\"=\u003e\"foo\",\n   \"params\"=\u003e{\n     \"isBetaUser\"=\u003e\"false\",\n     \"isScaredUser\"=\u003e\"false\"\n    }\n }, {\n\t\t\"version\": \"v2.3.0\"\n\t},)\n```\n\nTo track whether an experiment was successful you can call `experiment_success`. experiment_success takes the feature's name,the user, and any additional parameters for the event.\n\n```ruby\nclient.experiment_success(\"GOOGLE_SSO\", {\n   \"id\"=\u003e\"foo\",\n   \"params\"=\u003e{\n     \"isBetaUser\"=\u003e\"false\",\n     \"isScaredUser\"=\u003e\"false\"\n    }\n }, {\n\t\t\"version\": \"v2.3.0\"\n\t},)\n```\n\n## Example\n\n```ruby\nrequire 'molasses'\n\nclient = Molasses::Client.new(\"test_api_key\")\n\nif client.is_active('NEW_CHECKOUT') {\n  puts \"we are a go\"\nelse\n  puts \"we are a no go\"\nend\nfoo_test = client.is_active(\"FOO_TEST\", {\n  \"id\"=\u003e\"foo\",\n  \"params\"=\u003e{\n    \"isBetaUser\"=\u003e\"false\",\n    \"isScaredUser\"=\u003e\"false\"\n  }\n})\nif foo_test\n  puts \"we are a go\"\nelse\n  puts \"we are a no go\"\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmolassesapp%2Fmolasses-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmolassesapp%2Fmolasses-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmolassesapp%2Fmolasses-ruby/lists"}