Skip to content

Commit c43bedc

Browse files
Update get assignment arguments in Ruby docs (#511)
* Update get assignment arguments in Ruby docs * Update docs/sdks/server-sdks/ruby.md * Update docs/sdks/server-sdks/ruby.md * Update docs/sdks/server-sdks/ruby.md * Update docs/sdks/server-sdks/ruby.md * Update docs/sdks/server-sdks/ruby.md * Update ruby.md * Update ruby.md
1 parent de59c0b commit c43bedc

File tree

1 file changed

+9
-39
lines changed

1 file changed

+9
-39
lines changed

docs/sdks/server-sdks/ruby.md

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,21 @@ require 'eppo_client'
9393

9494
client = EppoClient::Client.instance
9595
variation = client.get_string_assignment(
96-
'<SUBJECT-KEY>',
9796
'<FLAG-KEY>',
97+
'<SUBJECT-KEY>',
9898
{
99-
# Optional map of subject metadata for targeting.
100-
}
99+
# Optional map of subject attributes for targeting.
100+
},
101+
'<DEFAULT-VALUE>'
101102
)
102103
```
103104

104-
The `get_string_assignment` function takes two required and one optional input to assign a variation:
105+
The `get_string_assignment` function takes the following parameters:
105106

106-
- `subject_key` - The entity ID that is being experimented on, typically represented by a uuid.
107-
- `flag_or_experiment_key` - This key is available on the detail page for both flags and experiments.
108-
- `subject_attributes` - An optional map of metadata about the subject used for targeting. If you create rules based on attributes on a flag/experiment, those attributes should be passed in on every assignment call.
107+
- `flag_key` (String): The key of the feature flag corresponding to the bandit
108+
- `subject_key` (String): The identifier of the subject (e.g., user) to be assigned a variation
109+
- `subject_attributes` (Attributes): Optional - Attributes of the subject, used by targeting rules
110+
- `default_value` (String): The value that will be returned if no allocation matches the subject, if the flag is not enabled, if get_string_assignment is invoked before the SDK has finished initializing, or if the SDK was not able to retrieve the flag configuration.
109111

110112
### Typed assignments
111113

@@ -118,37 +120,5 @@ get_json_string_assignment(...)
118120
get_parsed_json_assignment(...)
119121
```
120122

121-
### Handling `nil`
122-
123-
We recommend always handling the `nil` case in your code. Here are some examples of when the SDK returns `nil`:
124-
125-
1. The **Traffic Exposure** setting on experiments/allocations determines the percentage of subjects the SDK will assign to that experiment/allocation. For example, if Traffic Exposure is 25%, the SDK will assign a variation for 25% of subjects and `nil` for the remaining 75% (unless the subject is part of an allow list).
126-
127-
2. Assignments occur within the environments of feature flags. You must enable the environment corresponding to the feature flag's allocation in the user interface before `getStringAssignment` returns variations. It will return `nil` if the environment is not enabled.
128-
129-
![Toggle to enable environment](/img/feature-flagging/enable-environment.png)
130-
131-
3. If `get_string_assignment` is invoked before the SDK has finished initializing, the SDK may not have access to the most recent experiment configurations. In this case, the SDK will assign a variation based on any previously downloaded experiment configurations stored in local storage, or return `nil` if no configurations have been downloaded.
132-
133-
### Debugging `nil`
134-
135-
If you need more visibility into why `get_string_assignment` is returning `nil`, you can change the logging level to `Logger::DEBUG` to see more details in the standard output.
136-
137-
```ruby
138-
require 'eppo_client'
139-
require 'logger'
140-
141-
client = EppoClient::Client.instance
142-
variation = client.get_string_assignment(
143-
'<SUBJECT-KEY>',
144-
'<FLAG-KEY>',
145-
{},
146-
Logger::DEBUG
147-
)
148-
```
149-
150123
<br />
151124

152-
:::note
153-
It may take up to 10 seconds for changes to Eppo experiments to be reflected by the SDK assignments.
154-
:::

0 commit comments

Comments
 (0)