-
-
Notifications
You must be signed in to change notification settings - Fork 372
fix: Multiple attachments support for feedback #6752
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
Merged
+84
β42
Merged
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8d5be89
Fix multiple attachments support for feedback
tustanivsky eee7e7f
Merge branch 'main' into fix/feedback-attachments
itaybre eca3e59
Merge branch 'main' into fix/feedback-attachments
tustanivsky c1c5216
Merge branch 'main' into fix/feedback-attachments
tustanivsky 3745910
Fix file extension
tustanivsky c84fa77
Merge branch 'main' into fix/feedback-attachments
tustanivsky f2343e6
Move attachment serialization to extension
tustanivsky 75ae071
Update changelog
tustanivsky 5c3e737
Update public api
tustanivsky d5d2e20
Fix changelog
tustanivsky 4c86b44
add commit to trigger GHA
philprime f2f059c
Revert "add commit to trigger GHA"
philprime bafb3fd
Merge branch 'main' into fix/feedback-attachments
tustanivsky 07be60a
Fix changelog
tustanivsky 7ac664d
Merge branch 'main' into fix/feedback-attachments
tustanivsky d2e7f9e
Merge branch 'main' into fix/feedback-attachments
tustanivsky b1a3163
Fix sample
tustanivsky 653ed44
Merge branch 'main' into fix/feedback-attachments
tustanivsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,9 +205,9 @@ class ExtraViewController: UIViewController { | |
|
|
||
| @IBAction func captureUserFeedbackV2(_ sender: UIButton) { | ||
| highlightButton(sender) | ||
| var attachments: [Data]? | ||
| var attachments: [Attachment]? | ||
| if let url = BundleResourceProvider.screenshotURL, let data = try? Data(contentsOf: url) { | ||
| attachments = [data] | ||
| attachments = [Attachment(data: data, filename: "screenshot.png", contentType: "image/png")] | ||
| } | ||
| let errorEventID = SentrySDK.capture(error: NSError(domain: "test-error.user-feedback.iOS-Swift", code: 1)) | ||
| let feedback = SentryFeedback(message: "It broke again on iOS-Swift. I don't know why, but this happens.", name: "John Me", email: "[email protected]", source: .custom, associatedEventId: errorEventID, attachments: attachments) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,65 +30,84 @@ class SentryFeedbackTests: XCTestCase { | |
| } | ||
|
|
||
| func testSerializeWithAllFields() throws { | ||
| let sut = SentryFeedback(message: "Test feedback message", name: "Test feedback provider", email: "[email protected]", attachments: [Data()]) | ||
|
|
||
| let attachment = Attachment(data: Data(), filename: "screenshot.png", contentType: "image/png") | ||
| let sut = SentryFeedback(message: "Test feedback message", name: "Test feedback provider", email: "[email protected]", attachments: [attachment]) | ||
|
|
||
| let serialization = sut.serialize() | ||
| XCTAssertEqual(try XCTUnwrap(serialization["message"] as? String), "Test feedback message") | ||
| XCTAssertEqual(try XCTUnwrap(serialization["name"] as? String), "Test feedback provider") | ||
| XCTAssertEqual(try XCTUnwrap(serialization["contact_email"] as? String), "[email protected]") | ||
| XCTAssertEqual(try XCTUnwrap(serialization["source"] as? String), "widget") | ||
|
|
||
| let attachments = sut.attachmentsForEnvelope() | ||
| XCTAssertEqual(attachments.count, 1) | ||
| XCTAssertEqual(try XCTUnwrap(attachments.first).filename, "screenshot.png") | ||
| XCTAssertEqual(try XCTUnwrap(attachments.first).contentType, "application/png") | ||
| XCTAssertEqual(try XCTUnwrap(attachments.first).contentType, "image/png") | ||
| } | ||
|
|
||
| func testSerializeCustomFeedback() throws { | ||
| let sut = SentryFeedback(message: "Test feedback message", name: "Test feedback provider", email: "[email protected]", source: .custom, attachments: [Data()]) | ||
|
|
||
| let attachment = Attachment(data: Data(), filename: "screenshot.png", contentType: "image/png") | ||
| let sut = SentryFeedback(message: "Test feedback message", name: "Test feedback provider", email: "[email protected]", source: .custom, attachments: [attachment]) | ||
|
|
||
| let serialization = sut.serialize() | ||
| XCTAssertEqual(try XCTUnwrap(serialization["message"] as? String), "Test feedback message") | ||
| XCTAssertEqual(try XCTUnwrap(serialization["name"] as? String), "Test feedback provider") | ||
| XCTAssertEqual(try XCTUnwrap(serialization["contact_email"] as? String), "[email protected]") | ||
| XCTAssertEqual(try XCTUnwrap(serialization["source"] as? String), "custom") | ||
|
|
||
| let attachments = sut.attachmentsForEnvelope() | ||
| XCTAssertEqual(attachments.count, 1) | ||
| XCTAssertEqual(try XCTUnwrap(attachments.first).filename, "screenshot.png") | ||
| XCTAssertEqual(try XCTUnwrap(attachments.first).contentType, "application/png") | ||
| XCTAssertEqual(try XCTUnwrap(attachments.first).contentType, "image/png") | ||
| } | ||
|
|
||
| func testSerializeWithAssociatedEventID() throws { | ||
| let eventID = SentryId() | ||
|
|
||
| let sut = SentryFeedback(message: "Test feedback message", name: "Test feedback provider", email: "[email protected]", source: .custom, associatedEventId: eventID, attachments: [Data()]) | ||
| let attachment = Attachment(data: Data(), filename: "screenshot.png", contentType: "image/png") | ||
| let sut = SentryFeedback(message: "Test feedback message", name: "Test feedback provider", email: "[email protected]", source: .custom, associatedEventId: eventID, attachments: [attachment]) | ||
|
|
||
| let serialization = sut.serialize() | ||
| XCTAssertEqual(try XCTUnwrap(serialization["message"] as? String), "Test feedback message") | ||
| XCTAssertEqual(try XCTUnwrap(serialization["name"] as? String), "Test feedback provider") | ||
| XCTAssertEqual(try XCTUnwrap(serialization["contact_email"] as? String), "[email protected]") | ||
| XCTAssertEqual(try XCTUnwrap(serialization["source"] as? String), "custom") | ||
| XCTAssertEqual(try XCTUnwrap(serialization["associated_event_id"] as? String), eventID.sentryIdString) | ||
|
|
||
| let attachments = sut.attachmentsForEnvelope() | ||
| XCTAssertEqual(attachments.count, 1) | ||
| XCTAssertEqual(try XCTUnwrap(attachments.first).filename, "screenshot.png") | ||
| XCTAssertEqual(try XCTUnwrap(attachments.first).contentType, "application/png") | ||
| XCTAssertEqual(try XCTUnwrap(attachments.first).contentType, "image/png") | ||
| } | ||
|
|
||
| func testSerializeWithNoOptionalFields() throws { | ||
| let sut = SentryFeedback(message: "Test feedback message", name: nil, email: nil) | ||
|
|
||
| let serialization = sut.serialize() | ||
| XCTAssertEqual(try XCTUnwrap(serialization["message"] as? String), "Test feedback message") | ||
| XCTAssertNil(serialization["name"]) | ||
| XCTAssertNil(serialization["contact_email"]) | ||
| XCTAssertEqual(try XCTUnwrap(serialization["source"] as? String), "widget") | ||
|
|
||
| let attachments = sut.attachmentsForEnvelope() | ||
| XCTAssertEqual(attachments.count, 0) | ||
| } | ||
|
|
||
| func testMultipleAttachments() throws { | ||
| let screenshot = Attachment(data: Data("screenshot".utf8), filename: "screenshot.png", contentType: "image/png") | ||
| let logFile = Attachment(data: Data("log content".utf8), filename: "app.log", contentType: "text/plain") | ||
| let videoFile = Attachment(data: Data("video".utf8), filename: "recording.mp4", contentType: "video/mp4") | ||
|
|
||
| let sut = SentryFeedback(message: "Test feedback with multiple attachments", name: "Test User", email: "[email protected]", attachments: [screenshot, logFile, videoFile]) | ||
|
|
||
| let attachments = sut.attachmentsForEnvelope() | ||
| XCTAssertEqual(attachments.count, 3) | ||
| XCTAssertEqual(attachments[0].filename, "screenshot.png") | ||
| XCTAssertEqual(attachments[0].contentType, "image/png") | ||
| XCTAssertEqual(attachments[1].filename, "app.log") | ||
| XCTAssertEqual(attachments[1].contentType, "text/plain") | ||
| XCTAssertEqual(attachments[2].filename, "recording.mp4") | ||
| XCTAssertEqual(attachments[2].contentType, "video/mp4") | ||
| } | ||
|
|
||
| private let inputCombinations: [FeedbackTestCase] = [ | ||
| // base case: don't require name or email, don't input a name or email, don't input a message or screenshot | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.