Skip to content

Commit

Permalink
fix: Removes flag resolving from Confidence child instances (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziodemaria committed Jul 2, 2024
1 parent 4be8b1b commit 543c380
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions Sources/Confidence/Confidence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions Sources/Confidence/ConfidenceContextProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
15 changes: 14 additions & 1 deletion Sources/Confidence/ConfidenceEventSender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
22 changes: 0 additions & 22 deletions Sources/Confidence/Contextual.swift

This file was deleted.

0 comments on commit 543c380

Please sign in to comment.