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

Commit 016655a

Browse files
authored
Merge pull request #135 from launchdarkly/yus/sc-184207/react-native-client-sdk-add-support-for-application
[sc-184207] Support for application tags
2 parents f9ee647 + 731ee16 commit 016655a

File tree

10 files changed

+99
-38
lines changed

10 files changed

+99
-38
lines changed

.circleci/config.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ jobs:
4949
mkdir -p test
5050
cd test
5151
[ -d "CITest" ] || npx react-native@<<parameters.rn-version>> init CITest --version <<parameters.rn-version>> --skip-install
52+
53+
# HACK: rn 0.64.x init the test project targeting ios 10, which is incompatible with the ios SDK which requires
54+
# a minimum of ios 11
55+
sed -i.bak "s/platform :ios, '10.0'/platform :ios, '11.0'/" CITest/ios/Podfile
56+
sed -i.bak "s/IPHONEOS_DEPLOYMENT_TARGET = 10.0;/IPHONEOS_DEPLOYMENT_TARGET = 11.0;/" CITest/ios/CITest.xcodeproj/project.pbxproj
57+
58+
#HACK: force rn android 0.64.x init to use minSdkVersion 30 to pass the build
59+
sed -i.bak 's/buildToolsVersion = "29.0.3"/buildToolsVersion = "30.0.2"/' CITest/android/build.gradle
60+
sed -i.bak "s/compileSdkVersion = 29/compileSdkVersion = 31/" CITest/android/build.gradle
61+
sed -i.bak "s/targetSdkVersion = 29/targetSdkVersion = 31/" CITest/android/build.gradle
5262
5363
- save_cache:
5464
name: Save RN project template to cache
@@ -141,12 +151,12 @@ workflows:
141151
name: rn<<matrix.rn-version>>-xc<<matrix.xcode-version>>-build-apps-using-template
142152
matrix:
143153
parameters:
144-
rn-version: ["0.64.3", "0.65.2", "0.66.4", "0.67.3", "0.68.0","0.69.4", "0.70.1"]
145-
xcode-version: ["12.5.1", "13.2.1", "13.4.1", "14.0.1"]
154+
rn-version: [ "0.64.4", "0.65.2", "0.66.4", "0.67.3", "0.68.0","0.69.4", "0.70.1" ]
155+
xcode-version: [ "12.5.1", "13.2.1", "13.4.1", "14.0.1" ]
146156
exclude:
147-
- rn-version: "0.64.3"
157+
- rn-version: "0.64.4"
148158
xcode-version: "13.4.1"
149-
- rn-version: "0.64.3"
159+
- rn-version: "0.64.4"
150160
xcode-version: "14.0.1"
151161
- rn-version: "0.65.2"
152162
xcode-version: "13.4.1"

ManualTestApp/android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = "30.0.2"
65
minSdkVersion = 21
76
compileSdkVersion = 30
87
targetSdkVersion = 30
@@ -13,7 +12,7 @@ buildscript {
1312
mavenCentral()
1413
}
1514
dependencies {
16-
classpath("com.android.tools.build:gradle:4.2.2")
15+
classpath('com.android.tools.build:gradle:7.4.0')
1716
// NOTE: Do not place your application dependencies here; they belong
1817
// in the individual module build.gradle files
1918
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

ManualTestApp/ios/Podfile.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ PODS:
7272
- FlipperKit/FlipperKitNetworkPlugin
7373
- fmt (6.2.1)
7474
- glog (0.3.5)
75-
- LaunchDarkly (6.1.0):
76-
- LaunchDarkly/Core (= 6.1.0)
75+
- LaunchDarkly (7.1.0):
76+
- LaunchDarkly/Core (= 7.1.0)
7777
- launchdarkly-react-native-client-sdk (6.2.4):
78-
- LaunchDarkly (= 6.1.0)
78+
- LaunchDarkly (= 7.1.0)
7979
- React-Core
80-
- LaunchDarkly/Core (6.1.0):
81-
- LDSwiftEventSource (= 1.3.1)
82-
- LDSwiftEventSource (1.3.1)
80+
- LaunchDarkly/Core (7.1.0):
81+
- LDSwiftEventSource (= 3.0.0)
82+
- LDSwiftEventSource (3.0.0)
8383
- libevent (2.1.12)
8484
- OpenSSL-Universal (1.1.180)
8585
- RCT-Folly (2021.06.28.00-v2):
@@ -510,13 +510,13 @@ SPEC CHECKSUMS:
510510
Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541
511511
FlipperKit: d8d346844eca5d9120c17d441a2f38596e8ed2b9
512512
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
513-
glog: 85ecdd10ee8d8ec362ef519a6a45ff9aa27b2e85
514-
LaunchDarkly: 44e1728319bd7693a2a619561a8237187406b920
515-
launchdarkly-react-native-client-sdk: c7ad1b9af7c33b2af5eac2a536756b4af0135773
516-
LDSwiftEventSource: 1ac1b0986a07c5fe4f2c94d87f1d41f4de6ae727
513+
glog: bbaccdf9af7ec106ed6f0eb086217dc2bf37414c
514+
LaunchDarkly: 31da8b77e96cb744417208478bb5b24f35fd2491
515+
launchdarkly-react-native-client-sdk: d40d2a6c7d6e578c6bc528c403e8f94b2cd02ffa
516+
LDSwiftEventSource: 824ce51a4fa8e79498c9b67ae672bfa802bd7464
517517
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
518518
OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b
519-
RCT-Folly: 803a9cfd78114b2ec0f140cfa6fa2a6bafb2d685
519+
RCT-Folly: 19dac003a3f572f05a3b77277df72906a73469f1
520520
RCTRequired: cd47794163052d2b8318c891a7a14fcfaccc75ab
521521
RCTTypeSafety: 393bb40b3e357b224cde53d3fec26813c52428b1
522522
React: dec6476bc27155b250eeadfc11ea779265f53ebf

android/build.gradle

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:4.2.2'
8+
classpath 'com.android.tools.build:gradle:7.4.0'
99
}
1010
}
1111

