From 3a740534477b5b4b2a46602ec6f581f587f3e795 Mon Sep 17 00:00:00 2001 From: Md Junaed Hossain <169046794+junaed-optimizely@users.noreply.github.com> Date: Tue, 17 Jun 2025 20:52:51 +0600 Subject: [PATCH 1/6] pipeline test --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 9de4ddc7..daf8d598 100644 --- a/README.md +++ b/README.md @@ -252,3 +252,6 @@ Optimizely SDK uses third party software: - Ruby - https://github.com/optimizely/ruby-sdk - Swift - https://github.com/optimizely/swift-sdk + +## Test +Test pipeline \ No newline at end of file From 32581d2018d207c3c126e94d8e3ca2e3d2844dc0 Mon Sep 17 00:00:00 2001 From: Md Junaed Hossain <169046794+junaed-optimizely@users.noreply.github.com> Date: Tue, 17 Jun 2025 23:32:30 +0600 Subject: [PATCH 2/6] notification payload update --- OptimizelySDK.Tests/OptimizelyTest.cs | 24 +++++++++++++++++++ .../OptimizelyUserContextTest.cs | 6 +++++ OptimizelySDK/Optimizely.cs | 13 +++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/OptimizelySDK.Tests/OptimizelyTest.cs b/OptimizelySDK.Tests/OptimizelyTest.cs index 5dab3aec..a4709adc 100644 --- a/OptimizelySDK.Tests/OptimizelyTest.cs +++ b/OptimizelySDK.Tests/OptimizelyTest.cs @@ -339,6 +339,12 @@ public void TestDecisionNotificationSentWhenSendFlagDecisionsFalseAndFeature() { "decisionEventDispatched", true }, + { + "experimentId", "7718750065" + }, + { + "variationId", "7713030086" + } }))), Times.Once); EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny()), Times.Once); @@ -405,6 +411,12 @@ public void TestDecisionNotificationSentWhenSendFlagDecisionsTrueAndFeature() { "decisionEventDispatched", true }, + { + "experimentId", "7718750065" + }, + { + "variationId", "7713030086" + } }))), Times.Once); EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny()), Times.Once); @@ -476,6 +488,12 @@ public void TestDecisionNotificationNotSentWhenSendFlagDecisionsFalseAndRollout( { "decisionEventDispatched", false }, + { + "experimentId", experiment.Id + }, + { + "variationId", variation.Id + } }))), Times.Once); EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny()), Times.Never); @@ -547,6 +565,12 @@ public void TestDecisionNotificationSentWhenSendFlagDecisionsTrueAndRollout() { "decisionEventDispatched", true }, + { + "experimentId", experiment.Id + }, + { + "variationId", variation.Id + } }))), Times.Once); EventDispatcherMock.Verify(dispatcher => dispatcher.DispatchEvent(It.IsAny()), Times.Once); diff --git a/OptimizelySDK.Tests/OptimizelyUserContextTest.cs b/OptimizelySDK.Tests/OptimizelyUserContextTest.cs index 76d0d8b8..21ae10db 100644 --- a/OptimizelySDK.Tests/OptimizelyUserContextTest.cs +++ b/OptimizelySDK.Tests/OptimizelyUserContextTest.cs @@ -1081,6 +1081,12 @@ public void TestDecisionNotification() { "decisionEventDispatched", true }, + { + "experimentId", "122235" + }, + { + "variationId", "122236" + }, }; var userAttributes = new UserAttributes diff --git a/OptimizelySDK/Optimizely.cs b/OptimizelySDK/Optimizely.cs index b1766985..e28d2745 100644 --- a/OptimizelySDK/Optimizely.cs +++ b/OptimizelySDK/Optimizely.cs @@ -1000,7 +1000,10 @@ ProjectConfig projectConfig ) { var userId = user.GetUserId(); - + + string experimentId = null; + string variationId = null; + var flagEnabled = false; if (flagDecision.Variation != null) { @@ -1008,6 +1011,12 @@ ProjectConfig projectConfig { flagEnabled = true; } + variationId = flagDecision.Variation.Id; + } + + if (flagDecision.Experiment != null) + { + experimentId = flagDecision.Experiment.Id; } Logger.Log(LogLevel.INFO, @@ -1062,6 +1071,8 @@ ProjectConfig projectConfig { "ruleKey", ruleKey }, { "reasons", reasonsToReport }, { "decisionEventDispatched", decisionEventDispatched }, + { "experimentId", experimentId }, + { "variationId", variationId }, }; NotificationCenter.SendNotifications(NotificationCenter.NotificationType.Decision, From 80c90676aa28cfacea4b6ee8aa4c847e52b271a3 Mon Sep 17 00:00:00 2001 From: Md Junaed Hossain <169046794+junaed-optimizely@users.noreply.github.com> Date: Tue, 17 Jun 2025 23:47:19 +0600 Subject: [PATCH 3/6] readme update --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index daf8d598..68525502 100644 --- a/README.md +++ b/README.md @@ -251,7 +251,4 @@ Optimizely SDK uses third party software: - Ruby - https://github.com/optimizely/ruby-sdk -- Swift - https://github.com/optimizely/swift-sdk - -## Test -Test pipeline \ No newline at end of file +- Swift - https://github.com/optimizely/swift-sdk \ No newline at end of file From 5e10b14b285ad82202a8c3a32eeac39e70148346 Mon Sep 17 00:00:00 2001 From: Md Junaed Hossain <169046794+junaed-optimizely@users.noreply.github.com> Date: Wed, 18 Jun 2025 18:23:13 +0600 Subject: [PATCH 4/6] whitespace fix --- OptimizelySDK/Optimizely.cs | 4 ---- README.md | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/OptimizelySDK/Optimizely.cs b/OptimizelySDK/Optimizely.cs index e28d2745..99cbdaaf 100644 --- a/OptimizelySDK/Optimizely.cs +++ b/OptimizelySDK/Optimizely.cs @@ -1000,10 +1000,8 @@ ProjectConfig projectConfig ) { var userId = user.GetUserId(); - string experimentId = null; string variationId = null; - var flagEnabled = false; if (flagDecision.Variation != null) { @@ -1013,12 +1011,10 @@ ProjectConfig projectConfig } variationId = flagDecision.Variation.Id; } - if (flagDecision.Experiment != null) { experimentId = flagDecision.Experiment.Id; } - Logger.Log(LogLevel.INFO, $"Feature \"{flagKey}\" is enabled for user \"{userId}\"? {flagEnabled}"); diff --git a/README.md b/README.md index 68525502..9de4ddc7 100644 --- a/README.md +++ b/README.md @@ -251,4 +251,4 @@ Optimizely SDK uses third party software: - Ruby - https://github.com/optimizely/ruby-sdk -- Swift - https://github.com/optimizely/swift-sdk \ No newline at end of file +- Swift - https://github.com/optimizely/swift-sdk From cef0bbdde546412a05eeda2a26328da09858e9ea Mon Sep 17 00:00:00 2001 From: Md Junaed Hossain <169046794+junaed-optimizely@users.noreply.github.com> Date: Wed, 18 Jun 2025 20:52:23 +0600 Subject: [PATCH 5/6] whitespace fix --- OptimizelySDK.Tests/OptimizelyTest.cs | 67 +++++++++------------------ 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/OptimizelySDK.Tests/OptimizelyTest.cs b/OptimizelySDK.Tests/OptimizelyTest.cs index a4709adc..0adb57ec 100644 --- a/OptimizelySDK.Tests/OptimizelyTest.cs +++ b/OptimizelySDK.Tests/OptimizelyTest.cs @@ -2385,8 +2385,7 @@ public void Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Got variable value ""{variableValue}"" for variable ""{variableKey - }"" of feature flag ""{featureKey}"".")); + $@"Got variable value ""{variableValue}"" for variable ""{variableKey}"" of feature flag ""{featureKey}"".")); } [Test] @@ -2430,8 +2429,7 @@ public void Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Got variable value ""{variableValue}"" for variable ""{variableKey - }"" of feature flag ""{featureKey}"".")); + $@"Got variable value ""{variableValue}"" for variable ""{variableKey}"" of feature flag ""{featureKey}"".")); } [Test] @@ -2463,8 +2461,7 @@ public void Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Feature ""{featureKey}"" is not enabled for user {TestUserId - }. Returning the default variable value ""{variableValue}"".")); + $@"Feature ""{featureKey}"" is not enabled for user {TestUserId}. Returning the default variable value ""{variableValue}"".")); } [Test] @@ -2508,8 +2505,7 @@ public void Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Feature ""{featureKey}"" is not enabled for user {TestUserId - }. Returning the default variable value ""{variableValue}"".")); + $@"Feature ""{featureKey}"" is not enabled for user {TestUserId}. Returning the default variable value ""{variableValue}"".")); } [Test] @@ -2539,8 +2535,7 @@ public void Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Got variable value ""true"" for variable ""{variableKey}"" of feature flag ""{ - featureKey}"".")); + $@"Got variable value ""true"" for variable ""{variableKey}"" of feature flag ""{featureKey}"".")); } [Test] @@ -2586,8 +2581,7 @@ public void Assert.AreEqual(expectedStringValue, variableValue.GetValue("string_var")); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Got variable value ""{variableValue}"" for variable ""{variableKey - }"" of feature flag ""{featureKey}"".")); + $@"Got variable value ""{variableValue}"" for variable ""{variableKey}"" of feature flag ""{featureKey}"".")); } [Test] @@ -2633,8 +2627,7 @@ public void Assert.AreEqual(expectedStringValue, variableValue.GetValue("string_var")); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Got variable value ""{variableValue}"" for variable ""{variableKey - }"" of feature flag ""{featureKey}"".")); + $@"Got variable value ""{variableValue}"" for variable ""{variableKey}"" of feature flag ""{featureKey}"".")); } [Test] @@ -2678,8 +2671,7 @@ public void Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Got variable value ""{variableValue}"" for variable ""{variableKey - }"" of feature flag ""{featureKey}"".")); + $@"Got variable value ""{variableValue}"" for variable ""{variableKey}"" of feature flag ""{featureKey}"".")); } [Test] @@ -2708,8 +2700,7 @@ public void variableKey, TestUserId, null); Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Feature ""{featureKey}"" is not enabled for user {TestUserId - }. Returning the default variable value ""true"".")); + $@"Feature ""{featureKey}"" is not enabled for user {TestUserId}. Returning the default variable value ""true"".")); } [Test] @@ -2752,8 +2743,7 @@ public void Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Feature ""{featureKey}"" is not enabled for user {TestUserId - }. Returning the default variable value ""{variableValue}"".")); + $@"Feature ""{featureKey}"" is not enabled for user {TestUserId}. Returning the default variable value ""{variableValue}"".")); } [Test] @@ -2782,8 +2772,7 @@ public void Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"User ""{TestUserId}"" is not in any variation for feature flag ""{featureKey - }"", returning default value ""{variableValue}"".")); + $@"User ""{TestUserId}"" is not in any variation for feature flag ""{featureKey}"", returning default value ""{variableValue}"".")); } #endregion Feature Toggle Tests @@ -2846,8 +2835,7 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureKeyOrVariableKeyNotFou LoggerMock.Verify(l => l.Log(LogLevel.ERROR, $@"Feature key ""{featureKey}"" is not in datafile.")); LoggerMock.Verify(l => l.Log(LogLevel.ERROR, - $@"No feature variable was found for key ""{variableKey - }"" in feature flag ""double_single_variable_feature"".")); + $@"No feature variable was found for key ""{variableKey}"" in feature flag ""double_single_variable_feature"".")); } // Should return null and log error message when variable type is invalid. @@ -2875,17 +2863,13 @@ public void TestGetFeatureVariableValueForTypeGivenInvalidVariableType() "string_single_variable_feature", "json_var", TestUserId, null, variableTypeInt)); LoggerMock.Verify(l => l.Log(LogLevel.ERROR, - $@"Variable is of type ""double"", but you requested it as type ""{variableTypeBool - }"".")); + $@"Variable is of type ""double"", but you requested it as type ""{variableTypeBool}"".")); LoggerMock.Verify(l => l.Log(LogLevel.ERROR, - $@"Variable is of type ""boolean"", but you requested it as type ""{ - variableTypeDouble}"".")); + $@"Variable is of type ""boolean"", but you requested it as type ""{variableTypeDouble}"".")); LoggerMock.Verify(l => l.Log(LogLevel.ERROR, - $@"Variable is of type ""integer"", but you requested it as type ""{ - variableTypeString}"".")); + $@"Variable is of type ""integer"", but you requested it as type ""{variableTypeString}"".")); LoggerMock.Verify(l => l.Log(LogLevel.ERROR, - $@"Variable is of type ""string"", but you requested it as type ""{variableTypeInt - }"".")); + $@"Variable is of type ""string"", but you requested it as type ""{variableTypeInt}"".")); } [Test] @@ -2937,8 +2921,7 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureFlagIsNotEnabledForUse Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Feature ""{featureKey}"" is not enabled for user {TestUserId - }. Returning the default variable value ""{variableValue}"".")); + $@"Feature ""{featureKey}"" is not enabled for user {TestUserId}. Returning the default variable value ""{variableValue}"".")); } // Should return default value and log message when feature is enabled for the user @@ -2978,9 +2961,7 @@ public void Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Variable ""{variableKey - }"" is not used in variation ""control"", returning default value ""{expectedValue - }"".")); + $@"Variable ""{variableKey}"" is not used in variation ""control"", returning default value ""{expectedValue}"".")); } // Should return variable value from variation and log message when feature is enabled for the user @@ -3018,8 +2999,7 @@ public void Assert.AreEqual(expectedValue, variableValue); LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"Got variable value ""{variableValue}"" for variable ""{variableKey - }"" of feature flag ""{featureKey}"".")); + $@"Got variable value ""{variableValue}"" for variable ""{variableKey}"" of feature flag ""{featureKey}"".")); } // Verify that GetFeatureVariableValueForType returns correct variable value for rollout rule. @@ -3173,8 +3153,7 @@ public void TestIsFeatureEnabledGivenFeatureFlagIsEnabledAndUserIsNotBeingExperi // SendImpressionEvent() does not get called. LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"The user ""{TestUserId}"" is not being experimented on feature ""{featureKey - }""."), Times.Once); + $@"The user ""{TestUserId}"" is not being experimented on feature ""{featureKey}""."), Times.Once); LoggerMock.Verify(l => l.Log(LogLevel.INFO, $@"Feature flag ""{featureKey}"" is enabled for user ""{TestUserId}"".")); @@ -3207,8 +3186,7 @@ public void TestIsFeatureEnabledGivenFeatureFlagIsEnabledAndUserIsBeingExperimen // SendImpressionEvent() gets called. LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"The user ""{TestUserId}"" is not being experimented on feature ""{featureKey - }""."), Times.Never); + $@"The user ""{TestUserId}"" is not being experimented on feature ""{featureKey}""."), Times.Never); LoggerMock.Verify(l => l.Log(LogLevel.INFO, $@"Feature flag ""{featureKey}"" is enabled for user ""{TestUserId}"".")); @@ -3242,8 +3220,7 @@ public void TestIsFeatureEnabledGivenFeatureFlagIsNotEnabledAndUserIsBeingExperi // SendImpressionEvent() gets called. LoggerMock.Verify(l => l.Log(LogLevel.INFO, - $@"The user ""{TestUserId}"" is not being experimented on feature ""{featureKey - }""."), Times.Never); + $@"The user ""{TestUserId}"" is not being experimented on feature ""{featureKey}""."), Times.Never); LoggerMock.Verify(l => l.Log(LogLevel.INFO, $@"Feature flag ""{featureKey}"" is not enabled for user ""{TestUserId}"".")); From 7901cb6db562c8141070ad164edf4dec71fbce57 Mon Sep 17 00:00:00 2001 From: Md Junaed Hossain <169046794+junaed-optimizely@users.noreply.github.com> Date: Wed, 18 Jun 2025 22:59:45 +0600 Subject: [PATCH 6/6] pipeline fix --- .github/workflows/csharp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 0205baa8..1650a685 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -75,7 +75,7 @@ jobs: - name: Restore dependencies run: dotnet restore OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj - name: Build & strongly name assemblies - run: dotnet build OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=D:\a\csharp-sdk\csharp-sdk\keypair.snk -c Release + run: dotnet build OptimizelySDK.NetStandard16/OptimizelySDK.NetStandard16.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk -c Release netStandard20: name: Build Standard 2.0 @@ -98,7 +98,7 @@ jobs: - name: Restore dependencies run: dotnet restore OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj - name: Build & strongly name assemblies - run: dotnet build OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=D:\a\csharp-sdk\csharp-sdk\keypair.snk -c Release + run: dotnet build OptimizelySDK.NetStandard20/OptimizelySDK.NetStandard20.csproj /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=$(pwd)/keypair.snk -c Release integration_tests: name: Run Integration Tests