Fixes #614 - Add the user and device identifiers to rageshakes (#620)

* Fixes #614 - Add the user and device identifiers to rageshakes

* Add `base_bundle_identifier` to rageshakes
This commit is contained in:
Stefan Ceriu
2023-02-24 14:51:36 +02:00
committed by GitHub
parent 252a5f2bdc
commit a3abde9e23
15 changed files with 79 additions and 23 deletions
@@ -23,6 +23,9 @@ enum BugReportCoordinatorResult {
struct BugReportCoordinatorParameters {
let bugReportService: BugReportServiceProtocol
let userID: String
let deviceID: String?
weak var userIndicatorController: UserIndicatorControllerProtocol?
let screenshot: UIImage?
let isModallyPresented: Bool
@@ -38,6 +41,8 @@ final class BugReportCoordinator: CoordinatorProtocol {
self.parameters = parameters
viewModel = BugReportViewModel(bugReportService: parameters.bugReportService,
userID: parameters.userID,
deviceID: parameters.deviceID,
screenshot: parameters.screenshot,
isModallyPresented: parameters.isModallyPresented)
}
@@ -19,14 +19,21 @@ import SwiftUI
typealias BugReportViewModelType = StateStoreViewModel<BugReportViewState, BugReportViewAction>
class BugReportViewModel: BugReportViewModelType, BugReportViewModelProtocol {
let bugReportService: BugReportServiceProtocol
private let bugReportService: BugReportServiceProtocol
private let userID: String
private let deviceID: String?
var callback: ((BugReportViewModelAction) -> Void)?
init(bugReportService: BugReportServiceProtocol,
userID: String,
deviceID: String?,
screenshot: UIImage?,
isModallyPresented: Bool) {
self.bugReportService = bugReportService
self.userID = userID
self.deviceID = deviceID
let bindings = BugReportViewStateBindings(reportText: "", sendingLogsEnabled: true)
super.init(initialViewState: BugReportViewState(screenshot: screenshot,
bindings: bindings,
@@ -61,7 +68,9 @@ class BugReportViewModel: BugReportViewModelType, BugReportViewModelProtocol {
try pngData?.write(to: imageURL)
files.append(imageURL)
}
let bugReport = BugReport(text: context.reportText,
let bugReport = BugReport(userID: userID,
deviceID: deviceID,
text: context.reportText,
includeLogs: context.sendingLogsEnabled,
includeCrashLog: true,
githubLabels: [],
@@ -173,12 +173,16 @@ struct BugReportScreen: View {
struct BugReport_Previews: PreviewProvider {
static let viewModel = BugReportViewModel(bugReportService: MockBugReportService(),
userID: "@mock.client.com",
deviceID: nil,
screenshot: nil,
isModallyPresented: false)
static var previews: some View {
NavigationStack {
BugReportScreen(context: BugReportViewModel(bugReportService: MockBugReportService(),
userID: "@mock.client.com",
deviceID: nil,
screenshot: nil,
isModallyPresented: false).context)
.previewDisplayName("Without Screenshot")
@@ -186,6 +190,8 @@ struct BugReport_Previews: PreviewProvider {
NavigationStack {
BugReportScreen(context: BugReportViewModel(bugReportService: MockBugReportService(),
userID: "@mock.client.com",
deviceID: nil,
screenshot: Asset.Images.appLogo.image,
isModallyPresented: false).context)
.previewDisplayName("With Screenshot")