Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer base64 encode customMetadata #3438

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions DuckDuckGo/Feedback/VPNMetadataCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ struct VPNMetadata: Encodable {

return String(data: encodedMetadata, encoding: .utf8)
}

func toBase64() -> String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is still used in DefaultVPNFeedbackSender which is used when usesUnifiedFeedbackForm is false. Is it expected?

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
}
}
Loading