-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented support for tracking
Signed-off-by: Bernd Warmuth <bernd.warmuth@dynatrace.com>
- Loading branch information
Bernd Warmuth
committed
Nov 25, 2024
1 parent
234062c
commit 7831008
Showing
9 changed files
with
366 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/dev/openfeature/sdk/MutableTrackingEventDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package dev.openfeature.sdk; | ||
|
||
import dev.openfeature.sdk.internal.ExcludeFromGeneratedCoverageReport; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import lombok.experimental.Delegate; | ||
|
||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* MutableTrackingEventDetails represents data pertinent to a particular tracking event. | ||
*/ | ||
@EqualsAndHashCode | ||
@ToString | ||
public class MutableTrackingEventDetails implements TrackingEventDetails { | ||
|
||
|
||
@Getter | ||
private final float target; | ||
@Delegate(excludes = MutableTrackingEventDetails.DelegateExclusions.class) | ||
private final MutableStructure structure; | ||
|
||
public MutableTrackingEventDetails() { | ||
this.target = 0f; | ||
this.structure = new MutableStructure(); | ||
} | ||
|
||
public MutableTrackingEventDetails(final float target) { | ||
this.target = target; | ||
this.structure = new MutableStructure(); | ||
} | ||
|
||
|
||
@SuppressWarnings("all") | ||
private static class DelegateExclusions { | ||
@ExcludeFromGeneratedCoverageReport | ||
public <T extends Structure> Map<String, Value> merge(Function<Map<String, Value>, Structure> newStructure, | ||
Map<String, Value> base, | ||
Map<String, Value> overriding) { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package dev.openfeature.sdk; | ||
|
||
/** | ||
* Interface for Tracking events. | ||
*/ | ||
public interface Tracking { | ||
/** | ||
* Performs tracking of a particular action or application state. | ||
* | ||
* @param trackingEventName Event name to track | ||
*/ | ||
void track(String trackingEventName); | ||
|
||
/** | ||
* Performs tracking of a particular action or application state. | ||
* | ||
* @param trackingEventName Event name to track | ||
* @param context Evaluation context used in flag evaluation | ||
*/ | ||
void track(String trackingEventName, EvaluationContext context); | ||
|
||
/** | ||
* Performs tracking of a particular action or application state. | ||
* | ||
* @param trackingEventName Event name to track | ||
* @param details Data pertinent to a particular tracking event | ||
*/ | ||
void track(String trackingEventName, TrackingEventDetails details); | ||
|
||
/** | ||
* Performs tracking of a particular action or application state. | ||
* | ||
* @param trackingEventName Event name to track | ||
* @param context Evaluation context used in flag evaluation | ||
* @param details Data pertinent to a particular tracking event | ||
*/ | ||
void track(String trackingEventName, EvaluationContext context, TrackingEventDetails details); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package dev.openfeature.sdk; | ||
|
||
/** | ||
* Data pertinent to a particular tracking event. | ||
*/ | ||
public interface TrackingEventDetails extends Structure { | ||
} |
Oops, something went wrong.