|
| 1 | +package io.split.client; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | +import java.net.URISyntaxException; |
| 5 | + |
| 6 | +public class App { |
| 7 | + public static void main(String[] args) throws IOException, URISyntaxException { |
| 8 | + // TODO: Replace with your actual SDK key and feature flag name |
| 9 | + String sdkKey = "h1diffat7nmej6kulfdr4ectghnjc1quqa3c"; |
| 10 | + String featureFlagName = "TEST_MALDO"; |
| 11 | + String customerId = "CUSTOMER_ID"; |
| 12 | + |
| 13 | + SplitClientConfig config = SplitClientConfig.builder() |
| 14 | + .setBlockUntilReadyTimeout(10000) |
| 15 | + .enableDebug() |
| 16 | + .endpoint("https://sdk.split-stage.io", "https://events.split-stage.io/api") |
| 17 | + .build(); |
| 18 | + SplitFactory splitFactory = SplitFactoryBuilder.build(sdkKey, config); |
| 19 | + SplitClient client = splitFactory.client(); |
| 20 | + try { |
| 21 | + client.blockUntilReady(); |
| 22 | + } catch (Exception e) { |
| 23 | + System.err.println("Error waiting for Split SDK to be ready: " + e.getMessage()); |
| 24 | + e.printStackTrace(); |
| 25 | + } |
| 26 | + |
| 27 | + String treatment = client.getTreatment(customerId, featureFlagName); |
| 28 | + System.out.println("Treatment for user '" + customerId + "' and flag '" + featureFlagName + "': " + treatment); |
| 29 | + if (treatment.equals("on")) { |
| 30 | + System.out.println("Feature flag is enabled for this user!"); |
| 31 | + } else if (treatment.equals("off")) { |
| 32 | + System.out.println("Feature flag is disabled for this user!"); |
| 33 | + } else { |
| 34 | + System.out.println("Unable to perform evaluation."); |
| 35 | + } |
| 36 | + |
| 37 | + while (true) { |
| 38 | + |
| 39 | + } |
| 40 | + } |
| 41 | +} |
0 commit comments