Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

[EN-17473] Propagate the variation name to the AssignmentLogData #4

Merged
merged 3 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.glossgenius</groupId>
<artifactId>eppo-java-server-sdk</artifactId>
<version>2.1.0-0.1.1</version>
<version>2.1.0-0.2.0</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Eppo Server-Side SDK for Java</description>
Expand Down
26 changes: 23 additions & 3 deletions src/main/java/com/eppo/sdk/EppoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.Timer;

import static com.eppo.sdk.dto.AssignmentLogData.OVERRIDE_ALLOCATION_KEY;
import static com.eppo.sdk.dto.AssignmentLogData.OVERRIDE_ASSIGNMENT_NAME;

@Slf4j
public class EppoClient {
Expand Down Expand Up @@ -78,7 +79,14 @@ public Optional<AssignmentLogData> getAssignmentWithDetails(
// Check if subject has override variations
EppoValue subjectVariationOverride = this.getSubjectVariationOverride(subjectKey, configuration);
if (!subjectVariationOverride.isNull()) {
AssignmentLogData data = getAssignmentLogData(subjectKey, flagKey, subjectAttributes, OVERRIDE_ALLOCATION_KEY, subjectVariationOverride);
AssignmentLogData data = getAssignmentLogData(
subjectKey,
flagKey,
subjectAttributes,
OVERRIDE_ALLOCATION_KEY,
OVERRIDE_ASSIGNMENT_NAME,
subjectVariationOverride
);
return Optional.of(data);
}

Expand Down Expand Up @@ -107,7 +115,16 @@ public Optional<AssignmentLogData> getAssignmentWithDetails(
// Get assigned variation
Variation assignedVariation = this.getAssignedVariation(subjectKey, flagKey, configuration.getSubjectShards(),
allocation.getVariations());
return Optional.of(getAssignmentLogData(subjectKey, flagKey, subjectAttributes, allocationKey, assignedVariation.getTypedValue()));
return Optional.of(
getAssignmentLogData(
subjectKey,
flagKey,
subjectAttributes,
allocationKey,
assignedVariation.getName(),
assignedVariation.getTypedValue()
)
);
}

/**
Expand Down Expand Up @@ -146,12 +163,15 @@ private AssignmentLogData getAssignmentLogData(
String flagKey,
SubjectAttributes subjectAttributes,
String allocationKey,
EppoValue assignmentValue) {
String assignmentName,
EppoValue assignmentValue
) {
String experimentKey = ExperimentHelper.generateKey(flagKey, allocationKey);
return new AssignmentLogData(
experimentKey,
flagKey,
allocationKey,
assignmentName,
assignmentValue,
subjectKey,
subjectAttributes);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/eppo/sdk/dto/AssignmentLogData.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
public class AssignmentLogData {
public static final String OVERRIDE_ALLOCATION_KEY = "override";

public static final String OVERRIDE_ASSIGNMENT_NAME = "override_assignment";

public String experiment;
public String featureFlag;
public String allocation;
public String variation;
public String variationName;
public EppoValue variationValue;
public Date timestamp;
public String subject;
Expand All @@ -21,13 +24,15 @@ public AssignmentLogData(
String experiment,
String featureFlag,
String allocation,
String variationName,
EppoValue variationValue,
String subject,
SubjectAttributes subjectAttributes
) {
this.experiment = experiment;
this.featureFlag = featureFlag;
this.allocation = allocation;
this.variationName = variationName;
this.variationValue = variationValue;
this.variation = variationValue.stringValue();
this.timestamp = new Date();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/eppo/sdk/dto/Variation.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
@Data
public class Variation {
private String name;
private EppoValue typedValue;
private ShardRange shardRange;
}
Loading