Skip to content

Commit fe085cc

Browse files
authored
New config (#63)
1 parent d6f790c commit fe085cc

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

splitio_platform_interface/lib/split_configuration.dart

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SplitConfiguration {
2323
///
2424
/// [trafficType] The default traffic type for events tracked using the track method. If not specified, every track call should specify a traffic type.
2525
///
26-
/// [enableDebug] If true, the SDK will log debug messages to the console.
26+
/// [enableDebug] (Deprecated; use logLevel instead) If true, the SDK will log debug messages to the console.
2727
///
2828
/// [streamingEnabled] Boolean flag to enable the streaming service as default synchronization mechanism when in foreground. In the event of an issue with streaming, the SDK will fallback to the polling mechanism. If false, the SDK will poll for changes as usual without attempting to use streaming.
2929
///
@@ -32,6 +32,16 @@ class SplitConfiguration {
3232
/// [impressionListener] Enables impression listener. If true, generated impressions will be streamed in the impressionsStream() method of Splitio.
3333
///
3434
/// [syncConfig] Use it to filter specific feature flags to be synced and evaluated by the SDK. If not set, all feature flags will be downloaded.
35+
///
36+
/// [impressionsMode] This configuration defines how impressions (decisioning events) are queued. Supported modes are [ImpressionsMode.optimized], [ImpressionsMode.none], and [ImpressionsMode.debug]. In [ImpressionsMode.optimized] mode, only unique impressions are queued and posted to Split; this is the recommended mode for experimentation use cases. In [ImpressionsMode.none] mode, no impression is tracked in Split and only minimum viable data to support usage stats is, so never use this mode if you are experimenting with that instance impressions. Use [ImpressionsMode.none] when you want to optimize for feature flagging only use cases and reduce impressions network and storage load. In [ImpressionsMode.debug] mode, ALL impressions are queued and sent to Split; this is useful for validations. This mode doesn't impact the impression listener which receives all generated impressions locally.
37+
///
38+
/// [syncEnabled] Controls the SDK continuous synchronization flags. When true, a running SDK processes rollout plan updates performed in the Split user interface (default). When false, it fetches all data upon init, which ensures a consistent experience during a user session and optimizes resources when these updates are not consumed by the app.
39+
///
40+
/// [UserConsent] User consent status used to control the tracking of events and impressions. Possible values are [UserConsent.granted], [UserConsent.declined], and [UserConsent.unknown].
41+
///
42+
/// [encryptionEnabled] If set to true, the local database contents is encrypted. Defaults to false.
43+
///
44+
/// [logLevel] Enables logging according to the level specified. Options are [SplitLogLevel.verbose], [SplitLogLevel.none], [SplitLogLevel.debug], [SplitLogLevel.info], [SplitLogLevel.warning], and [SplitLogLevel.error].
3545
SplitConfiguration({
3646
int? featuresRefreshRate,
3747
int? segmentsRefreshRate,
@@ -42,7 +52,7 @@ class SplitConfiguration {
4252
int? eventFlushInterval,
4353
int? eventsPerPush,
4454
String? trafficType,
45-
bool? enableDebug,
55+
@Deprecated('Use logLevel instead') bool? enableDebug,
4656
bool? streamingEnabled,
4757
bool? persistentAttributesEnabled,
4858
bool? impressionListener,
@@ -52,6 +62,11 @@ class SplitConfiguration {
5262
String? streamingServiceEndpoint,
5363
String? telemetryServiceEndpoint,
5464
SyncConfig? syncConfig,
65+
ImpressionsMode? impressionsMode,
66+
bool? syncEnabled,
67+
UserConsent? userConsent,
68+
bool? encryptionEnabled,
69+
SplitLogLevel? logLevel,
5570
}) {
5671
if (featuresRefreshRate != null) {
5772
configurationMap['featuresRefreshRate'] = featuresRefreshRate;
@@ -132,5 +147,39 @@ class SplitConfiguration {
132147
'syncConfigPrefixes': syncConfig.prefixes.toList(growable: false)
133148
};
134149
}
150+
151+
if (impressionsMode != null) {
152+
configurationMap['impressionsMode'] = impressionsMode.name;
153+
}
154+
155+
if (syncEnabled != null) {
156+
configurationMap['syncEnabled'] = syncEnabled;
157+
}
158+
159+
if (userConsent != null) {
160+
configurationMap['userConsent'] = userConsent.name;
161+
}
162+
163+
if (encryptionEnabled != null) {
164+
configurationMap['encryptionEnabled'] = encryptionEnabled;
165+
}
166+
167+
if (logLevel != null) {
168+
configurationMap['logLevel'] = logLevel.name;
169+
}
135170
}
136171
}
172+
173+
enum ImpressionsMode {
174+
debug,
175+
optimized,
176+
none,
177+
}
178+
179+
enum UserConsent {
180+
granted,
181+
declined,
182+
unknown,
183+
}
184+
185+
enum SplitLogLevel { verbose, debug, info, warning, error, none }

splitio_platform_interface/test/splitio_configuration_test.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ void main() {
2424
streamingServiceEndpoint: 'streamingServiceEndpoint.split.io',
2525
telemetryServiceEndpoint: 'telemetryServiceEndpoint.split.io',
2626
syncConfig:
27-
SyncConfig(names: ['one', 'two', 'three'], prefixes: ['pre1']));
27+
SyncConfig(names: ['one', 'two', 'three'], prefixes: ['pre1']),
28+
impressionsMode: ImpressionsMode.none,
29+
syncEnabled: false,
30+
userConsent: UserConsent.declined,
31+
encryptionEnabled: true,
32+
logLevel: SplitLogLevel.debug,
33+
);
2834

2935
expect(config.configurationMap['eventFlushInterval'], 2000);
3036
expect(config.configurationMap['eventsPerPush'], 300);
@@ -51,6 +57,11 @@ void main() {
5157
['one', 'two', 'three']);
5258
expect(
5359
config.configurationMap['syncConfig']['syncConfigPrefixes'], ['pre1']);
60+
expect(config.configurationMap['impressionsMode'], 'none');
61+
expect(config.configurationMap['syncEnabled'], false);
62+
expect(config.configurationMap['userConsent'], 'declined');
63+
expect(config.configurationMap['encryptionEnabled'], true);
64+
expect(config.configurationMap['logLevel'], 'debug');
5465
});
5566

5667
test('noSpecialValuesLeavesMapEmpty', () async {

0 commit comments

Comments
 (0)