Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
Merged
2 changes: 1 addition & 1 deletion ManualTestApp/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,7 @@
},
"dependencies": {
"@react-native-picker/picker": "^2.2.1",
"launchdarkly-react-native-client-sdk": "^6.3.0",
"launchdarkly-react-native-client-sdk": "^7.0.1",
"react": "^18.2.0",
"react-native": "0.70.7"
},
Expand Down
31 changes: 26 additions & 5 deletions ManualTestApp/yarn.lock
Original file line numberDiff line numberDiff line change
Expand Up@@ -1613,7 +1613,7 @@ balanced-match@^1.0.0:
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

base64-js@^1.1.2, base64-js@^1.3.1:
base64-js@^1.1.2, base64-js@^1.3.0, base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
Expand DownExpand Up@@ -2525,6 +2525,11 @@ extglob@^2.0.4:
snapdragon "^0.8.1"
to-regex "^3.0.1"

fast-deep-equal@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49"
integrity sha512-bCK/2Z4zLidyB4ReuIsvALH6w31YfAQDmXMqMx6FyfHqvBxtjC0eRumeSu4Bs3XtXwpyIywtSTrVT99BxY1f9w==

fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
Expand DownExpand Up@@ -3549,10 +3554,21 @@ kleur@^3.0.3:
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==

launchdarkly-react-native-client-sdk@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/launchdarkly-react-native-client-sdk/-/launchdarkly-react-native-client-sdk-6.3.0.tgz#a0c067732c9c6df48272a005c2ea1978497f7c79"
integrity sha512-ckrbU+h5LwmnkKRRE2ij2cw5rPSYbI9nbJVjjv3dj/sVvd7ijyeFmbqaj/FhB2kFypo5KNnJ2r0DvufRWMwquw==
launchdarkly-js-sdk-common@5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/launchdarkly-js-sdk-common/-/launchdarkly-js-sdk-common-5.0.2.tgz#c1b6943a2a4038c31ee3cfdba18f347382a33529"
integrity sha512-fD4YndDUVWSyAFE2NdzeBSgpjPxyRN8+mz3p+VXKnDAPt3bdzGIEHrvusbY/K8fKZjpo4vRd7soNiA1EejkEPQ==
dependencies:
base64-js "^1.3.0"
fast-deep-equal "^2.0.1"
uuid "^8.0.0"

launchdarkly-react-native-client-sdk@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/launchdarkly-react-native-client-sdk/-/launchdarkly-react-native-client-sdk-7.0.1.tgz#2dc19983526b08623bdb7a912d55cc81e383c29d"
integrity sha512-1TdcU2IT8gN8YiBklPnBdJsOjirAQB10r8cBItAYC0CBuWluvnn+faegLFABQAA58AOeYqfUrfPosX+LUKnR9w==
dependencies:
launchdarkly-js-sdk-common "5.0.2"

leven@^3.1.0:
version "3.1.0"
Expand DownExpand Up@@ -5536,6 +5552,11 @@ utils-merge@1.0.1:
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==

uuid@^8.0.0:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

vary@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,7 +56,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;

import timber.log.Timber;

Expand DownExpand Up@@ -133,14 +132,6 @@ && validateConfig("debugMode", configMap, ReadableType.Boolean)
LaunchdarklyReactNativeClientModule.debugLoggingStarted = true;
}

try {
LDClient.get();
promise.reject(ERROR_INIT, "Client was already initialized");
return;
} catch (LaunchDarklyException e) {
// This exception indicates that the SDK has not been initialized yet
}

final Application application = (Application) getReactApplicationContext().getApplicationContext();