@@ -22,9 +22,11 @@ android {
2222
versionName = "1.0"
2323
consumerProguardFiles("consumer-proguard-rules.pro")
2424
}
25+
2526
lintOptions {
2627
abortOnError false
2728
}
29+
2830
compileOptions {
2931
sourceCompatibility JavaVersion.VERSION_1_8
3032
targetCompatibility JavaVersion.VERSION_1_8
@@ -33,6 +35,22 @@ android {
3335

3436
allprojects {
3537
repositories {
38+
// Ripped from https://stackoverflow.com/questions/74333787/react-native-2-files-found-with-path-lib-arm64-v8a-libfbjni-so-from-inputs
39+
exclusiveContent {
40+
// We get React Native's Android binaries exclusively through npm,
41+
// from a local Maven repo inside node_modules/react-native/.
42+
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
43+
// and potentially getting a wrong version.)
44+
filter {
45+
includeGroup "com.facebook.react"
46+
}
47+
forRepository {
48+
maven {
49+
url "$rootDir/../node_modules/react-native/android"
50+
}
51+
}
52+
}
53+
3654
mavenLocal()
3755
google()
3856
mavenCentral()
@@ -45,7 +63,7 @@ allprojects {
4563

4664
dependencies {
4765
implementation("com.facebook.react:react-native:+")
48-
implementation("com.launchdarkly:launchdarkly-android-client-sdk:3.2.0")
66+
implementation("com.launchdarkly:launchdarkly-android-client-sdk:3.6.0")
4967
implementation("com.jakewharton.timber:timber:5.0.1")
5068
implementation("com.google.code.gson:gson:2.8.9")
5169
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Thu Jan 26 10:47:00 PST 2023
12
distributionBase=GRADLE_USER_HOME
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
24
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4-
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6+
zipStoreBase=GRADLE_USER_HOME

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

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.launchdarkly.sdk.LDValue;
2929
import com.launchdarkly.sdk.ObjectBuilder;
3030
import com.launchdarkly.sdk.UserAttribute;
31+
import com.launchdarkly.sdk.android.Components;
3132
import com.launchdarkly.sdk.android.ConnectionInformation;
3233
import com.launchdarkly.sdk.android.FeatureFlagChangeListener;
3334
import com.launchdarkly.sdk.android.LDAllFlagsListener;
@@ -36,6 +37,7 @@
3637
import com.launchdarkly.sdk.android.LDFailure;
3738
import com.launchdarkly.sdk.android.LDStatusListener;
3839
import com.launchdarkly.sdk.android.LaunchDarklyException;
40+
import com.launchdarkly.sdk.android.integrations.ApplicationInfoBuilder;
3941

4042
import org.jetbrains.annotations.NotNull;
4143

@@ -51,7 +53,6 @@
5153
import timber.log.Timber;
5254

5355
public class LaunchdarklyReactNativeClientModule extends ReactContextBaseJavaModule {
54-
5556
private static final Gson gson = new Gson();
5657
private static final String ERROR_INIT = "E_INITIALIZE";
5758
private static final String ERROR_IDENTIFY = "E_IDENTIFY";
@@ -64,6 +65,7 @@ public class LaunchdarklyReactNativeClientModule extends ReactContextBaseJavaMod
6465
private final Map<String, FeatureFlagChangeListener> listeners = new HashMap<>();
6566
private final Map<String, LDStatusListener> connectionModeListeners = new HashMap<>();
6667
private final Map<String, LDAllFlagsListener> allFlagsListeners = new HashMap<>();
68+
6769
public LaunchdarklyReactNativeClientModule(ReactApplicationContext reactContext) {
6870
super(reactContext);
6971
}
@@ -252,13 +254,6 @@ private void internalConfigure(ReadableMap config, ReadableMap user, final Integ
252254

253255
final LDConfig.Builder ldConfigBuilder = configBuild(config);
254256
final LDUser ldUser = userBuild(user).build();
255-
256-
if (config.hasKey("allUserAttributesPrivate")
257-
&& config.getType("allUserAttributesPrivate").equals(ConfigEntryType.Boolean.getReadableType())
258-
&& config.getBoolean("allUserAttributesPrivate")) {
259-
ldConfigBuilder.allAttributesPrivate();
260-
}
261-
262257
final Application application = (Application) getReactApplicationContext().getApplicationContext();
263258

264259
if (application != null) {
@@ -285,14 +280,37 @@ public void run() {
285280
}
286281
}
287282

288-
private LDConfig.Builder configBuild(ReadableMap options) {
289-
LDConfig.Builder builder = new LDConfig.Builder();
283+
private LDConfig.Builder configBuild(ReadableMap config) {
284+
LDConfig.Builder ldConfigBuilder = new LDConfig.Builder();
290285

286+
// build trivial config options
291287
for (ConfigMapping entry : ConfigMapping.values()) {
292-
entry.loadFromMap(options, builder);
288+
entry.loadFromMap(config, ldConfigBuilder);
289+
}
290+
291+
// build application tags
292+
if (config.hasKey("application") && config.getType("application") == ReadableType.Map) {
293+
ReadableMap application = config.getMap("application");
294+
ApplicationInfoBuilder applicationInfoBuilder = Components.applicationInfo();
295+
296+
if (application.hasKey("id") && application.getType("id") == ReadableType.String) {
297+
applicationInfoBuilder.applicationId(application.getString("id"));
298+
}
299+
if (application.hasKey("version") && application.getType("version") == ReadableType.String) {
300+
applicationInfoBuilder.applicationVersion(application.getString("version"));
301+
}
302+
303+
ldConfigBuilder.applicationInfo(applicationInfoBuilder);
304+
}
305+
306+
// build private user attributes
307+
if (config.hasKey("allUserAttributesPrivate")
308+
&& config.getType("allUserAttributesPrivate").equals(ConfigEntryType.Boolean.getReadableType())
309+
&& config.getBoolean("allUserAttributesPrivate")) {
310+
ldConfigBuilder.allAttributesPrivate();
293311
}
294312

295-
return builder;
313+
return ldConfigBuilder;
296314
}
297315

298316
private LDUser.Builder userBuild(ReadableMap options) {

ios/LaunchdarklyReactNativeClient.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ class LaunchdarklyReactNativeClient: RCTEventEmitter {
9797
try! ldConfig.setSecondaryMobileKeys(val)
9898
}
9999

100+
if let c = config["application"] as? [String: String] {
101+
var applicationInfo = ApplicationInfo()
102+
103+
if let applicationId = c["id"] {
104+
applicationInfo.applicationIdentifier(applicationId)
105+
}
106+
107+
if let applicationVersion = c["version"] {
108+
applicationInfo.applicationVersion(applicationVersion)
109+
}
110+
111+
ldConfig.applicationInfo = applicationInfo
112+
}
113+
100114
return ldConfig
101115
}
102116

ios/LaunchdarklyReactNativeClient.xcodeproj/project.pbxproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
developmentRegion = English;
9393
hasScannedForEncodings = 0;
9494
knownRegions = (
95+
English,
9596
en,
9697
);
9798
mainGroup = 58B511D21A9E6C8500147676;
@@ -169,7 +170,7 @@
169170
"$(SRCROOT)/../../../React/**",
170171
"$(SRCROOT)/../../react-native/React/**",
171172
);
172-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
173+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
173174
MTL_ENABLE_DEBUG_INFO = YES;
174175
ONLY_ACTIVE_ARCH = YES;
175176
SDKROOT = iphoneos;
@@ -220,7 +221,7 @@
220221
"$(SRCROOT)/../../../React/**",
221222
"$(SRCROOT)/../../react-native/React/**",
222223
);
223-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
224+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
224225
MTL_ENABLE_DEBUG_INFO = NO;
225226
SDKROOT = iphoneos;
226227
SWIFT_COMPILATION_MODE = wholemodule;

launchdarkly-react-native-client-sdk.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ Pod::Spec.new do |s|
99
s.homepage = package["homepage"]
1010
s.license = { :type => "Apache-2.0", :file => "LICENSE" }
1111
s.author = { "author" => "[email protected]" }
12-
s.platform = :ios, "10.0"
12+
s.platform = :ios, "11.0"
1313
s.source = { :git => "https://github.com/launchdarkly/react-native-client-sdk.git", :tag => s.version }
1414
s.source_files = "ios/**/*.{h,m,swift}"
1515
s.swift_version = "5.0"
1616

1717
s.dependency "React-Core"
18-
s.dependency "LaunchDarkly", "6.1.0"
18+
s.dependency "LaunchDarkly", "7.1.0"
1919

2020
end

0 commit comments

Comments
 (0)