From fc1f839d7b32a5c67f4fcd64845c368061c09ce8 Mon Sep 17 00:00:00 2001 From: Muzahidul Islam <129880873+muzahidul-opti@users.noreply.github.com> Date: Wed, 5 Feb 2025 21:53:29 +0600 Subject: [PATCH 1/5] Update swift.yml --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 1fc4011b..49d57b81 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -96,7 +96,7 @@ jobs: BRANCH: ${{ github.ref_name }} GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }} COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }} - COCOAPODS_VERSION: '1.12.1' + COCOAPODS_VERSION: '1.15.2' run: | gem install cocoapods -v $COCOAPODS_VERSION Scripts/run_release.sh From 1e7de1046167a07a56b9a68cb228fe10da0d4bcf Mon Sep 17 00:00:00 2001 From: muzahidul-opti Date: Mon, 2 Jun 2025 22:48:03 +0600 Subject: [PATCH 2/5] Add exp id an variation id into decision notiifcation payload --- Sources/Implementation/DecisionInfo.swift | 10 ++++++- Sources/Utils/Constants.swift | 2 ++ .../DecisionListenerTests_Datafile.swift | 27 ++++++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Sources/Implementation/DecisionInfo.swift b/Sources/Implementation/DecisionInfo.swift index 72c38c30..b2c60b4e 100644 --- a/Sources/Implementation/DecisionInfo.swift +++ b/Sources/Implementation/DecisionInfo.swift @@ -140,9 +140,17 @@ struct DecisionInfo { decisionInfo[Constants.DecisionInfoKeys.variationKey] = variation?.key ?? NSNull() // keep key in the map even with nil value decisionInfo[Constants.DecisionInfoKeys.ruleKey] = ruleKey ?? NSNull() // decisionInfo[Constants.DecisionInfoKeys.reasons] = reasons - decisionInfo[Constants.DecisionInfoKeys.decisionEventDispatched] = decisionEventDispatched } + decisionInfo[Constants.DecisionInfoKeys.decisionEventDispatched] = decisionEventDispatched + + if let expId = experiment?.id { + decisionInfo[Constants.ExperimentDecisionInfoKeys.experimentId] = expId + } + + if let varId = variation?.id { + decisionInfo[Constants.ExperimentDecisionInfoKeys.variationId] = varId + } return decisionInfo } diff --git a/Sources/Utils/Constants.swift b/Sources/Utils/Constants.swift index f60f6fdc..100a2e6e 100644 --- a/Sources/Utils/Constants.swift +++ b/Sources/Utils/Constants.swift @@ -88,7 +88,9 @@ struct Constants { } struct ExperimentDecisionInfoKeys { + static let experimentId = "experimentId" static let experiment = "experimentKey" + static let variationId = "variationId" static let variation = "variationKey" } diff --git a/Tests/OptimizelyTests-Common/DecisionListenerTests_Datafile.swift b/Tests/OptimizelyTests-Common/DecisionListenerTests_Datafile.swift index 708f8217..85f25b65 100644 --- a/Tests/OptimizelyTests-Common/DecisionListenerTests_Datafile.swift +++ b/Tests/OptimizelyTests-Common/DecisionListenerTests_Datafile.swift @@ -37,12 +37,16 @@ class DecisionListenerTests_Datafile: XCTestCase { var notificationVariation: String? var notificationExperiment: String? var notificationType: String? + var expId: String? + var varId: String? let exp = expectation(description: "x") _ = notificationCenter.addDecisionNotificationListener(decisionListener: { (type, _, _, decisionInfo) in notificationExperiment = decisionInfo[Constants.ExperimentDecisionInfoKeys.experiment] as? String notificationVariation = decisionInfo[Constants.ExperimentDecisionInfoKeys.variation] as? String + expId = decisionInfo[Constants.ExperimentDecisionInfoKeys.experimentId] as? String + varId = decisionInfo[Constants.ExperimentDecisionInfoKeys.variationId] as? String notificationType = type exp.fulfill() }) @@ -56,6 +60,8 @@ class DecisionListenerTests_Datafile: XCTestCase { XCTAssertEqual(variation, "all_traffic_variation") XCTAssertEqual(notificationExperiment, "ab_running_exp_audience_combo_empty_conditions") XCTAssertEqual(notificationVariation, "all_traffic_variation") + XCTAssertEqual(expId, "10390977723") + XCTAssertEqual(varId, "10416523170") XCTAssertEqual(notificationType, Constants.DecisionType.abTest.rawValue) } @@ -63,12 +69,18 @@ class DecisionListenerTests_Datafile: XCTestCase { var notificationVariation: String? var notificationExperiment: String? var notificationType: String? + var expId: String? + var varId: String? let exp = expectation(description: "x") _ = notificationCenter.addDecisionNotificationListener(decisionListener: { (type, _, _, decisionInfo) in notificationExperiment = decisionInfo[Constants.ExperimentDecisionInfoKeys.experiment] as? String notificationVariation = decisionInfo[Constants.ExperimentDecisionInfoKeys.variation] as? String + expId = decisionInfo[Constants.ExperimentDecisionInfoKeys.experimentId] as? String + varId = decisionInfo[Constants.ExperimentDecisionInfoKeys.variationId] as? String + expId = decisionInfo[Constants.ExperimentDecisionInfoKeys.experimentId] as? String + varId = decisionInfo[Constants.ExperimentDecisionInfoKeys.variationId] as? String notificationType = type exp.fulfill() }) @@ -81,6 +93,8 @@ class DecisionListenerTests_Datafile: XCTestCase { XCTAssertEqual(notificationExperiment, "ab_running_exp_audience_combo_exact_foo_or_true__and__42_or_4_2") XCTAssertEqual(notificationVariation, nil) + XCTAssertEqual(expId, "10390977714") + XCTAssertEqual(varId, nil) XCTAssertEqual(notificationType, Constants.DecisionType.abTest.rawValue) notificationCenter.clearAllNotificationListeners() } @@ -93,12 +107,16 @@ class DecisionListenerTests_Datafile: XCTestCase { var notificationVariation: String? var notificationExperiment: String? var notificationType: String? + var expId: String? + var varId: String? let exp = expectation(description: "x") _ = notificationCenter.addDecisionNotificationListener(decisionListener: { (type, _, _, decisionInfo) in notificationExperiment = decisionInfo[Constants.ExperimentDecisionInfoKeys.experiment] as? String notificationVariation = decisionInfo[Constants.ExperimentDecisionInfoKeys.variation] as? String + expId = decisionInfo[Constants.ExperimentDecisionInfoKeys.experimentId] as? String + varId = decisionInfo[Constants.ExperimentDecisionInfoKeys.variationId] as? String notificationType = type exp.fulfill() }) @@ -111,6 +129,8 @@ class DecisionListenerTests_Datafile: XCTestCase { XCTAssertEqual(notificationExperiment, "ab_running_exp_audience_combo_empty_conditions") XCTAssertEqual(notificationVariation, "all_traffic_variation") XCTAssertEqual(notificationType, Constants.DecisionType.abTest.rawValue) + XCTAssertEqual(expId, "10390977723") + XCTAssertEqual(varId, "10416523170") notificationCenter.clearAllNotificationListeners() } @@ -118,12 +138,15 @@ class DecisionListenerTests_Datafile: XCTestCase { var notificationVariation: String? var notificationExperiment: String? var notificationType: String? - + var expId: String? + var varId: String? let exp = expectation(description: "x") _ = notificationCenter.addDecisionNotificationListener(decisionListener: { (type, _, _, decisionInfo) in notificationExperiment = decisionInfo[Constants.ExperimentDecisionInfoKeys.experiment] as? String notificationVariation = decisionInfo[Constants.ExperimentDecisionInfoKeys.variation] as? String + expId = decisionInfo[Constants.ExperimentDecisionInfoKeys.experimentId] as? String + varId = decisionInfo[Constants.ExperimentDecisionInfoKeys.variationId] as? String notificationType = type exp.fulfill() }) @@ -133,6 +156,8 @@ class DecisionListenerTests_Datafile: XCTestCase { XCTAssertEqual(notificationExperiment, "ab_running_exp_audience_combo_exact_foo_or_true__and__42_or_4_2") XCTAssertEqual(notificationVariation, nil) + XCTAssertEqual(expId, "10390977714") + XCTAssertEqual(varId, nil) XCTAssertEqual(notificationType, Constants.DecisionType.abTest.rawValue) notificationCenter.clearAllNotificationListeners() } From dcd0008ad55aac64bf793a6bd1c12ef54687475b Mon Sep 17 00:00:00 2001 From: muzahidul-opti Date: Mon, 2 Jun 2025 22:54:35 +0600 Subject: [PATCH 3/5] Update doc for release 5.1.1 --- .github/workflows/swift.yml | 2 +- CHANGELOG.md | 6 ++++++ Package.swift | 2 +- README.md | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 49d57b81..d5de5b7a 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -17,7 +17,7 @@ on: description: release env: - VERSION: 5.1.0 + VERSION: 5.1.1 jobs: diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c9af189..fae41347 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Optimizely Swift SDK Changelog +## 5.1.1 +Jun 2th, 2025 + +### Functionality Enhancement +* Add experiment id and variation id added into decision notification payload ([#589](https://github.com/optimizely/swift-sdk/pull/589)). + ## 5.1.0 February 4th, 2025 diff --git a/Package.swift b/Package.swift index 22653f4e..24b0467a 100644 --- a/Package.swift +++ b/Package.swift @@ -24,5 +24,5 @@ let package = Package( resources: [.copy("Supporting Files/PrivacyInfo.xcprivacy")] ) ], - swiftLanguageVersions: [.v5, .version("5.9")] + swiftLanguageVersions: [.v5] ) diff --git a/README.md b/README.md index 2c89721e..19355a2d 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ If you have a name conflict with other swift packages when you add the Optimizel #### CocoaPods 1. Add the following lines to the _Podfile_:
 ```use_frameworks!```
-```pod 'OptimizelySwiftSDK', '~> 5.1.0'```
+```pod 'OptimizelySwiftSDK', '~> 5.1.1'```
 
2. Run the following command:
``` pod install ```
From fa6e64e7887a4016696cff9a921e692df2b3f1bf Mon Sep 17 00:00:00 2001 From: muzahidul-opti Date: Mon, 2 Jun 2025 23:59:29 +0600 Subject: [PATCH 4/5] update yml --- .github/workflows/integration_tests.yml | 12 +++--------- .github/workflows/swift.yml | 8 +++----- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 1064e691..de0c6398 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -5,9 +5,6 @@ on: secrets: CI_USER_TOKEN: required: true - TRAVIS_COM_TOKEN: - required: true - jobs: integration_tests: runs-on: ubuntu-latest @@ -16,8 +13,8 @@ jobs: with: # You should create a personal access token and store it in your repository token: ${{ secrets.CI_USER_TOKEN }} - repository: 'optimizely/travisci-tools' - path: 'home/runner/travisci-tools' + repository: 'optimizely/ci-helper-tools' + path: 'home/runner/ci-helper-tools' ref: 'master' - name: set SDK Branch if PR env: @@ -31,7 +28,6 @@ jobs: if: ${{ github.event_name != 'pull_request' }} run: | echo "SDK_BRANCH=$REF_NAME" >> $GITHUB_ENV - echo "TRAVIS_BRANCH=$REF_NAME" >> $GITHUB_ENV - name: Trigger build env: SDK: swift @@ -41,14 +37,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }} EVENT_TYPE: ${{ github.event_name }} GITHUB_CONTEXT: ${{ toJson(github) }} - #REPO_SLUG: ${{ github.repository }} PULL_REQUEST_SLUG: ${{ github.repository }} UPSTREAM_REPO: ${{ github.repository }} PULL_REQUEST_SHA: ${{ github.event.pull_request.head.sha }} PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} UPSTREAM_SHA: ${{ github.sha }} - TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} EVENT_MESSAGE: ${{ github.event.message }} HOME: 'home/runner' run: | - home/runner/travisci-tools/trigger-script-with-status-update.sh + home/runner/ci-helper-tools/trigger-script-with-status-update.sh \ No newline at end of file diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index d5de5b7a..44387a32 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -29,7 +29,6 @@ jobs: uses: optimizely/swift-sdk/.github/workflows/integration_tests.yml@master secrets: CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }} - TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} lint: runs-on: macos-13 @@ -41,14 +40,13 @@ jobs: - env: SRCCLR_API_TOKEN: ${{ secrets.SRCCLR_API_TOKEN }} run: | - gem install cocoapods -v '1.9.3' + gem install cocoapods -v '1.15.2' pod spec lint --quick curl -sSL https://download.sourceclear.com/ci.sh | bash unittests: if: "${{ github.event.inputs.PREP == '' && github.event.inputs.RELEASE == '' }}" uses: optimizely/swift-sdk/.github/workflows/unit_tests.yml@master - prepare_for_release: runs-on: macos-13 if: "${{ github.event.inputs.PREP == 'true' && github.event_name == 'workflow_dispatch' }}" @@ -69,7 +67,7 @@ jobs: BRANCH: ${{ github.ref_name }} GITHUB_USER: optibot GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }} - COCOAPODS_VERSION: '1.12.1' + COCOAPODS_VERSION: '1.15.2' run: | gem install cocoapods -v $COCOAPODS_VERSION Scripts/run_prep.sh @@ -99,4 +97,4 @@ jobs: COCOAPODS_VERSION: '1.15.2' run: | gem install cocoapods -v $COCOAPODS_VERSION - Scripts/run_release.sh + Scripts/run_release.sh \ No newline at end of file From ae8f6b5a304a7da073ce08bf4f72fa5e9d550c75 Mon Sep 17 00:00:00 2001 From: optibot Date: Mon, 2 Jun 2025 20:08:13 +0200 Subject: [PATCH 5/5] ci(git-action): auto release prep for 5.1.1 (#595) Co-authored-by: optibot --- OptimizelySwiftSDK.podspec | 2 +- Sources/Utils/SDKVersion.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OptimizelySwiftSDK.podspec b/OptimizelySwiftSDK.podspec index 14d38f88..22790261 100644 --- a/OptimizelySwiftSDK.podspec +++ b/OptimizelySwiftSDK.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "OptimizelySwiftSDK" s.module_name = "Optimizely" - s.version = "5.1.0" + s.version = "5.1.1" s.summary = "Optimizely experiment framework for iOS/tvOS/watchOS" s.homepage = "https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs" s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" } diff --git a/Sources/Utils/SDKVersion.swift b/Sources/Utils/SDKVersion.swift index 1caaec32..298c7227 100644 --- a/Sources/Utils/SDKVersion.swift +++ b/Sources/Utils/SDKVersion.swift @@ -17,4 +17,4 @@ /// Do not edit this field. /// - It is auto updated (Scripts/updated_version.sh) to reflect the current version /// - Do not put underscores in the name (Swiftlint can modify unexpectedly) -let OPTIMIZELYSDKVERSION = "5.1.0" +let OPTIMIZELYSDKVERSION = "5.1.1"