Skip to content

feat: integrate eppo module with android-sdk-framework (v4 migration 2/2) - #261

Open
typotter wants to merge 11 commits into
typo/v4-split-1/framework-modulefrom
typo/v4-split-2/eppo-integration
Open

typotter wants to merge 11 commits into
typo/v4-split-1/framework-modulefrom
typo/v4-split-2/eppo-integration

Conversation

@typotter

Copy link
Copy Markdown
Collaborator

Summary

  • EppoClient extends AndroidBaseClient<Configuration, JsonNode> (was BaseEppoClient directly)
  • JacksonConfigurationParser: 2-param ConfigurationParser with parseFlagConfig + buildConfig(FlagConfigResponse, ...)
  • OkHttpEppoClient: implements EppoConfigurationClient interface
  • Example module: GsonConfigurationParser, GsonConfigurationCodec, CustomClientActivity
  • Removes old ConfigurationStore, BaseCacheFile, ConfigCacheFile (moved to framework)
  • Bumps :eppo to 5.0.0-SNAPSHOT, sdk-common-jvm to 4.0.0

Depends on #260.

Test plan

  • Unit tests pass: ./gradlew :eppo:test
  • Connected tests pass (46 tests): ./gradlew :eppo:connectedDebugAndroidTest
  • Example app installs and runs: ./gradlew :example:installDebug

@typotter

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@typotter, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ae9123cb-6884-43ce-99bd-260e5c264709

📥 Commits

Reviewing files that changed from the base of the PR and between e83b8bc and 9040aa0.

📒 Files selected for processing (30)
  • android-batteries-included-notes.md
  • eppo/build.gradle
  • eppo/src/androidTest/java/cloud/eppo/android/EppoClientTest.java
  • eppo/src/androidTest/java/cloud/eppo/android/TestConfigCacheFile.java
  • eppo/src/androidTest/java/cloud/eppo/android/helpers/AssignmentTestCase.java
  • eppo/src/androidTest/java/cloud/eppo/android/helpers/AssignmentTestCaseDeserializer.java
  • eppo/src/main/java/cloud/eppo/android/BaseCacheFile.java
  • eppo/src/main/java/cloud/eppo/android/ConfigCacheFile.java
  • eppo/src/main/java/cloud/eppo/android/ConfigurationStore.java
  • eppo/src/main/java/cloud/eppo/android/EppoClient.java
  • eppo/src/main/java/cloud/eppo/android/JacksonConfigurationParser.java
  • eppo/src/main/java/cloud/eppo/android/OkHttpEppoClient.java
  • eppo/src/main/java/cloud/eppo/android/PrecomputedCacheFile.java
  • eppo/src/main/java/cloud/eppo/android/dto/adapters/BanditParametersResponseDeserializer.java
  • eppo/src/main/java/cloud/eppo/android/dto/adapters/DateSerializer.java
  • eppo/src/main/java/cloud/eppo/android/dto/adapters/EppoModule.java
  • eppo/src/main/java/cloud/eppo/android/dto/adapters/EppoValueDeserializer.java
  • eppo/src/main/java/cloud/eppo/android/dto/adapters/EppoValueSerializer.java
  • eppo/src/main/java/cloud/eppo/android/dto/adapters/FlagConfigResponseDeserializer.java
  • example/build.gradle
  • example/src/main/AndroidManifest.xml
  • example/src/main/java/cloud/eppo/androidexample/Constants.java
  • example/src/main/java/cloud/eppo/androidexample/CustomClientActivity.java
  • example/src/main/java/cloud/eppo/androidexample/GsonConfigurationCodec.java
  • example/src/main/java/cloud/eppo/androidexample/GsonConfigurationParser.java
  • example/src/main/java/cloud/eppo/androidexample/HeaderInjectingEppoClient.java
  • example/src/main/java/cloud/eppo/androidexample/MainActivity.java
  • example/src/main/java/cloud/eppo/androidexample/SecondActivity.java
  • example/src/main/res/layout/activity_main.xml
  • example/src/main/res/values/strings.xml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@typotter
