Skip to content

Commit

Permalink
Merge pull request #524 from splitio/imp_track_field_fix
Browse files Browse the repository at this point in the history
correct field trackImpressions name
  • Loading branch information
chillaq authored Dec 18, 2024
2 parents 747ca31 + 1064243 commit 17a0760
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 33 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 trackImpression;
public boolean trackImpressions;

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.trackImpression = parsedSplit.trackImpression();
splitView.trackImpressions = parsedSplit.trackImpressions();

return splitView;
}
Expand Down
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 trackImpression = null;
public Boolean trackImpressions = null;

@Override
public String toString() {
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.trackImpression());
parsedSplit.trackImpressions());
}

/*
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.trackImpression());
parsedSplit.changeNumber(), config, parsedSplit.trackImpressions());
}

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

Expand All @@ -142,7 +142,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
Labels.DEFAULT_RULE,
parsedSplit.changeNumber(),
config,
parsedSplit.trackImpression());
parsedSplit.trackImpressions());
} 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 _trackImpression;
private final boolean _trackImpressions;

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

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

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

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

public boolean trackImpression() {
return _trackImpression;
public boolean trackImpressions() {
return _trackImpressions;
}

@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 + (_trackImpression ? 1 : 0);
result = 31 * result + (_trackImpressions ? 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)
&& _trackImpression == other._trackImpression;
&& _trackImpressions == other._trackImpressions;
}

@Override
Expand All @@ -228,8 +228,8 @@ public String toString() {
bldr.append(_algo);
bldr.append(", config:");
bldr.append(_configurations);
bldr.append(", trackImpression:");
bldr.append(_trackImpression);
bldr.append(", trackImpressions:");
bldr.append(_trackImpressions);
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.trackImpression)) {
_log.debug("trackImpression field not detected for Feature flag `" + split.name + "`, setting it to `true`.");
split.trackImpression = true;
if (Objects.isNull(split.trackImpressions)) {
_log.debug("trackImpressions field not detected for Feature flag `" + split.name + "`, setting it to `true`.");
split.trackImpressions = true;
}
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.trackImpression);
split.trackImpressions);
}

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.trackImpression()
parsedSplit.trackImpressions()
);

_concurrentMap.put(splitName, updatedSplit);
Expand Down
Original file line number Diff line number Diff line change
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.trackImpression);
assertTrue(splitView.trackImpressions);
splitView = splitManager.split("impression_toggle_on");
assertTrue(splitView.trackImpression);
assertTrue(splitView.trackImpressions);
splitView = splitManager.split("impression_toggle_off");
assertFalse(splitView.trackImpression);
assertFalse(splitView.trackImpressions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public void works() {
ParsedSplit expected = ParsedSplit.createParsedSplitForTests("first.name", 123, false, Treatments.OFF, listOfMatcherAndSplits, "user", 1, 1, new HashSet<>(), true);

Assert.assertEquals(actual, expected);
assertTrue(expected.hashCode() != 0);
assertTrue(expected.equals(expected));
}

@Test
Expand Down Expand Up @@ -650,15 +652,15 @@ public void ImpressionToggleParseTest() throws IOException {
for (Split split : change.splits) {
ParsedSplit parsedSplit = parser.parse(split);
if (split.name.equals("without_impression_toggle")) {
assertTrue(parsedSplit.trackImpression());
assertTrue(parsedSplit.trackImpressions());
check1 = true;
}
if (split.name.equals("impression_toggle_on")) {
assertTrue(parsedSplit.trackImpression());
assertTrue(parsedSplit.trackImpressions());
check2 = true;
}
if (split.name.equals("impression_toggle_off")) {
assertFalse(parsedSplit.trackImpression());
assertFalse(parsedSplit.trackImpressions());
check3 = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/test/resources/splits_imp_toggle.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"label": "default rule"
}
],
"trackImpression": true
"trackImpressions": true
},
{
"trafficTypeName": "user",
Expand Down Expand Up @@ -147,7 +147,7 @@
"label": "default rule"
}
],
"trackImpression": false
"trackImpressions": false
}
],
"since": -1,
Expand Down

0 comments on commit 17a0760

Please sign in to comment.