@@ -220,7 +220,11 @@ OptimizelyDecideOption[] options
220
220
{
221
221
if ( UserProfileService != null && ! ignoreUPS )
222
222
{
223
- SaveVariation ( experiment , decisionVariationResult . ResultObject ) ;
223
+ var bucketerUserProfile = _userProfile ??
224
+ new UserProfile ( userId ,
225
+ new Dictionary < string , Decision > ( ) ) ;
226
+ SaveVariation ( experiment , decisionVariationResult . ResultObject ,
227
+ bucketerUserProfile ) ;
224
228
}
225
229
else
226
230
{
@@ -475,14 +479,22 @@ ProjectConfig config
475
479
/// </summary>
476
480
/// <param name="experiment">The experiment the user was buck</param>
477
481
/// <param name="variation">The Variation to save.</param>
478
- public void SaveVariation ( Experiment experiment , Variation variation )
482
+ /// <param name = "userProfile" > instance of the user information.</param>
483
+ public void SaveVariation ( Experiment experiment , Variation variation ,
484
+ UserProfile userProfile
485
+ )
479
486
{
480
487
//only save if the user has implemented a user profile service
481
488
if ( UserProfileService == null )
482
489
{
483
490
return ;
484
491
}
485
492
493
+ if ( _userProfile == null )
494
+ {
495
+ _userProfile = userProfile ;
496
+ }
497
+
486
498
Decision decision ;
487
499
if ( _userProfile . ExperimentBucketMap . ContainsKey ( experiment . Id ) )
488
500
{
@@ -507,8 +519,8 @@ private void SaveToUserProfileService(Experiment experiment = null,
507
519
)
508
520
{
509
521
var useSpecificLogEntry = experiment != null && variation != null &&
510
- ! string . IsNullOrEmpty ( _userProfile ? . UserId ) ;
511
-
522
+ ! string . IsNullOrEmpty ( _userProfile ? . UserId ) ;
523
+
512
524
try
513
525
{
514
526
if ( _userProfile != null )
@@ -536,6 +548,7 @@ private void SaveToUserProfileService(Experiment experiment = null,
536
548
{
537
549
Logger . Log ( LogLevel . ERROR , "Failed to save user profile after batch decision." ) ;
538
550
}
551
+
539
552
ErrorHandler . HandleError (
540
553
new Exceptions . OptimizelyRuntimeException ( exception . Message ) ) ;
541
554
}
0 commit comments