typotter force-pushed the typo/v4-split-2/eppo-integration branch from 9040aa0 to 4e65faa Compare August 20, 2026 22:17
Wire the :eppo module to use :android-sdk-framework abstractions:

- EppoClient extends AndroidBaseClient<Configuration, JsonNode>
- JacksonConfigurationParser: implements 2-param ConfigurationParser
  with parseFlagConfig + buildConfig(FlagConfigResponse, ...)
- OkHttpEppoClient: implements EppoConfigurationClient interface
- GsonConfigurationParser + GsonConfigurationCodec in example module

Removes old ConfigurationStore, BaseCacheFile, ConfigCacheFile (moved
to framework). Bumps eppo to 5.0.0-SNAPSHOT, sdk-common-jvm to
4.0.0-SNAPSHOT.
@typotter
typotter force-pushed the typo/v4-split-2/eppo-integration branch from 4e65faa to f92f834 Compare August 21, 2026 12:53
Delete cloud.eppo.android.dto.adapters/ — these were near-identical
copies of cloud.eppo.ufc.dto.adapters/ from sdk-common-jvm. The :eppo
module already depends on sdk-common-jvm, so import directly.
@aarsilv aarsilv added the crucible: reviewing A Crucible review has started; this PR has reviewer attention. label Oct 30, 2026
Comment thread eppo/build.gradle Resolved
ConfigurationCodec<Configuration> codec = new ConfigurationCodec.Default();

// Cache at a per-API key level (useful for development)
return new FileBackedConfigStore<>(application, safeCacheKey(apiKey), codec);

@aarsilv aarsilv Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Comment from Claude working with Aaron Silverman:

[P2] Read the 4.x cache file once, and use the SHA-256 cache key now that the file name changes.

4.x wrote eppo-sdk-config-v4-flags-<key prefix>.json, which holds the raw flag configuration JSON. This PR reads only eppo-sdk-flags-<key prefix>.ser. Nothing reads or deletes the old file. On the first launch after the upgrade, an offline start has no configuration: strict initialization fails and graceful mode serves default values. The old file stays in filesDir.

This line also uses cloud.eppo.android.util.Utils.safeCacheKey, which takes the first eight characters of the SDK key, removes non-word characters, and throws StringIndexOutOfBoundsException for shorter keys. The SHA-256 safeCacheKey that #260 added after an earlier review thread is only in the framework Utils. The file name changes in this PR anyway, so a switch now orphans no additional cache files.

What the test shows

The test writes a 4.x cache file (obfuscated CLIENT JSON, as 4.x stored it) and then starts the client with offlineMode(true) and isGracefulMode(false):

  • At this head, initialization fails: EppoInitializationException: Unable to initialize client; Configuration could not be loaded.
  • With the patch below, the client serves the cached value, the legacy file is deleted, and the new .ser file uses the SHA-256 key.

Limitation: the legacy file stays if the caller sets ignoreCachedConfiguration(true), an explicit initialConfiguration, or a custom configStore.

What an upgrade from 4.12.2 does (emulator run)

Android 16 (API 36) emulator, minified release builds of the example app plus a small probe activity (not part of the patch). Version 4.12.2 writes eppo-sdk-config-v4-flags-<key prefix>.json offline. Then the next build is installed over it, and the client starts with offlineMode(true) and isGracefulMode(false):

  • This head: initialization fails with Unable to initialize client; Configuration could not be loaded. The 4.x file stays unused.
  • With the patch below: the client serves the cached value, deletes the 4.x file, and writes the new .ser file.
