From 712ff6e927ed7d760af2dfe821e66a5a954027da Mon Sep 17 00:00:00 2001 From: Fabrizio Demaria Date: Tue, 19 Nov 2024 15:52:12 +0100 Subject: [PATCH] feat: Client Key in Resolve Debug logs (#176) --- Sources/Confidence/Confidence.swift | 2 +- Sources/Confidence/DebugLogger.swift | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/Confidence/Confidence.swift b/Sources/Confidence/Confidence.swift index 8e5d8896..64aadbc4 100644 --- a/Sources/Confidence/Confidence.swift +++ b/Sources/Confidence/Confidence.swift @@ -391,7 +391,7 @@ extension Confidence { public func build() -> Confidence { if debugLogger == nil { if loggerLevel != LoggerLevel.NONE { - debugLogger = DebugLoggerImpl(loggerLevel: loggerLevel) + debugLogger = DebugLoggerImpl(loggerLevel: loggerLevel, clientKey: clientSecret) debugLogger?.logContext(action: "InitialContext", context: initialContext) } } diff --git a/Sources/Confidence/DebugLogger.swift b/Sources/Confidence/DebugLogger.swift index b5dbd92f..5b45fc7e 100644 --- a/Sources/Confidence/DebugLogger.swift +++ b/Sources/Confidence/DebugLogger.swift @@ -17,19 +17,21 @@ private extension Logger { internal class DebugLoggerImpl: DebugLogger { private let encoder = JSONEncoder() + private let clientKey: String func logResolveDebugURL(flagName: String, context: ConfidenceStruct) { let ctxNetworkValue = TypeMapper.convert(structure: context) if let ctxNetworkData = try? encoder.encode(ctxNetworkValue), let ctxNetworkString = String(data: ctxNetworkData, encoding: .utf8) { - log(messageLevel: .DEBUG, message: "[Resolve Debug] https://app.confidence.spotify.com/flags/resolver-test?flag=flags/\(flagName)&context=\(ctxNetworkString)") + log(messageLevel: .DEBUG, message: "[Resolve Debug] https://app.confidence.spotify.com/flags/resolver-test?client-key=\(clientKey)&flag=flags/\(flagName)&context=\(ctxNetworkString)") } } private let loggerLevel: LoggerLevel - init(loggerLevel: LoggerLevel) { + init(loggerLevel: LoggerLevel, clientKey: String) { self.loggerLevel = loggerLevel + self.clientKey = clientKey } func logMessage(message: String, isWarning: Bool = false) {