Skip to content

Commit 4011308

Browse files
Automatic AB enrollment (#130)
* initial commit * changed vars and comment added * changelog and conditions * Update main.dart --------- Co-authored-by: Artūrs Kadiķis <kadikis.arturs@gmail.com>
1 parent 7ffb169 commit 4011308

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 23.8.1
2+
* Added `enrollABOnRCDownload` config method to enroll users to AB tests when downloading Remote Config values
3+
* Fixed a bug where enabling consent requirements would enable consents for all features for Android
4+
15
## 23.8.0
26
* ! Minor breaking change ! Manual view recording calls are now ignored if automatic view recording mode is enabled.
37

android/src/main/java/ly/count/dart/countly_flutter/CountlyFlutterPlugin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,8 +1543,12 @@ public void callback(String error) {
15431543
this.config.setGlobalViewSegmentation(toMap(globalViewSegmentation));
15441544
}
15451545

1546-
if (_config.has("enableAllConsents")) {
1546+
if (_config.has("enableAllConsents") && _config.getBoolean("enableAllConsents")) {
15471547
this.config.giveAllConsents();
15481548
}
1549+
1550+
if (_config.has("autoEnrollABOnDownload") && _config.getBoolean("autoEnrollABOnDownload")) {
1551+
this.config.enrollABOnRCDownload();
1552+
}
15491553
}
15501554
}

example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class _MyAppState extends State<MyApp> {
111111
..setRecordAppStartTime(true) // Enable APM features, which includes the recording of app start time.
112112
..setStarRatingTextMessage('Message for start rating dialog')
113113
..setLoggingEnabled(true) // Enable countly internal debugging logs
114+
//..enrollABOnRCDownload() // This is for specific circumstances only
114115
..setParameterTamperingProtectionSalt('salt') // Set the optional salt to be used for calculating the checksum of requested data which will be sent with each request
115116
..setHttpPostForced(false); // Set to 'true' if you want HTTP POST to be used for all requests
116117
if (_enableManualSession) {

lib/countly_config.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class CountlyConfig {
3535
bool _remoteConfigValueCaching = false;
3636
Map<String, Object>? _globalViewSegmentation;
3737
bool _enableAllConsents = false;
38+
bool _autoEnrollABOnDownload = false;
3839

3940
CountlyConfig(this._serverURL, this._appKey);
4041

@@ -105,6 +106,8 @@ class CountlyConfig {
105106

106107
bool get enableAllConsents => _enableAllConsents;
107108

109+
bool get autoEnrollABOnDownload => _autoEnrollABOnDownload;
110+
108111
/// URL of the Countly server to submit data to.
109112
/// Mandatory field.
110113
CountlyConfig setServerURL(String serverURL) {
@@ -296,4 +299,10 @@ class CountlyConfig {
296299
_enableAllConsents = true;
297300
return this;
298301
}
302+
303+
/// This is used for enrolling user to AB testing on RC download
304+
CountlyConfig enrollABOnRCDownload() {
305+
_autoEnrollABOnDownload = true;
306+
return this;
307+
}
299308
}

lib/countly_flutter.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class Countly {
5555
_userProfileInternal = UserProfileInternal(this, _countlyState);
5656
_viewsInternal = ViewsInternal(this, _countlyState);
5757
_sessionsInternal = SessionsInternal(this, _countlyState);
58-
5958
}
6059
static final instance = _instance;
6160
static final _instance = Countly._();
@@ -236,7 +235,7 @@ class Countly {
236235
}
237236
if (config.manualSessionEnabled != null) {
238237
_manualSessionControlEnabled = config.manualSessionEnabled!;
239-
if(config.manualSessionEnabled!) {
238+
if (config.manualSessionEnabled!) {
240239
_instance._sessionsInternal.enableManualSession();
241240
}
242241
}
@@ -577,7 +576,6 @@ class Countly {
577576
return result;
578577
}
579578

580-
581579
@Deprecated('Automatic sessions are handled by underlying SDK, this function will do nothing')
582580
static Future<String?> start() async {
583581
String msg = 'Automatic sessions are handled by underlying SDK, this function will do nothing';
@@ -2000,10 +1998,14 @@ class Countly {
20001998
countlyConfig['globalViewSegmentation'] = config.globalViewSegmentation;
20011999
}
20022000

2003-
if (config.enableAllConsents != null) {
2001+
if (config.enableAllConsents) {
20042002
countlyConfig['enableAllConsents'] = config.enableAllConsents;
20052003
}
20062004

2005+
if (config.autoEnrollABOnDownload) {
2006+
countlyConfig['autoEnrollABOnDownload'] = config.autoEnrollABOnDownload;
2007+
}
2008+
20072009
countlyConfig['remoteConfigAutomaticTriggers'] = config.remoteConfigAutomaticTriggers;
20082010

20092011
countlyConfig['remoteConfigValueCaching'] = config.remoteConfigValueCaching;

0 commit comments

Comments
 (0)