Suggested patch (compiled and tested alone on the #261 head)
--- a/eppo/src/main/java/cloud/eppo/android/EppoClient.java
+++ b/eppo/src/main/java/cloud/eppo/android/EppoClient.java
@@ -2,4 +2,4 @@ package cloud.eppo.android;
 
+import static cloud.eppo.android.framework.util.Utils.safeCacheKey;
 import static cloud.eppo.android.util.Utils.logTag;
-import static cloud.eppo.android.util.Utils.safeCacheKey;
 
@@ -17,2 +17,3 @@ import cloud.eppo.android.framework.storage.ConfigurationCodec;
 import cloud.eppo.android.framework.storage.FileBackedConfigStore;
+import cloud.eppo.android.util.Utils;
 import cloud.eppo.api.Configuration;
@@ -23,2 +24,5 @@ import cloud.eppo.parser.ConfigurationParser;
 import com.fasterxml.jackson.databind.JsonNode;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
 import java.util.concurrent.CompletableFuture;
@@ -294,4 +298,11 @@ public class EppoClient extends AndroidBaseClient<Configuration, JsonNode> {
 
+      // Create batteries-included implementations (use provided overrides or defaults)
+      ConfigurationParser<Configuration, JsonNode> parserToUse =
+          this.configurationParser != null
+              ? this.configurationParser
+              : new JacksonConfigurationParser();
+
       // Get caching from config store
-      if (configStore == null) {
+      boolean usesDefaultStore = configStore == null;
+      if (usesDefaultStore) {
         configStore = createDefaultConfigStore();
@@ -303,10 +314,13 @@ public class EppoClient extends AndroidBaseClient<Configuration, JsonNode> {
         initialConfiguration = configStore.loadFromStorage();
+        if (usesDefaultStore) {
+          // Async: the legacy read does file I/O and must stay off the caller's thread.
+          initialConfiguration =
+              initialConfiguration.thenApplyAsync(
+                  cached -> {
+                    Configuration legacy = readAndDeleteLegacyCache(parserToUse);
+                    return cached != null ? cached : legacy;
+                  });
+        }
       }
 
-      // Create batteries-included implementations (use provided overrides or defaults)
-      ConfigurationParser<Configuration, JsonNode> parserToUse =
-          this.configurationParser != null
-              ? this.configurationParser
-              : new JacksonConfigurationParser();
-
       EppoConfigurationClient clientToUse =
@@ -416,2 +430,27 @@ public class EppoClient extends AndroidBaseClient<Configuration, JsonNode> {
 
+    // 4.x cached the raw flag configuration JSON under this name. Read it once, then delete it.
+    @Nullable private Configuration readAndDeleteLegacyCache(
+        ConfigurationParser<Configuration, JsonNode> parser) {
+      File legacy;
+      try {
+        legacy =
+            new File(
+                application.getFilesDir(),
+                "eppo-sdk-config-v4-flags-" + Utils.safeCacheKey(apiKey) + ".json");
+      } catch (RuntimeException e) {
+        return null; // 4.x could not create a cache for this key.
+      }
+      if (!legacy.exists()) {
+        return null;
+      }
+      try (InputStream in = new FileInputStream(legacy)) {
+        return parser.buildConfig(parser.parseFlagConfig(Utils.toByteArray(in)), null, null, null);
+      } catch (Exception e) {
+        Log.w(TAG, "Ignoring unreadable 4.x configuration cache", e);
+        return null;
+      } finally {
+        legacy.delete();
+      }
+    }
+
     private CachingConfigurationStore<Configuration> createDefaultConfigStore() {

Also change the safeCacheKey import to the framework Utils in EppoClientTest.java and example/.../MainActivity.java, so they name the same file. EppoPrecomputedClient keeps its own cache name.

Test (Robolectric)
package cloud.eppo.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.app.Application;
import cloud.eppo.android.framework.util.Utils;
import cloud.eppo.android.util.ObfuscationUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;

@RunWith(RobolectricTestRunner.class)
public class LegacyCacheMigrationTest {
  private static final String API_KEY = "legacy-cache-api-key";
  private static final ObjectMapper MAPPER = new ObjectMapper();

  // 4.x cached the raw obfuscated CLIENT response: md5 flag keys, base64 values.
  private static byte[] obfuscatedClientConfig() throws Exception {
    ObjectNode config = MAPPER.createObjectNode();
    config.put("format", "CLIENT");
    config.put("createdAt", "2026-10-14T00:00:00.000Z");
    config.putObject("environment").put("name", "Test");
    String flagHash = ObfuscationUtils.md5Hex("str_flag", null);
    ObjectNode flag = config.putObject("flags").putObject(flagHash);
    flag.put("key", flagHash);
    flag.put("enabled", true);
    flag.put("variationType", "STRING");
    flag.put("totalShards", 10000);
    flag.putObject("variations")
        .putObject(encode("on"))
        .put("key", encode("on"))
        .put("value", encode("cached-in-4x"));
    ObjectNode allocation = flag.putArray("allocations").addObject();
    allocation.put("key", encode("all"));
    allocation.put("doLog", false);
    allocation.putArray("splits").addObject().put("variationKey", encode("on")).putArray("shards");
    return MAPPER.writeValueAsBytes(config);
  }

  private static String encode(String value) {
    return Base64.getEncoder().encodeToString(value.getBytes(StandardCharsets.UTF_8));
  }

  @Test
  public void offlineStartAfterUpgradeUsesAndRemoves4xCache() throws Exception {
    Application app = RuntimeEnvironment.getApplication();
    // 4.x name (first eight key characters, non-word characters removed) and format (raw JSON).
    String legacyKey = cloud.eppo.android.util.Utils.safeCacheKey(API_KEY);
    File legacy = new File(app.getFilesDir(), "eppo-sdk-config-v4-flags-" + legacyKey + ".json");
    try (OutputStream out = new FileOutputStream(legacy)) {
      out.write(obfuscatedClientConfig());
    }

    EppoClient client =
        new EppoClient.Builder(API_KEY, app)
            .forceReinitialize(true)
            .offlineMode(true)
            .isGracefulMode(false)
            .buildAndInitAsync()
            .get(10, TimeUnit.SECONDS);

    assertEquals("cached-in-4x", client.getStringAssignment("str_flag", "subject", "default"));
    assertFalse(legacy.exists());
    File current =
        new File(app.getFilesDir(), "eppo-sdk-flags-" + Utils.safeCacheKey(API_KEY) + ".ser");
    assertTrue(current.exists());
  }
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Comment from Codex working with @typotter:

Confirmed the offline upgrade failure with the supplied legacy-cache test. This update does not yet migrate the 4.x cache or change the standard client's cache-key helper.

The suggested migration deletes the old file in finally, before the replacement cache is durably saved. I would retain the old file until the new write succeeds, and cover failed writes, corrupt input and explicit store/configuration overrides. The migration guide now states the current cache limitation. This thread remains open.

spyClient.getJSONAssignment(
"subject1", "experiment1", new Attributes(), mapper.readTree("{}")));
}
// TODO: These tests need to be rewritten for the v4 SDK framework

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Comment from Claude working with Aaron Silverman:

[P2] Add Android tests for the assignment details APIs, and restore assignment-error graceful-mode coverage.

With sdk-common 4.0.3, EppoClient gets the public get*AssignmentDetails, getJSONAssignmentDetails and getBanditActionDetails methods. No eppo test calls them. These two graceful-mode tests are commented out, so the connected tests drop from 48 to 46, and no remaining test checks graceful handling of assignment-evaluation errors.

The test below needs no network. It covers matched and unmatched allocations, error codes, a JSON value, the bandit fallback, and graceful mode for the string value and details methods. The original tests covered more value types; this test covers strings only.

What the test shows
  • All three tests pass at this head, without other changes.
  • I swapped isGracefulMode and expectObfuscatedConfig in the EppoClient constructor's super(...) call. gracefulModeAppliesToDetails then fails, so the test detects a lost graceful flag.
  • The empty-subject behavior (throw in strict mode, default value in graceful mode) matches 4.x. The evaluation-code assertions pin sdk-common 4.0.3 behavior.
Test (Robolectric)
package cloud.eppo.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

import cloud.eppo.api.AllocationEvaluationCode;
import cloud.eppo.api.AssignmentDetails;
import cloud.eppo.api.Attributes;
import cloud.eppo.api.BanditActions;
import cloud.eppo.api.Configuration;
import cloud.eppo.api.EppoValue;
import cloud.eppo.api.EvaluationDetails;
import cloud.eppo.api.FlagEvaluationCode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;

@RunWith(RobolectricTestRunner.class)
public class AssignmentDetailsApiTest {
  private static final String UFC =
      "{\"format\":\"SERVER\",\"createdAt\":\"2026-10-14T00:00:00.000Z\","
          + "\"environment\":{\"name\":\"Test\"},\"banditReferences\":{},\"flags\":{"
          + "\"str_flag\":{\"key\":\"str_flag\",\"enabled\":true,\"variationType\":\"STRING\","
          + "\"totalShards\":10000,\"variations\":{\"us\":{\"key\":\"us\",\"value\":\"us-value\"},"
          + "\"other\":{\"key\":\"other\",\"value\":\"other-value\"}},\"allocations\":["
          + "{\"key\":\"us-only\",\"doLog\":true,\"rules\":[{\"conditions\":[{\"attribute\":"
          + "\"country\",\"operator\":\"ONE_OF\",\"value\":[\"US\"]}]}],"
          + "\"splits\":[{\"variationKey\":\"us\",\"shards\":[]}]},"
          + "{\"key\":\"everyone\",\"doLog\":true,"
          + "\"splits\":[{\"variationKey\":\"other\",\"shards\":[]}]}]},"
          + "\"json_flag\":{\"key\":\"json_flag\",\"enabled\":true,\"variationType\":\"JSON\","
          + "\"totalShards\":10000,\"variations\":{\"j\":{\"key\":\"j\",\"value\":\"{\\\"a\\\":1}\"}},"
          + "\"allocations\":[{\"key\":\"all\",\"doLog\":true,"
          + "\"splits\":[{\"variationKey\":\"j\",\"shards\":[]}]}]}}}";

  private EppoClient client;

  @Before
  public void setUp() throws Exception {
    JacksonConfigurationParser parser = new JacksonConfigurationParser();
    Configuration config =
        parser.buildConfig(
            parser.parseFlagConfig(UFC.getBytes(StandardCharsets.UTF_8)), null, null, null);
    client =
        new EppoClient.Builder("mock-api-key", RuntimeEnvironment.getApplication())
            .forceReinitialize(true)
            .offlineMode(true)
            .isGracefulMode(false)
            .assignmentCache(null)
            .initialConfiguration(CompletableFuture.completedFuture(config))
            .buildAndInitAsync()
            .get(10, TimeUnit.SECONDS);
  }

  private static Attributes country(String value) {
    Attributes attributes = new Attributes();
    attributes.put("country", EppoValue.valueOf(value));
    return attributes;
  }

  @Test
  public void stringDetailsReportMatchedAndUnmatchedAllocations() {
    AssignmentDetails<String> us =
        client.getStringAssignmentDetails("str_flag", "alice", country("US"), "default");
    EvaluationDetails details = us.getEvaluationDetails();
    assertEquals("us-value", us.getVariation());
    assertEquals(FlagEvaluationCode.MATCH, details.getFlagEvaluationCode());
    assertEquals("us", details.getVariationKey());
    assertEquals("us-only", details.getMatchedAllocation().getKey());
    assertEquals("everyone", details.getUnevaluatedAllocations().get(0).getKey());

    EvaluationDetails canada =
        client
            .getStringAssignmentDetails("str_flag", "bob", country("CA"), "default")
            .getEvaluationDetails();
    assertEquals("everyone", canada.getMatchedAllocation().getKey());
    assertEquals(
        AllocationEvaluationCode.FAILING_RULE,
        canada.getUnmatchedAllocations().get(0).getAllocationEvaluationCode());
  }

  @Test
  public void detailsReportErrorCodesJsonValuesAndBanditFallback() throws Exception {
    AssignmentDetails<Boolean> missing = client.getBooleanAssignmentDetails("nope", "alice", true);
    assertTrue(missing.getVariation());
    assertEquals(
        FlagEvaluationCode.FLAG_UNRECOGNIZED_OR_DISABLED,
        missing.getEvaluationDetails().getFlagEvaluationCode());

    AssignmentDetails<Integer> wrongType =
        client.getIntegerAssignmentDetails("str_flag", "alice", 7);
    assertEquals(Integer.valueOf(7), wrongType.getVariation());
    assertEquals(
        FlagEvaluationCode.TYPE_MISMATCH, wrongType.getEvaluationDetails().getFlagEvaluationCode());

    assertEquals(
        1,
        client
            .getJSONAssignmentDetails("json_flag", "alice", new ObjectMapper().readTree("{}"))
            .getVariation()
            .get("a")
            .asInt());

    AssignmentDetails<String> bandit =
        client.getBanditActionDetails(
            "str_flag",
            "alice",
            country("US"),
            new BanditActions(Collections.singleton("a1")),
            "default");
    assertEquals("us-value", bandit.getVariation());
    assertNull(bandit.getAction());
    assertEquals(FlagEvaluationCode.MATCH, bandit.getEvaluationDetails().getFlagEvaluationCode());
  }

  @Test
  public void gracefulModeAppliesToDetails() {
    assertThrows(RuntimeException.class, () -> client.getStringAssignment("str_flag", "", "d"));
    assertThrows(
        RuntimeException.class, () -> client.getStringAssignmentDetails("str_flag", "", "d"));
    client.setIsGracefulFailureMode(true);
    assertEquals("d", client.getStringAssignment("str_flag", "", "d"));
    assertEquals(
        FlagEvaluationCode.ASSIGNMENT_ERROR,
        client
            .getStringAssignmentDetails("str_flag", "", "d")
            .getEvaluationDetails()
            .getFlagEvaluationCode());
  }
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Comment from Codex working with @typotter:

Added AssignmentDetailsApiTest with the allocation details, error-code, JSON, bandit fallback and string graceful-error cases. All three Robolectric tests pass.

This adds local Android coverage, but does not restore every value-type case from the former tests. These new cases have not been run as connected device tests.

Comment on lines +4 to +5
public static final String INITIAL_SUBJECT_ID = "jsmith123";
public static final String INITIAL_FLAG_KEY = "ai-metric-explores";

@aarsilv aarsilv Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Comment from Claude working with Aaron Silverman:

[P2] Clean up the example app. Customers copy it to build their integrations.

  • Constants.java: these values look like local test data. On main both are "".
  • SecondActivity.java:90-91: the only details example on the EppoClient path is commented out. Make it real code (patch below).
  • CustomClientActivity:
    • The non-static inner builder (line 59) holds the activity until initialization completes.
    • The on-screen log prints the injected header values. HeaderInjectingEppoClient's Javadoc suggests authentication tokens as a use, so log only the header names.
    • forceReinitialize(true) in onCreate initializes again on every rotation.
  • GsonConfigurationCodec:
    • It reads non-public Configuration fields (flags, banditReferences, bandits) by reflection, and its Javadoc says the format is "immune to serialVersionUID drift".
    • getBanditReferences() and getBandits() are public, so only flags needs reflection. Suggested Javadoc paragraph to replace the "immune" and "does not expose its internal maps" sentences: "Configuration exposes getBanditReferences() and getBandits(), but not its flag map. This codec reads the private flags field by reflection. That is not a supported API: the field can change in any sdk-common release."
  • EppoClient.java:213-216: the Javadoc says "pollingIntervalMs default 60000 and pollingJitterMs default 600". The defaults are 5 minutes (DEFAULT_POLLING_INTERVAL_MS) and 10% of the interval. Suggested text: "Used in conjunction with pollingIntervalMs (default 300000, five minutes) and pollingJitterMs (default 10% of the interval)." Line 224 ("A suggested interval is one minute (60000).") can stay.

Correction: an earlier version of this comment said that R8's renaming of Configuration.flags breaks this reflection in the minified build. That was wrong. R8 also rewrites the constant field names passed to getDeclaredField, and on an emulator CustomClientActivity opens without a crash in the example's release build. I removed that claim.

Suggested patch for Constants, SecondActivity and CustomClientActivity (tested together with the other suggested changes on the #261 head; the example compiles and builds its minified release)
--- a/example/src/main/java/cloud/eppo/androidexample/Constants.java
+++ b/example/src/main/java/cloud/eppo/androidexample/Constants.java
@@ -3,4 +3,4 @@ package cloud.eppo.androidexample;
 public class Constants {
-  public static final String INITIAL_SUBJECT_ID = "jsmith123";
-  public static final String INITIAL_FLAG_KEY = "ai-metric-explores";
+  public static final String INITIAL_SUBJECT_ID = "";
+  public static final String INITIAL_FLAG_KEY = "";
 }
--- a/example/src/main/java/cloud/eppo/androidexample/SecondActivity.java
+++ b/example/src/main/java/cloud/eppo/androidexample/SecondActivity.java
@@ -14,2 +14,3 @@ import androidx.appcompat.app.AppCompatActivity;
 import cloud.eppo.android.EppoClient;
+import cloud.eppo.api.AssignmentDetails;
 import cloud.eppo.api.Attributes;
@@ -86,8 +87,13 @@ public class SecondActivity extends AppCompatActivity {
 
-    String assignedVariation =
+    AssignmentDetails<String> details =
         EppoClient.getInstance()
-            .getStringAssignment(experimentKey, subjectId, new Attributes(), "DEFAULT");
-    //    AssignmentDetails<Boolean> details =         EppoClient.getInstance()
-    //            .getBooleanAssignmentDetails(experimentKey, subjectId, new Attributes(), false);
-    Log.i("Eppo", "Assignment: " + assignedVariation);
+            .getStringAssignmentDetails(experimentKey, subjectId, new Attributes(), "DEFAULT");
+    String assignedVariation = details.getVariation();
+    Log.i(
+        "Eppo",
+        "Assignment: "
+            + assignedVariation
+            + " ("
+            + details.getEvaluationDetails().getFlagEvaluationCode()
+            + ")");
     appendToAssignmentLogView("Assigned variation: " + assignedVariation);
--- a/example/src/main/java/cloud/eppo/androidexample/CustomClientActivity.java
+++ b/example/src/main/java/cloud/eppo/androidexample/CustomClientActivity.java
@@ -58,3 +58,3 @@ public class CustomClientActivity extends AppCompatActivity {
 
-  private class GsonAndroidBaseClientBuilder
+  private static final class GsonAndroidBaseClientBuilder
       extends AndroidBaseClient.Builder<
@@ -162,3 +162,3 @@ public class CustomClientActivity extends AppCompatActivity {
                               + "Injected headers: "
-                              + customHeaders));
+                              + customHeaders.keySet()));
             })

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Comment from Codex working with @typotter:

Updated the example: cleared sample constants, made the builder static, logs header names only, and enabled a string assignment-details example. The codec uses public bandit getters and documents its remaining private flags reflection. Polling defaults are corrected.

The example compiles and its minified build passes. Rotation reinitialization and pending-initialization lifecycle handling remain open. Your correction about R8 rewriting constant reflection names is retained; I am not treating that as a demonstrated crash.

@typotter
typotter requested a review from aarsilv November 6, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

crucible: reviewing A Crucible review has started; this PR has reviewer attention.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants