Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions OptimizelySDK.Tests/OptimizelyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ public void TestDecisionNotificationSentWhenSendFlagDecisionsFalseAndFeature()
{
"decisionEventDispatched", true
},
{
"experimentId", "7718750065"
},
{
"variationId", "7713030086"
}
}))), Times.Once);
EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny<LogEvent>()),
Times.Once);
Expand Down Expand Up @@ -405,6 +411,12 @@ public void TestDecisionNotificationSentWhenSendFlagDecisionsTrueAndFeature()
{
"decisionEventDispatched", true
},
{
"experimentId", "7718750065"
},
{
"variationId", "7713030086"
}
}))), Times.Once);
EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny<LogEvent>()),
Times.Once);
Expand Down Expand Up @@ -476,6 +488,12 @@ public void TestDecisionNotificationNotSentWhenSendFlagDecisionsFalseAndRollout(
{
"decisionEventDispatched", false
},
{
"experimentId", experiment.Id
},
{
"variationId", variation.Id
}
}))), Times.Once);
EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny<LogEvent>()),
Times.Never);
Expand Down Expand Up @@ -547,6 +565,12 @@ public void TestDecisionNotificationSentWhenSendFlagDecisionsTrueAndRollout()
{
"decisionEventDispatched", true
},
{
"experimentId", experiment.Id
},
{
"variationId", variation.Id
}
}))), Times.Once);
EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny<LogEvent>()),
Times.Once);
Expand Down
6 changes: 6 additions & 0 deletions OptimizelySDK.Tests/OptimizelyUserContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,12 @@ public void TestDecisionNotification()
{
"decisionEventDispatched", true
},
{
"experimentId", "122235"
},
{
"variationId", "122236"
},
};

var userAttributes = new UserAttributes
Expand Down
13 changes: 12 additions & 1 deletion OptimizelySDK/Optimizely.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,14 +1000,23 @@ ProjectConfig projectConfig
)
{
var userId = user.GetUserId();


string experimentId = null;
string variationId = null;

var flagEnabled = false;
if (flagDecision.Variation != null)
{
if (flagDecision.Variation.IsFeatureEnabled)
{
flagEnabled = true;
}
variationId = flagDecision.Variation.Id;
}

if (flagDecision.Experiment != null)
{
experimentId = flagDecision.Experiment.Id;
}

Logger.Log(LogLevel.INFO,
Expand Down Expand Up @@ -1062,6 +1071,8 @@ ProjectConfig projectConfig
{ "ruleKey", ruleKey },
{ "reasons", reasonsToReport },
{ "decisionEventDispatched", decisionEventDispatched },
{ "experimentId", experimentId },
{ "variationId", variationId },
};

NotificationCenter.SendNotifications(NotificationCenter.NotificationType.Decision,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,4 @@ Optimizely SDK uses third party software:

- Ruby - https://github.com/optimizely/ruby-sdk

- Swift - https://github.com/optimizely/swift-sdk
- Swift - https://github.com/optimizely/swift-sdk