diff --git a/DuckDuckGo/Feedback/VPNMetadataCollector.swift b/DuckDuckGo/Feedback/VPNMetadataCollector.swift index a2f6b69669..1b8862dc6a 100644 --- a/DuckDuckGo/Feedback/VPNMetadataCollector.swift +++ b/DuckDuckGo/Feedback/VPNMetadataCollector.swift @@ -93,6 +93,17 @@ struct VPNMetadata: Encodable { return String(data: encodedMetadata, encoding: .utf8) } + + func toBase64() -> String { + let encoder = JSONEncoder() + + do { + let encodedMetadata = try encoder.encode(self) + return encodedMetadata.base64EncodedString() + } catch { + return "Failed to encode metadata to JSON, error message: \(error.localizedDescription)" + } + } } protocol VPNMetadataCollector { diff --git a/DuckDuckGo/Subscription/Feedback/UnifiedFeedbackSender.swift b/DuckDuckGo/Subscription/Feedback/UnifiedFeedbackSender.swift index 76f7a03590..c818708712 100644 --- a/DuckDuckGo/Subscription/Feedback/UnifiedFeedbackSender.swift +++ b/DuckDuckGo/Subscription/Feedback/UnifiedFeedbackSender.swift @@ -122,7 +122,7 @@ struct DefaultFeedbackSender: UnifiedFeedbackSender { category: Category.from(category), subcategory: Subcategory.from(subcategory), description: description, - metadata: metadata?.toBase64() ?? ""), + metadata: metadata?.toString() ?? ""), frequency: .regular) } diff --git a/DuckDuckGo/Subscription/Feedback/UnifiedMetadataCollector.swift b/DuckDuckGo/Subscription/Feedback/UnifiedMetadataCollector.swift index e6a0c25161..40f1c80a18 100644 --- a/DuckDuckGo/Subscription/Feedback/UnifiedMetadataCollector.swift +++ b/DuckDuckGo/Subscription/Feedback/UnifiedMetadataCollector.swift @@ -26,18 +26,17 @@ protocol UnifiedMetadataCollector { } protocol UnifiedFeedbackMetadata: Encodable { - func toBase64() -> String + func toString() -> String } extension UnifiedFeedbackMetadata { - func toBase64() -> String { + func toString() -> String { let encoder = JSONEncoder() - do { let encodedMetadata = try encoder.encode(self) - return encodedMetadata.base64EncodedString() + return String(data: encodedMetadata, encoding: .utf8) ?? "" } catch { - return "Failed to encode metadata to JSON, error message: \(error.localizedDescription)" + return "Failed to encode metadata to JSON string, error message: \(error.localizedDescription)" } } }