Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit 6083c96

Browse files
committed
Merge branch 'master' into contrib
2 parents 44c196b + 466aa1e commit 6083c96

File tree

16 files changed

+2028
-218
lines changed

16 files changed

+2028
-218
lines changed

.circleci/config.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
ios:
3838
macos:
39-
xcode: "10.2.1"
39+
xcode: "11.4"
4040
steps:
4141
- checkout
4242

@@ -48,9 +48,19 @@ jobs:
4848
- run: cp -r ../project/ ../hello-react-native/node_modules/launchdarkly-react-native-client-sdk/
4949
- run: cd ../hello-react-native && react-native run-ios --configuration Release --simulator rn-ios
5050

51+
common:
52+
docker:
53+
- image: circleci/node:11.10.1
54+
steps:
55+
- checkout
56+
57+
- run: npm install
58+
- run: npm run check-typescript
59+
5160
workflows:
5261
version: 2
5362
android-ios:
5463
jobs:
5564
- android
56-
- ios
65+
- ios
66+
- common

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ build/
3737
.gradle
3838
local.properties
3939
*.iml
40+
org.eclipse*
41+
android/.project
42+
android/.classpath
4043

4144
# BUCK
4245
buck-out/
4346
\.buckd/
4447
*.keystore
4548

49+
# Auto-generated
50+
test-types.js

.ldrelease/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ template:
1111
skip:
1212
- test
1313

14+
documentation:
15+
githubPages: true
16+
title: LaunchDarkly Client-Side SDK for React Native
17+
1418
sdk:
1519
displayName: React Native

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,37 @@
22

