mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 09:32:52 +02:00
Add AutoReported, re-work big client interface and hook up AutoReporter.
This commit is contained in:
@@ -295,47 +295,8 @@
|
||||
{
|
||||
self.isSendingLogs = YES;
|
||||
|
||||
// Setup data to send
|
||||
bugReportRestClient = [[MXBugReportRestClient alloc] initWithBugReportEndpoint:BuildSettings.bugReportEndpointUrlString];
|
||||
|
||||
// App info
|
||||
bugReportRestClient.appName = BuildSettings.bugReportApplicationId;
|
||||
bugReportRestClient.version = [AppDelegate theDelegate].appVersion;
|
||||
bugReportRestClient.build = [AppDelegate theDelegate].build;
|
||||
|
||||
// Device info
|
||||
bugReportRestClient.deviceModel = [GBDeviceInfo deviceInfo].modelString;
|
||||
bugReportRestClient.deviceOS = [NSString stringWithFormat:@"%@ %@", [[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion]];
|
||||
|
||||
// User info (TODO: handle multi-account and find a way to expose them in rageshake API)
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
MXKAccount *mainAccount = [MXKAccountManager sharedManager].accounts.firstObject;
|
||||
if (mainAccount.mxSession.myUser.userId)
|
||||
{
|
||||
userInfo[@"user_id"] = mainAccount.mxSession.myUser.userId;
|
||||
}
|
||||
if (mainAccount.mxSession.matrixRestClient.credentials.deviceId)
|
||||
{
|
||||
userInfo[@"device_id"] = mainAccount.mxSession.matrixRestClient.credentials.deviceId;
|
||||
}
|
||||
|
||||
userInfo[@"locale"] = [NSLocale preferredLanguages][0];
|
||||
userInfo[@"default_app_language"] = [[NSBundle mainBundle] preferredLocalizations][0]; // The language chosen by the OS
|
||||
userInfo[@"app_language"] = [NSBundle mxk_language] ? [NSBundle mxk_language] : userInfo[@"default_app_language"]; // The language chosen by the user
|
||||
|
||||
// Application settings
|
||||
userInfo[@"lazy_loading"] = [MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers ? @"ON" : @"OFF";
|
||||
|
||||
NSDate *currentDate = [NSDate date];
|
||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
||||
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
|
||||
userInfo[@"local_time"] = [dateFormatter stringFromDate:currentDate];
|
||||
|
||||
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
|
||||
userInfo[@"utc_time"] = [dateFormatter stringFromDate:currentDate];
|
||||
|
||||
bugReportRestClient.others = userInfo;
|
||||
|
||||
bugReportRestClient = [MXBugReportRestClient vc_bugReportRestClientWithAppName:BuildSettings.bugReportApplicationId];
|
||||
|
||||
// Screenshot
|
||||
NSArray<NSURL*> *files;
|
||||
if (_screenshot && _sendScreenshot)
|
||||
@@ -347,56 +308,23 @@
|
||||
|
||||
files = @[screenShotFile];
|
||||
}
|
||||
|
||||
// Prepare labels to attach to the GitHub issue
|
||||
NSMutableArray<NSString*> *gitHubLabels = [NSMutableArray array];
|
||||
if (_reportCrash)
|
||||
{
|
||||
// Label the GH issue as "crash"
|
||||
[gitHubLabels addObject:@"crash"];
|
||||
}
|
||||
|
||||
// Add a Github label giving information about the version
|
||||
if (bugReportRestClient.version && bugReportRestClient.build)
|
||||
{
|
||||
NSString *build = bugReportRestClient.build;
|
||||
NSString *versionLabel = bugReportRestClient.version;
|
||||
|
||||
// If this is not the app store version, be more accurate on the build origin
|
||||
if ([build isEqualToString:[VectorL10n settingsConfigNoBuildInfo]])
|
||||
{
|
||||
// This is a debug session from Xcode
|
||||
versionLabel = [versionLabel stringByAppendingString:@"-debug"];
|
||||
}
|
||||
else if (build && ![build containsString:@"master"])
|
||||
{
|
||||
// This is a Jenkins build. Add the branch and the build number
|
||||
NSString *buildString = [build stringByReplacingOccurrencesOfString:@" " withString:@"-"];
|
||||
versionLabel = [[versionLabel stringByAppendingString:@"-"] stringByAppendingString:buildString];
|
||||
}
|
||||
|
||||
[gitHubLabels addObject:versionLabel];
|
||||
}
|
||||
|
||||
|
||||
NSMutableString *bugReportDescription = [NSMutableString stringWithString:_bugReportDescriptionTextView.text];
|
||||
|
||||
if (_reportCrash)
|
||||
{
|
||||
// Append the crash dump to the user description in order to ease triaging of GH issues
|
||||
NSString *crashLogFile = [MXLogger crashLog];
|
||||
NSString *crashLog = [NSString stringWithContentsOfFile:crashLogFile encoding:NSUTF8StringEncoding error:nil];
|
||||
[bugReportDescription appendFormat:@"\n\n\n--------------------------------------------------------------------------------\n\n%@", crashLog];
|
||||
}
|
||||
|
||||
|
||||
// starting a background task to have a bit of extra time in case of user forgets about the report and sends the app to background
|
||||
__block UIBackgroundTaskIdentifier operationBackgroundId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
|
||||
[[UIApplication sharedApplication] endBackgroundTask:operationBackgroundId];
|
||||
operationBackgroundId = UIBackgroundTaskInvalid;
|
||||
}];
|
||||
|
||||
// Submit
|
||||
[bugReportRestClient sendBugReport:bugReportDescription sendLogs:_sendLogs sendCrashLog:_reportCrash sendFiles:files attachGitHubLabels:gitHubLabels progress:^(MXBugReportState state, NSProgress *progress) {
|
||||
|
||||
[bugReportRestClient vc_sendBugReportWithDescription:bugReportDescription
|
||||
sendLogs:_sendLogs
|
||||
sendCrashLog:_reportCrash
|
||||
sendFiles:files
|
||||
additionalLabels:nil
|
||||
customFields:nil
|
||||
progress:^(MXBugReportState state, NSProgress *progress) {
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case MXBugReportStateProgressZipping:
|
||||
@@ -413,7 +341,7 @@
|
||||
|
||||
self.sendingProgress.progress = progress.fractionCompleted;
|
||||
|
||||
} success:^{
|
||||
} success:^(NSString *reportUrl){
|
||||
|
||||
self->bugReportRestClient = nil;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user