Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,19 @@ jobs:
- run: cp -r ../project/ ../hello-react-native/node_modules/launchdarkly-react-native-client-sdk/
- run: cd ../hello-react-native && react-native run-ios --configuration Release --simulator rn-ios

common:
docker:
- image: circleci/node:11.10.1
steps:
- checkout

- run: npm install
- run: npm run check-typescript

workflows:
version: 2
android-ios:
jobs:
- android
- ios
- ios
- common
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ build/
.gradle
local.properties
*.iml
org.eclipse*
android/.project
android/.classpath

# BUCK
buck-out/
\.buckd/
*.keystore

# Auto-generated
test-types.js
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ allprojects {

dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'com.launchdarkly:launchdarkly-android-client-sdk:2.9.0'
implementation 'com.launchdarkly:launchdarkly-android-client-sdk:2.10.0'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation "com.google.code.gson:gson:2.8.5"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.launchdarkly.android.LDStatusListener;
import com.launchdarkly.android.LDAllFlagsListener;
import com.launchdarkly.android.EvaluationDetail;
import com.launchdarkly.android.EvaluationReason;
import com.launchdarkly.android.LDFailure;

import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -565,14 +566,16 @@ public void boolVariationDetail(String flagKey, Promise promise) {

@ReactMethod
public void boolVariationDetailFallback(String flagKey, Boolean fallback, Promise promise) {
EvaluationDetail<Boolean> detailResult;
try {
EvaluationDetail<Boolean> detailResult = ldClient.boolVariationDetail(flagKey, fallback);
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
WritableMap detailMap = fromJsonObject(jsonObject);
promise.resolve(detailMap);
detailResult = ldClient.boolVariationDetail(flagKey, fallback);
} catch (Exception e) {
promise.resolve(fallback);
e.printStackTrace();
detailResult = new EvaluationDetail<Boolean>(EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION), null, fallback);
}
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
WritableMap detailMap = fromJsonObject(jsonObject);
promise.resolve(detailMap);
}

@ReactMethod
Expand All @@ -582,14 +585,16 @@ public void intVariationDetail(String flagKey, Promise promise) {

@ReactMethod
public void intVariationDetailFallback(String flagKey, Integer fallback, Promise promise) {
EvaluationDetail<Integer> detailResult;
try {
EvaluationDetail<Integer> detailResult = ldClient.intVariationDetail(flagKey, fallback);
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
WritableMap detailMap = fromJsonObject(jsonObject);
promise.resolve(detailMap);
detailResult = ldClient.intVariationDetail(flagKey, fallback);
} catch (Exception e) {
promise.resolve(fallback);
e.printStackTrace();
detailResult = new EvaluationDetail<Integer>(EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION), null, fallback);
}
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
WritableMap detailMap = fromJsonObject(jsonObject);
promise.resolve(detailMap);
}

@ReactMethod
Expand All @@ -599,14 +604,16 @@ public void floatVariationDetail(String flagKey, Promise promise) {

@ReactMethod
public void floatVariationDetailFallback(String flagKey, Float fallback, Promise promise) {
EvaluationDetail<Float> detailResult;
try {
EvaluationDetail<Float> detailResult = ldClient.floatVariationDetail(flagKey, fallback);
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
WritableMap detailMap = fromJsonObject(jsonObject);
promise.resolve(detailMap);
detailResult = ldClient.floatVariationDetail(flagKey, fallback);
} catch (Exception e) {
promise.resolve(fallback);
e.printStackTrace();
detailResult = new EvaluationDetail<Float>(EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION), null, fallback);
}
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
WritableMap detailMap = fromJsonObject(jsonObject);
promise.resolve(detailMap);
}

@ReactMethod
Expand All @@ -616,14 +623,16 @@ public void stringVariationDetail(String flagKey, Promise promise) {

@ReactMethod
public void stringVariationDetailFallback(String flagKey, String fallback, Promise promise) {
EvaluationDetail<String> detailResult;
try {
EvaluationDetail<String> detailResult = ldClient.stringVariationDetail(flagKey, fallback);
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
WritableMap detailMap = fromJsonObject(jsonObject);
promise.resolve(detailMap);
detailResult = ldClient.stringVariationDetail(flagKey, fallback);
} catch (Exception e) {
promise.resolve(fallback);
e.printStackTrace();
detailResult = new EvaluationDetail<String>(EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION), null, fallback);
}
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
WritableMap detailMap = fromJsonObject(jsonObject);
promise.resolve(detailMap);
}

@ReactMethod
Expand Down Expand Up @@ -673,12 +682,14 @@ private void jsonVariationBase(String flagKey, JsonElement fallback, Promise pro
}

private void jsonVariationDetailBase(String flagKey, JsonElement fallback, Promise promise) {
EvaluationDetail<JsonElement> jsonElementDetail;
try {
EvaluationDetail<JsonElement> jsonElementDetail = ldClient.jsonVariationDetail(flagKey, fallback);
resolveJsonElementDetail(promise, jsonElementDetail);
jsonElementDetail = ldClient.jsonVariationDetail(flagKey, fallback);
} catch (Exception e) {
resolveJsonElement(promise, fallback);
e.printStackTrace();
jsonElementDetail = new EvaluationDetail<JsonElement>(EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION), null, fallback);
}
resolveJsonElementDetail(promise, jsonElementDetail);
}


Expand Down
Loading