You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sdks/server-sdks/ruby.md
+9-39Lines changed: 9 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,19 +93,21 @@ require 'eppo_client'
93
93
94
94
client =EppoClient::Client.instance
95
95
variation = client.get_string_assignment(
96
-
'<SUBJECT-KEY>',
97
96
'<FLAG-KEY>',
97
+
'<SUBJECT-KEY>',
98
98
{
99
-
# Optional map of subject metadata for targeting.
100
-
}
99
+
# Optional map of subject attributes for targeting.
100
+
},
101
+
'<DEFAULT-VALUE>'
101
102
)
102
103
```
103
104
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:
105
106
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.
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
-

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
-
150
123
<br />
151
124
152
-
:::note
153
-
It may take up to 10 seconds for changes to Eppo experiments to be reflected by the SDK assignments.
0 commit comments