diff --git a/Sources/OpenFeature/Hook.swift b/Sources/OpenFeature/Hook.swift index 2b037f6..fcf4bff 100644 --- a/Sources/OpenFeature/Hook.swift +++ b/Sources/OpenFeature/Hook.swift @@ -11,7 +11,7 @@ public protocol Hook { func error(ctx: HookContext, error: Error, hints: [String: Any]) - func finally(ctx: HookContext, hints: [String: Any]) + func finally(ctx: HookContext, details: FlagEvaluationDetails, hints: [String: Any]) func supportsFlagValueType(flagValueType: FlagValueType) -> Bool } @@ -31,7 +31,7 @@ extension Hook { // Default implementation } - public func finally(ctx: HookContext, hints: [String: Any]) { + public func finally(ctx: HookContext, details: FlagEvaluationDetails, hints: [String: Any]) { // Default implementation } diff --git a/Sources/OpenFeature/HookSupport.swift b/Sources/OpenFeature/HookSupport.swift index 1f4375d..acf9455 100644 --- a/Sources/OpenFeature/HookSupport.swift +++ b/Sources/OpenFeature/HookSupport.swift @@ -33,10 +33,14 @@ class HookSupport { } func finallyHooks( - flagValueType: FlagValueType, hookCtx: HookContext, hooks: [any Hook], hints: [String: Any] + flagValueType: FlagValueType, + hookCtx: HookContext, + details: FlagEvaluationDetails, + hooks: [any Hook], + hints: [String: Any] ) { hooks .filter { $0.supportsFlagValueType(flagValueType: flagValueType) } - .forEach { $0.finally(ctx: hookCtx, hints: hints) } + .forEach { $0.finally(ctx: hookCtx, details: details, hints: hints) } } } diff --git a/Sources/OpenFeature/OpenFeatureClient.swift b/Sources/OpenFeature/OpenFeatureClient.swift index d54cdc6..30396e3 100644 --- a/Sources/OpenFeature/OpenFeatureClient.swift +++ b/Sources/OpenFeature/OpenFeatureClient.swift @@ -144,7 +144,7 @@ extension OpenFeatureClient { flagValueType: T.flagValueType, hookCtx: hookCtx, error: error, hooks: mergedHooks, hints: hints) } hookSupport.finallyHooks( - flagValueType: T.flagValueType, hookCtx: hookCtx, hooks: mergedHooks, hints: hints) + flagValueType: T.flagValueType, hookCtx: hookCtx, details: details, hooks: mergedHooks, hints: hints) return details } diff --git a/Tests/OpenFeatureTests/Helpers/BooleanHookMock.swift b/Tests/OpenFeatureTests/Helpers/BooleanHookMock.swift index 6cd4807..dbccca7 100644 --- a/Tests/OpenFeatureTests/Helpers/BooleanHookMock.swift +++ b/Tests/OpenFeatureTests/Helpers/BooleanHookMock.swift @@ -38,7 +38,7 @@ class BooleanHookMock: Hook { self.addEval(self.prefix.isEmpty ? "error" : "\(self.prefix) error") } - func finally(ctx: HookContext, hints: [String: Any]) { + func finally(ctx: HookContext, details: FlagEvaluationDetails, hints: [String: Any]) { finallyCalled += 1 self.addEval(self.prefix.isEmpty ? "finally" : "\(self.prefix) finally") } diff --git a/Tests/OpenFeatureTests/Helpers/IntHookMock.swift b/Tests/OpenFeatureTests/Helpers/IntHookMock.swift index 78d6623..0a5f050 100644 --- a/Tests/OpenFeatureTests/Helpers/IntHookMock.swift +++ b/Tests/OpenFeatureTests/Helpers/IntHookMock.swift @@ -38,7 +38,7 @@ class IntHookMock: Hook { self.addEval(self.prefix.isEmpty ? "error" : "\(self.prefix) error") } - func finally(ctx: HookContext, hints: [String: Any]) { + func finally(ctx: HookContext, details: FlagEvaluationDetails, hints: [String: Any]) { finallyCalled += 1 self.addEval(self.prefix.isEmpty ? "finally" : "\(self.prefix) finally") } diff --git a/Tests/OpenFeatureTests/HookSupportTests.swift b/Tests/OpenFeatureTests/HookSupportTests.swift index 145fcf7..78a9b52 100644 --- a/Tests/OpenFeatureTests/HookSupportTests.swift +++ b/Tests/OpenFeatureTests/HookSupportTests.swift @@ -37,6 +37,7 @@ final class HookSupportTests: XCTestCase { hookSupport.finallyHooks( flagValueType: .boolean, hookCtx: hookContext, + details: FlagEvaluationDetails(flagKey: "", value: false), hooks: [hook], hints: [:])