Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 3 additions & 9 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
secrets:
CI_USER_TOKEN:
required: true
TRAVIS_COM_TOKEN:
required: true

jobs:
integration_tests:
runs-on: ubuntu-latest
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
12 changes: 5 additions & 7 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
description: release

env:
VERSION: 5.1.0
VERSION: 5.1.1

jobs:

Expand All @@ -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
Expand All @@ -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' }}"
Expand All @@ -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
Expand All @@ -96,7 +94,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
Scripts/run_release.sh
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ let package = Package(
resources: [.copy("Supporting Files/PrivacyInfo.xcprivacy")]
)
],
swiftLanguageVersions: [.v5, .version("5.9")]
swiftLanguageVersions: [.v5]
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_:<pre>
```use_frameworks!```
```pod 'OptimizelySwiftSDK', '~> 5.1.0'```
```pod 'OptimizelySwiftSDK', '~> 5.1.1'```
</pre>

2. Run the following command: <pre>``` pod install ```</pre>
Expand Down
10 changes: 9 additions & 1 deletion Sources/Implementation/DecisionInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/Utils/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ struct Constants {
}

struct ExperimentDecisionInfoKeys {
static let experimentId = "experimentId"
static let experiment = "experimentKey"
static let variationId = "variationId"
static let variation = "variationKey"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand All @@ -56,19 +60,27 @@ 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)
}

func testDecisionListenerWithActivateWhenUserNotInExperiment() {
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()
})
Expand All @@ -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()
}
Expand All @@ -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()
})
Expand All @@ -111,19 +129,24 @@ 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()
}

func testDecisionListenerWithGetVariationWhenUserNotInExperiment() {
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()
})
Expand All @@ -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()
}
Expand Down