if (application != null) {
Expand DownExpand Up@@ -495,25 +486,16 @@ private ObjectBuilder objectBuilderFromDetail(EvaluationDetail<?> detail) {

@ReactMethod
public void allFlags(String environment, Promise promise) {
try {
LDClient.get();
} catch (LaunchDarklyException e) {
promise.reject(ERROR_INIT, "SDK has been not configured");
return;
}
ObjectBuilder resultBuilder = LDValue.buildObject();

try {
ObjectBuilder resultBuilder = LDValue.buildObject();
for (Map.Entry<String, LDValue> entry : LDClient.getForMobileKey(environment).allFlags().entrySet()) {
resultBuilder.put(entry.getKey(), entry.getValue());
}
promise.resolve(ldValueToBridge(resultBuilder.build()));
} catch (LaunchDarklyException e) {
// Since we confirmed the SDK has been configured, this exception should only be thrown if the env doesn't exist
promise.reject(ERROR_UNKNOWN, "SDK not configured with requested environment");
} catch (Exception e) {
promise.reject(ERROR_UNKNOWN, "Unknown exception in allFlags");
Timber.w(e);
Timber.w(e, "Warning: exception caught in allFlags");
promise.resolve(ldValueToBridge(resultBuilder.build()));
}
}

Expand DownExpand Up@@ -546,7 +528,8 @@ public void setOffline(Promise promise) {
LDClient.get().setOffline();
promise.resolve(true);
} catch (Exception e) {
promise.reject(ERROR_UNKNOWN, e);
Timber.w(e, "Warning: exception caught in setOffline");
promise.resolve(null);
}
}

Expand All@@ -556,7 +539,8 @@ public void isOffline(Promise promise) {
boolean result = LDClient.get().isOffline();
promise.resolve(result);
} catch (Exception e) {
promise.reject(ERROR_UNKNOWN, e);
Timber.w(e, "Warning: exception caught in isOffline");
promise.resolve(null);
}
}

Expand All@@ -566,7 +550,8 @@ public void setOnline(Promise promise) {
LDClient.get().setOnline();
promise.resolve(true);
} catch (Exception e) {
promise.reject(ERROR_UNKNOWN, e);
Timber.w(e, "Warning: exception caught in setOnline");
promise.resolve(null);
}
}

Expand All@@ -585,7 +570,7 @@ public void flush() {
try {
LDClient.get().flush();
} catch (Exception e) {
Timber.w(e);
Timber.w(e, "Warning: exception caught in flush");
}
}

Expand All@@ -595,7 +580,8 @@ public void close(Promise promise) {
LDClient.get().close();
promise.resolve(true);
} catch (Exception e) {
promise.reject(ERROR_CLOSE, e);
Timber.w(e, "Warning: exception caught in close");
promise.resolve(null);
}
}

Expand All@@ -609,19 +595,14 @@ public void identify(ReadableMap contextMap, boolean isContext, final Promise pr
public void run() {
try {
LDClient.get().identify(context).get();
promise.resolve(null);
} catch (InterruptedException e) {
Timber.w(e);
promise.reject(ERROR_IDENTIFY, "Identify Interrupted");
} catch (ExecutionException e) {
Timber.w(e);
promise.reject(ERROR_IDENTIFY, "Exception while executing identify");
} catch (Exception e) {
Timber.w(e);
promise.reject(ERROR_UNKNOWN, e);
Timber.w(e, "Warning: exception caught in identify");
}

promise.resolve(null);
}
});

background.start();
} else {
final LDUser user = configureLegacyUser(contextMap);
Expand All@@ -630,19 +611,14 @@ public void run() {
public void run() {
try {
LDClient.get().identify(user).get();
promise.resolve(null);
} catch (InterruptedException e) {
Timber.w(e);
promise.reject(ERROR_IDENTIFY, "Identify Interrupted");
} catch (ExecutionException e) {
Timber.w(e);
promise.reject(ERROR_IDENTIFY, "Exception while executing identify");
} catch (Exception e) {
Timber.w(e);
promise.reject(ERROR_UNKNOWN, e);
Timber.w(e, "Warning: exception caught in identify");
}

promise.resolve(null);
}
});

