-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFirebaseStaticReporter.swift
46 lines (37 loc) · 1.17 KB
/
FirebaseStaticReporter.swift
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
/*
* Copyright 2020 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/
import FirebaseCrashlytics
import MCRCDynamicProxy
public class MokoFirebaseCrashlytics: FirebaseCrashlyticsReporter {
public func setUserId(userId: String) {
Crashlytics.crashlytics().setUserID(userId)
}
public func setCustomValue(value: String, forKey: String) {
Crashlytics.crashlytics().setCustomValue(value, forKey: forKey)
}
public func recordException(name: String, reason: String, stackTrace: [UInt]) {
let exceptionModel = ExceptionModel(
name: name,
reason: reason
)
let stackFrames = stackTrace.map {
StackFrame(address: $0)
}
exceptionModel.stackTrace = stackFrames
Crashlytics.crashlytics().record(exceptionModel: exceptionModel)
}
public func recordFatalException(
name: String,
reason: String,
stackTrace: [UInt]
) {
recordException(name: name, reason: reason, stackTrace: stackTrace)
}
public func log(message: String) {
Crashlytics.crashlytics().log(message)
}
public static func setup() {
FirebaseDynamicProxy.reporter = MokoFirebaseCrashlytics()
}
}