33
All notable changes to the LaunchDarkly React Native SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [3.1.0] - 2020-04-01
6+
### Changed:
7+
- The SDK is now compatible with React Native version 0.62.x and React version 16.11.x
8+
9+
## [3.0.2] - 2020-03-31
10+
### Changed:
11+
- Updated SDK code to build, run, and test on Xcode 11.4.
12+
13+
## [3.0.1] - 2020-02-26
14+
### Added:
15+
- Generated TypeDoc documentation for all types, properties, and methods is now available online at https://launchdarkly.github.io/react-native-client-sdk/. Currently this will only be for the latest released version.
16+
17+
### Fixed:
18+
- Fixed some incorrect and incomplete typedoc comments.
19+
20+
21+
## [3.0.0] - 2020-02-20
22+
### Added:
23+
- Added TypeScript type definitions (thanks, [eeynard](https://github.com/launchdarkly/react-native-client-sdk/pull/32)!)
24+
- Added TypeDoc comments
25+
- The SDK now specifies a uniquely identifiable request header when sending events to LaunchDarkly to ensure that events are only processed once, even if the SDK sends them two times due to a failed initial attempt.
26+
27+
### Changed:
28+
- Changed the default value for the `anonymous` user property has been changed to `false`. Previously this default was inconsistent; the default value was `true` when running in iOS and `false` when running in Android.
29+
- Changed the default value for the `backgroundPollingIntervalMillis` SDK configuration property has been changed to `3600000` (one hour). Previously this default was inconsistent; the default value was `900000` (15 minutes) when running in iOS and `3600000` (one hour) when running in Android.
30+
- Changed the default value for the `disableBackgroundUpdating ` SDK configuration property has been changed to `false`. Previously this default was inconsistent; the default value was `true` when running in iOS and `false` when running in Android.
31+
32+
### Fixed:
33+
- Fixed the `*VariationDetail` methods so that they now always return a promise containing the variation detail information. Previously, when running in Android, this promise would have instead contained just the variation value if the underlying process threw an exception.
34+
- Fixed an issue where React Native apps could crash after reloading when running in iOS (thanks, [shercoder](https://github.com/launchdarkly/react-native-client-sdk/pull/39)!)
35+
536
## [2.2.0] - 2020-01-24
637
### Added:
738
- Adds `evaluationReasons` configuration option.

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Contributing to the LaunchDarkly Client-side SDK for React Native
1+
Contributing to the LaunchDarkly Client-Side SDK for React Native
22
================================================
33

4-
LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this SDK.
4+
LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/sdk/concepts/contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this SDK.
55

66
Submitting bug reports and feature requests
77
------------------

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
LaunchDarkly Client-side SDK for React Native
1+
LaunchDarkly Client-Side SDK for React Native
22
===========================
33

44
[![CircleCI](https://circleci.com/gh/launchdarkly/react-native-client-sdk.svg?style=svg)](https://circleci.com/gh/launchdarkly/react-native-client-sdk)
55

66
LaunchDarkly overview
77
-------------------------
8-
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/docs/getting-started) using LaunchDarkly today!
8+
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
99

1010
[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)
1111

1212
Supported versions
1313
-------------------------
1414

15-
This SDK is compatible with React Native 0.61.2 and Xcode 10.2.1 and is tested in Android 27 and iOS 12.4. Earlier versions of this SDK are compatible with prior versions of React Native, Android, and iOS.
15+
This SDK is compatible with React Native 0.62.x and Xcode 11.4 and is tested in Android 27 and iOS 12.4. Earlier versions of this SDK are compatible with prior versions of React Native, Android, and iOS.
1616

1717
Getting started
1818
---------------
1919

20-
Refer to the [SDK documentation](https://docs.launchdarkly.com/docs/react-native-sdk-reference#section-getting-started) for instructions on getting started with using the SDK.
20+
Refer to the [SDK documentation](https://docs.launchdarkly.com/sdk/client-side/react-native#getting-started) for instructions on getting started with using the SDK.
2121

2222
Learn more
2323
-----------
2424

25-
Check out our [documentation](https://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/docs/react-native-sdk-reference).
25+
Check out our [documentation](https://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/client-side/react-native).
2626

2727
Testing
2828
-------
@@ -42,10 +42,10 @@ About LaunchDarkly
4242
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
4343
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
4444
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
45-
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/docs) for a complete list.
45+
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com) for a complete list.
4646
* Explore LaunchDarkly
4747
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
4848
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
4949
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
5050
* [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
51-
* [Feature Flagging Guide](https://github.com/launchdarkly/featureflags/ "Feature Flagging Guide") for best practices and strategies
51+
* [Feature Flagging Guide](https://github.com/launchdarkly/featureflags/ "Feature Flagging Guide") for best practices and strategies

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ allprojects {
4848

4949
dependencies {
5050
implementation 'com.facebook.react:react-native:+'
51-
implementation 'com.launchdarkly:launchdarkly-android-client-sdk:2.9.0'
51+
implementation 'com.launchdarkly:launchdarkly-android-client-sdk:2.10.0'
5252
implementation 'com.jakewharton.timber:timber:4.7.1'
5353
implementation "com.google.code.gson:gson:2.8.5"
5454
}

android/src/main/java/com/launchdarkly/reactnative/LaunchdarklyReactNativeClientModule.java

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.launchdarkly.android.LDStatusListener;
3535
import com.launchdarkly.android.LDAllFlagsListener;
3636
import com.launchdarkly.android.EvaluationDetail;
37+
import com.launchdarkly.android.EvaluationReason;
3738
import com.launchdarkly.android.LDFailure;
3839

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

566567
@ReactMethod
567568
public void boolVariationDetailFallback(String flagKey, Boolean fallback, Promise promise) {
569+
EvaluationDetail<Boolean> detailResult;
568570
try {
569-
EvaluationDetail<Boolean> detailResult = ldClient.boolVariationDetail(flagKey, fallback);
570-
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
571-
WritableMap detailMap = fromJsonObject(jsonObject);
572-
promise.resolve(detailMap);
571+
detailResult = ldClient.boolVariationDetail(flagKey, fallback);
573572
} catch (Exception e) {
574-
promise.resolve(fallback);
573+
e.printStackTrace();
574+
detailResult = new EvaluationDetail<Boolean>(EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION), null, fallback);
575575
}
576+
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
577+
WritableMap detailMap = fromJsonObject(jsonObject);
578+
promise.resolve(detailMap);
576579
}
577580

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

583586
@ReactMethod
584587
public void intVariationDetailFallback(String flagKey, Integer fallback, Promise promise) {
588+
EvaluationDetail<Integer> detailResult;
585589
try {
586-
EvaluationDetail<Integer> detailResult = ldClient.intVariationDetail(flagKey, fallback);
587-
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
588-
WritableMap detailMap = fromJsonObject(jsonObject);
589-
promise.resolve(detailMap);
590+
detailResult = ldClient.intVariationDetail(flagKey, fallback);
590591
} catch (Exception e) {
591-
promise.resolve(fallback);
592+
e.printStackTrace();
593+
detailResult = new EvaluationDetail<Integer>(EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION), null, fallback);
592594
}
595+
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
596+
WritableMap detailMap = fromJsonObject(jsonObject);
597+
promise.resolve(detailMap);
593598
}
594599

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

600605
@ReactMethod
601606
public void floatVariationDetailFallback(String flagKey, Float fallback, Promise promise) {
607+
EvaluationDetail<Float> detailResult;
602608
try {
603-
EvaluationDetail<Float> detailResult = ldClient.floatVariationDetail(flagKey, fallback);
604-
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
605-
WritableMap detailMap = fromJsonObject(jsonObject);
606-
promise.resolve(detailMap);
609+
detailResult = ldClient.floatVariationDetail(flagKey, fallback);
607610
} catch (Exception e) {
608-
promise.resolve(fallback);
611+
e.printStackTrace();
612+
detailResult = new EvaluationDetail<Float>(EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION), null, fallback);
609613
}
614+
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
615+
WritableMap detailMap = fromJsonObject(jsonObject);
616+
promise.resolve(detailMap);
610617
}
611618

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

617624
@ReactMethod
618625
public void stringVariationDetailFallback(String flagKey, String fallback, Promise promise) {
626+
EvaluationDetail<String> detailResult;
619627
try {
620-
EvaluationDetail<String> detailResult = ldClient.stringVariationDetail(flagKey, fallback);
621-
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
622-
WritableMap detailMap = fromJsonObject(jsonObject);
623-
promise.resolve(detailMap);
628+
detailResult = ldClient.stringVariationDetail(flagKey, fallback);
624629
} catch (Exception e) {
625-
promise.resolve(fallback);
630+
e.printStackTrace();
631+
detailResult = new EvaluationDetail<String>(EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION), null, fallback);
626632
}
633+
JsonObject jsonObject = gson.toJsonTree(detailResult).getAsJsonObject();
634+
WritableMap detailMap = fromJsonObject(jsonObject);
635+
promise.resolve(detailMap);
627636
}
628637

629638
@ReactMethod
@@ -673,12 +682,14 @@ private void jsonVariationBase(String flagKey, JsonElement fallback, Promise pro
673682
}
674683

675684
private void jsonVariationDetailBase(String flagKey, JsonElement fallback, Promise promise) {
685+
EvaluationDetail<JsonElement> jsonElementDetail;
676686
try {
677-
EvaluationDetail<JsonElement> jsonElementDetail = ldClient.jsonVariationDetail(flagKey, fallback);
678-
resolveJsonElementDetail(promise, jsonElementDetail);
687+
jsonElementDetail = ldClient.jsonVariationDetail(flagKey, fallback);
679688
} catch (Exception e) {
680-
resolveJsonElement(promise, fallback);
689+
e.printStackTrace();
690+
jsonElementDetail = new EvaluationDetail<JsonElement>(EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION), null, fallback);
681691
}
692+
resolveJsonElementDetail(promise, jsonElementDetail);
682693
}
683694

684695

0 commit comments

Comments
 (0)