diff --git a/ConfidenceDemoApp/ConfidenceDemoApp/ConfidenceDemoApp.swift b/ConfidenceDemoApp/ConfidenceDemoApp/ConfidenceDemoApp.swift index 1dc1cf1..3876976 100644 --- a/ConfidenceDemoApp/ConfidenceDemoApp/ConfidenceDemoApp.swift +++ b/ConfidenceDemoApp/ConfidenceDemoApp/ConfidenceDemoApp.swift @@ -21,7 +21,6 @@ struct ConfidenceDemoApp: App { let secret = ProcessInfo.processInfo.environment["CLIENT_SECRET"] ?? "" let confidence = Confidence.Builder(clientSecret: secret, loggerLevel: .TRACE) .withContext(initialContext: ["targeting_key": ConfidenceValue(string: UUID.init().uuidString)]) - .withRegion(region: .europe) .build() let status = Status() diff --git a/Sources/Confidence/Confidence.swift b/Sources/Confidence/Confidence.swift index 67c6f10..22ff132 100644 --- a/Sources/Confidence/Confidence.swift +++ b/Sources/Confidence/Confidence.swift @@ -262,10 +262,7 @@ public class Confidence: ConfidenceEventSender { } } - /** - Sets the initial Context. - */ - public func withContext(_ context: ConfidenceStruct) -> Self { + public func withContext(_ context: ConfidenceStruct) -> ConfidenceEventSender { return Self.init( clientSecret: clientSecret, region: region, diff --git a/Sources/Confidence/ConfidenceContextProvider.swift b/Sources/Confidence/ConfidenceContextProvider.swift index 33366dc..57516d1 100644 --- a/Sources/Confidence/ConfidenceContextProvider.swift +++ b/Sources/Confidence/ConfidenceContextProvider.swift @@ -4,5 +4,8 @@ import Foundation A Contextual implementer returns the current context */ public protocol ConfidenceContextProvider { + /** + Returns the current context, including the ancestors' context data + */ func getContext() -> ConfidenceStruct } diff --git a/Sources/Confidence/ConfidenceEventSender.swift b/Sources/Confidence/ConfidenceEventSender.swift index f1af53b..18e7b82 100644 --- a/Sources/Confidence/ConfidenceEventSender.swift +++ b/Sources/Confidence/ConfidenceEventSender.swift @@ -3,7 +3,7 @@ import Foundation /** Sends events to Confidence. Contextual data is appended to each event */ -public protocol ConfidenceEventSender: Contextual { +public protocol ConfidenceEventSender: ConfidenceContextProvider { /** Upon return, the event has been correctly stored and will be emitted to the backend according to the configured flushing logic @@ -18,4 +18,17 @@ public protocol ConfidenceEventSender: Contextual { Schedule a manual flush of the event data currently stored on disk */ func flush() + /** + Adds/override entry to local context data + */ + func putContext(key: String, value: ConfidenceValue) + /** + Removes entry from localcontext data + It hides entries with this key from parents' data (without modifying parents' data) + */ + func removeKey(key: String) + /** + Creates a child event sender instance that maintains access to its parent's data + */ + func withContext(_ context: ConfidenceStruct) -> ConfidenceEventSender } diff --git a/Sources/Confidence/Contextual.swift b/Sources/Confidence/Contextual.swift deleted file mode 100644 index 1172c2f..0000000 --- a/Sources/Confidence/Contextual.swift +++ /dev/null @@ -1,22 +0,0 @@ -import Foundation - -/** -A Contextual implementer maintains local context data and can create child instances -that can still access their parent's data -Each ConfidenceContextProvider returns local data reconciled with parents' data. Local data has precedence -*/ -public protocol Contextual: ConfidenceContextProvider { - /** - Adds/override entry to local data - */ - func putContext(key: String, value: ConfidenceValue) - /** - Removes entry from local data - It hides entries with this key from parents' data (without modifying parents' data) - */ - func removeKey(key: String) - /** - Creates a child Contextual instance that maintains access to its parent's data - */ - func withContext(_ context: ConfidenceStruct) -> Self -}