Skip to content

Commit 0d7c902

Browse files
mario-launchdarklyMario Canto
andauthored
feat: allow any type instead encodable in evaluation series data (#446)
**Requirements** - [ ] I have added test coverage for new or changed functionality - [ ] I have followed the repository's [pull request submission guidelines](../blob/v9/CONTRIBUTING.md#submitting-pull-requests) - [ X ] I have validated my changes against all supported platform versions **Related issues** Provide links to any issues in this repository or elsewhere relating to this pull request. **Describe the solution you've provided** Requirement for EvaluationSeriesData changed from Encodable to Any since it doesn't need serialization. **Describe alternatives you've considered** No other alternative considered since EvaluationSeriesData is not serializable. **Additional context** Needed by Observability plugin for swift. Co-authored-by: Mario Canto <mcanto@DYJ41XP7NT-M4.local>
1 parent 9d3c761 commit 0d7c902

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

ContractTests/Source/Models/hook.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ struct EvaluationPayload: Encodable {
9696

9797
var nested = container.nestedContainer(keyedBy: DynamicKey.self, forKey: .evaluationSeriesData)
9898
try evaluationSeriesData.forEach { (_, _) in
99-
try evaluationSeriesData.forEach { try nested.encode($1, forKey: DynamicKey(stringValue: $0)!) }
99+
for (key, value) in evaluationSeriesData {
100+
guard let encodable = value as? Encodable, let dynamicKey = DynamicKey(stringValue: key) else { continue }
101+
try nested.encode(encodable, forKey: dynamicKey)
102+
}
100103
}
101104
}
102105
}

LaunchDarkly/LaunchDarkly/Models/Hooks/Hook.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Foundation
33
/// Implementation specific hook data for evaluation stages.
44
///
55
/// Hook implementations can use this to store data needed between stages.
6-
public typealias EvaluationSeriesData = [String: Encodable]
6+
public typealias EvaluationSeriesData = [String: Any]
77

88
/// Protocol for extending SDK functionality via hooks.
99
public protocol Hook {

0 commit comments

Comments
 (0)