From 705a281f5fc3f8da49ab4196f92ac3151b58fbbf Mon Sep 17 00:00:00 2001 From: Gaston Thea Date: Wed, 6 Sep 2023 13:43:49 -0300 Subject: [PATCH 1/2] Sets config telemetry --- .../android/client/SplitFactoryHelper.java | 2 +- .../io/split/android/client/SplitFilter.java | 11 ++- .../localhost/LocalhostSplitFactory.java | 2 +- .../executor/SplitTaskFactoryImpl.java | 15 +++- .../telemetry/TelemetryTaskFactoryImpl.java | 11 ++- .../client/telemetry/model/Config.java | 22 +++++ .../storage/TelemetryConfigProviderImpl.java | 10 ++- .../validators/FlagSetsValidatorImpl.java | 10 ++- .../validators/SplitFilterValidator.java | 22 ++++- .../TelemetryConfigBodySerializerTest.java | 6 +- .../TelemetryConfigProviderImplTest.java | 4 +- .../validators/FlagSetsValidatorImplTest.java | 84 +++++++++++-------- 12 files changed, 143 insertions(+), 56 deletions(-) diff --git a/src/main/java/io/split/android/client/SplitFactoryHelper.java b/src/main/java/io/split/android/client/SplitFactoryHelper.java index 8e224773e..76393dc34 100644 --- a/src/main/java/io/split/android/client/SplitFactoryHelper.java +++ b/src/main/java/io/split/android/client/SplitFactoryHelper.java @@ -428,7 +428,7 @@ Pair, String>, Set> getFilterConfiguration(SyncCo SplitFilter splitFilter = groupedFilters.get(0); // In the case of BY_SET, all filters will be grouped into one with the {@link SplitFilter.Type#BY_SET} type - if (splitFilter.getType() == SplitFilter.Type.BY_SET) { + if (splitFilter != null && splitFilter.getType() == SplitFilter.Type.BY_SET) { configuredFlagSets.addAll(splitFilter.getValues()); } } diff --git a/src/main/java/io/split/android/client/SplitFilter.java b/src/main/java/io/split/android/client/SplitFilter.java index cdd7ce283..908f01c34 100644 --- a/src/main/java/io/split/android/client/SplitFilter.java +++ b/src/main/java/io/split/android/client/SplitFilter.java @@ -60,6 +60,7 @@ public int maxValuesCount() { private final SplitFilter.Type mType; private final List mValues; + private int mInvalidValueCount; public static SplitFilter byName(@NonNull List values) { return new SplitFilter(Type.BY_NAME, values); @@ -74,7 +75,7 @@ public static SplitFilter bySet(@NonNull List values) { } // This constructor is not private (but default) to allow Split Sync Config builder be agnostic when creating filters - // Also is not public to force SDK users to use static functions "byName" and "byPrefix" + // Also is not public to force SDK users to use static functions "byName", "byPrefix", "bySet" SplitFilter(Type type, List values) { if (values == null) { throw new IllegalArgumentException("Values can't be null for " + type.toString() + " filter"); @@ -85,7 +86,9 @@ public static SplitFilter bySet(@NonNull List values) { SplitFilter(Type type, List values, SplitFilterValidator validator) { mType = type; - mValues = validator.cleanup(values); + SplitFilterValidator.ValidationResult validationResult = validator.cleanup(values); + mValues = validationResult.getValues(); + mInvalidValueCount = validationResult.getInvalidValueCount(); } public Type getType() { @@ -95,4 +98,8 @@ public Type getType() { public List getValues() { return mValues; } + + public int getInvalidValueCount() { + return mInvalidValueCount; + } } diff --git a/src/main/java/io/split/android/client/localhost/LocalhostSplitFactory.java b/src/main/java/io/split/android/client/localhost/LocalhostSplitFactory.java index e0ece35ca..de3efad14 100644 --- a/src/main/java/io/split/android/client/localhost/LocalhostSplitFactory.java +++ b/src/main/java/io/split/android/client/localhost/LocalhostSplitFactory.java @@ -79,7 +79,7 @@ public LocalhostSplitFactory(String key, Context context, List groupedFilters = new FilterBuilder(config.syncConfig().getFilters()) .getGroupedFilter(); - if (!groupedFilters.isEmpty() && groupedFilters.get(0).getType() == SplitFilter.Type.BY_SET) { + if (!groupedFilters.isEmpty() && groupedFilters.get(0) != null && groupedFilters.get(0).getType() == SplitFilter.Type.BY_SET) { configuredSets.addAll(groupedFilters.get(0).getValues()); } } diff --git a/src/main/java/io/split/android/client/service/executor/SplitTaskFactoryImpl.java b/src/main/java/io/split/android/client/service/executor/SplitTaskFactoryImpl.java index d3f191424..142d8f14b 100644 --- a/src/main/java/io/split/android/client/service/executor/SplitTaskFactoryImpl.java +++ b/src/main/java/io/split/android/client/service/executor/SplitTaskFactoryImpl.java @@ -92,14 +92,23 @@ public SplitTaskFactoryImpl(@NonNull SplitClientConfig splitClientConfig, mTelemetryRuntimeProducer); } + mFilters = (filters == null) ? new ArrayList<>() : filters; + + int flagSetCount = 0; + int invalidFlagSetCount = 0; + if (!mFilters.isEmpty() && mFilters.get(0) != null && mFilters.get(0).getType() == SplitFilter.Type.BY_SET) { + flagSetCount = mFilters.get(0).getValues().size(); + invalidFlagSetCount = mFilters.get(0).getInvalidValueCount(); + } + mTelemetryTaskFactory = new TelemetryTaskFactoryImpl(mSplitApiFacade.getTelemetryConfigRecorder(), mSplitApiFacade.getTelemetryStatsRecorder(), telemetryStorage, splitClientConfig, mSplitsStorageContainer.getSplitsStorage(), - mSplitsStorageContainer.getMySegmentsStorageContainer()); - - mFilters = (filters == null) ? new ArrayList<>() : filters; + mSplitsStorageContainer.getMySegmentsStorageContainer(), + flagSetCount, + invalidFlagSetCount); } @Override diff --git a/src/main/java/io/split/android/client/service/telemetry/TelemetryTaskFactoryImpl.java b/src/main/java/io/split/android/client/service/telemetry/TelemetryTaskFactoryImpl.java index 624b0f948..08a24f672 100644 --- a/src/main/java/io/split/android/client/service/telemetry/TelemetryTaskFactoryImpl.java +++ b/src/main/java/io/split/android/client/service/telemetry/TelemetryTaskFactoryImpl.java @@ -2,9 +2,11 @@ import androidx.annotation.NonNull; +import java.util.List; + import io.split.android.client.SplitClientConfig; +import io.split.android.client.SplitFilter; import io.split.android.client.service.http.HttpRecorder; -import io.split.android.client.storage.mysegments.MySegmentsStorage; import io.split.android.client.storage.mysegments.MySegmentsStorageContainer; import io.split.android.client.storage.splits.SplitsStorage; import io.split.android.client.telemetry.model.Config; @@ -15,7 +17,6 @@ import io.split.android.client.telemetry.storage.TelemetryStatsProvider; import io.split.android.client.telemetry.storage.TelemetryStatsProviderImpl; import io.split.android.client.telemetry.storage.TelemetryStorage; -import io.split.android.client.telemetry.storage.TelemetryStorageConsumer; public class TelemetryTaskFactoryImpl implements TelemetryTaskFactory { @@ -30,9 +31,11 @@ public TelemetryTaskFactoryImpl(@NonNull HttpRecorder telemetryConfigRec @NonNull TelemetryStorage telemetryStorage, @NonNull SplitClientConfig splitClientConfig, @NonNull SplitsStorage splitsStorage, - @NonNull MySegmentsStorageContainer mySegmentsStorageContainer) { + @NonNull MySegmentsStorageContainer mySegmentsStorageContainer, + int flagSetCount, + int invalidFlagSetCount) { mTelemetryConfigRecorder = telemetryConfigRecorder; - mTelemetryConfigProvider = new TelemetryConfigProviderImpl(telemetryStorage, splitClientConfig); + mTelemetryConfigProvider = new TelemetryConfigProviderImpl(telemetryStorage, splitClientConfig, flagSetCount, invalidFlagSetCount); mTelemetryStatsRecorder = telemetryStatsRecorder; mTelemetryStatsProvider = new TelemetryStatsProviderImpl(telemetryStorage, splitsStorage, mySegmentsStorageContainer); mTelemetryRuntimeProducer = telemetryStorage; diff --git a/src/main/java/io/split/android/client/telemetry/model/Config.java b/src/main/java/io/split/android/client/telemetry/model/Config.java index 25ec3ee42..bf6849271 100644 --- a/src/main/java/io/split/android/client/telemetry/model/Config.java +++ b/src/main/java/io/split/android/client/telemetry/model/Config.java @@ -60,6 +60,12 @@ public class Config { @SerializedName("i") private List integrations; + @SerializedName("fsT") + private int flagSetsTotal; + + @SerializedName("fsI") + private int flagSetsInvalid; + public int getOperationMode() { return operationMode; } @@ -195,4 +201,20 @@ public List getIntegrations() { public void setIntegrations(List integrations) { this.integrations = integrations; } + + public int getFlagSetsTotal() { + return flagSetsTotal; + } + + public void setFlagSetsTotal(int flagSetsTotal) { + this.flagSetsTotal = flagSetsTotal; + } + + public int getFlagSetsInvalid() { + return flagSetsInvalid; + } + + public void setFlagSetsInvalid(int flagSetsInvalid) { + this.flagSetsInvalid = flagSetsInvalid; + } } diff --git a/src/main/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImpl.java b/src/main/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImpl.java index adfb6f97f..b937411c4 100644 --- a/src/main/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImpl.java +++ b/src/main/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImpl.java @@ -20,11 +20,17 @@ public class TelemetryConfigProviderImpl implements TelemetryConfigProvider { private final TelemetryStorageConsumer mTelemetryConsumer; private final SplitClientConfig mSplitClientConfig; + private final int mFlagSetCount; + private final int mInvalidFlagSetCount; public TelemetryConfigProviderImpl(@NonNull TelemetryStorageConsumer telemetryConsumer, - @NonNull SplitClientConfig splitClientConfig) { + @NonNull SplitClientConfig splitClientConfig, + int flagSetCount, + int invalidFlagSetCount) { mTelemetryConsumer = checkNotNull(telemetryConsumer); mSplitClientConfig = checkNotNull(splitClientConfig); + mFlagSetCount = flagSetCount; + mInvalidFlagSetCount = invalidFlagSetCount; } @Override @@ -44,6 +50,8 @@ public Config getConfigTelemetry() { config.setImpressionsQueueSize(mSplitClientConfig.impressionsQueueSize()); config.setEventsQueueSize(mSplitClientConfig.eventsQueueSize()); config.setUserConsent(mSplitClientConfig.userConsent().intValue()); + config.setFlagSetsTotal(mFlagSetCount); + config.setFlagSetsInvalid(mInvalidFlagSetCount); if (mSplitClientConfig.impressionsMode() == ImpressionsMode.DEBUG) { config.setImpressionsMode(io.split.android.client.telemetry.model.ImpressionsMode.DEBUG.intValue()); } else if (mSplitClientConfig.impressionsMode() == ImpressionsMode.OPTIMIZED) { diff --git a/src/main/java/io/split/android/client/validators/FlagSetsValidatorImpl.java b/src/main/java/io/split/android/client/validators/FlagSetsValidatorImpl.java index 2be41e83f..5e14a45a3 100644 --- a/src/main/java/io/split/android/client/validators/FlagSetsValidatorImpl.java +++ b/src/main/java/io/split/android/client/validators/FlagSetsValidatorImpl.java @@ -19,14 +19,17 @@ public class FlagSetsValidatorImpl implements SplitFilterValidator { * @return list of unique alphanumerically ordered valid flag sets */ @Override - public List cleanup(List values) { + public ValidationResult cleanup(List values) { if (values == null || values.isEmpty()) { - return Collections.emptyList(); + return new ValidationResult(Collections.emptyList(), 0); } + int invalidValueCount = 0; + TreeSet cleanedUpSets = new TreeSet<>(); for (String set : values) { if (set == null || set.isEmpty()) { + invalidValueCount++; continue; } @@ -43,11 +46,12 @@ public List cleanup(List values) { if (set.matches(FLAG_SET_REGEX)) { cleanedUpSets.add(set); } else { + invalidValueCount++; Logger.w("SDK config: you passed "+ set +", Flag Set must adhere to the regular expressions "+ FLAG_SET_REGEX +". This means a Flag Set must be start with a letter, be in lowercase, alphanumeric and have a max length of 50 characters. "+ set +" was discarded."); } } - return new ArrayList<>(cleanedUpSets); + return new ValidationResult(new ArrayList<>(cleanedUpSets), invalidValueCount); } @Override diff --git a/src/main/java/io/split/android/client/validators/SplitFilterValidator.java b/src/main/java/io/split/android/client/validators/SplitFilterValidator.java index d605f17c0..110043d47 100644 --- a/src/main/java/io/split/android/client/validators/SplitFilterValidator.java +++ b/src/main/java/io/split/android/client/validators/SplitFilterValidator.java @@ -4,7 +4,27 @@ public interface SplitFilterValidator { - List cleanup(List values); + ValidationResult cleanup(List values); boolean isValid(String value); + + class ValidationResult { + + private final List mValues; + + private final int mInvalidValueCount; + + public ValidationResult(List values, int invalidValueCount) { + mValues = values; + mInvalidValueCount = invalidValueCount; + } + + public List getValues() { + return mValues; + } + + public int getInvalidValueCount() { + return mInvalidValueCount; + } + } } diff --git a/src/test/java/io/split/android/client/telemetry/TelemetryConfigBodySerializerTest.java b/src/test/java/io/split/android/client/telemetry/TelemetryConfigBodySerializerTest.java index 183ea2f42..f15584ed5 100644 --- a/src/test/java/io/split/android/client/telemetry/TelemetryConfigBodySerializerTest.java +++ b/src/test/java/io/split/android/client/telemetry/TelemetryConfigBodySerializerTest.java @@ -24,7 +24,7 @@ public void setUp() { @Test public void jsonIsBuiltAsExpected() { - final String expectedJson = "{\"oM\":0,\"st\":\"memory\",\"sE\":true,\"rR\":{\"sp\":4000,\"ms\":5000,\"im\":3000,\"ev\":2000,\"te\":1000},\"uO\":{\"s\":true,\"e\":true,\"a\":true,\"st\":true,\"t\":true},\"iQ\":4000,\"eQ\":3000,\"iM\":1,\"iL\":true,\"hP\":true,\"aF\":1,\"rF\":0,\"tR\":300,\"tC\":0,\"nR\":3,\"uC\":1,\"t\":[\"tag1\",\"tag2\"],\"i\":[\"integration1\",\"integration2\"]}"; + final String expectedJson = "{\"oM\":0,\"st\":\"memory\",\"sE\":true,\"rR\":{\"sp\":4000,\"ms\":5000,\"im\":3000,\"ev\":2000,\"te\":1000},\"uO\":{\"s\":true,\"e\":true,\"a\":true,\"st\":true,\"t\":true},\"iQ\":4000,\"eQ\":3000,\"iM\":1,\"iL\":true,\"hP\":true,\"aF\":1,\"rF\":0,\"tR\":300,\"tC\":0,\"nR\":3,\"uC\":1,\"t\":[\"tag1\",\"tag2\"],\"i\":[\"integration1\",\"integration2\"],\"fsT\":4,\"fsI\":2}"; final String serializedConfig = telemetryConfigBodySerializer.serialize(buildMockConfig()); assertEquals(expectedJson, serializedConfig); @@ -33,7 +33,7 @@ public void jsonIsBuiltAsExpected() { @Test public void nullValuesAreIgnoredForJson() { - final String expectedJson = "{\"oM\":0,\"st\":\"memory\",\"sE\":true,\"iQ\":4000,\"eQ\":3000,\"iM\":1,\"iL\":true,\"hP\":true,\"aF\":1,\"rF\":0,\"tR\":300,\"tC\":0,\"nR\":3,\"uC\":0,\"t\":[\"tag1\",\"tag2\"],\"i\":[\"integration1\",\"integration2\"]}"; + final String expectedJson = "{\"oM\":0,\"st\":\"memory\",\"sE\":true,\"iQ\":4000,\"eQ\":3000,\"iM\":1,\"iL\":true,\"hP\":true,\"aF\":1,\"rF\":0,\"tR\":300,\"tC\":0,\"nR\":3,\"uC\":0,\"t\":[\"tag1\",\"tag2\"],\"i\":[\"integration1\",\"integration2\"],\"fsT\":0,\"fsI\":0}"; final String serializedConfig = telemetryConfigBodySerializer.serialize(buildMockConfigWithNulls()); assertEquals(expectedJson, serializedConfig); @@ -71,6 +71,8 @@ private Config buildMockConfig() { config.setUserConsent(1); config.setTags(Arrays.asList("tag1", "tag2")); config.setIntegrations(Arrays.asList("integration1", "integration2")); + config.setFlagSetsTotal(4); + config.setFlagSetsInvalid(2); return config; } diff --git a/src/test/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImplTest.java b/src/test/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImplTest.java index 6047c2c20..ab4352c1f 100644 --- a/src/test/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImplTest.java +++ b/src/test/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImplTest.java @@ -60,7 +60,7 @@ public void close() { } }) .build(); - mTelemetryConfigProvider = new TelemetryConfigProviderImpl(mTelemetryStorageConsumer, mSplitClientConfig); + mTelemetryConfigProvider = new TelemetryConfigProviderImpl(mTelemetryStorageConsumer, mSplitClientConfig, 4, 2); Config configTelemetry = mTelemetryConfigProvider.getConfigTelemetry(); @@ -81,5 +81,7 @@ public void close() { assertTrue(configTelemetry.getUrlOverrides().isEvents()); assertTrue(configTelemetry.getUrlOverrides().isAuth()); assertTrue(configTelemetry.getUrlOverrides().isStream()); + assertEquals(4, configTelemetry.getFlagSetsTotal()); + assertEquals(2, configTelemetry.getFlagSetsInvalid()); } } diff --git a/src/test/java/io/split/android/client/validators/FlagSetsValidatorImplTest.java b/src/test/java/io/split/android/client/validators/FlagSetsValidatorImplTest.java index cd8bc9604..72e3482db 100644 --- a/src/test/java/io/split/android/client/validators/FlagSetsValidatorImplTest.java +++ b/src/test/java/io/split/android/client/validators/FlagSetsValidatorImplTest.java @@ -15,80 +15,90 @@ public class FlagSetsValidatorImplTest { @Test public void nullInputReturnsEmptyList() { - List result = mValidator.cleanup(null); - assertTrue(result.isEmpty()); + SplitFilterValidator.ValidationResult result = mValidator.cleanup(null); + assertTrue(result.getValues().isEmpty()); + assertEquals(0, result.getInvalidValueCount()); } @Test public void emptyInputReturnsEmptyList() { - List result = mValidator.cleanup(Collections.emptyList()); - assertTrue(result.isEmpty()); + SplitFilterValidator.ValidationResult result = mValidator.cleanup(Collections.emptyList()); + assertTrue(result.getValues().isEmpty()); + assertEquals(0, result.getInvalidValueCount()); } @Test public void duplicatedInputValuesAreRemoved() { - List result = mValidator.cleanup(Arrays.asList("set1", "set1")); - assertEquals(1, result.size()); - assertTrue(result.contains("set1")); + SplitFilterValidator.ValidationResult result = mValidator.cleanup(Arrays.asList("set1", "set1")); + assertEquals(1, result.getValues().size()); + assertTrue(result.getValues().contains("set1")); + assertEquals(0, result.getInvalidValueCount()); } @Test public void valuesAreSortedAlphanumerically() { - List result = mValidator.cleanup(Arrays.asList("set2", "set1", "set_1", "1set")); - assertEquals(4, result.size()); - assertEquals("1set", result.get(0)); - assertEquals("set1", result.get(1)); - assertEquals("set2", result.get(2)); - assertEquals("set_1", result.get(3)); + SplitFilterValidator.ValidationResult result = mValidator.cleanup(Arrays.asList("set2", "set1", "set_1", "1set")); + assertEquals(4, result.getValues().size()); + assertEquals("1set", result.getValues().get(0)); + assertEquals("set1", result.getValues().get(1)); + assertEquals("set2", result.getValues().get(2)); + assertEquals("set_1", result.getValues().get(3)); + assertEquals(0, result.getInvalidValueCount()); } @Test public void invalidValuesAreRemoved() { - List result = mValidator.cleanup(Arrays.asList("set1", "set2", "set_1", "set-1", "set 1", "set 2")); - assertEquals(3, result.size()); - assertEquals("set1", result.get(0)); - assertEquals("set2", result.get(1)); - assertEquals("set_1", result.get(2)); + SplitFilterValidator.ValidationResult result = mValidator.cleanup(Arrays.asList("set1", "set2", "set_1", "set-1", "set 1", "set 2")); + assertEquals(3, result.getValues().size()); + assertEquals("set1", result.getValues().get(0)); + assertEquals("set2", result.getValues().get(1)); + assertEquals("set_1", result.getValues().get(2)); + assertEquals(3, result.getInvalidValueCount()); } @Test public void setWithMoreThan50CharsIsRemoved() { String longSet = "abcdfghijklmnopqrstuvwxyz1234567890abcdfghijklmnopq"; - List result = mValidator.cleanup(Arrays.asList("set1", longSet)); + SplitFilterValidator.ValidationResult result = mValidator.cleanup(Arrays.asList("set1", longSet)); assertEquals(51, longSet.length()); - assertEquals(1, result.size()); - assertEquals("set1", result.get(0)); + assertEquals(1, result.getValues().size()); + assertEquals("set1", result.getValues().get(0)); + assertEquals(1, result.getInvalidValueCount()); } @Test public void setWithLessThanOneCharIsOrEmptyRemoved() { - List result = mValidator.cleanup(Arrays.asList("set1", "", " ")); - assertEquals(1, result.size()); - assertEquals("set1", result.get(0)); + SplitFilterValidator.ValidationResult result = mValidator.cleanup(Arrays.asList("set1", "", " ")); + assertEquals(1, result.getValues().size()); + assertEquals("set1", result.getValues().get(0)); + assertEquals(2, result.getInvalidValueCount()); } @Test public void nullSetIsRemoved() { - List result = mValidator.cleanup(Arrays.asList("set1", null)); - assertEquals(1, result.size()); - assertEquals("set1", result.get(0)); + SplitFilterValidator.ValidationResult result = mValidator.cleanup(Arrays.asList("set1", null)); + assertEquals(1, result.getValues().size()); + assertEquals("set1", result.getValues().get(0)); + assertEquals(1, result.getInvalidValueCount()); } @Test public void setWithExtraWhitespaceIsTrimmed() { - List result = mValidator.cleanup(Arrays.asList("set1 ", " set2\r", "set3 ", "set 4\n")); - assertEquals(3, result.size()); - assertEquals("set1", result.get(0)); - assertEquals("set2", result.get(1)); - assertEquals("set3", result.get(2)); + SplitFilterValidator.ValidationResult result = mValidator.cleanup(Arrays.asList("set1 ", " set2\r", "set3 ", "set 4\n")); + assertEquals(3, result.getValues().size()); + assertEquals("set1", result.getValues().get(0)); + assertEquals("set2", result.getValues().get(1)); + assertEquals("set3", result.getValues().get(2)); + assertEquals(1, result.getInvalidValueCount()); } @Test public void setsAreLowercase() { - List result = mValidator.cleanup(Arrays.asList("SET1", "Set2", "SET_3")); - assertEquals(3, result.size()); - assertEquals("set1", result.get(0)); - assertEquals("set2", result.get(1)); - assertEquals("set_3", result.get(2)); + SplitFilterValidator.ValidationResult result = mValidator.cleanup(Arrays.asList("SET1", "Set2", "SET_3")); + assertEquals(3, result.getValues().size()); + assertEquals("set1", result.getValues().get(0)); + assertEquals("set2", result.getValues().get(1)); + assertEquals("set_3", result.getValues().get(2)); + assertEquals(0, result.getInvalidValueCount()); } } From c9662a3fe6b32b3b2c92b6e43d2689fdbe877a55 Mon Sep 17 00:00:00 2001 From: Gaston Thea Date: Wed, 6 Sep 2023 17:17:14 -0300 Subject: [PATCH 2/2] Fix fst count --- .../telemetry/storage/TelemetryConfigProviderImpl.java | 8 ++++---- .../storage/TelemetryConfigProviderImplTest.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImpl.java b/src/main/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImpl.java index b937411c4..1e98944f2 100644 --- a/src/main/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImpl.java +++ b/src/main/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImpl.java @@ -20,16 +20,16 @@ public class TelemetryConfigProviderImpl implements TelemetryConfigProvider { private final TelemetryStorageConsumer mTelemetryConsumer; private final SplitClientConfig mSplitClientConfig; - private final int mFlagSetCount; + private final int mValidFlagSetCount; private final int mInvalidFlagSetCount; public TelemetryConfigProviderImpl(@NonNull TelemetryStorageConsumer telemetryConsumer, @NonNull SplitClientConfig splitClientConfig, - int flagSetCount, + int validFlagSetCount, int invalidFlagSetCount) { mTelemetryConsumer = checkNotNull(telemetryConsumer); mSplitClientConfig = checkNotNull(splitClientConfig); - mFlagSetCount = flagSetCount; + mValidFlagSetCount = validFlagSetCount; mInvalidFlagSetCount = invalidFlagSetCount; } @@ -50,7 +50,7 @@ public Config getConfigTelemetry() { config.setImpressionsQueueSize(mSplitClientConfig.impressionsQueueSize()); config.setEventsQueueSize(mSplitClientConfig.eventsQueueSize()); config.setUserConsent(mSplitClientConfig.userConsent().intValue()); - config.setFlagSetsTotal(mFlagSetCount); + config.setFlagSetsTotal(mValidFlagSetCount + mInvalidFlagSetCount); config.setFlagSetsInvalid(mInvalidFlagSetCount); if (mSplitClientConfig.impressionsMode() == ImpressionsMode.DEBUG) { config.setImpressionsMode(io.split.android.client.telemetry.model.ImpressionsMode.DEBUG.intValue()); diff --git a/src/test/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImplTest.java b/src/test/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImplTest.java index ab4352c1f..8e4b773f6 100644 --- a/src/test/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImplTest.java +++ b/src/test/java/io/split/android/client/telemetry/storage/TelemetryConfigProviderImplTest.java @@ -81,7 +81,7 @@ public void close() { assertTrue(configTelemetry.getUrlOverrides().isEvents()); assertTrue(configTelemetry.getUrlOverrides().isAuth()); assertTrue(configTelemetry.getUrlOverrides().isStream()); - assertEquals(4, configTelemetry.getFlagSetsTotal()); + assertEquals(6, configTelemetry.getFlagSetsTotal()); assertEquals(2, configTelemetry.getFlagSetsInvalid()); } }