11/// **************************************************************************
2- /// Copyright 2022, Optimizely, Inc. and contributors *
2+ /// Copyright 2022-2023 , Optimizely, Inc. and contributors *
33/// *
44/// Licensed under the Apache License, Version 2.0 (the "License"); *
55/// you may not use this file except in compliance with the License. *
@@ -21,6 +21,8 @@ import 'package:optimizely_flutter_sdk/src/data_objects/activate_response.dart';
2121import 'package:optimizely_flutter_sdk/src/data_objects/base_response.dart' ;
2222import 'package:optimizely_flutter_sdk/src/data_objects/datafile_options.dart' ;
2323import 'package:optimizely_flutter_sdk/src/data_objects/event_options.dart' ;
24+ import 'package:optimizely_flutter_sdk/src/data_objects/get_vuid_response.dart' ;
25+ import 'package:optimizely_flutter_sdk/src/data_objects/sdk_settings.dart' ;
2426import 'package:optimizely_flutter_sdk/src/data_objects/get_variation_response.dart' ;
2527import 'package:optimizely_flutter_sdk/src/data_objects/optimizely_config_response.dart' ;
2628import 'package:optimizely_flutter_sdk/src/optimizely_client_wrapper.dart' ;
@@ -33,7 +35,7 @@ export 'package:optimizely_flutter_sdk/src/user_context/optimizely_forced_decisi
3335export 'package:optimizely_flutter_sdk/src/user_context/optimizely_decision_context.dart'
3436 show OptimizelyDecisionContext;
3537export 'package:optimizely_flutter_sdk/src/user_context/optimizely_user_context.dart'
36- show OptimizelyUserContext, OptimizelyDecideOption;
38+ show OptimizelyUserContext, OptimizelyDecideOption, OptimizelySegmentOption ;
3739export 'package:optimizely_flutter_sdk/src/data_objects/decide_response.dart'
3840 show Decision;
3941export 'package:optimizely_flutter_sdk/src/data_objects/track_listener_response.dart'
@@ -44,6 +46,8 @@ export 'package:optimizely_flutter_sdk/src/data_objects/logevent_listener_respon
4446 show LogEventListenerResponse;
4547export 'package:optimizely_flutter_sdk/src/data_objects/event_options.dart'
4648 show EventOptions;
49+ export 'package:optimizely_flutter_sdk/src/data_objects/sdk_settings.dart'
50+ show SDKSettings;
4751export 'package:optimizely_flutter_sdk/src/data_objects/datafile_options.dart'
4852 show DatafileHostOptions;
4953
@@ -59,17 +63,19 @@ class OptimizelyFlutterSdk {
5963 final int _datafilePeriodicDownloadInterval;
6064 final Map <ClientPlatform , DatafileHostOptions > _datafileHostOptions;
6165 final Set <OptimizelyDecideOption > _defaultDecideOptions;
62- OptimizelyFlutterSdk (
63- this ._sdkKey, {
64- EventOptions eventOptions = const EventOptions (),
65- int datafilePeriodicDownloadInterval =
66- 10 * 60 , // Default time interval in seconds
67- Map <ClientPlatform , DatafileHostOptions > datafileHostOptions = const {},
68- Set <OptimizelyDecideOption > defaultDecideOptions = const {},
69- }) : _eventOptions = eventOptions,
66+ final SDKSettings _sdkSettings;
67+ OptimizelyFlutterSdk (this ._sdkKey,
68+ {EventOptions eventOptions = const EventOptions (),
69+ int datafilePeriodicDownloadInterval =
70+ 10 * 60 , // Default time interval in seconds
71+ Map <ClientPlatform , DatafileHostOptions > datafileHostOptions = const {},
72+ Set <OptimizelyDecideOption > defaultDecideOptions = const {},
73+ SDKSettings sdkSettings = const SDKSettings ()})
74+ : _eventOptions = eventOptions,
7075 _datafilePeriodicDownloadInterval = datafilePeriodicDownloadInterval,
7176 _datafileHostOptions = datafileHostOptions,
72- _defaultDecideOptions = defaultDecideOptions;
77+ _defaultDecideOptions = defaultDecideOptions,
78+ _sdkSettings = sdkSettings;
7379
7480 /// Starts Optimizely SDK (Synchronous) with provided sdkKey.
7581 Future <BaseResponse > initializeClient () async {
@@ -78,7 +84,8 @@ class OptimizelyFlutterSdk {
7884 _eventOptions,
7985 _datafilePeriodicDownloadInterval,
8086 _datafileHostOptions,
81- _defaultDecideOptions);
87+ _defaultDecideOptions,
88+ _sdkSettings);
8289 }
8390
8491 /// Use the activate method to start an experiment.
@@ -140,17 +147,40 @@ class OptimizelyFlutterSdk {
140147 return await OptimizelyClientWrapper .getOptimizelyConfig (_sdkKey);
141148 }
142149
150+ /// Send an event to the ODP server.
151+ ///
152+ /// Takes [action] The event action name.
153+ /// Optional [type] The event type (default = "fullstack").
154+ /// Optional [identifiers] A dictionary for identifiers.
155+ /// Optional [data] A dictionary for associated data. The default event data will be added to this data before sending to the ODP server.
156+ /// Returns [BaseResponse] A object containing success result or reason of failure.
157+ Future <BaseResponse > sendOdpEvent (String action,
158+ {String ? type,
159+ Map <String , String > identifiers = const {},
160+ Map <String , dynamic > data = const {}}) async {
161+ return await OptimizelyClientWrapper .sendOdpEvent (_sdkKey, action,
162+ type: type, identifiers: identifiers, data: data);
163+ }
164+
165+ /// Returns the device vuid.
166+ ///
167+ /// Returns [GetVuidResponse] A object containing device vuid
168+ Future <GetVuidResponse > getVuid () async {
169+ return await OptimizelyClientWrapper .getVuid (_sdkKey);
170+ }
171+
143172 /// Creates a context of the user for which decision APIs will be called.
144173 ///
145174 /// NOTE: A user context will only be created successfully when the SDK is fully configured using initializeClient.
146175 ///
147- /// Takes [userId] the [String] user ID to be used for bucketing.
176+ /// Optional [userId] the [String] user ID to be used for bucketing.
177+ /// The device vuid will be used as an userId when userId is not provided.
148178 /// Takes [attributes] An Optional [Map] of attribute names to current user attribute values.
149179 /// Returns An [OptimizelyUserContext] associated with this OptimizelyClient.
150- Future <OptimizelyUserContext ?> createUserContext (String userId,
151- [ Map <String , dynamic > attributes = const {}] ) async {
152- return await OptimizelyClientWrapper .createUserContext (
153- _sdkKey, userId, attributes);
180+ Future <OptimizelyUserContext ?> createUserContext (
181+ { String ? userId, Map <String , dynamic > attributes = const {}} ) async {
182+ return await OptimizelyClientWrapper .createUserContext (_sdkKey,
183+ userId : userId, attributes : attributes);
154184 }
155185
156186 /// Allows user to remove notification listener using id.
0 commit comments