Java library for Confidence.
<dependency>
<groupId>com.spotify.confidence</groupId>
<artifactId>sdk-java</artifactId>
<version>0.0.14-SNAPSHOT</version>
</dependency>
We deploy snapshots from the main
branch to Sonatype OSSRH.
To use a snapshot, add the following repository to your pom.xml
:
<distributionManagement>
<snapshotRepository>
<id>oss.snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
The SDK is instantiated using a client secret that is configured in the Confidence UI or via the management console.
Flag values are evaluated remotely and returned to the application:
final Confidence confidence = Confidence.builder("<CLIENT_TOKEN>").build();
confidence.setContext(Map.of("country", ConfidenceValue.of("SE")));
final String propertyValue =
confidence
.withContext(
Map.of(
"user_id", ConfidenceValue.of("<some-user-id>"),
"country", ConfidenceValue.of("SE")))
.getValue("flag-name.property-name", "defaultValue");
Events are emitted to the Confidence backend:
confidence.track("my-event", ConfidenceValue.of(Map.of("field", ConfidenceValue.of("data"))));
The library includes a Provider
for
the OpenFeature Java SDK, that can be
used to resolve feature flag values from the Confidence platform.
To learn more about the basic concepts (flags, targeting key, evaluation contexts), the OpenFeature reference documentation can be useful.