From 87cc5004b8dc6b8e0ec2ae5e8313fa2c5a24ccc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Thea?= Date: Tue, 16 May 2023 13:35:52 -0300 Subject: [PATCH] Release 3.2.1 (#498) --- .github/workflows/test.yml | 15 ++++- CHANGES.txt | 32 +++++----- README.md | 24 ++++--- build.gradle | 17 +++-- gradle.properties | 3 +- gradle/wrapper/gradle-wrapper.properties | 2 +- project/build.gradle | 4 +- .../gradle/wrapper/gradle-wrapper.properties | 4 +- src/androidTest/AndroidManifest.xml | 4 +- .../java/fake/SplitClientStub.java | 12 ++-- src/main/AndroidManifest.xml | 3 +- .../AlwaysReturnControlSplitClient.java | 22 +++---- .../io/split/android/client/SplitClient.java | 62 +++++++++---------- .../android/client/SplitClientConfig.java | 16 ++--- .../split/android/client/SplitClientImpl.java | 24 +++---- .../android/client/SplitFactoryBuilder.java | 24 +++---- .../android/client/SplitFactoryImpl.java | 2 +- .../io/split/android/client/SplitManager.java | 9 +-- .../android/client/SplitManagerImpl.java | 12 ++-- .../split/android/client/api/SplitView.java | 4 +- .../localhost/LocalhostSplitClient.java | 28 ++++----- .../client/localhost/LocalhostSplitFile.java | 56 ----------------- .../localhost/LocalhostYamlFileParser.java | 6 +- .../sseclient/PushNotificationManager.java | 2 +- .../sseclient/sseclient/SseAuthenticator.java | 4 +- .../client/validators/ApiKeyValidator.java | 8 +-- .../validators/ApiKeyValidatorImpl.java | 10 +-- .../client/validators/EventValidatorImpl.java | 4 +- .../client/validators/SplitValidatorImpl.java | 10 +-- .../engine/experiments/SplitParser.java | 4 +- .../validators/ApiKeyValidatorTest.java | 6 +- .../client/validators/EventValidatorTest.java | 4 +- .../client/validators/SplitValidatorTest.java | 15 ++--- 33 files changed, 209 insertions(+), 243 deletions(-) delete mode 100644 src/main/java/io/split/android/client/localhost/LocalhostSplitFile.java diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 95d82b9c9..55be8f6b7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,18 @@ jobs: name: Build App runs-on: ubuntu-latest steps: - - name: Checkout code + - name: checkout uses: actions/checkout@v3 + + - name: Gradle cache + uses: gradle/gradle-build-action@v2.4.2 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 11 + cache: 'gradle' + - name: Test with Gradle - run: cd project; ./gradlew test \ No newline at end of file + run: ./gradlew test diff --git a/CHANGES.txt b/CHANGES.txt index daf1e531a..01daad850 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +3.2.1 (May 15, 2023) +- Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. +The core change is the term split for feature flag on things like logs and Javadoc comments. + 3.2.0 (Apr 25, 2023) - Added the ability to encrypt the local cache of rollout plans via encryptionEnabled config. @@ -39,7 +43,7 @@ 2.13.0 (Oct 4, 2022) - Added a new impressions mode for the SDK called NONE, to be used in factory when there is no desire to capture impressions on an SDK factory to feed Split's analytics engine. Running NONE mode, the SDK will only capture unique keys evaluated for a particular feature flag instead of full blown impressions. - Fixed issue when scheduling new tasks. -- Fixed issue in splits background synchronization when using splits filter. +- Fixed issue in feature flag background synchronization when using feature flag filter. 2.12.2 (Sep 15, 2022) - Fixed issue in telemetry for latencies. @@ -56,12 +60,12 @@ - Added a new config option to control the tasks that listen or poll for updates on feature flags and segments, via the new config syncEnabled . Running online Split will always pull the most recent updates upon initialization, this only affects updates fetching on a running instance. Useful when a consistent session experience is a must or to save resources when updates are not being used. 2.10.3 (Jun 10, 2022) -- Fixed issue that prevented split list from being updated after modifying sync config. +- Fixed issue that prevented feature flag list from being updated after modifying sync config. 2.10.2 (May 9, 2022) - Added support for resumed streaming event. - SplitClient instances are tracked by key. -- Improved logging and error handling when encountering incorrect format in splits file for localhost mode. +- Improved logging and error handling when encountering incorrect format in feature flags file for localhost mode. 2.10.1 (Apr 25, 2022) - Updated the synchronization flow to be more reliable in the event of an edge case generating delay in cache purge propagation, keeping the SDK cache properly synced. @@ -71,7 +75,7 @@ - Added support for multiple clients: Factories can now create multiple clients with different keys while reusing the common tasks, data and behavior. Read more in our Android SDK docs. 2.9.1 (Feb 24, 2022) -- Updated splits initialization workflow to reduce latencies. +- Updated feature flag initialization workflow to reduce latencies. - Removed sizeInBytes property in Events. 2.9.0 (Jan 24, 2022) @@ -84,7 +88,7 @@ 2.8.0: (Nov 19, 2021) - Added Attribute binding feature to allow to optionally keep user attributes loaded within the SDK, along with the user ID, for easier usage when requesting flag. -- Updated localhost mode by converting yaml and properties config to split rollout rules. +- Updated localhost mode by converting yaml and properties config to feature flag rollout rules. 2.7.4: (Oct 28, 2021) - Added support for a user key containing a slash character. @@ -107,7 +111,7 @@ - Added telemetry headers to SSE connection 2.7.0: (Abr 21, 2021) -- Added SDK Update event to notify when Splits or My Segments have changed +- Added SDK Update event to notify when feature flags or segments have changed 2.6.10: (Mar 26, 2021) - Fixed issue when using two factories with api keys from different environments @@ -126,7 +130,7 @@ - Fixed backoff algorithm issue 2.6.6: (Ago 03, 2020) -- Added `syncConfig.addFilter()` method to SDK configuration to pass a list of filters for the splits that will be downloaded. Read more in our docs. +- Added `syncConfig.addFilter()` method to SDK configuration to pass a list of filters for the feature flags that will be downloaded. Read more in our docs. 2.6.5: (Jul 23, 2020) - Improved logic to refresh streaming token @@ -147,13 +151,13 @@ - Fixed Interruption handling on workers 2.6.1: (Jun 2, 2020) -- Added expiration policy to split cache +- Added expiration policy to feature flag cache - Replaced HttpUrlConnection by OkHttp - Fixed some issues on streaming while host app in background - Fixed issue when retrying sending impressions and events 2.6.0: (Apr 30, 2020) -- Added support for the new Split streaming architecture. When enabled, the SDK will not poll for updates but instead receive notifications every time there's a change in your environments, allowing to process those much quicker. If disabled (default) or in the event of an issue, the SDK will fallback to the known polling mechanism to provide a seamless experience. +- Added support for the new streaming architecture. When enabled, the SDK will not poll for updates but instead receive notifications every time there's a change in your environments, allowing to process those much quicker. If disabled (default) or in the event of an issue, the SDK will fallback to the known polling mechanism to provide a seamless experience. 2.5.0: (Mar 13, 2020) - Replaced disk files by Room to handle cache data @@ -191,7 +195,7 @@ - Added integration tests 2.3.1: (Jun 14, 2019) - - Bugfixing - concurrence issue when writing split to disk + - Bugfixing - concurrence issue when writing feature flag to disk - Added missing UTF-8 support to some json parsing 2.3.0: (May 24, 2019) @@ -210,17 +214,17 @@ - Added several validations for passed parameters 1.2.3: (Jan 21, 2019) - - Storing splits, segments, impressions and tracks on disk only when app goes to background or close + - Storing feature flags, segments, impressions and tracks on disk only when app goes to background or close - Bugfixing - issue when traffic allocation equals to zero 1.2.2: (Oct 1, 2018) - - Fixed issue fetching split changes + - Fixed issue fetching feature flag changes 1.2.1: (Sep 27, 2018) - Added proguard rules file 1.2.0: (Sep 24, 2018) - - Added split manager feature + - Added Split Manager feature 1.1.0: (Aug 28, 2018) - Added get treatments feature @@ -235,7 +239,7 @@ - Added .Track feature 0.9.4: (May 24, 2018) - - Bugfixing - event SDK_READY not reachable when segments were not linked to a split definition + - Bugfixing - event SDK_READY not reachable when segments were not linked to a feature flag definition 0.9.3: (Apr 16, 2018) - Added Events listener. Available events: SDK_READY, SDK_READY_TIMEOUT diff --git a/README.md b/README.md index 4cd4aa760..2668b9f71 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Build Status](https://github.com/splitio/android-client/actions/workflows/sonar.yml/badge.svg?branch=master) ## Overview -This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via a Split feature flag to manage your complete customer experience. +This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via feature flags to manage your complete customer experience. [![Twitter Follow](https://img.shields.io/twitter/follow/splitsoftware.svg?style=social&label=Follow&maxAge=1529000)](https://twitter.com/intent/follow?screen_name=splitsoftware) @@ -12,7 +12,7 @@ This SDK is compatible with Android SDK versions 15 and later (4.0.3 Ice Cream S ## Getting started Below is a simple example that describes the instantiation and most basic usage of our SDK: ``` -String apikey = "API_KEY"; +String sdkKey = "YOUR_SDK_KEY"; SplitClientConfig config = SplitClientConfig.builder() .build(); // User Key @@ -22,7 +22,7 @@ Key key = new Key(matchingKey); SplitClient splitClient = null; try { // Create a Split factory - SplitFactory splitFactory = SplitFactoryBuilder.build(apikey, key, config, getApplicationContext()); + SplitFactory splitFactory = SplitFactoryBuilder.build(sdkKey, key, config, getApplicationContext()); // Get Split Client instance splitClient = splitFactory.client(); } catch (Exception e) { @@ -34,7 +34,7 @@ splitClient.on(SplitEvent.SDK_READY, new SplitEventTask(){ public void onPostExecution(SplitClient client) { Log.i("TAG", "Do some NO UI work"); - String treatment = client.getTreatment("SPLIT_NAME"); + String treatment = client.getTreatment("FEATURE_FLAG_NAME"); if (treatment.equals("on")) { Log.i("TAG", "I'm ON "); @@ -72,16 +72,22 @@ To learn more about Split, contact hello@split.io, or get started with feature f Split has built and maintains SDKs for: +* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK) +* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK) +* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK) +* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK) * Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK) * Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK) +* Javascript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK) * Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK) -* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK) -* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK) * PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK) * Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK) -* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK) -* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK) -* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK) +* React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK) +* React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK) +* Redux [Github](https://github.com/splitio/redux-client) [Docs](https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK) +* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK) +* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities) +* Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin) For a comprehensive list of open source projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20). diff --git a/build.gradle b/build.gradle index 36c9aadd0..a08d959c6 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.0.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31" + classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21' } } @@ -16,7 +16,7 @@ apply plugin: 'signing' apply plugin: 'kotlin-android' ext { - splitVersion = '3.2.0' + splitVersion = '3.2.1' } android { @@ -33,8 +33,6 @@ android { minSdkVersion 15 targetSdkVersion 30 - versionCode 0 - versionName splitVersion multiDexEnabled true consumerProguardFiles 'split-proguard-rules.pro' @@ -57,10 +55,6 @@ android { javadocDeps } - lintOptions { - disable 'InvalidPackage' - abortOnError false - } testOptions { unitTests.returnDefaultValues = true @@ -85,6 +79,11 @@ android { buildConfigField("String", "SPLIT_VERSION_NAME", "\"${splitVersion}\"") } } + namespace 'io.split.android.android_client' + lint { + abortOnError false + disable 'InvalidPackage' + } } repositories { diff --git a/gradle.properties b/gradle.properties index ab539f4c7..7de624fb0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ ossrhUsername= ossrhPassword= -android.useAndroidX = true \ No newline at end of file +android.enableJetifier=true +android.useAndroidX=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9eb64e0e8..52f11743c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip diff --git a/project/build.gradle b/project/build.gradle index 158895771..fd3ad14bc 100644 --- a/project/build.gradle +++ b/project/build.gradle @@ -6,7 +6,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.0.2' + classpath 'com.android.tools.build:gradle:7.4.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -32,4 +32,4 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir -} \ No newline at end of file +} diff --git a/project/gradle/wrapper/gradle-wrapper.properties b/project/gradle/wrapper/gradle-wrapper.properties index 9eb64e0e8..69ecd4abb 100644 --- a/project/gradle/wrapper/gradle-wrapper.properties +++ b/project/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Jun 27 18:55:55 ART 2019 +#Sat Apr 22 10:53:48 ART 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip diff --git a/src/androidTest/AndroidManifest.xml b/src/androidTest/AndroidManifest.xml index a5d0587cf..f12791046 100644 --- a/src/androidTest/AndroidManifest.xml +++ b/src/androidTest/AndroidManifest.xml @@ -1,6 +1,4 @@ - + diff --git a/src/androidTest/java/fake/SplitClientStub.java b/src/androidTest/java/fake/SplitClientStub.java index 765bee4c9..b20df3182 100644 --- a/src/androidTest/java/fake/SplitClientStub.java +++ b/src/androidTest/java/fake/SplitClientStub.java @@ -14,27 +14,27 @@ public class SplitClientStub implements SplitClient { @Override - public String getTreatment(String split) { - return getTreatment(split); + public String getTreatment(String featureFlagName) { + return getTreatment(featureFlagName); } @Override - public String getTreatment(String split, Map attributes) { + public String getTreatment(String featureFlagName, Map attributes) { return "control"; } @Override - public SplitResult getTreatmentWithConfig(String split, Map attributes) { + public SplitResult getTreatmentWithConfig(String featureFlagName, Map attributes) { return null; } @Override - public Map getTreatments(List splits, Map attributes) { + public Map getTreatments(List featureFlagNames, Map attributes) { return null; } @Override - public Map getTreatmentsWithConfig(List splits, Map attributes) { + public Map getTreatmentsWithConfig(List featureFlagNames, Map attributes) { return null; } diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index ee47799c1..6b2f52238 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -1,4 +1,3 @@ + xmlns:tools="http://schemas.android.com/tools"> diff --git a/src/main/java/io/split/android/client/AlwaysReturnControlSplitClient.java b/src/main/java/io/split/android/client/AlwaysReturnControlSplitClient.java index af2a2a601..70b6356f2 100644 --- a/src/main/java/io/split/android/client/AlwaysReturnControlSplitClient.java +++ b/src/main/java/io/split/android/client/AlwaysReturnControlSplitClient.java @@ -18,43 +18,43 @@ public class AlwaysReturnControlSplitClient implements io.split.android.client.SplitClient { @Override - public String getTreatment(String split) { + public String getTreatment(String featureFlagName) { return Treatments.CONTROL; } @Override - public Map getTreatments(List splits, Map attributes) { + public Map getTreatments(List featureFlagNames, Map attributes) { Map results = new HashMap<>(); - if(splits == null) { + if(featureFlagNames == null) { return results; } - for(String split : splits) { - results.put(split, Treatments.CONTROL); + for(String featureFlagName : featureFlagNames) { + results.put(featureFlagName, Treatments.CONTROL); } return results; } @Override - public Map getTreatmentsWithConfig(List splits, Map attributes) { + public Map getTreatmentsWithConfig(List featureFlagNames, Map attributes) { Map results = new HashMap<>(); - if(splits == null) { + if(featureFlagNames == null) { return results; } - for(String split : splits) { - results.put(split, new SplitResult(Treatments.CONTROL)); + for(String featureFlagName : featureFlagNames) { + results.put(featureFlagName, new SplitResult(Treatments.CONTROL)); } return results; } @Override - public String getTreatment(String split, Map attributes) { + public String getTreatment(String featureFlagName, Map attributes) { return Treatments.CONTROL; } @Override - public SplitResult getTreatmentWithConfig(String split, Map attributes) { + public SplitResult getTreatmentWithConfig(String featureFlagName, Map attributes) { return new SplitResult(Treatments.CONTROL); } diff --git a/src/main/java/io/split/android/client/SplitClient.java b/src/main/java/io/split/android/client/SplitClient.java index dc036b201..bd2fb1473 100644 --- a/src/main/java/io/split/android/client/SplitClient.java +++ b/src/main/java/io/split/android/client/SplitClient.java @@ -10,35 +10,35 @@ public interface SplitClient extends AttributesManager { /** - * Returns the treatment to show this key for this feature. The set of treatments - * for a feature can be configured on the Split web console. + * Returns the treatment to show this key for this feature flag. The set of treatments + * for a feature flag can be configured on the Split user interface. *

*

* This method returns the string 'control' if: *

    *
  1. Any of the parameters were null
  2. *
  3. There was an exception in evaluating the treatment
  4. - *
  5. The SDK does not know of the existence of this feature
  6. - *
  7. The feature was deleted through the web console.
  8. + *
  9. The SDK does not know of the existence of this feature flag
  10. + *
  11. The feature flag was deleted through the Split user interface.
  12. *
* 'control' is a reserved treatment (you cannot create a treatment with the * same name) to highlight these exceptional circumstances. *

*

- * The sdk returns the default treatment of this feature if: + * The sdk returns the default treatment of this feature flag if: *

    - *
  1. The feature was killed
  2. + *
  3. The feature flag was killed
  4. *
  5. The key did not match any of the conditions in the feature roll-out plan
  6. *
- * The default treatment of a feature is set on the Split web console. + * The default treatment of a feature flag is set on the Split user interface. *

*

* This method does not throw any exceptions. It also never returns null. * - * @param split the feature we want to evaluate. MUST NOT be null. - * @return the evaluated treatment, the default treatment of this feature, or 'control'. + * @param featureFlagName the feature flag we want to evaluate. MUST NOT be null. + * @return the evaluated treatment, the default treatment of this feature flag, or 'control'. */ - String getTreatment(String split); + String getTreatment(String featureFlagName); /** * This method is useful when you want to determine the treatment to show @@ -50,11 +50,11 @@ public interface SplitClient extends AttributesManager { * vs. premium plan. Another example is to show a different treatment * to users created after a certain date. * - * @param split the feature we want to evaluate. MUST NOT be null. + * @param featureFlagName the feature flag we want to evaluate. MUST NOT be null. * @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty. - * @return the evaluated treatment, the default treatment of this feature, or 'control'. + * @return the evaluated treatment, the default treatment of this feature flag, or 'control'. */ - String getTreatment(String split, Map attributes); + String getTreatment(String featureFlagName, Map attributes); /** @@ -67,44 +67,44 @@ public interface SplitClient extends AttributesManager { * vs. premium plan. Another example is to show a different treatment * to users created after a certain date. * - * @param split the feature we want to evaluate. MUST NOT be null. + * @param featureFlagName the feature flag we want to evaluate. MUST NOT be null. * @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty. - * @return the evaluated treatment, the default treatment of this feature, or 'control' + * @return the evaluated treatment, the default treatment of this feature flag, or 'control' * with its corresponding configurations if it has one. */ - SplitResult getTreatmentWithConfig(String split, Map attributes); + SplitResult getTreatmentWithConfig(String featureFlagName, Map attributes); /** - * This method is useful when you want to determine the treatment of several splits at + * This method is useful when you want to determine the treatment of several feature flags at * the same time. *

*

* It can be used to cache treatments you know it won't change very often. * - * @param splits the features you want to evaluate. MUST NOT be null. + * @param featureFlagNames the feature flags you want to evaluate. MUST NOT be null. * @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty. * @return the evaluated treatments, the default treatment of a feature, or 'control'. */ - Map getTreatments(List splits, Map attributes); + Map getTreatments(List featureFlagNames, Map attributes); /** - * This method is useful when you want to determine the treatment of several splits at + * This method is useful when you want to determine the treatment of several feature flags at * the same time. *

*

* It can be used to cache treatments you know it won't change very often. * - * @param splits the features you want to evaluate. MUST NOT be null. + * @param featureFlagNames the feature flags you want to evaluate. MUST NOT be null. * @param attributes of the customer (user, account etc.) to use in evaluation. Can be null or empty. - * @return the evaluated treatments, the default treatment of a feature, or 'control' + * @return the evaluated treatments, the default treatment of a feature flag, or 'control' * with its corresponding configurations if it has one. */ - Map getTreatmentsWithConfig(List splits, Map attributes); + Map getTreatmentsWithConfig(List featureFlagNames, Map attributes); /** * Destroys the background processes and clears the cache, releasing the resources used by - * the any instances of SplitClient or SplitManager generated by the client's parent SplitFactory + * any instances of SplitClient or SplitManager generated by the client's parent SplitFactory */ void destroy(); @@ -122,7 +122,7 @@ public interface SplitClient extends AttributesManager { void on(SplitEvent event, SplitEventTask task); /** - * Enqueue a new event to be sent to split data collection services. + * Enqueue a new event to be sent to Split data collection services. * * The traffic type used is the one set by trafficType() in SplitClientConfig. * @@ -136,7 +136,7 @@ public interface SplitClient extends AttributesManager { boolean track(String eventType); /** - * Enqueue a new event to be sent to split data collection services + * Enqueue a new event to be sent to Split data collection services * * Example: * client.track(“account”, “checkout”, 200.00) @@ -150,7 +150,7 @@ public interface SplitClient extends AttributesManager { boolean track(String trafficType, String eventType, double value); /** - * Enqueue a new event to be sent to split data collection services + * Enqueue a new event to be sent to Split data collection services * * Example: * client.track(“account”, “checkout”) @@ -163,7 +163,7 @@ public interface SplitClient extends AttributesManager { boolean track(String trafficType, String eventType); /** - * Enqueue a new event to be sent to split data collection services + * Enqueue a new event to be sent to Split data collection services * * The traffic type used is the one set by trafficType() in SplitClientConfig. @@ -178,7 +178,7 @@ public interface SplitClient extends AttributesManager { boolean track(String eventType, double value); /** - * Enqueue a new event to be sent to split data collection services. + * Enqueue a new event to be sent to Split data collection services. * * The traffic type used is the one set by trafficType() in SplitClientConfig. * @@ -193,7 +193,7 @@ public interface SplitClient extends AttributesManager { boolean track(String eventType, Map properties); /** - * Enqueue a new event to be sent to split data collection services + * Enqueue a new event to be sent to Split data collection services * * Example: * client.track(“account”, “checkout”, 200.00) @@ -222,7 +222,7 @@ public interface SplitClient extends AttributesManager { boolean track(String trafficType, String eventType, Map properties); /** - * Enqueue a new event to be sent to split data collection services + * Enqueue a new event to be sent to Split data collection services * * The traffic type used is the one set by trafficType() in SplitClientConfig. diff --git a/src/main/java/io/split/android/client/SplitClientConfig.java b/src/main/java/io/split/android/client/SplitClientConfig.java index 06a7c4b5d..3247a8f17 100644 --- a/src/main/java/io/split/android/client/SplitClientConfig.java +++ b/src/main/java/io/split/android/client/SplitClientConfig.java @@ -337,7 +337,7 @@ int maximumKeyLength() { /** * Default data folder to use when some * problem arises while creating it - * based on api key + * based on SDK key * @return Default data folder */ String defaultDataFolder() { @@ -586,9 +586,9 @@ public Builder segmentsRefreshRate(int seconds) { } /** - * The ImpressionListener captures the which key saw what treatment ("on", "off", etc) - * at what time. This log is periodically pushed back to split endpoint. - * This parameter controls how quickly does the cache expire after a write. + * The ImpressionListener captures the key saw what treatment ("on", "off", etc) + * at what time. This log is periodically pushed to Split. + * This parameter controls how quickly the cache expires after a write. *

* This is an ADVANCED parameter * @@ -602,9 +602,9 @@ public Builder impressionsRefreshRate(int seconds) { /** * The impression listener captures the which key saw what treatment ("on", "off", etc) - * at what time. This log is periodically pushed back to split endpoint. + * at what time. This log is periodically pushed to Split. * This parameter controls the in-memory queue size to store them before they are - * pushed back to split endpoint. + * pushed to Split. *

* If the value chosen is too small and more than the default size(5000) of impressions * are generated, the old ones will be dropped and the sdk will show a warning. @@ -705,7 +705,7 @@ public Builder disableLabels() { /** * The SDK kicks off background threads to download data necessary * for using the SDK. You can choose to block until the SDK has - * downloaded split definitions so that you will not get + * downloaded feature flag definitions so that you will not get * the 'control' treatment. *

*

@@ -943,7 +943,7 @@ public Builder persistentAttributesEnabled(boolean enabled) { } /** - * Only used in localhost mode. If offlineRefreshRate is a positive integer, split values + * Only used in localhost mode. If offlineRefreshRate is a positive integer, feature flag values * will be loaded from a local file every `offlineRefreshRate` seconds. * * @return: This builder diff --git a/src/main/java/io/split/android/client/SplitClientImpl.java b/src/main/java/io/split/android/client/SplitClientImpl.java index 5dc067352..00f4feaf7 100644 --- a/src/main/java/io/split/android/client/SplitClientImpl.java +++ b/src/main/java/io/split/android/client/SplitClientImpl.java @@ -132,14 +132,14 @@ public boolean isReady() { } @Override - public String getTreatment(String split) { - return getTreatment(split, Collections.emptyMap()); + public String getTreatment(String featureFlagName) { + return getTreatment(featureFlagName, Collections.emptyMap()); } @Override - public String getTreatment(String split, Map attributes) { + public String getTreatment(String featureFlagName, Map attributes) { try { - return mTreatmentManager.getTreatment(split, attributes, mIsClientDestroyed); + return mTreatmentManager.getTreatment(featureFlagName, attributes, mIsClientDestroyed); } catch (Exception exception) { Logger.e("Client getTreatment exception", exception); @@ -150,9 +150,9 @@ public String getTreatment(String split, Map attributes) { } @Override - public SplitResult getTreatmentWithConfig(String split, Map attributes) { + public SplitResult getTreatmentWithConfig(String featureFlagName, Map attributes) { try { - return mTreatmentManager.getTreatmentWithConfig(split, attributes, mIsClientDestroyed); + return mTreatmentManager.getTreatmentWithConfig(featureFlagName, attributes, mIsClientDestroyed); } catch (Exception exception) { Logger.e("Client getTreatmentWithConfig exception", exception); @@ -163,28 +163,28 @@ public SplitResult getTreatmentWithConfig(String split, Map attr } @Override - public Map getTreatments(List splits, Map attributes) { + public Map getTreatments(List featureFlagNames, Map attributes) { try { - return mTreatmentManager.getTreatments(splits, attributes, mIsClientDestroyed); + return mTreatmentManager.getTreatments(featureFlagNames, attributes, mIsClientDestroyed); } catch (Exception exception) { Logger.e("Client getTreatments exception", exception); mTelemetryStorageProducer.recordException(Method.TREATMENTS); - return TreatmentManagerHelper.controlTreatmentsForSplits(splits, mSplitValidator); + return TreatmentManagerHelper.controlTreatmentsForSplits(featureFlagNames, mSplitValidator); } } @Override - public Map getTreatmentsWithConfig(List splits, Map attributes) { + public Map getTreatmentsWithConfig(List featureFlagNames, Map attributes) { try { - return mTreatmentManager.getTreatmentsWithConfig(splits, attributes, mIsClientDestroyed); + return mTreatmentManager.getTreatmentsWithConfig(featureFlagNames, attributes, mIsClientDestroyed); } catch (Exception exception) { Logger.e("Client getTreatmentsWithConfig exception", exception); mTelemetryStorageProducer.recordException(Method.TREATMENTS_WITH_CONFIG); - return TreatmentManagerHelper.controlTreatmentsForSplitsWithConfig(splits, mSplitValidator); + return TreatmentManagerHelper.controlTreatmentsForSplitsWithConfig(featureFlagNames, mSplitValidator); } } diff --git a/src/main/java/io/split/android/client/SplitFactoryBuilder.java b/src/main/java/io/split/android/client/SplitFactoryBuilder.java index 8deff7dbb..ab60d90d3 100644 --- a/src/main/java/io/split/android/client/SplitFactoryBuilder.java +++ b/src/main/java/io/split/android/client/SplitFactoryBuilder.java @@ -21,8 +21,8 @@ public class SplitFactoryBuilder { /** * - * @param apiToken - * @param matchingkey + * @param sdkKey + * @param matchingKey * @param context * @return * @throws IOException @@ -30,15 +30,15 @@ public class SplitFactoryBuilder { * @throws TimeoutException * @throws URISyntaxException */ - public static SplitFactory build(String apiToken, String matchingkey, Context context) throws IOException, InterruptedException, TimeoutException, URISyntaxException { - Key key = new Key(matchingkey, null); - return build(apiToken, key, context); + public static SplitFactory build(String sdkKey, String matchingKey, Context context) throws IOException, InterruptedException, TimeoutException, URISyntaxException { + Key key = new Key(matchingKey, null); + return build(sdkKey, key, context); } /** * Instantiates a SplitFactory with default configurations * - * @param apiToken the API token. MUST NOT be null + * @param sdkKey the SDK key. MUST NOT be null * @return a SplitFactory * @throws IOException if the SDK was being started in 'localhost' mode, but * there were problems reading the override file from disk. @@ -47,12 +47,12 @@ public static SplitFactory build(String apiToken, String matchingkey, Context co * @throws java.util.concurrent.TimeoutException if you asked to block until the sdk was * ready and the timeout specified via config#ready() passed. */ - public static SplitFactory build(String apiToken, Key key, Context context) throws IOException, InterruptedException, TimeoutException, URISyntaxException { - return build(apiToken, key, SplitClientConfig.builder().build(), context); + public static SplitFactory build(String sdkKey, Key key, Context context) throws IOException, InterruptedException, TimeoutException, URISyntaxException { + return build(sdkKey, key, SplitClientConfig.builder().build(), context); } /** - * @param apiToken the API token. MUST NOT be null + * @param sdkKey the SDK key. MUST NOT be null * @param config parameters to control sdk construction. MUST NOT be null. * @return a SplitFactory * @throws java.io.IOException if the SDK was being started in 'localhost' mode, but @@ -62,11 +62,11 @@ public static SplitFactory build(String apiToken, Key key, Context context) thro * @throws java.util.concurrent.TimeoutException if you asked to block until the sdk was * ready and the timeout specified via config#ready() passed. */ - public static synchronized SplitFactory build(String apiToken, Key key, SplitClientConfig config, Context context) throws IOException, InterruptedException, TimeoutException, URISyntaxException { - if (ServiceConstants.LOCALHOST.equals(apiToken)) { + public static synchronized SplitFactory build(String sdkKey, Key key, SplitClientConfig config, Context context) throws IOException, InterruptedException, TimeoutException, URISyntaxException { + if (ServiceConstants.LOCALHOST.equals(sdkKey)) { return new LocalhostSplitFactory(key.matchingKey(), context, config); } else { - return new SplitFactoryImpl(apiToken, key, config, context); + return new SplitFactoryImpl(sdkKey, key, config, context); } } diff --git a/src/main/java/io/split/android/client/SplitFactoryImpl.java b/src/main/java/io/split/android/client/SplitFactoryImpl.java index d1eb083e5..85c76b642 100644 --- a/src/main/java/io/split/android/client/SplitFactoryImpl.java +++ b/src/main/java/io/split/android/client/SplitFactoryImpl.java @@ -118,7 +118,7 @@ private SplitFactoryImpl(String apiToken, Key key, SplitClientConfig config, int factoryCount = mFactoryMonitor.count(apiToken); if (factoryCount > 0) { - validationLogger.w("You already have " + factoryCount + (factoryCount == 1 ? " factory" : " factories") + "with this API Key. We recommend keeping only " + + validationLogger.w("You already have " + factoryCount + (factoryCount == 1 ? " factory" : " factories") + " with this SDK Key. We recommend keeping only " + "one instance of the factory at all times (Singleton pattern) and reusing it throughout your application.", validationTag); } else if (mFactoryMonitor.count() > 0) { validationLogger.w("You already have an instance of the Split factory. Make sure you definitely want this additional instance. We recommend " + diff --git a/src/main/java/io/split/android/client/SplitManager.java b/src/main/java/io/split/android/client/SplitManager.java index 09239c5c2..1047b0dc0 100644 --- a/src/main/java/io/split/android/client/SplitManager.java +++ b/src/main/java/io/split/android/client/SplitManager.java @@ -8,8 +8,9 @@ * An interface to manage an instance of Split SDK. */ public interface SplitManager { + /** - * Retrieves the features (or Splits) that are currently registered with the + * Retrieves the feature flags that are currently registered with the * SDK. * * @return a List of SplitView or empty @@ -17,14 +18,14 @@ public interface SplitManager { List splits(); /** - * Returns the feature (or Split) registered with the SDK of this name. + * Returns the feature flag registered with the SDK of this name. * * @return SplitView or null */ - SplitView split(String featureName); + SplitView split(String featureFlagName); /** - * Returns the names of features (or Splits) registered with the SDK. + * Returns the names of feature flags registered with the SDK. * * @return a List of String (Split Feature Names) or empty */ diff --git a/src/main/java/io/split/android/client/SplitManagerImpl.java b/src/main/java/io/split/android/client/SplitManagerImpl.java index 750b19d47..533142730 100644 --- a/src/main/java/io/split/android/client/SplitManagerImpl.java +++ b/src/main/java/io/split/android/client/SplitManagerImpl.java @@ -61,17 +61,17 @@ public List splits() { } } } catch (Exception exception) { - Logger.e("Error getting splits: " + exception.getLocalizedMessage()); + Logger.e("Error getting feature flags: " + exception.getLocalizedMessage()); } return result; } @Override - public SplitView split(String featureName) { + public SplitView split(String featureFlagName) { final String validationTag = "split"; - String splitName = featureName; + String splitName = featureFlagName; try { if (_isManagerDestroyed) { @@ -79,13 +79,13 @@ public SplitView split(String featureName) { return null; } - ValidationErrorInfo errorInfo = _splitValidator.validateName(featureName); + ValidationErrorInfo errorInfo = _splitValidator.validateName(featureFlagName); if (errorInfo != null) { _validationMessageLogger.log(errorInfo, validationTag); if (errorInfo.isError()) { return null; } - splitName = featureName.trim(); + splitName = featureFlagName.trim(); } ParsedSplit parsedSplit = null; @@ -124,7 +124,7 @@ public List splitNames() { return result; } catch (Exception exception) { - Logger.e("Error getting split names: " + exception.getLocalizedMessage()); + Logger.e("Error getting feature flags: " + exception.getLocalizedMessage()); return result; } diff --git a/src/main/java/io/split/android/client/api/SplitView.java b/src/main/java/io/split/android/client/api/SplitView.java index da83baa2e..dd13b3463 100644 --- a/src/main/java/io/split/android/client/api/SplitView.java +++ b/src/main/java/io/split/android/client/api/SplitView.java @@ -3,8 +3,10 @@ import java.util.List; import java.util.Map; +import io.split.android.client.SplitManager; + /** - * A view of a Split meant for consumption through SplitManager interface. + * A view of a feature flag, meant for consumption through {@link SplitManager} interface. * */ public class SplitView { diff --git a/src/main/java/io/split/android/client/localhost/LocalhostSplitClient.java b/src/main/java/io/split/android/client/localhost/LocalhostSplitClient.java index 9508be2a3..4023e0060 100644 --- a/src/main/java/io/split/android/client/localhost/LocalhostSplitClient.java +++ b/src/main/java/io/split/android/client/localhost/LocalhostSplitClient.java @@ -72,9 +72,9 @@ mEvaluator, new KeyValidatorImpl(), } @Override - public String getTreatment(String split) { + public String getTreatment(String featureFlagName) { try { - return mTreatmentManager.getTreatment(split, null, mIsClientDestroyed); + return mTreatmentManager.getTreatment(featureFlagName, null, mIsClientDestroyed); } catch (Exception exception) { Logger.e(exception); @@ -83,9 +83,9 @@ public String getTreatment(String split) { } @Override - public String getTreatment(String split, Map attributes) { + public String getTreatment(String featureFlagName, Map attributes) { try { - return mTreatmentManager.getTreatment(split, attributes, mIsClientDestroyed); + return mTreatmentManager.getTreatment(featureFlagName, attributes, mIsClientDestroyed); } catch (Exception exception) { Logger.e(exception); @@ -94,9 +94,9 @@ public String getTreatment(String split, Map attributes) { } @Override - public SplitResult getTreatmentWithConfig(String split, Map attributes) { + public SplitResult getTreatmentWithConfig(String featureFlagName, Map attributes) { try { - return mTreatmentManager.getTreatmentWithConfig(split, attributes, mIsClientDestroyed); + return mTreatmentManager.getTreatmentWithConfig(featureFlagName, attributes, mIsClientDestroyed); } catch (Exception exception) { Logger.e(exception); @@ -105,16 +105,16 @@ public SplitResult getTreatmentWithConfig(String split, Map attr } @Override - public Map getTreatments(List splits, Map attributes) { + public Map getTreatments(List featureFlagNames, Map attributes) { try { - return mTreatmentManager.getTreatments(splits, attributes, mIsClientDestroyed); + return mTreatmentManager.getTreatments(featureFlagNames, attributes, mIsClientDestroyed); } catch (Exception exception) { Logger.e(exception); Map result = new HashMap<>(); - for (String split : splits) { - result.put(split, Treatments.CONTROL); + for (String featureFlagName : featureFlagNames) { + result.put(featureFlagName, Treatments.CONTROL); } return result; @@ -122,16 +122,16 @@ public Map getTreatments(List splits, Map getTreatmentsWithConfig(List splits, Map attributes) { + public Map getTreatmentsWithConfig(List featureFlagNames, Map attributes) { try { - return mTreatmentManager.getTreatmentsWithConfig(splits, attributes, mIsClientDestroyed); + return mTreatmentManager.getTreatmentsWithConfig(featureFlagNames, attributes, mIsClientDestroyed); } catch (Exception exception) { Logger.e(exception); Map result = new HashMap<>(); - for (String split : splits) { - result.put(split, new SplitResult(Treatments.CONTROL)); + for (String featureFlagName : featureFlagNames) { + result.put(featureFlagName, new SplitResult(Treatments.CONTROL)); } return result; diff --git a/src/main/java/io/split/android/client/localhost/LocalhostSplitFile.java b/src/main/java/io/split/android/client/localhost/LocalhostSplitFile.java deleted file mode 100644 index 101ec91e7..000000000 --- a/src/main/java/io/split/android/client/localhost/LocalhostSplitFile.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.split.android.client.localhost; - -import com.google.common.collect.Maps; - -import io.split.android.client.utils.logger.Logger; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkNotNull; - -public class LocalhostSplitFile { - - private final File _file; - - public LocalhostSplitFile(String directory, String fileName) throws IOException { - _file = new File(checkNotNull(directory), checkNotNull(fileName)); - } - - public Map readOnSplits() throws IOException { - Map onSplits = Maps.newHashMap(); - - try (BufferedReader reader = new BufferedReader(new FileReader(_file))) { - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - line = line.trim(); - if (line.isEmpty() || line.startsWith("#")) { - continue; - } - - String[] feature_treatment = line.split("\\s+"); - - if (feature_treatment.length != 2) { - Logger.d("Ignoring line since it does not have exactly two columns: %s", line); - continue; - } - - onSplits.put(feature_treatment[0], feature_treatment[1]); - Logger.d("100%% of keys will see %s for %s", feature_treatment[1], feature_treatment[0]); - } - } catch (FileNotFoundException e) { - Logger.w(e, "There was no file named %s found. " + - "We created a split client that returns default " + - "treatments for all features for all of your users. " + - "If you wish to return a specific treatment for a feature, " + - "enter the name of that feature name and treatment name separated " + - "by whitespace in %s; one pair per line. Empty lines or lines " + - "starting with '#' are considered comments", _file.getPath(), _file.getPath()); - } - - return onSplits; - } -} \ No newline at end of file diff --git a/src/main/java/io/split/android/client/localhost/LocalhostYamlFileParser.java b/src/main/java/io/split/android/client/localhost/LocalhostYamlFileParser.java index c2615e8b7..21ebc97c5 100644 --- a/src/main/java/io/split/android/client/localhost/LocalhostYamlFileParser.java +++ b/src/main/java/io/split/android/client/localhost/LocalhostYamlFileParser.java @@ -26,7 +26,7 @@ public Map parse(String content) { try { List loadedSplits = parser.parse(content); if (loadedSplits == null) { - Logger.e("Split file could not be parsed because it is not in the correct format."); + Logger.e("Feature flag file could not be parsed because it is not in the correct format."); return null; } @@ -35,11 +35,11 @@ public Map parse(String content) { try { addLoadedSplitToParsedSplits(splits, (Map) loadedSplit); } catch (Exception exception) { - Logger.e("An error has occurred while parsing a split" + (loadedSplit != null ? (", source: '" + loadedSplit + "'") : "")); + Logger.e("An error has occurred while parsing a feature flag" + (loadedSplit != null ? (", source: '" + loadedSplit + "'") : "")); } } } catch (Exception e) { - Logger.e("An error has occurred while parsing localhost splits content"); + Logger.e("An error has occurred while parsing localhost feature flags content"); } return splits; } diff --git a/src/main/java/io/split/android/client/service/sseclient/sseclient/PushNotificationManager.java b/src/main/java/io/split/android/client/service/sseclient/sseclient/PushNotificationManager.java index f27cba7f2..60a752765 100644 --- a/src/main/java/io/split/android/client/service/sseclient/sseclient/PushNotificationManager.java +++ b/src/main/java/io/split/android/client/service/sseclient/sseclient/PushNotificationManager.java @@ -180,7 +180,7 @@ public void run() { mTelemetryRuntimeProducer.recordSyncLatency(OperationType.TOKEN, System.currentTimeMillis() - startTime); if (authResult.isSuccess() && !authResult.isPushEnabled()) { - Logger.d("Streaming disabled for api key"); + Logger.d("Streaming disabled for SDK key"); mBroadcasterChannel.pushMessage(new PushStatusEvent(EventType.PUSH_SUBSYSTEM_DOWN)); mIsStopped.set(true); return; diff --git a/src/main/java/io/split/android/client/service/sseclient/sseclient/SseAuthenticator.java b/src/main/java/io/split/android/client/service/sseclient/sseclient/SseAuthenticator.java index cdde557da..16c1142c6 100644 --- a/src/main/java/io/split/android/client/service/sseclient/sseclient/SseAuthenticator.java +++ b/src/main/java/io/split/android/client/service/sseclient/sseclient/SseAuthenticator.java @@ -52,12 +52,12 @@ public SseAuthenticationResult authenticate() { Logger.d("SSE Authentication done, now parsing token"); if(authResponse.isClientError()) { - Logger.d("Error while authenticating to streaming. Check your api key is correct."); + Logger.d("Error while authenticating to streaming. Check your SDK key is correct."); return new SseAuthenticationResult(false, false, false, 0, null); } if(!authResponse.isStreamingEnabled()) { - Logger.d("Streaming disabled for api key"); + Logger.d("Streaming disabled for SDK key"); return new SseAuthenticationResult(true, true, false, 0, null); } diff --git a/src/main/java/io/split/android/client/validators/ApiKeyValidator.java b/src/main/java/io/split/android/client/validators/ApiKeyValidator.java index 50db9203c..b113b81bd 100644 --- a/src/main/java/io/split/android/client/validators/ApiKeyValidator.java +++ b/src/main/java/io/split/android/client/validators/ApiKeyValidator.java @@ -7,10 +7,10 @@ public interface ApiKeyValidator { /** - * Checks that an ApiKey is valid - * @param apiKey: ApiKey string - * @return true when the api key is valid, false when it is not + * Checks that an SDK key is valid + * @param sdkKey: SDK key string + * @return true when the SDK key is valid, false when it is not */ - ValidationErrorInfo validate(String apiKey); + ValidationErrorInfo validate(String sdkKey); } diff --git a/src/main/java/io/split/android/client/validators/ApiKeyValidatorImpl.java b/src/main/java/io/split/android/client/validators/ApiKeyValidatorImpl.java index 50aec7866..109c62220 100644 --- a/src/main/java/io/split/android/client/validators/ApiKeyValidatorImpl.java +++ b/src/main/java/io/split/android/client/validators/ApiKeyValidatorImpl.java @@ -5,14 +5,14 @@ public class ApiKeyValidatorImpl implements ApiKeyValidator { @Override - public ValidationErrorInfo validate(String apiKey) { + public ValidationErrorInfo validate(String sdkKey) { - if (apiKey == null) { - return new ValidationErrorInfo(ValidationErrorInfo.ERROR_SOME, "you passed a null api_key, the api_key must be a non-empty string"); + if (sdkKey == null) { + return new ValidationErrorInfo(ValidationErrorInfo.ERROR_SOME, "you passed a null sdkKey, the sdkKey must be a non-empty string"); } - if (Strings.isNullOrEmpty(apiKey.trim())) { - return new ValidationErrorInfo(ValidationErrorInfo.ERROR_SOME, "you passed an empty api_key, api_key must be a non-empty string"); + if (Strings.isNullOrEmpty(sdkKey.trim())) { + return new ValidationErrorInfo(ValidationErrorInfo.ERROR_SOME, "you passed an empty sdkKey, sdkKey must be a non-empty string"); } return null; diff --git a/src/main/java/io/split/android/client/validators/EventValidatorImpl.java b/src/main/java/io/split/android/client/validators/EventValidatorImpl.java index bb8bd9de0..8b1d9a029 100644 --- a/src/main/java/io/split/android/client/validators/EventValidatorImpl.java +++ b/src/main/java/io/split/android/client/validators/EventValidatorImpl.java @@ -59,8 +59,8 @@ public ValidationErrorInfo validate(Event event, boolean validateTrafficType) { } if (validateTrafficType && !mSplitsStorage.isValidTrafficType(event.trafficTypeName)) { - String message = "Traffic Type " + event.trafficTypeName + " does not have any corresponding Splits in this environment, " - + "make sure you’re tracking your events to a valid traffic type defined in the Split console"; + String message = "Traffic Type " + event.trafficTypeName + " does not have any corresponding feature flags in this environment, " + + "make sure you’re tracking your events to a valid traffic type defined in the Split user interface"; if(errorInfo == null) { errorInfo = new ValidationErrorInfo(ValidationErrorInfo.WARNING_TRAFFIC_TYPE_WITHOUT_SPLIT_IN_ENVIRONMENT, message, true); } else { diff --git a/src/main/java/io/split/android/client/validators/SplitValidatorImpl.java b/src/main/java/io/split/android/client/validators/SplitValidatorImpl.java index 65f153d31..7d47255c7 100644 --- a/src/main/java/io/split/android/client/validators/SplitValidatorImpl.java +++ b/src/main/java/io/split/android/client/validators/SplitValidatorImpl.java @@ -17,21 +17,21 @@ public ValidationErrorInfo validateName(String name) { if (name == null) { return new ValidationErrorInfo( ValidationErrorInfo.ERROR_SOME, - "you passed a null split name, split name must " + + "you passed a null feature flag name, flag name must " + "be a non-empty string"); } if (Strings.isNullOrEmpty(name.trim())) { return new ValidationErrorInfo( ValidationErrorInfo.ERROR_SOME, - "you passed an empty split name, " + - "split name must be a non-empty string"); + "you passed an empty feature flag name, " + + "flag name must be a non-empty string"); } if (name.trim().length() != name.length()) { return new ValidationErrorInfo( ValidationErrorInfo.WARNING_SPLIT_NAME_SHOULD_BE_TRIMMED, - "split name '" + name + "' has extra whitespace, trimming", + "feature flag name '" + name + "' has extra whitespace, trimming", true); } @@ -41,7 +41,7 @@ public ValidationErrorInfo validateName(String name) { public String splitNotFoundMessage(String splitName) { return "split: you passed '" + splitName + "' that does not exist in this environment, " + - "please double check what Splits exist in the web console."; + "please double check what feature flags exist in the Split user interface."; } } diff --git a/src/main/java/io/split/android/engine/experiments/SplitParser.java b/src/main/java/io/split/android/engine/experiments/SplitParser.java index 9f73dd3db..f07087e0f 100644 --- a/src/main/java/io/split/android/engine/experiments/SplitParser.java +++ b/src/main/java/io/split/android/engine/experiments/SplitParser.java @@ -62,7 +62,7 @@ public ParsedSplit parse(@Nullable Split split, @Nullable String matchingKey) { try { return parseWithoutExceptionHandling(split, matchingKey); } catch (Throwable t) { - Logger.e(t, "Could not parse split: %s", split); + Logger.e(t, "Could not parse feature flag: %s", split); return null; } } @@ -77,7 +77,7 @@ private ParsedSplit parseWithoutExceptionHandling(Split split, String matchingKe } if (split.conditions.size() > CONDITIONS_UPPER_LIMIT) { - Logger.w("Dropping Split name=%s due to large number of conditions(%d)", + Logger.w("Dropping feature flag name=%s due to large number of conditions(%d)", split.name, split.conditions.size()); return null; } diff --git a/src/test/java/io/split/android/client/validators/ApiKeyValidatorTest.java b/src/test/java/io/split/android/client/validators/ApiKeyValidatorTest.java index 3e3cd5e50..d6aa71ba1 100644 --- a/src/test/java/io/split/android/client/validators/ApiKeyValidatorTest.java +++ b/src/test/java/io/split/android/client/validators/ApiKeyValidatorTest.java @@ -27,7 +27,7 @@ public void testNullKey() { Assert.assertNotNull(errorInfo); Assert.assertTrue(errorInfo.isError()); - Assert.assertEquals("you passed a null api_key, the api_key must be a non-empty string", errorInfo.getErrorMessage()); + Assert.assertEquals("you passed a null sdkKey, the sdkKey must be a non-empty string", errorInfo.getErrorMessage()); } @Test @@ -36,7 +36,7 @@ public void testInvalidEmptyKey() { Assert.assertNotNull(errorInfo); Assert.assertTrue(errorInfo.isError()); - Assert.assertEquals("you passed an empty api_key, api_key must be a non-empty string", errorInfo.getErrorMessage()); + Assert.assertEquals("you passed an empty sdkKey, sdkKey must be a non-empty string", errorInfo.getErrorMessage()); } @Test @@ -45,6 +45,6 @@ public void testInvalidAllSpacesKey() { Assert.assertNotNull(errorInfo); Assert.assertTrue(errorInfo.isError()); - Assert.assertEquals("you passed an empty api_key, api_key must be a non-empty string", errorInfo.getErrorMessage()); + Assert.assertEquals("you passed an empty sdkKey, sdkKey must be a non-empty string", errorInfo.getErrorMessage()); } } diff --git a/src/test/java/io/split/android/client/validators/EventValidatorTest.java b/src/test/java/io/split/android/client/validators/EventValidatorTest.java index 080d491ef..54286b799 100644 --- a/src/test/java/io/split/android/client/validators/EventValidatorTest.java +++ b/src/test/java/io/split/android/client/validators/EventValidatorTest.java @@ -272,8 +272,8 @@ public void noChachedServerTrafficType() { Assert.assertNotNull(errorInfo); Assert.assertFalse(errorInfo.isError()); - Assert.assertEquals("Traffic Type nocached does not have any corresponding Splits in this environment, " - + "make sure you’re tracking your events to a valid traffic type defined in the Split console", errorInfo.getWarnings().get(ValidationErrorInfo.WARNING_TRAFFIC_TYPE_WITHOUT_SPLIT_IN_ENVIRONMENT)); + Assert.assertEquals("Traffic Type nocached does not have any corresponding feature flags in this environment, " + + "make sure you’re tracking your events to a valid traffic type defined in the Split user interface", errorInfo.getWarnings().get(ValidationErrorInfo.WARNING_TRAFFIC_TYPE_WITHOUT_SPLIT_IN_ENVIRONMENT)); } private Event newEventTypeName() { diff --git a/src/test/java/io/split/android/client/validators/SplitValidatorTest.java b/src/test/java/io/split/android/client/validators/SplitValidatorTest.java index f1aad48e6..4370f6d99 100644 --- a/src/test/java/io/split/android/client/validators/SplitValidatorTest.java +++ b/src/test/java/io/split/android/client/validators/SplitValidatorTest.java @@ -31,7 +31,7 @@ public void testNullName() { Assert.assertNotNull(errorInfo); Assert.assertTrue(errorInfo.isError()); - Assert.assertEquals("you passed a null split name, split name must be a non-empty string", errorInfo.getErrorMessage()); + Assert.assertEquals("you passed a null feature flag name, flag name must be a non-empty string", errorInfo.getErrorMessage()); } @Test @@ -40,35 +40,36 @@ public void testInvalidEmptyName() { Assert.assertNotNull(errorInfo); Assert.assertTrue(errorInfo.isError()); - Assert.assertEquals("you passed an empty split name, split name must be a non-empty string", errorInfo.getErrorMessage()); + Assert.assertEquals("you passed an empty feature flag name, flag name must be a non-empty string", errorInfo.getErrorMessage()); } + @Test public void testInvalidAllSpacesInName() { ValidationErrorInfo errorInfo = validator.validateName(" "); Assert.assertNotNull(errorInfo); Assert.assertTrue(errorInfo.isError()); - Assert.assertEquals("you passed a empty split name, split name must be a non-empty string", errorInfo.getErrorMessage()); + Assert.assertEquals("you passed an empty feature flag name, flag name must be a non-empty string", errorInfo.getErrorMessage()); } @Test public void testLeadingSpacesName() { - String splitName = " splitName"; + String splitName = " featureFlag"; ValidationErrorInfo errorInfo = validator.validateName(splitName); Assert.assertNotNull(errorInfo); Assert.assertFalse(errorInfo.isError()); - Assert.assertEquals("split name ' splitName' has extra whitespace, trimming", errorInfo.getWarnings().get(ValidationErrorInfo.WARNING_SPLIT_NAME_SHOULD_BE_TRIMMED)); + Assert.assertEquals("feature flag name ' featureFlag' has extra whitespace, trimming", errorInfo.getWarnings().get(ValidationErrorInfo.WARNING_SPLIT_NAME_SHOULD_BE_TRIMMED)); } @Test public void testTrailingSpacesName() { - String splitName = "splitName "; + String splitName = "featureFlag "; ValidationErrorInfo errorInfo = validator.validateName(splitName); Assert.assertNotNull(errorInfo); Assert.assertFalse(errorInfo.isError()); - Assert.assertEquals("split name 'splitName ' has extra whitespace, trimming", errorInfo.getWarnings().get(ValidationErrorInfo.WARNING_SPLIT_NAME_SHOULD_BE_TRIMMED)); + Assert.assertEquals("feature flag name 'featureFlag ' has extra whitespace, trimming", errorInfo.getWarnings().get(ValidationErrorInfo.WARNING_SPLIT_NAME_SHOULD_BE_TRIMMED)); } private Split createSplit(String name) {