Skip to content

Commit

Permalink
renamed trackImpressions field
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal Al committed Jan 2, 2025
1 parent 17a0760 commit 3948497
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 120 deletions.
4 changes: 2 additions & 2 deletions client/src/main/java/io/split/client/api/SplitView.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class SplitView {
public Map<String, String> configs;
public List<String> sets;
public String defaultTreatment;
public boolean trackImpressions;
public boolean impressionsDisabled;

public static SplitView fromParsedSplit(ParsedSplit parsedSplit) {
SplitView splitView = new SplitView();
Expand All @@ -47,7 +47,7 @@ public static SplitView fromParsedSplit(ParsedSplit parsedSplit) {

splitView.treatments = new ArrayList<String>(treatments);
splitView.configs = parsedSplit.configurations() == null? Collections.<String, String>emptyMap() : parsedSplit.configurations() ;
splitView.trackImpressions = parsedSplit.trackImpressions();
splitView.impressionsDisabled = parsedSplit.impressionsDisabled();

return splitView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

public class DecoratedImpression {
private Impression impression;
private boolean track;
private boolean disabled;

public DecoratedImpression(Impression impression, boolean track) {
public DecoratedImpression(Impression impression, boolean disabled) {
this.impression = impression;
this.track = track;
this.disabled = disabled;
}

public Impression impression() { return this.impression;}

public boolean track() { return this.track;}
public boolean disabled() { return this.disabled;}
}

2 changes: 1 addition & 1 deletion client/src/main/java/io/split/client/dtos/Split.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Split {
public int algo;
public Map<String, String> configurations;
public HashSet<String> sets;
public Boolean trackImpressions = null;
public Boolean impressionsDisabled = null;

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void track(List<DecoratedImpression> decoratedImpressions) {

for (int i = 0; i < decoratedImpressions.size(); i++) {
ImpressionsResult impressionsResult;
if (decoratedImpressions.get(i).track()) {
if (!decoratedImpressions.get(i).disabled()) {
impressionsResult = _processImpressionStrategy.process(Stream.of(
decoratedImpressions.get(i).impression()).collect(Collectors.toList()));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
Labels.KILLED,
parsedSplit.changeNumber(),
config,
parsedSplit.trackImpressions());
parsedSplit.impressionsDisabled());
}

/*
Expand All @@ -117,7 +117,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
String config = parsedSplit.configurations() != null ?
parsedSplit.configurations().get(parsedSplit.defaultTreatment()) : null;
return new TreatmentLabelAndChangeNumber(parsedSplit.defaultTreatment(), Labels.NOT_IN_SPLIT,
parsedSplit.changeNumber(), config, parsedSplit.trackImpressions());
parsedSplit.changeNumber(), config, parsedSplit.impressionsDisabled());
}

}
Expand All @@ -132,7 +132,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
parsedCondition.label(),
parsedSplit.changeNumber(),
config,
parsedSplit.trackImpressions());
parsedSplit.impressionsDisabled());
}
}

Expand All @@ -142,7 +142,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
Labels.DEFAULT_RULE,
parsedSplit.changeNumber(),
config,
parsedSplit.trackImpressions());
parsedSplit.impressionsDisabled());
} catch (Exception e) {
throw new ChangeNumberExceptionWrapper(e, parsedSplit.changeNumber());
}
Expand Down
26 changes: 13 additions & 13 deletions client/src/main/java/io/split/engine/experiments/ParsedSplit.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ParsedSplit {
private final int _algo;
private final Map<String, String> _configurations;
private final HashSet<String> _flagSets;
private final boolean _trackImpressions;
private final boolean _impressionsDisabled;

public static ParsedSplit createParsedSplitForTests(
String feature,
Expand All @@ -44,7 +44,7 @@ public static ParsedSplit createParsedSplitForTests(
long changeNumber,
int algo,
HashSet<String> flagSets,
boolean trackImpressions
boolean impressionsDisabled
) {
return new ParsedSplit(
feature,
Expand All @@ -59,7 +59,7 @@ public static ParsedSplit createParsedSplitForTests(
algo,
null,
flagSets,
trackImpressions
impressionsDisabled
);
}

Expand All @@ -74,7 +74,7 @@ public static ParsedSplit createParsedSplitForTests(
int algo,
Map<String, String> configurations,
HashSet<String> flagSets,
boolean trackImpressions
boolean impressionsDisabled
) {
return new ParsedSplit(
feature,
Expand All @@ -89,7 +89,7 @@ public static ParsedSplit createParsedSplitForTests(
algo,
configurations,
flagSets,
trackImpressions
impressionsDisabled
);
}

Expand All @@ -106,7 +106,7 @@ public ParsedSplit(
int algo,
Map<String, String> configurations,
HashSet<String> flagSets,
boolean trackImpressions
boolean impressionsDisabled
) {
_split = feature;
_seed = seed;
Expand All @@ -123,7 +123,7 @@ public ParsedSplit(
_trafficAllocationSeed = trafficAllocationSeed;
_configurations = configurations;
_flagSets = flagSets;
_trackImpressions = trackImpressions;
_impressionsDisabled = impressionsDisabled;
}

public String feature() {
Expand Down Expand Up @@ -167,8 +167,8 @@ public Map<String, String> configurations() {
return _configurations;
}

public boolean trackImpressions() {
return _trackImpressions;
public boolean impressionsDisabled() {
return _impressionsDisabled;
}

@Override
Expand All @@ -183,7 +183,7 @@ public int hashCode() {
result = 31 * result + (int)(_changeNumber ^ (_changeNumber >>> 32));
result = 31 * result + (_algo ^ (_algo >>> 32));
result = 31 * result + (_configurations == null? 0 : _configurations.hashCode());
result = 31 * result + (_trackImpressions ? 1 : 0);
result = 31 * result + (_impressionsDisabled ? 1 : 0);
return result;
}

Expand All @@ -204,7 +204,7 @@ public boolean equals(Object obj) {
&& _changeNumber == other._changeNumber
&& _algo == other._algo
&& _configurations == null ? other._configurations == null : _configurations.equals(other._configurations)
&& _trackImpressions == other._trackImpressions;
&& _impressionsDisabled == other._impressionsDisabled;
}

@Override
Expand All @@ -228,8 +228,8 @@ public String toString() {
bldr.append(_algo);
bldr.append(", config:");
bldr.append(_configurations);
bldr.append(", trackImpressions:");
bldr.append(_trackImpressions);
bldr.append(", impressionsDisabled:");
bldr.append(_impressionsDisabled);
return bldr.toString();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public ParsedSplit parse(Split split) {

private ParsedSplit parseWithoutExceptionHandling(Split split) {
List<ParsedCondition> parsedConditionList = Lists.newArrayList();
if (Objects.isNull(split.trackImpressions)) {
_log.debug("trackImpressions field not detected for Feature flag `" + split.name + "`, setting it to `true`.");
split.trackImpressions = true;
if (Objects.isNull(split.impressionsDisabled)) {
_log.debug("impressionsDisabled field not detected for Feature flag `" + split.name + "`, setting it to `false`.");
split.impressionsDisabled = false;
}
for (Condition condition : split.conditions) {
List<Partition> partitions = condition.partitions;
Expand All @@ -95,7 +95,7 @@ private ParsedSplit parseWithoutExceptionHandling(Split split) {
split.algo,
split.configurations,
split.sets,
split.trackImpressions);
split.impressionsDisabled);
}

private boolean checkUnsupportedMatcherExist(List<io.split.client.dtos.Matcher> matchers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void kill(String splitName, String defaultTreatment, long changeNumber) {
parsedSplit.algo(),
parsedSplit.configurations(),
parsedSplit.flagSets(),
parsedSplit.trackImpressions()
parsedSplit.impressionsDisabled()
);

_concurrentMap.put(splitName, updatedSplit);
Expand Down
16 changes: 8 additions & 8 deletions client/src/test/java/io/split/client/SplitManagerImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void splitCallWithExistentSplit() {
String existent = "existent";

SplitCacheConsumer splitCacheConsumer = mock(SplitCacheConsumer.class);
ParsedSplit response = ParsedSplit.createParsedSplitForTests("FeatureName", 123, true, "off", Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, new HashSet<>(), true);
ParsedSplit response = ParsedSplit.createParsedSplitForTests("FeatureName", 123, true, "off", Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, new HashSet<>(), false);
when(splitCacheConsumer.get(existent)).thenReturn(response);

SplitManagerImpl splitManager = new SplitManagerImpl(splitCacheConsumer,
Expand All @@ -91,7 +91,7 @@ public void splitCallWithExistentSplitAndConfigs() {
Map<String, String> configurations = new HashMap<>();
configurations.put(Treatments.OFF, "{\"size\" : 30}");

ParsedSplit response = ParsedSplit.createParsedSplitForTests("FeatureName", 123, true, "off", Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, configurations, new HashSet<>(), true);
ParsedSplit response = ParsedSplit.createParsedSplitForTests("FeatureName", 123, true, "off", Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, configurations, new HashSet<>(), false);
when(splitCacheConsumer.get(existent)).thenReturn(response);

SplitManagerImpl splitManager = new SplitManagerImpl(splitCacheConsumer,
Expand Down Expand Up @@ -127,7 +127,7 @@ public void splitsCallWithSplit() {
List<ParsedSplit> parsedSplits = Lists.newArrayList();
SDKReadinessGates gates = mock(SDKReadinessGates.class);
when(gates.isSDKReady()).thenReturn(false);
ParsedSplit response = ParsedSplit.createParsedSplitForTests("FeatureName", 123, true, "off", Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, new HashSet<>(), true);
ParsedSplit response = ParsedSplit.createParsedSplitForTests("FeatureName", 123, true, "off", Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, new HashSet<>(), false);
parsedSplits.add(response);

when(splitCacheConsumer.getAll()).thenReturn(parsedSplits);
Expand Down Expand Up @@ -202,7 +202,7 @@ public void splitCallWithExistentSets() {
String existent = "existent";
SplitCacheConsumer splitCacheConsumer = mock(SplitCacheConsumer.class);
ParsedSplit response = ParsedSplit.createParsedSplitForTests("FeatureName", 123, true, "off",
Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, new HashSet<>(Arrays.asList("set1", "set2", "set3")), true);
Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, new HashSet<>(Arrays.asList("set1", "set2", "set3")), false);
when(splitCacheConsumer.get(existent)).thenReturn(response);

SplitManagerImpl splitManager = new SplitManagerImpl(splitCacheConsumer,
Expand All @@ -217,7 +217,7 @@ public void splitCallWithEmptySets() {
String existent = "existent";
SplitCacheConsumer splitCacheConsumer = mock(SplitCacheConsumer.class);
ParsedSplit response = ParsedSplit.createParsedSplitForTests("FeatureName", 123, true, "off",
Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, null, true);
Lists.newArrayList(getTestCondition("off")), "traffic", 456L, 1, null, false);
when(splitCacheConsumer.get(existent)).thenReturn(response);

SplitManagerImpl splitManager = new SplitManagerImpl(splitCacheConsumer,
Expand Down Expand Up @@ -246,10 +246,10 @@ public void ImpressionToggleParseTest() throws IOException {
mock(SDKReadinessGates.class), TELEMETRY_STORAGE);

SplitView splitView = splitManager.split("without_impression_toggle");
assertTrue(splitView.trackImpressions);
assertFalse(splitView.impressionsDisabled);
splitView = splitManager.split("impression_toggle_on");
assertTrue(splitView.trackImpressions);
assertFalse(splitView.impressionsDisabled);
splitView = splitManager.split("impression_toggle_off");
assertFalse(splitView.trackImpressions);
assertTrue(splitView.impressionsDisabled);
}
}
Loading

0 comments on commit 3948497

Please sign in to comment.