-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBacktraceWrapper.m
54 lines (40 loc) · 1.93 KB
/
BacktraceWrapper.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#import "BacktraceWrapper.h"
#if defined(__arm64__) && __arm64__
#import "Backtrace-Swift.h"
#import "Backtrace-PLCrashReporter-umbrella.h"
#endif
@implementation BacktraceWrapper
#pragma mark Globals
#if defined(__arm64__) && __arm64__
static BacktraceClient* client;
#endif
#pragma mark Private
+(void)initializeBacktrace {
#if defined(__arm64__) && __arm64__
if (client != nil) {
return;
}
BacktraceCredentials* credentials = [[BacktraceCredentials alloc] initWithSubmissionUrl: [NSURL URLWithString: @"https://submit.backtrace.io/BACKTRACE_SUBDOMAIN/BACKTRACE_SUBMISSION_TOKEN/plcrash"]];
BacktraceDatabaseSettings *dbSettings = [[BacktraceDatabaseSettings alloc] init];
dbSettings.maxRecordCount = 10;
BacktraceClientConfiguration *configuration = [[BacktraceClientConfiguration alloc]
initWithCredentials: credentials
dbSettings: dbSettings
reportsPerMin: 30 // Default is 30
allowsAttachingDebugger: FALSE // If false, disables backtrace during development
detectOOM: FALSE];
BacktraceCrashReporter* crashReporter = [[BacktraceCrashReporter alloc] initWithConfig: PLCrashReporterConfig.defaultConfiguration];
client = [[BacktraceClient alloc] initWithConfiguration:configuration crashReporter:crashReporter error:nil];
[client.metrics enableWithSettings:[[BacktraceMetricsSettings alloc] init]];
#endif
}
#pragma mark Public
+(void)sendError:(NSError*)error attributes:(NSDictionary*)extra {
#if defined(__arm64__) && __arm64__
[self initializeBacktrace];
[client sendWithError:error attachmentPaths:@[] completion:^(BacktraceResult * _Nonnull result) {
NSLog(@"Backtrace error sent: %@", [error description]);
}];
#endif
}
@end