Skip to content

Commit 32581d2

Browse files
notification payload update
1 parent 3a74053 commit 32581d2

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

OptimizelySDK.Tests/OptimizelyTest.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ public void TestDecisionNotificationSentWhenSendFlagDecisionsFalseAndFeature()
339339
{
340340
"decisionEventDispatched", true
341341
},
342+
{
343+
"experimentId", "7718750065"
344+
},
345+
{
346+
"variationId", "7713030086"
347+
}
342348
}))), Times.Once);
343349
EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny<LogEvent>()),
344350
Times.Once);
@@ -405,6 +411,12 @@ public void TestDecisionNotificationSentWhenSendFlagDecisionsTrueAndFeature()
405411
{
406412
"decisionEventDispatched", true
407413
},
414+
{
415+
"experimentId", "7718750065"
416+
},
417+
{
418+
"variationId", "7713030086"
419+
}
408420
}))), Times.Once);
409421
EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny<LogEvent>()),
410422
Times.Once);
@@ -476,6 +488,12 @@ public void TestDecisionNotificationNotSentWhenSendFlagDecisionsFalseAndRollout(
476488
{
477489
"decisionEventDispatched", false
478490
},
491+
{
492+
"experimentId", experiment.Id
493+
},
494+
{
495+
"variationId", variation.Id
496+
}
479497
}))), Times.Once);
480498
EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny<LogEvent>()),
481499
Times.Never);
@@ -547,6 +565,12 @@ public void TestDecisionNotificationSentWhenSendFlagDecisionsTrueAndRollout()
547565
{
548566
"decisionEventDispatched", true
549567
},
568+
{
569+
"experimentId", experiment.Id
570+
},
571+
{
572+
"variationId", variation.Id
573+
}
550574
}))), Times.Once);
551575
EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny<LogEvent>()),
552576
Times.Once);

OptimizelySDK.Tests/OptimizelyUserContextTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,12 @@ public void TestDecisionNotification()
10811081
{
10821082
"decisionEventDispatched", true
10831083
},
1084+
{
1085+
"experimentId", "122235"
1086+
},
1087+
{
1088+
"variationId", "122236"
1089+
},
10841090
};
10851091

10861092
var userAttributes = new UserAttributes

OptimizelySDK/Optimizely.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,14 +1000,23 @@ ProjectConfig projectConfig
10001000
)
10011001
{
10021002
var userId = user.GetUserId();
1003-
1003+
1004+
string experimentId = null;
1005+
string variationId = null;
1006+
10041007
var flagEnabled = false;
10051008
if (flagDecision.Variation != null)
10061009
{
10071010
if (flagDecision.Variation.IsFeatureEnabled)
10081011
{
10091012
flagEnabled = true;
10101013
}
1014+
variationId = flagDecision.Variation.Id;
1015+
}
1016+
1017+
if (flagDecision.Experiment != null)
1018+
{
1019+
experimentId = flagDecision.Experiment.Id;
10111020
}
10121021

10131022
Logger.Log(LogLevel.INFO,
@@ -1062,6 +1071,8 @@ ProjectConfig projectConfig
10621071
{ "ruleKey", ruleKey },
10631072
{ "reasons", reasonsToReport },
10641073
{ "decisionEventDispatched", decisionEventDispatched },
1074+
{ "experimentId", experimentId },
1075+
{ "variationId", variationId },
10651076
};
10661077

10671078
NotificationCenter.SendNotifications(NotificationCenter.NotificationType.Decision,

0 commit comments

Comments
 (0)