diff --git a/README.md b/README.md index a8bb019..256d37b 100755 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ public class MyClass { private DVCCloudClient dvcCloudClient; public MyClass() { - dvcCloudClient = new DVCCloudClient("your_server_key"); + dvcCloudClient = new DVCCloudClient("YOUR_DVC_SERVER_SDK_KEY"); } } ``` @@ -62,7 +62,7 @@ public class MyClass { private DVCLocalClient dvcLocalClient; public MyClass() { - dvcLocalClient = new DVCLocalClient("your_server_key"); + dvcLocalClient = new DVCLocalClient("YOUR_DVC_SERVER_SDK_KEY"); } } ``` diff --git a/docs/DVC.md b/docs/DVC.md index 8e2c467..d1783c1 100755 --- a/docs/DVC.md +++ b/docs/DVC.md @@ -22,7 +22,7 @@ public class MyClass { private DVCClient dvcClient; public MyClass() { - dvcClient = new DVCClient("your_server_key"); + dvcClient = new DVCClient("YOUR_DVC_SERVER_SDK_KEY"); } public void allFeatures() { @@ -61,7 +61,7 @@ public class MyClass { private DVCClient dvcClient; public MyClass() { - dvcClient = new DVCClient("your_server_key"); + dvcClient = new DVCClient("YOUR_DVC_SERVER_SDK_KEY"); } public void setFlag() { @@ -109,7 +109,7 @@ public class MyClass { private DVCClient dvcClient; public MyClass() { - dvcClient = new DVCClient("your_server_key"); + dvcClient = new DVCClient("YOUR_DVC_SERVER_SDK_KEY"); } public void allVariables() { @@ -148,7 +148,7 @@ public class MyClass { private DVCClient dvcClient; public MyClass() { - dvcClient = new DVCClient("your_server_key"); + dvcClient = new DVCClient("YOUR_DVC_SERVER_SDK_KEY"); } public void addAnEvent() { diff --git a/example-cloud/README.md b/example-cloud/README.md index 43b4c31..f222f2f 100755 --- a/example-cloud/README.md +++ b/example-cloud/README.md @@ -9,4 +9,4 @@ being used Rerun the example after creating a feature and a variable and that will be shown -replace application.properties devcycle.serverKey with your server SDK key \ No newline at end of file +replace application.properties devcycle.sdkKey with your server SDK key \ No newline at end of file diff --git a/example-cloud/src/main/java/com/devcycle/example/java/sdk/app/configuration/HelloWorldConfiguration.java b/example-cloud/src/main/java/com/devcycle/example/java/sdk/app/configuration/HelloWorldConfiguration.java index 2044a27..ec0d8b2 100644 --- a/example-cloud/src/main/java/com/devcycle/example/java/sdk/app/configuration/HelloWorldConfiguration.java +++ b/example-cloud/src/main/java/com/devcycle/example/java/sdk/app/configuration/HelloWorldConfiguration.java @@ -12,10 +12,10 @@ @ConfigurationProperties(prefix = "devcycle") public class HelloWorldConfiguration { - private String serverKey; + private String sdkKey; - @Bean("devcycleServerKey") - public String getServerKey() { - return serverKey; + @Bean("devcycleSDKKey") + public String getSdkKey() { + return sdkKey; } } diff --git a/example-cloud/src/main/java/com/devcycle/example/java/sdk/app/controller/HelloWorld.java b/example-cloud/src/main/java/com/devcycle/example/java/sdk/app/controller/HelloWorld.java index b0c160d..fc93054 100644 --- a/example-cloud/src/main/java/com/devcycle/example/java/sdk/app/controller/HelloWorld.java +++ b/example-cloud/src/main/java/com/devcycle/example/java/sdk/app/controller/HelloWorld.java @@ -20,8 +20,8 @@ public class HelloWorld { private DVCCloudOptions dvcCloudOptions = DVCCloudOptions.builder().enableEdgeDB(false).build(); - public HelloWorld(@Qualifier("devcycleServerKey") String serverKey) { - dvcCloud = new DVCCloudClient(serverKey, dvcCloudOptions); + public HelloWorld(@Qualifier("devcycleSDKKey") String sdkKey) { + dvcCloud = new DVCCloudClient(sdkKey, dvcCloudOptions); } @Value("${spring.application.name}") diff --git a/example-cloud/src/main/resources/application.properties b/example-cloud/src/main/resources/application.properties index d6cf137..bffc3f2 100644 --- a/example-cloud/src/main/resources/application.properties +++ b/example-cloud/src/main/resources/application.properties @@ -6,4 +6,4 @@ spring.thymeleaf.suffix=.html spring.application.name=Default Flag spring.application.oops=Default Flag when variation could not be fetched -devcycle.serverKey=your SDK Key \ No newline at end of file +devcycle.sdkKey=your SDK Key \ No newline at end of file diff --git a/example-local/README.md b/example-local/README.md index 66bfbb1..b572276 100755 --- a/example-local/README.md +++ b/example-local/README.md @@ -9,4 +9,4 @@ being used Rerun the example after creating a feature and a variable and that will be shown -replace application.properties devcycle.serverKey with your server SDK key \ No newline at end of file +replace application.properties devcycle.sdkKey with your server SDK key \ No newline at end of file diff --git a/example-local/src/main/java/com/devcycle/example/java/sdk/app/configuration/HelloWorldConfiguration.java b/example-local/src/main/java/com/devcycle/example/java/sdk/app/configuration/HelloWorldConfiguration.java index 12f043a..7b46b16 100644 --- a/example-local/src/main/java/com/devcycle/example/java/sdk/app/configuration/HelloWorldConfiguration.java +++ b/example-local/src/main/java/com/devcycle/example/java/sdk/app/configuration/HelloWorldConfiguration.java @@ -12,10 +12,10 @@ @ConfigurationProperties(prefix = "devcycle") public class HelloWorldConfiguration { - private String serverKey; + private String sdkKey; - @Bean("devcycleServerKey") - public String getServerKey() { - return serverKey; + @Bean("devcycleSDKKey") + public String getSdkKey() { + return sdkKey; } } diff --git a/example-local/src/main/java/com/devcycle/example/java/sdk/app/controller/HelloWorld.java b/example-local/src/main/java/com/devcycle/example/java/sdk/app/controller/HelloWorld.java index c51fd29..dd0daba 100644 --- a/example-local/src/main/java/com/devcycle/example/java/sdk/app/controller/HelloWorld.java +++ b/example-local/src/main/java/com/devcycle/example/java/sdk/app/controller/HelloWorld.java @@ -24,8 +24,8 @@ public class HelloWorld { .eventFlushIntervalMS(5000) .build(); - public HelloWorld(@Qualifier("devcycleServerKey") String serverKey) { - dvcClient = new DVCLocalClient(serverKey, dvcLocalOptions); + public HelloWorld(@Qualifier("devcycleSDKKey") String sdkKey) { + dvcClient = new DVCLocalClient(sdkKey, dvcLocalOptions); } @Value("${spring.application.name}") diff --git a/example-local/src/main/resources/application.properties b/example-local/src/main/resources/application.properties index d6cf137..bffc3f2 100644 --- a/example-local/src/main/resources/application.properties +++ b/example-local/src/main/resources/application.properties @@ -6,4 +6,4 @@ spring.thymeleaf.suffix=.html spring.application.name=Default Flag spring.application.oops=Default Flag when variation could not be fetched -devcycle.serverKey=your SDK Key \ No newline at end of file +devcycle.sdkKey=your SDK Key \ No newline at end of file diff --git a/src/main/java/com/devcycle/sdk/server/cloud/api/DVCCloudClient.java b/src/main/java/com/devcycle/sdk/server/cloud/api/DVCCloudClient.java index 258352c..988224c 100755 --- a/src/main/java/com/devcycle/sdk/server/cloud/api/DVCCloudClient.java +++ b/src/main/java/com/devcycle/sdk/server/cloud/api/DVCCloudClient.java @@ -21,13 +21,13 @@ public final class DVCCloudClient { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); - public DVCCloudClient(String serverKey) { - this(serverKey, DVCCloudOptions.builder().build()); + public DVCCloudClient(String sdkKey) { + this(sdkKey, DVCCloudOptions.builder().build()); } - public DVCCloudClient(String serverKey, DVCCloudOptions options) { + public DVCCloudClient(String sdkKey, DVCCloudOptions options) { this.dvcOptions = options; - api = new DVCCloudApiClient(serverKey, options).initialize(); + api = new DVCCloudApiClient(sdkKey, options).initialize(); OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); } diff --git a/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalApiClient.java b/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalApiClient.java index 54f7ec6..cd183fa 100755 --- a/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalApiClient.java +++ b/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalApiClient.java @@ -46,7 +46,7 @@ private DVCLocalApiClient(DVCLocalOptions options) { .addConverterFactory(JacksonConverterFactory.create()); } - public DVCLocalApiClient(String serverKey, DVCLocalOptions options) { + public DVCLocalApiClient(String sdkKey, DVCLocalOptions options) { this(options); } diff --git a/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalClient.java b/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalClient.java index bb2bd4d..cacd422 100755 --- a/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalClient.java +++ b/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalClient.java @@ -17,21 +17,21 @@ public final class DVCLocalClient { private EnvironmentConfigManager configManager; - private final String serverKey; + private final String sdkKey; private EventQueueManager eventQueueManager; - public DVCLocalClient(String serverKey) { - this(serverKey, DVCLocalOptions.builder().build()); + public DVCLocalClient(String sdkKey) { + this(sdkKey, DVCLocalOptions.builder().build()); } - public DVCLocalClient(String serverKey, DVCLocalOptions dvcOptions) { + public DVCLocalClient(String sdkKey, DVCLocalOptions dvcOptions) { localBucketing.setPlatformData(PlatformData.builder().build().toString()); - configManager = new EnvironmentConfigManager(serverKey, localBucketing, dvcOptions); - this.serverKey = serverKey; + configManager = new EnvironmentConfigManager(sdkKey, localBucketing, dvcOptions); + this.sdkKey = sdkKey; try { - eventQueueManager = new EventQueueManager(serverKey, localBucketing, dvcOptions); + eventQueueManager = new EventQueueManager(sdkKey, localBucketing, dvcOptions); } catch (Exception e) { System.out.printf("Error creating event queue due to error: %s%n", e.getMessage()); } @@ -47,7 +47,7 @@ public Map allFeatures(User user) { BucketedUserConfig bucketedUserConfig = null; try { - bucketedUserConfig = localBucketing.generateBucketedConfig(serverKey, user); + bucketedUserConfig = localBucketing.generateBucketedConfig(sdkKey, user); } catch (JsonProcessingException e) { System.out.printf("Unable to parse JSON for allFeatures due to error: %s%n", e.getMessage()); return Collections.emptyMap(); @@ -87,7 +87,7 @@ public Variable variable(User user, String key, T defaultValue) { .build(); try { - BucketedUserConfig bucketedUserConfig = localBucketing.generateBucketedConfig(serverKey, user); + BucketedUserConfig bucketedUserConfig = localBucketing.generateBucketedConfig(sdkKey, user); if (bucketedUserConfig.variables.containsKey(key)) { Variable variable = bucketedUserConfig.variables.get(key); variable.setIsDefaulted(false); @@ -119,7 +119,7 @@ public Map allVariables(User user) { BucketedUserConfig bucketedUserConfig = null; try { - bucketedUserConfig = localBucketing.generateBucketedConfig(serverKey, user); + bucketedUserConfig = localBucketing.generateBucketedConfig(sdkKey, user); } catch (JsonProcessingException e) { System.out.printf("Unable to parse JSON for allVariables due to error: %s%n", e.getMessage()); return Collections.emptyMap(); diff --git a/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalEventsApiClient.java b/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalEventsApiClient.java index f1bfe79..a8d675e 100644 --- a/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalEventsApiClient.java +++ b/src/main/java/com/devcycle/sdk/server/local/api/DVCLocalEventsApiClient.java @@ -37,9 +37,9 @@ private DVCLocalEventsApiClient(DVCLocalOptions options) { .addConverterFactory(JacksonConverterFactory.create()); } - public DVCLocalEventsApiClient(String serverKey, DVCLocalOptions options) { + public DVCLocalEventsApiClient(String sdkKey, DVCLocalOptions options) { this(options); - okBuilder.addInterceptor(new AuthorizationHeaderInterceptor(serverKey)); + okBuilder.addInterceptor(new AuthorizationHeaderInterceptor(sdkKey)); } public IDVCApi initialize() { diff --git a/src/main/java/com/devcycle/sdk/server/local/managers/EnvironmentConfigManager.java b/src/main/java/com/devcycle/sdk/server/local/managers/EnvironmentConfigManager.java index f88d1ff..0aa3303 100644 --- a/src/main/java/com/devcycle/sdk/server/local/managers/EnvironmentConfigManager.java +++ b/src/main/java/com/devcycle/sdk/server/local/managers/EnvironmentConfigManager.java @@ -31,14 +31,14 @@ public final class EnvironmentConfigManager { private ProjectConfig config; private String configETag = ""; - private String serverKey; + private String sdkKey; private int pollingIntervalMS; - public EnvironmentConfigManager(String serverKey, LocalBucketing localBucketing, DVCLocalOptions options) { - this.serverKey = serverKey; + public EnvironmentConfigManager(String sdkKey, LocalBucketing localBucketing, DVCLocalOptions options) { + this.sdkKey = sdkKey; this.localBucketing = localBucketing; - configApiClient = new DVCLocalApiClient(serverKey, options).initialize(); + configApiClient = new DVCLocalApiClient(sdkKey, options).initialize(); int configPollingIntervalMS = options.getConfigPollingIntervalMS(); pollingIntervalMS = configPollingIntervalMS >= MIN_INTERVALS_MS ? configPollingIntervalMS @@ -66,7 +66,7 @@ public boolean isConfigInitialized() { } private ProjectConfig getConfig() throws DVCException, JsonProcessingException { - Call config = this.configApiClient.getConfig(this.serverKey, this.configETag); + Call config = this.configApiClient.getConfig(this.sdkKey, this.configETag); this.config = getConfigResponse(config); return this.config; @@ -91,7 +91,7 @@ private ProjectConfig getConfigResponse(Call call) throws DVCExce ProjectConfig config = response.body(); try { ObjectMapper mapper = new ObjectMapper(); - localBucketing.storeConfig(serverKey, mapper.writeValueAsString(config)); + localBucketing.storeConfig(sdkKey, mapper.writeValueAsString(config)); } catch (JsonProcessingException e) { if (this.config != null) { System.out.printf("Unable to parse config with etag: %s. Using cache, etag %s%n", currentETag, this.configETag); diff --git a/src/main/java/com/devcycle/sdk/server/local/managers/EventQueueManager.java b/src/main/java/com/devcycle/sdk/server/local/managers/EventQueueManager.java index 6eb6350..1145ac1 100644 --- a/src/main/java/com/devcycle/sdk/server/local/managers/EventQueueManager.java +++ b/src/main/java/com/devcycle/sdk/server/local/managers/EventQueueManager.java @@ -19,7 +19,7 @@ public class EventQueueManager { private LocalBucketing localBucketing; - private final String serverKey; + private final String sdkKey; private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private IDVCApi eventsApiClient; private int eventFlushIntervalMS; @@ -28,18 +28,18 @@ public class EventQueueManager { private int flushEventQueueSize; private int maxEventQueueSize; - public EventQueueManager(String serverKey, LocalBucketing localBucketing, DVCLocalOptions options) throws Exception { + public EventQueueManager(String sdkKey, LocalBucketing localBucketing, DVCLocalOptions options) throws Exception { this.localBucketing = localBucketing; - this.serverKey = serverKey; + this.sdkKey = sdkKey; eventFlushIntervalMS = options.getEventFlushIntervalMS(); flushEventQueueSize = options.getFlushEventQueueSize(); maxEventQueueSize = options.getMaxEventQueueSize(); - eventsApiClient = new DVCLocalEventsApiClient(serverKey, options).initialize(); + eventsApiClient = new DVCLocalEventsApiClient(sdkKey, options).initialize(); OBJECT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); - this.localBucketing.initEventQueue(serverKey, OBJECT_MAPPER.writeValueAsString(options)); + this.localBucketing.initEventQueue(sdkKey, OBJECT_MAPPER.writeValueAsString(options)); setupScheduler(); } @@ -64,13 +64,13 @@ public void run() { public void flushEvents() throws Exception { if (isFlushingEvents) return; - if (serverKey == null || serverKey.equals("")) { + if (sdkKey == null || sdkKey.equals("")) { throw new Exception("DevCycle is not yet initialized to publish events."); } FlushPayload[] flushPayloads = new FlushPayload[0]; try { - flushPayloads = this.localBucketing.flushEventQueue(this.serverKey); + flushPayloads = this.localBucketing.flushEventQueue(this.sdkKey); } catch (Exception e) { System.out.printf("DVC Error Flushing Events: %s%n", e.getMessage()); } @@ -82,7 +82,7 @@ public void flushEvents() throws Exception { isFlushingEvents = true; for (FlushPayload payload: flushPayloads) { eventCount += payload.eventCount; - publishEvents(this.serverKey, payload); + publishEvents(this.sdkKey, payload); } isFlushingEvents = false; System.out.printf("DVC Flush %d AS Events, for %d Users%n", eventCount, flushPayloads.length); @@ -97,7 +97,7 @@ public void queueEvent(User user, Event event) throws Exception { return; } - this.localBucketing.queueEvent(this.serverKey, OBJECT_MAPPER.writeValueAsString(user), OBJECT_MAPPER.writeValueAsString(event)); + this.localBucketing.queueEvent(this.sdkKey, OBJECT_MAPPER.writeValueAsString(user), OBJECT_MAPPER.writeValueAsString(event)); } /** @@ -111,13 +111,13 @@ public void queueAggregateEvent(Event event, BucketedUserConfig bucketedConfig) } if (bucketedConfig != null) { - this.localBucketing.queueAggregateEvent(this.serverKey, OBJECT_MAPPER.writeValueAsString(event), OBJECT_MAPPER.writeValueAsString(bucketedConfig.variableVariationMap)); + this.localBucketing.queueAggregateEvent(this.sdkKey, OBJECT_MAPPER.writeValueAsString(event), OBJECT_MAPPER.writeValueAsString(bucketedConfig.variableVariationMap)); } else { - this.localBucketing.queueAggregateEvent(this.serverKey, OBJECT_MAPPER.writeValueAsString(event), "{}"); + this.localBucketing.queueAggregateEvent(this.sdkKey, OBJECT_MAPPER.writeValueAsString(event), "{}"); } } - private void publishEvents(String serverKey, FlushPayload flushPayload) throws InterruptedException { + private void publishEvents(String sdkKey, FlushPayload flushPayload) throws InterruptedException { Thread publishEventsThread = new Thread(new Runnable() { @Override public void run() { @@ -125,10 +125,10 @@ public void run() { int responseCode = getResponse(response); if (responseCode == 201) { - localBucketing.onPayloadSuccess(serverKey, flushPayload.payloadId); + localBucketing.onPayloadSuccess(sdkKey, flushPayload.payloadId); } else { System.out.printf("DVC Error Publishing Events: %d%n", responseCode); - localBucketing.onPayloadFailure(serverKey, flushPayload.payloadId, responseCode >= 500); + localBucketing.onPayloadFailure(sdkKey, flushPayload.payloadId, responseCode >= 500); } } }); @@ -158,7 +158,7 @@ private int getResponse(Call call) { * Flushes events if event queue size is equal or greater to flushEventQueueSize */ private boolean checkEventQueueSize() throws Exception { - int queueSize = localBucketing.getEventQueueSize(serverKey); + int queueSize = localBucketing.getEventQueueSize(sdkKey); if (queueSize >= flushEventQueueSize) { if (!isFlushingEvents) {