background.start();
}
}
Expand All@@ -652,7 +628,8 @@ public void getConnectionMode(String environment, Promise promise) {
try {
promise.resolve(LDClient.getForMobileKey(environment).getConnectionInformation().getConnectionMode().name());
} catch (Exception e) {
promise.reject(ERROR_UNKNOWN, e);
Timber.w(e, "Warning: exception caught in getConnectionMode");
promise.resolve(null);
}
}

Expand All@@ -661,7 +638,8 @@ public void getLastSuccessfulConnection(String environment, Promise promise) {
try {
promise.resolve(LDClient.getForMobileKey(environment).getConnectionInformation().getLastSuccessfulConnection().intValue());
} catch (Exception e) {
promise.reject(ERROR_UNKNOWN, e);
Timber.w(e, "Warning: exception caught in getLastSuccessfulConnection");
promise.resolve(0);
}
}

Expand All@@ -670,7 +648,8 @@ public void getLastFailedConnection(String environment, Promise promise) {
try {
promise.resolve(LDClient.getForMobileKey(environment).getConnectionInformation().getLastFailedConnection().intValue());
} catch (Exception e) {
promise.reject(ERROR_UNKNOWN, e);
Timber.w(e, "Warning: exception caught in getLastFailedConnection");
promise.resolve(0);
}
}

Expand All@@ -679,7 +658,8 @@ public void getLastFailure(String environment, Promise promise) {
try {
promise.resolve(LDClient.getForMobileKey(environment).getConnectionInformation().getLastFailure().getFailureType().name());
} catch (Exception e) {
promise.reject(ERROR_UNKNOWN, e);
Timber.w(e, "Warning: exception caught in getLastSuccessfulConnection");
promise.resolve(null);
}
}

Expand DownExpand Up@@ -707,7 +687,7 @@ public void onFeatureFlagChange(String flagKey) {
LDClient.getForMobileKey(environment).registerFeatureFlagListener(flagKey, listener);
listeners.put(flagKey, listener);
} catch (Exception e) {
Timber.w(e);
Timber.w(e, "Warning: exception caught in registerFeatureFlagListener");
}
}

Expand All@@ -720,7 +700,7 @@ public void unregisterFeatureFlagListener(String flagKey, String environment) {
listeners.remove(multiListenerId);
}
} catch (Exception e) {
Timber.w(e);
Timber.w(e, "Warning: exception caught in unregisterFeatureFlagListener");
}
}

Expand DownExpand Up@@ -748,7 +728,7 @@ public void onInternalFailure(LDFailure ldFailure) {
LDClient.getForMobileKey(environment).registerStatusListener(listener);
connectionModeListeners.put(multiListenerId, listener);
} catch (Exception e) {
Timber.w(e);
Timber.w(e, "Warning: exception caught in registerCurrentConnectionModeListener");
}
}

Expand All@@ -761,7 +741,7 @@ public void unregisterCurrentConnectionModeListener(String listenerId, String en
connectionModeListeners.remove(multiListenerId);
}
} catch (Exception e) {
Timber.w(e);
Timber.w(e, "Warning: exception caught in unregisterCurrentConnectionModeListener");
}
}

Expand All@@ -785,7 +765,7 @@ public void onChange(List<String> flagKeys) {
LDClient.getForMobileKey(environment).registerAllFlagsListener(listener);
allFlagsListeners.put(multiListenerId, listener);
} catch (Exception e) {
Timber.w(e);
Timber.w(e, "Warning: exception caught in registerAllFlagsListener");
}
}

Expand All@@ -798,7 +778,7 @@ public void unregisterAllFlagsListener(String listenerId, String environment) {
allFlagsListeners.remove(multiListenerId);
}
} catch (Exception e) {
Timber.w(e);
Timber.w(e, "Warning: exception caught in unregisterAllFlagsListener");
}
}

Expand Down
Loading