Skip to content

Commit

Permalink
2.16.0 (#108)
Browse files Browse the repository at this point in the history
* updating versions

* addding init timeout to dart

* add to android and testing

* adding for ios

* formatting

* fixing tests
  • Loading branch information
uc-franciscocunha authored Sep 4, 2024
1 parent a66e7c5 commit 11ef15a
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[Release Notes](https://docs.usercentrics.com/cmp_in_app_sdk/latest/about/history/)

### 2.16.0 - September 4, 2024

## Features

* New timeout mode - In this version, you are able to customize the global timeout for the maximum amount of time that the SDK should take to fully initialize, just set the new parameter on the [UsercentricsOptions](https://usercentrics.com/docs/apps/api/core-api/#usercentricsoptions)

### 2.15.6 - August 14, 2024

## Other Fixes
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def usercentrics_version = "2.15.6"
def usercentrics_version = "2.16.0"

group 'com.usercentrics.sdk.flutter'
version usercentrics_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ internal fun Any?.deserializeOptions(): UsercentricsOptions {
this["consentMediation"]?.let {
options.consentMediation = it as Boolean
}
this["initTimeoutMillis"]?.let {
options.initTimeoutMillis = (it as Int).toLong()
}
return options
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ class InitializeBridgeUnitTest {
InitializeMock.callWithDataNetworkMode,
usercentricsProxy.initializeOptionsArgument?.networkMode
)
assertEquals(
InitializeMock.callWithDataInitTimeoutMillis,
usercentricsProxy.initializeOptionsArgument?.initTimeoutMillis
)
assertEquals(1, result.successCount)
assertEquals(InitializeMock.expected, result.successResultArgument)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal object InitializeMock {
"timeoutMillis" to 1000,
"version" to "1.2.3",
"networkMode" to "EU",
"initTimeoutMillis" to 1500,
)
)
val callWithDataSettingsId = "AAAAA"
Expand All @@ -26,6 +27,7 @@ internal object InitializeMock {
val callWithDataTimeoutMillis = 1000L
val callWithDataVersion = "1.2.3"
val callWithDataNetworkMode = NetworkMode.EU
val callWithDataInitTimeoutMillis = 1500L
val callWithoutData = FakeFlutterMethodCall(
method = "initialize",
arguments = mapOf(
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PODS:
- Flutter (1.0.0)
- Usercentrics (2.15.6)
- usercentrics_sdk (2.15.6):
- Usercentrics (2.16.0)
- usercentrics_sdk (2.16.0):
- Flutter
- UsercentricsUI (= 2.15.6)
- UsercentricsUI (2.15.6):
- Usercentrics (= 2.15.6)
- UsercentricsUI (= 2.16.0)
- UsercentricsUI (2.16.0):
- Usercentrics (= 2.16.0)
- webview_flutter_wkwebview (0.0.1):
- Flutter

Expand Down
4 changes: 4 additions & 0 deletions example/ios/RunnerTests/Bridge/InitializeBridgeTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class InitializeBridgeTest: XCTestCase, BaseBridgeTestProtocol {
XCTAssertEqual(self.usercentrics.configureOptions?.ruleSetId, "BBBBB")
XCTAssertEqual(self.usercentrics.configureOptions?.loggerLevel, .debug)
XCTAssertEqual(self.usercentrics.configureOptions?.timeoutMillis, 1000)
XCTAssertEqual(self.usercentrics.configureOptions?.initTimeoutMillis, 1500)
XCTAssertEqual(self.usercentrics.configureOptions?.version, "1.2.3")
XCTAssertEqual(self.usercentrics.configureOptions?.networkMode, .eu)

Expand All @@ -49,6 +50,7 @@ class InitializeBridgeTest: XCTestCase, BaseBridgeTestProtocol {
"ruleSetId": "BBBBB",
"loggerLevel": "DEBUG",
"timeoutMillis": 1000,
"initTimeoutMillis": 1500,
"version": "1.2.3",
"networkMode": "EU"
]
Expand All @@ -68,6 +70,7 @@ class InitializeBridgeTest: XCTestCase, BaseBridgeTestProtocol {
XCTAssertEqual(self.usercentrics.configureOptions?.settingsId, "AAAAA")
XCTAssertEqual(self.usercentrics.configureOptions?.loggerLevel, .debug)
XCTAssertEqual(self.usercentrics.configureOptions?.timeoutMillis, 1000)
XCTAssertEqual(self.usercentrics.configureOptions?.initTimeoutMillis, 1500)
XCTAssertEqual(self.usercentrics.configureOptions?.version, "1.2.3")

expectation.fulfill()
Expand All @@ -78,6 +81,7 @@ class InitializeBridgeTest: XCTestCase, BaseBridgeTestProtocol {
"settingsId": "AAAAA",
"loggerLevel": "DEBUG",
"timeoutMillis": 1000,
"initTimeoutMillis": 1500,
"version": "1.2.3"
]

Expand Down
1 change: 1 addition & 0 deletions example/test/fake_usercentrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class FakeUsercentrics extends UsercentricsPlatform {
String? version,
NetworkMode? networkMode,
bool? consentMediation,
int? initTimeoutMillis,
}) {
initializeCount++;
}
Expand Down
4 changes: 4 additions & 0 deletions ios/Classes/Serializer/InitializeOptionsSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ extension UsercentricsOptions {
options.networkMode = networkMode
}
}

if let initTimeoutMillis = dict["initTimeoutMillis"] as? Int {
options.initTimeoutMillis = Int64(initTimeoutMillis)
}

return options
}
Expand Down
2 changes: 1 addition & 1 deletion ios/usercentrics_sdk.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'usercentrics_sdk'
s.version = '2.15.6'
s.version = '2.16.0'
s.summary = 'Usercentrics Flutter SDK.'
s.description = <<-DESC
Usercentrics Flutter SDK.
Expand Down
3 changes: 3 additions & 0 deletions lib/src/internal/bridge/initialize_bridge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ abstract class InitializeBridge {
String? version,
NetworkMode? networkMode,
bool? consentMediation,
int? initTimeoutMillis,
});
}

Expand All @@ -35,6 +36,7 @@ class MethodChannelInitialize extends InitializeBridge {
String? version,
NetworkMode? networkMode,
bool? consentMediation,
int? initTimeoutMillis,
}) {
final arguments = InitializeOptionsSerializer.serialize(
settingsId: settingsId,
Expand All @@ -45,6 +47,7 @@ class MethodChannelInitialize extends InitializeBridge {
version: version,
networkMode: networkMode,
consentMediation: consentMediation,
initTimeoutMillis: initTimeoutMillis,
);
channel.invokeMethod(_name, arguments);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/src/internal/platform/method_channel_usercentrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class MethodChannelUsercentrics extends UsercentricsPlatform {
String? version,
NetworkMode? networkMode,
bool? consentMediation,
int? initTimeoutMillis,
}) async {
final ongoingInit = isReadyCompleter;

Expand All @@ -94,7 +95,8 @@ class MethodChannelUsercentrics extends UsercentricsPlatform {
timeoutMillis: timeoutMillis,
version: version,
networkMode: networkMode,
consentMediation: consentMediation);
consentMediation: consentMediation,
initTimeoutMillis: initTimeoutMillis);

status
.then((value) => isReadyCompleter?.complete(null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class InitializeOptionsSerializer {
String? version,
NetworkMode? networkMode,
bool? consentMediation,
int? initTimeoutMillis,
}) =>
{
'settingsId': settingsId,
Expand All @@ -23,6 +24,7 @@ class InitializeOptionsSerializer {
'timeoutMillis': timeoutMillis,
'version': version,
'networkMode': NetworkModeSerializer.serialize(networkMode),
'consentMediation': consentMediation
'consentMediation': consentMediation,
'initTimeoutMillis': initTimeoutMillis,
};
}
1 change: 1 addition & 0 deletions lib/src/platform/usercentrics_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract class UsercentricsPlatform {
String? version,
NetworkMode? networkMode,
bool? consentMediation,
int? initTimeoutMillis,
});

Future<UsercentricsReadyStatus> get status;
Expand Down
21 changes: 12 additions & 9 deletions lib/src/usercentrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Usercentrics {
/// - The [timeoutMillis] sets a timeout for network requests in milliseconds. The default value is 10000 milliseconds.
/// - The [version] freezes the configuration version shown to your users, you may pass a specific version here. E.g. "3.0.4". The default value is "latest".
/// - The [networkMode] sets the network operation mode. Be careful, use this option only if we have confirmed that it is ready to use because it has a significant impact on the whole system's performance. The default value is "world".
/// - The [consentMediation] enables the feature of consent mediation, this feature works with a set of selected SDKs that you can find in the documentation.
/// - The [initTimeoutMillis] sets a timeout for the SDK to initialize. Minimum value is 5000ms. The default value is 10000ms.
static void initialize({
String settingsId = "",
String ruleSetId = "",
Expand All @@ -34,17 +36,18 @@ class Usercentrics {
String? version,
NetworkMode? networkMode,
bool? consentMediation,
int? initTimeoutMillis,
}) =>
_delegate.initialize(
settingsId: settingsId,
ruleSetId: ruleSetId,
defaultLanguage: defaultLanguage,
loggerLevel: loggerLevel,
timeoutMillis: timeoutMillis,
version: version,
networkMode: networkMode,
consentMediation: consentMediation,
);
settingsId: settingsId,
ruleSetId: ruleSetId,
defaultLanguage: defaultLanguage,
loggerLevel: loggerLevel,
timeoutMillis: timeoutMillis,
version: version,
networkMode: networkMode,
consentMediation: consentMediation,
initTimeoutMillis: initTimeoutMillis);

/// {@template initialize}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository: https://github.com/Usercentrics/flutter-sdk/
# [X] android/build.gradle
# [X] ios/usercentrics_sdk.podspec + pod install/update
# [X] CHANGELOG.md
version: 2.15.6
version: 2.16.0

environment:
sdk: ">=2.17.1 <4.0.0"
Expand Down
3 changes: 3 additions & 0 deletions test/internal/bridge/fake_initialize_bridge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class FakeInitializeBridge extends InitializeBridge {
String? invokeVersionArgument;
NetworkMode? invokeNetworkModeArgument;
bool? invokeConsentMediationArgument;
int? invokeInitTimeoutMillisArgument;

@override
void invoke({
Expand All @@ -26,6 +27,7 @@ class FakeInitializeBridge extends InitializeBridge {
String? version,
NetworkMode? networkMode,
bool? consentMediation,
int? initTimeoutMillis,
}) {
invokeCount++;
invokeChannelArgument = channel;
Expand All @@ -37,5 +39,6 @@ class FakeInitializeBridge extends InitializeBridge {
invokeVersionArgument = version;
invokeNetworkModeArgument = networkMode;
invokeConsentMediationArgument = consentMediation;
invokeInitTimeoutMillisArgument = initTimeoutMillis;
}
}
7 changes: 5 additions & 2 deletions test/internal/bridge/initialize_bridge_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ void main() {
"version": "1.0.0",
"timeoutMillis": 20000,
"networkMode": "EU",
'consentMediation': true
'consentMediation': true,
"initTimeoutMillis": 25000
};
const mockSettingsId = 'Yi9N3aXia';
const mockRuleSetId = 'XXxXXXYYyyyYY';
const mockLoggerLevel = UsercentricsLoggerLevel.debug;
const mockVersion = "1.0.0";
const mockDefaultLanguage = "en";
const mockTimeoutMillis = 20000;
const mockInitTimeoutMillis = 25000;
const mockNetworkMode = NetworkMode.eu;
const mockConsentMediation = true;

Expand Down Expand Up @@ -54,7 +56,8 @@ void main() {
defaultLanguage: mockDefaultLanguage,
timeoutMillis: mockTimeoutMillis,
networkMode: mockNetworkMode,
consentMediation: mockConsentMediation);
consentMediation: mockConsentMediation,
initTimeoutMillis: mockInitTimeoutMillis);

expect(callCounter, 1);
expect(receivedCall?.method, 'initialize');
Expand Down
6 changes: 5 additions & 1 deletion test/internal/platform/method_channel_usercentrics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void main() {
const version = "1.1.1";
const networkMode = NetworkMode.eu;
const consentMediation = true;
const initTimeoutMillis = 7000;

instance.initialize(
settingsId: settingsId,
Expand All @@ -59,7 +60,8 @@ void main() {
timeoutMillis: timeoutMillis,
version: version,
networkMode: networkMode,
consentMediation: consentMediation);
consentMediation: consentMediation,
initTimeoutMillis: initTimeoutMillis);
await instance.isReadyCompleter?.future;

expect(initializeBridge.invokeCount, 1);
Expand All @@ -72,6 +74,8 @@ void main() {
expect(initializeBridge.invokeVersionArgument, version);
expect(initializeBridge.invokeNetworkModeArgument, networkMode);
expect(initializeBridge.invokeConsentMediationArgument, consentMediation);
expect(
initializeBridge.invokeInitTimeoutMillisArgument, initTimeoutMillis);

expect(isReadyBridge.invokeCount, 1);
expect(isReadyBridge.invokeChannelArgument?.name, "usercentrics");
Expand Down
3 changes: 3 additions & 0 deletions test/platform/fake_usercentrics_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class FakeUsercentricsPlatform extends UsercentricsPlatform {
String? initializeVersionArgument;
NetworkMode? networkModeArgument;
bool? consentMediationArgument;
int? initializeInitTimeoutMillisArgument;

@override
void initialize({
Expand All @@ -76,6 +77,7 @@ class FakeUsercentricsPlatform extends UsercentricsPlatform {
String? version,
NetworkMode? networkMode,
bool? consentMediation,
int? initTimeoutMillis,
}) {
initializeCount++;
initializeSettingsIdArgument = settingsId;
Expand All @@ -86,6 +88,7 @@ class FakeUsercentricsPlatform extends UsercentricsPlatform {
initializeVersionArgument = version;
networkModeArgument = networkMode;
consentMediationArgument = consentMediation;
initializeInitTimeoutMillisArgument = initTimeoutMillis;
}

final UsercentricsReadyStatus? restoreUserSessionAnswer;
Expand Down

0 comments on commit 11ef15a

Please sign in to comment.