Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions pages/docs/tracking-methods/sdks/java/java-flags.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ MixpanelAPI mixpanel = new MixpanelAPI(localConfig);
// Start polling for flag definitions
mixpanel.getLocalFlags().startPollingForDefinitions();

// Wait for flags to be ready (recommended)
while (!mixpanel.getLocalFlags().areFlagsReady()) {
Thread.sleep(100);
}

// This should be the 'key' of the feature flag from Mixpanel's UX.
String flagKey = "sample-flag";

Expand Down Expand Up @@ -177,10 +172,6 @@ LocalFlagsConfig config = LocalFlagsConfig.builder()
MixpanelAPI mixpanel = new MixpanelAPI(config);
mixpanel.getLocalFlags().startPollingForDefinitions();

while (!mixpanel.getLocalFlags().areFlagsReady()) {
Thread.sleep(100);
}

Map<String, Object> userContext = new HashMap<>();
userContext.put("distinct_id", "user-123");

Expand All @@ -205,23 +196,6 @@ mixpanel.close();
- Include any custom properties used in your flag targeting rules
- Use consistent data types for context values across your application

### Readiness Check

- For local evaluation, always check if flags are ready before evaluating using `areFlagsReady()`
- This prevents race conditions where you might evaluate flags before they've been loaded from the server
- Implement appropriate retry or wait logic until flags are ready

```java
mixpanel.getLocalFlags().startPollingForDefinitions();

// Wait for flags to be ready
while (!mixpanel.getLocalFlags().areFlagsReady()) {
Thread.sleep(100);
}

// Now safe to evaluate flags
```

### Resource Management

- Initialize the `MixpanelAPI` once and reuse it throughout your application
Expand Down