From 7f8c9add5903565a8e290584ce32331a8b7a5d7e Mon Sep 17 00:00:00 2001 From: Fabrizio Demaria Date: Thu, 23 May 2024 14:29:42 +0200 Subject: [PATCH 1/6] refactor: Rename repo and pointers to sdk-java --- .github/CONTRIBUTING.md | 2 +- .gitignore | 1 + README.md | 65 ++++++++++++++++---------------------- catalog-info.yaml | 2 +- pom.xml | 18 +++++------ release-please-config.json | 2 +- 6 files changed, 40 insertions(+), 50 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index ed140c0f..08d28595 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -37,4 +37,4 @@ Github Actions are set up that are able to: In order to promote an uploaded version from **Staging** to **Release** (hence making it openly available on [Maven Central Search](https://central.sonatype.com/)) a user with the right credentials must login into the the [Sonatype UI](https://oss.sonatype.org/#welcome) and perform the release process manually. #### After realeasing -After a release PR is merged, the main branch will stay at the release version (non-snapshot) until updated. Release please will create a PR ([example](https://github.com/spotify/confidence-openfeature-provider-java/pull/55)) that does this "snapshot bump". The recommendation is to merge that PR directly when possible. +After a release PR is merged, the main branch will stay at the release version (non-snapshot) until updated. Release please will create a PR ([example](https://github.com/spotify/sdk-java/pull/55)) that does this "snapshot bump". The recommendation is to merge that PR directly when possible. diff --git a/.gitignore b/.gitignore index 3da0c7e1..2b610012 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ !.git* /target/ *.iml +**dependency-reduced-pom.xml \ No newline at end of file diff --git a/README.md b/README.md index b232a9e4..29cdf074 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,6 @@ -# Confidence OpenFeature Java Provider +# Java Confidence SDK -Java library for the [Confidence](https://confidence.spotify.com/) feature flag provider. - -The library includes a `Provider` for -the [OpenFeature Java SDK](https://openfeature.dev/docs/tutorials/getting-started/java), 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](https://openfeature.dev/docs/reference/intro) can be -useful. +Java library for [Confidence](https://confidence.spotify.com/). ## Install @@ -18,14 +10,14 @@ useful. ```xml com.spotify.confidence - openfeature-provider + sdk-java 0.0.12-SNAPSHOT ``` #### Depending on a development snapshot -We deploy snapshots from the `main` branch to [Sonatype OSSRH](https://oss.sonatype.org/content/repositories/snapshots/com/spotify/confidence/openfeature-provider/). +We deploy snapshots from the `main` branch to [Sonatype OSSRH](https://oss.sonatype.org/content/repositories/snapshots/com/spotify/confidence/sdk-java/). To use a snapshot, add the following repository to your `pom.xml`: ```xml @@ -38,34 +30,31 @@ To use a snapshot, add the following repository to your `pom.xml`: ## Usage -The provider is instantiated using a client token that is configured in the Confidence UI or via the -management API. After that all interaction with the feature flags happens using the OpenFeature client APIs. +The SDK is instantiated using a client token that is configured in the Confidence UI or via the +management. +### Resolving flags +Flag values are evaluated remotely and returned to the application: ```java -package com.spotify.confidence.openfeature; - -import com.spotify.confidence.ConfidenceFeatureProvider; -import dev.openfeature.sdk.Client; -import dev.openfeature.sdk.MutableContext; -import dev.openfeature.sdk.OpenFeatureAPI; -import dev.openfeature.sdk.Value; -import java.util.Map; - -public final class ResolveFlags { +final Confidence confidence = Confidence.builder("").build(); +confidence.setContext(Map.of("country", ConfidenceValue.of("SE"))); +final String propertyValue = confidence.getValue( + "flag-name.property-name", + "defaultValue" +); +``` - public static final String CLIENT_TOKEN = "<>"; +### Tracking events +Events are emitted to the Confidence backend: +```java +confidence.track("my-event", ConfidenceValue.of(Map.of("field", ConfidenceValue.of("data")))); +``` - public static void main(String[] args) { - final OpenFeatureAPI api = OpenFeatureAPI.getInstance(); - api.setProvider(new ConfidenceFeatureProvider(CLIENT_TOKEN)); - final Client client = api.getClient(); +## OpenFeature +The library includes a `Provider` for +the [OpenFeature Java SDK](https://openfeature.dev/docs/tutorials/getting-started/java), that can be +used to resolve feature flag values from the Confidence platform. - final String targetingKey = "userId"; - final Map context = Map.of("country", new Value("SE")); - final MutableContext ctx = new MutableContext(targetingKey, context); - final String propertyValue = client.getStringValue("flagName.propertyName", "defaultValue", - ctx); - System.out.println(propertyValue); - } -} -``` +To learn more about the basic concepts (flags, targeting key, evaluation contexts), +the [OpenFeature reference documentation](https://openfeature.dev/docs/reference/intro) can be +useful. \ No newline at end of file diff --git a/catalog-info.yaml b/catalog-info.yaml index 1ac371cd..5dfd1fe7 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -1,7 +1,7 @@ apiVersion: backstage.io/v1alpha1 kind: Component metadata: - name: confidence-openfeature-provider-java + name: sdk-java spec: type: library owner: hawkeye \ No newline at end of file diff --git a/pom.xml b/pom.xml index 676091bd..58003836 100644 --- a/pom.xml +++ b/pom.xml @@ -14,11 +14,11 @@ com.spotify.confidence - openfeature-provider + sdk-java 0.0.12-SNAPSHOT - https://github.com/spotify/confidence-openfeature-provider-java - Confidence OpenFeature provider for Java + https://github.com/spotify/sdk-java + Confidence SDK for Java @@ -35,7 +35,7 @@ UTF-8 - Confidence OpenFeature Provider + Confidence SDK com.spotify https://github.com/spotify @@ -43,24 +43,24 @@ GitHub - https://github.com/spotify/confidence-openfeature-provider-java/issues + https://github.com/spotify/sdk-java/issues Apache License 2.0 - https://github.com/spotify/confidence-openfeature-provider-java/blob/main/LICENSE + https://github.com/spotify/sdk-java/blob/main/LICENSE repo - https://github.com/spotify/confidence-openfeature-provider-java + https://github.com/spotify/sdk-java - scm:git:git@github.com:spotify/confidence-openfeature-provider-java.git + scm:git:git@github.com:spotify/sdk-java.git - scm:git:git@github.com:spotify/confidence-openfeature-provider-java.git + scm:git:git@github.com:spotify/sdk-java.git diff --git a/release-please-config.json b/release-please-config.json index 7fb96d50..a7f82ebf 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -2,7 +2,7 @@ "bootstrap-sha": "188faf7e47b03bde3bf02c3521771301c77580d6", "packages": { ".": { - "package-name": "com.spotify.confidence.openfeature-provider", + "package-name": "com.spotify.confidence.java-sdk", "release-type": "maven", "monorepo-tags": false, "include-component-in-tag": false, From 406797dbfbdc9baa3b66def4c6f4641f541b8f74 Mon Sep 17 00:00:00 2001 From: Fabrizio Demaria Date: Thu, 23 May 2024 15:01:08 +0200 Subject: [PATCH 2/6] fix: repo URL --- .github/CONTRIBUTING.md | 2 +- pom.xml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 08d28595..c7101898 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -37,4 +37,4 @@ Github Actions are set up that are able to: In order to promote an uploaded version from **Staging** to **Release** (hence making it openly available on [Maven Central Search](https://central.sonatype.com/)) a user with the right credentials must login into the the [Sonatype UI](https://oss.sonatype.org/#welcome) and perform the release process manually. #### After realeasing -After a release PR is merged, the main branch will stay at the release version (non-snapshot) until updated. Release please will create a PR ([example](https://github.com/spotify/sdk-java/pull/55)) that does this "snapshot bump". The recommendation is to merge that PR directly when possible. +After a release PR is merged, the main branch will stay at the release version (non-snapshot) until updated. Release please will create a PR ([example](https://github.com/spotify/confidence-sdk-java/pull/55)) that does this "snapshot bump". The recommendation is to merge that PR directly when possible. diff --git a/pom.xml b/pom.xml index 58003836..dcee5aba 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ sdk-java 0.0.12-SNAPSHOT - https://github.com/spotify/sdk-java + https://github.com/spotify/confidence-sdk-java Confidence SDK for Java @@ -43,19 +43,19 @@ GitHub - https://github.com/spotify/sdk-java/issues + https://github.com/spotify/confidence-sdk-java/issues Apache License 2.0 - https://github.com/spotify/sdk-java/blob/main/LICENSE + https://github.com/spotify/confidence-sdk-java/blob/main/LICENSE repo - https://github.com/spotify/sdk-java + https://github.com/spotify/confidence-sdk-java scm:git:git@github.com:spotify/sdk-java.git From 3ac962ca5893353f50999ec33f8a01b985c59abb Mon Sep 17 00:00:00 2001 From: Fabrizio Demaria Date: Thu, 23 May 2024 15:04:00 +0200 Subject: [PATCH 3/6] fix: Better snippet in README --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 29cdf074..647f9195 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,13 @@ Flag values are evaluated remotely and returned to the application: ```java final Confidence confidence = Confidence.builder("").build(); confidence.setContext(Map.of("country", ConfidenceValue.of("SE"))); -final String propertyValue = confidence.getValue( - "flag-name.property-name", - "defaultValue" -); +final String propertyValue = + confidence + .withContext( + Map.of( + "user_id", ConfidenceValue.of(""), + "country", ConfidenceValue.of("SE"))) + .getValue("flag-name.property-name", "defaultValue"); ``` ### Tracking events From c95e98f9c57458057deb0f9437942a9d89ce0052 Mon Sep 17 00:00:00 2001 From: Fabrizio Demaria Date: Thu, 23 May 2024 15:05:23 +0200 Subject: [PATCH 4/6] fix: README errors --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 647f9195..f7cb9a39 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ To use a snapshot, add the following repository to your `pom.xml`: ## Usage -The SDK is instantiated using a client token that is configured in the Confidence UI or via the -management. +The SDK is instantiated using a client secret that is configured in the Confidence UI or via the +management console. ### Resolving flags Flag values are evaluated remotely and returned to the application: From b99303412098c7323cc12312f90e5e8fffa1b271 Mon Sep 17 00:00:00 2001 From: Fabrizio Demaria Date: Thu, 23 May 2024 15:13:45 +0200 Subject: [PATCH 5/6] Update pom.xml Co-authored-by: Nicklas Lundin --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dcee5aba..51a6428f 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ https://github.com/spotify/confidence-sdk-java - scm:git:git@github.com:spotify/sdk-java.git + scm:git:git@github.com:spotify/confidence-sdk-java.git scm:git:git@github.com:spotify/sdk-java.git From 97f8ce91323f1da44cecf94dfd40e1df488cc23d Mon Sep 17 00:00:00 2001 From: Fabrizio Demaria Date: Thu, 23 May 2024 15:13:49 +0200 Subject: [PATCH 6/6] Update pom.xml Co-authored-by: Nicklas Lundin --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 51a6428f..2745ef3d 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ scm:git:git@github.com:spotify/confidence-sdk-java.git - scm:git:git@github.com:spotify/sdk-java.git + scm:git:git@github.com:spotify/confidence-sdk-java.git