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

prepare 4.2.1 release #81

Merged
merged 26 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
67fb5ce
Removed the guides link
bwoskow-ld Feb 3, 2021
b6a113c
V4.0 (#68)
torchhound Apr 1, 2021
a193441
merge from public after release
LaunchDarklyCI Apr 1, 2021
510e581
Update iOS SDK dependency to fix Throttler behavior (#69)
torchhound Apr 7, 2021
0afc773
merge from public after release
LaunchDarklyCI Apr 7, 2021
9df202f
V4.1.0 (#72)
torchhound Apr 14, 2021
17e2d75
merge from public after release
LaunchDarklyCI Apr 14, 2021
35b61e1
Fixed jsonVariationDetail parsing on Android and fixed a typo in json…
torchhound Apr 16, 2021
fceade3
Merge branch 'master' of github.com:launchdarkly/react-native-client-sdk
bwoskow-ld Apr 23, 2021
82ba5fe
Releasing version 4.0.2
bwoskow-ld Apr 23, 2021
5489162
Merge branch 'v4.0.x-squashed' of github.com:launchdarkly/react-nativ…
bwoskow-ld Apr 23, 2021
ccc28c3
Merge branch 'master' of github.com:launchdarkly/react-native-client-sdk
bwoskow-ld Apr 24, 2021
c4a2891
Merge branch 'master' of github.com:launchdarkly/react-native-client-sdk
bwoskow-ld Apr 24, 2021
cae667b
Removes Typescript enums and replaces them with types that extend str…
torchhound Apr 28, 2021
f975de3
Releasing version 4.0.3
bwoskow-ld Apr 28, 2021
881c2fb
Merge branch 'v4.0.x-squashed'
bwoskow-ld Apr 28, 2021
b23e1c0
Merge branch 'master' of github.com:launchdarkly/react-native-client-…
bwoskow-ld Apr 28, 2021
c261c78
Merge branch 'master' of github.com:launchdarkly/react-native-client-sdk
bwoskow-ld Apr 28, 2021
5ad0499
Multi Environment (#65)
torchhound May 11, 2021
4ca1a1f
Add secondary user attribute (#76)
torchhound May 11, 2021
4a9530e
Merge branch 'master' of github.com:launchdarkly/react-native-client-sdk
bwoskow-ld May 11, 2021
81ae48d
Fix multi environment on restwrapper (#77)
torchhound May 19, 2021
0029ba5
merge from public after release
LaunchDarklyCI May 19, 2021
83640b7
[ch109800] Await Android client initialization. (#78)
gwhelanLD May 28, 2021
2668c2a
Update iOS method signature to match implementation (#79)
bwoskow-ld Jun 1, 2021
9703765
Merge remote-tracking branch 'public/master'
gwhelanLD Jun 1, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,11 @@ public void configureWithTimeout(ReadableMap config, ReadableMap user, Integer t

private void internalConfigure(ReadableMap config, ReadableMap user, final Integer timeout, final Promise promise) {
try {
if (LDClient.get() != null) {
promise.reject(ERROR_INIT, "Client was already initialized");
return;
}
} catch (LaunchDarklyException e) {
//This exception indicates that the SDK has not been initialized yet
} catch (Exception e) {
Timber.w(e);
promise.reject(ERROR_INIT, e);
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 LDConfig.Builder ldConfigBuilder = configBuild(config);
Expand Down Expand Up @@ -236,7 +231,11 @@ public void run() {
if (timeout != null) {
LDClient.init(application, ldConfigBuilder.build(), userBuilder.build(), timeout);
} else {
LDClient.init(application, ldConfigBuilder.build(), userBuilder.build());
try {
LDClient.init(application, ldConfigBuilder.build(), userBuilder.build()).get();
} catch (ExecutionException | InterruptedException e) {
Timber.e(e, "Exception during Client initialization");
}
}
promise.resolve(null);
}
Expand Down Expand Up @@ -605,13 +604,9 @@ private void resolveJsonElementDetail(Promise promise, EvaluationDetail<JsonElem
@ReactMethod
public void allFlags(String environment, Promise promise) {
try {
if (!LDClient.get().isInitialized()) {
promise.reject(ERROR_INIT, "Client is not yet initialized");
return;
}
} catch (Exception e) {
Timber.w(e);
promise.reject(ERROR_INIT, "Client is not yet initialized");
LDClient.get();
} catch (LaunchDarklyException e) {
promise.reject(ERROR_INIT, "SDK has been not configured");
return;
}

Expand Down Expand Up @@ -661,7 +656,11 @@ public void allFlags(String environment, Promise promise) {
}
}
promise.resolve(response);
} 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);
}
}
Expand Down
37 changes: 21 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@ export default class LDClient {
}

configure(config, user, timeout) {
if (this.isInitialized() == true) {
Promise.reject('LaunchDarkly SDK already initialized');
}
const configWithOverriddenDefaults = Object.assign({
backgroundPollingIntervalMillis: 3600000, // the iOS SDK defaults this to 900000
disableBackgroundUpdating: false, // the iOS SDK defaults this to true
pollUri: 'https://clientsdk.launchdarkly.com',
wrapperName: 'react-native-client-sdk',
wrapperVersion: this.getVersion()
}, config);

if (timeout == undefined) {
return LaunchdarklyReactNativeClient.configure(configWithOverriddenDefaults, this._addUserOverrides(user));
} else {
return LaunchdarklyReactNativeClient.configureWithTimeout(configWithOverriddenDefaults, this._addUserOverrides(user), timeout);
}
return LaunchdarklyReactNativeClient.isInitialized("default")
.then(
ignored => {
throw new Error('LaunchDarkly SDK already initialized');
},
() => {
const configWithOverriddenDefaults = Object.assign({
backgroundPollingIntervalMillis: 3600000, // the iOS SDK defaults this to 900000
disableBackgroundUpdating: false, // the iOS SDK defaults this to true
pollUri: 'https://clientsdk.launchdarkly.com',
wrapperName: 'react-native-client-sdk',
wrapperVersion: this.getVersion()
}, config);

if (timeout == undefined) {
return LaunchdarklyReactNativeClient.configure(configWithOverriddenDefaults, this._addUserOverrides(user));
} else {
return LaunchdarklyReactNativeClient.configureWithTimeout(configWithOverriddenDefaults, this._addUserOverrides(user), timeout);
}
}
);
}

boolVariation(flagKey, defaultValue, environment) {
Expand Down
7 changes: 5 additions & 2 deletions ios/LaunchdarklyReactNativeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class LaunchdarklyReactNativeClient: RCTEventEmitter {
private let CONNECTION_MODE_PREFIX = "LaunchDarkly-Connection-Mode-"
private let ERROR_INIT = "E_INITIALIZE"
private let ERROR_IDENTIFY = "E_IDENTIFY"
private let ERROR_UNKNOWN = "E_UNKNOWN"

override func supportedEvents() -> [String]! {
return [FLAG_PREFIX, ALL_FLAGS_PREFIX, CONNECTION_MODE_PREFIX]
Expand Down Expand Up @@ -605,9 +606,11 @@ class LaunchdarklyReactNativeClient: RCTEventEmitter {

@objc func isInitialized(_ environment: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
if LDClient.get() == nil {
resolve(false)
reject(ERROR_UNKNOWN, "SDK has not been configured", nil)
} else if let client = LDClient.get(environment: environment) {
resolve(client.isInitialized)
} else {
resolve(LDClient.get(environment: environment)!.isInitialized)
reject(ERROR_UNKNOWN, "SDK not configured with requested environment", nil)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ios/LaunchdarklyReactNativeClientBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ @interface RCT_EXTERN_MODULE(LaunchdarklyReactNativeClient, RCTEventEmitter)

RCT_EXTERN_METHOD(configure:(NSDictionary *)config user:(NSDictionary *)user resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(configureWithTimeout:(NSDictionary *)config userConfig:(NSDictionary *)userConfig timeout:(NSInteger *)timeout resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(configureWithTimeout:(NSDictionary *)config user:(NSDictionary *)user timeout:(NSInteger *)timeout resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(boolVariationDefaultValue:(NSString *)flagKey defaultValue:(BOOL *)defaultValue environment:(NSString *)environment resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)

Expand Down