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
When testing the SDKs locally with a local API server running on `localhost:5000`, you'll need to configure the `__internal_baseUrl` option to point to your local development server instead of the production API.
207
+
208
+
### Using SDKs Locally
209
+
210
+
For **JavaScript SDK**:
211
+
212
+
```javascript
213
+
import { Flagix } from"@flagix/js-sdk";
214
+
215
+
awaitFlagix.initialize({
216
+
apiKey:"your-dev-api-key",
217
+
__internal_baseUrl:"http://localhost:5000", // Points to local API server
218
+
initialContext: {
219
+
userId:"test_user",
220
+
email:"test@example.com"
221
+
}
222
+
});
223
+
```
224
+
225
+
For **React SDK**:
226
+
227
+
```jsx
228
+
import { FlagixProvider } from"@flagix/react";
229
+
230
+
constoptions= {
231
+
apiKey:"your-dev-api-key",
232
+
__internal_baseUrl:"http://localhost:5000", // Points to local API server
233
+
initialContext: {
234
+
userId:"test_user",
235
+
email:"test@example.com"
236
+
}
237
+
};
238
+
239
+
functionApp() {
240
+
return (
241
+
<FlagixProvider options={options}>
242
+
<YourApp />
243
+
</FlagixProvider>
244
+
);
245
+
}
246
+
```
247
+
248
+
**Note:** The `__internal_baseUrl` option is for local development and testing only. Do not include it in production code—the SDK will automatically use the production API endpoint.
@@ -39,7 +38,6 @@ import { Flagix } from "@flagix/js-sdk";
39
38
40
39
awaitFlagix.initialize({
41
40
apiKey:"your-api-key",
42
-
apiBaseUrl:"https://api.flagix.com",
43
41
initialContext: {
44
42
userId:"user_123",
45
43
email:"user@example.com",
@@ -161,6 +159,57 @@ Flagix.setContext({
161
159
// → Reactive updates triggered again
162
160
```
163
161
162
+
### Flagix.identify()
163
+
164
+
Replaces the entire global evaluation context, clearing all previous context values.
165
+
166
+
```typescript
167
+
identify(newContext: EvaluationContext): void
168
+
```
169
+
170
+
#### Parameters
171
+
172
+
-`newContext` - New context object that will completely replace the existing context
173
+
174
+
#### Use Cases
175
+
176
+
Unlike `setContext()` which merges with existing context, `identify()` is useful when you need to:
177
+
178
+
-**Clear user context on logout**: Remove all user-specific attributes
179
+
-**Switch between different users**: Replace one user's context entirely with another's
180
+
-**Reset evaluation context**: Start fresh with a completely new context
181
+
182
+
#### Reactivity
183
+
184
+
Calling `identify()` instantly replaces the global context and triggers re-evaluation of all cached flags. Any active listeners subscribed via `onFlagUpdate()` are triggered.
0 commit comments