forked from GitLiveApp/firebase-kotlin-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
/
crashlytics.kt
238 lines (220 loc) · 9.39 KB
/
crashlytics.kt
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
package dev.gitlive.firebase.crashlytics
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.FirebaseApp
import dev.gitlive.firebase.FirebaseException
/** Returns the [FirebaseCrashlytics] instance of the default [FirebaseApp]. */
public expect val Firebase.crashlytics: FirebaseCrashlytics
/** Returns the [FirebaseCrashlytics] instance of a given [FirebaseApp]. */
public expect fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics
/**
* The Firebase Crashlytics API provides methods to annotate and manage fatal crashes, non-fatal
* errors, and ANRs captured and reported to Firebase Crashlytics.
*
* By default, Firebase Crashlytics is automatically initialized.
*
* Call [Firebase.crashlytics] to get the singleton instance of
* [FirebaseCrashlytics].
*/
public expect class FirebaseCrashlytics {
/**
* Records a non-fatal report to send to Crashlytics.
*
* @param exception a [Throwable] to be recorded as a non-fatal event.
*/
public fun recordException(exception: Throwable)
/**
* Logs a message that's included in the next fatal, non-fatal, or ANR report.
*
* Logs are visible in the session view on the Firebase Crashlytics console.
*
* Newline characters are stripped and extremely long messages are truncated. The maximum log
* size is 64k. If exceeded, the log rolls such that messages are removed, starting from the
* oldest.
*
* @param message the message to be logged
*/
public fun log(message: String)
/**
* Records a user ID (identifier) that's associated with subsequent fatal, non-fatal, and ANR
* reports.
*
* The user ID is visible in the session view on the Firebase Crashlytics console.
*
* Identifiers longer than 1024 characters will be truncated.
*
* @param userId a unique identifier for the current user
*/
public fun setUserId(userId: String)
/**
* Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR
* reports.
*
* Multiple calls to this method with the same key update the value for that key.
*
* The value of any key at the time of a fatal, non-fatal, or ANR event is associated with that
* event.
*
* Keys and associated values are visible in the session view on the Firebase Crashlytics
* console.
*
* Accepts a maximum of 64 key/value pairs. New keys beyond that limit are ignored. Keys or
* values that exceed 1024 characters are truncated.
*
* @param key A unique key
* @param value A value to be associated with the given key
*/
public fun setCustomKey(key: String, value: String)
/**
* Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR
* reports.
*
* Multiple calls to this method with the same key update the value for that key.
*
* The value of any key at the time of a fatal, non-fatal, or ANR event is associated with that
* event.
*
* Keys and associated values are visible in the session view on the Firebase Crashlytics
* console.
*
* Accepts a maximum of 64 key/value pairs. New keys beyond that limit are ignored. Keys or
* values that exceed 1024 characters are truncated.
*
* @param key A unique key
* @param value A value to be associated with the given key
*/
public fun setCustomKey(key: String, value: Boolean)
/**
* Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR
* reports.
*
* Multiple calls to this method with the same key update the value for that key.
*
* The value of any key at the time of a fatal, non-fatal, or ANR event is associated with that
* event.
*
* Keys and associated values are visible in the session view on the Firebase Crashlytics
* console.
*
* Accepts a maximum of 64 key/value pairs. New keys beyond that limit are ignored. Keys or
* values that exceed 1024 characters are truncated.
*
* @param key A unique key
* @param value A value to be associated with the given key
*/
public fun setCustomKey(key: String, value: Double)
/**
* Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR
* reports.
*
* Multiple calls to this method with the same key update the value for that key.
*
* The value of any key at the time of a fatal, non-fatal, or ANR event is associated with that
* event.
*
* Keys and associated values are visible in the session view on the Firebase Crashlytics
* console.
*
* Accepts a maximum of 64 key/value pairs. New keys beyond that limit are ignored. Keys or
* values that exceed 1024 characters are truncated.
*
* @param key A unique key
* @param value A value to be associated with the given key
*/
public fun setCustomKey(key: String, value: Float)
/**
* Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR
* reports.
*
* Multiple calls to this method with the same key update the value for that key.
*
* The value of any key at the time of a fatal, non-fatal, or ANR event is associated with that
* event.
*
* Keys and associated values are visible in the session view on the Firebase Crashlytics
* console.
*
* Accepts a maximum of 64 key/value pairs. New keys beyond that limit are ignored. Keys or
* values that exceed 1024 characters are truncated.
*
* @param key A unique key
* @param value A value to be associated with the given key
*/
public fun setCustomKey(key: String, value: Int)
/**
* Sets a custom key and value that are associated with subsequent fatal, non-fatal, and ANR
* reports.
*
* Multiple calls to this method with the same key update the value for that key.
*
* The value of any key at the time of a fatal, non-fatal, or ANR event is associated with that
* event.
*
* Keys and associated values are visible in the session view on the Firebase Crashlytics
* console.
*
* Accepts a maximum of 64 key/value pairs. New keys beyond that limit are ignored. Keys or
* values that exceed 1024 characters are truncated.
*
* @param key A unique key
* @param value A value to be associated with the given key
*/
public fun setCustomKey(key: String, value: Long)
/**
* Sets multiple custom keys and values that are associated with subsequent fatal, non-fatal, and
* ANR reports. This method is intended as an alternative to [setCustomKey] in order to
* reduce the computational load of writing out multiple key/value pairs at the same time.
*
* Multiple calls to this method with the same key update the value for that key.
*
* The value of any key at the time of a fatal, non-fatal, or ANR event is associated with that
* event.
*
* Keys and associated values are visible in the session view on the Firebase Crashlytics
* console.
*
* Accepts a maximum of 64 key/value pairs. If calling this method results in the number of
* custom keys exceeding this limit, only some of the keys will be logged (however many are needed
* to get to 64). Which keys are logged versus dropped is unpredictable as there is no intrinsic
* sorting of keys. Keys or values that exceed 1024 characters are truncated.
*
* @param customKeys A dictionary of keys and the values to associate with each key
*/
public fun setCustomKeys(customKeys: Map<String, Any>)
/**
* Enables or disables the automatic data collection configuration for Crashlytics.
*
* If this is set, it overrides any automatic data collection settings configured in the
* AndroidManifest.xml as well as any Firebase-wide settings.
*
* If automatic data collection is disabled for Crashlytics, crash reports are stored on the
* device. Use [sendUnsentReports] to upload existing reports even when automatic data collection is
* disabled. Use [deleteUnsentReports] to delete any reports stored on the device without
* sending them to Crashlytics.
*
* @param enabled whether to enable automatic data collection. When set to `false`, the new
* value does not apply until the next run of the app. To disable data collection by default
* for all app runs, add the `firebase_crashlytics_collection_enabled` flag to your
* app's AndroidManifest.xml.
*/
public fun setCrashlyticsCollectionEnabled(enabled: Boolean)
/**
* Checks whether the app crashed on its previous run.
*
* @return true if a crash was recorded during the previous run of the app.
*/
public fun didCrashOnPreviousExecution(): Boolean
/**
* If automatic data collection is disabled, this method queues up all the reports on a device to
* send to Crashlytics. Otherwise, this method is a no-op.
*/
public fun sendUnsentReports()
/**
* If automatic data collection is disabled, this method queues up all the reports on a device for
* deletion. Otherwise, this method is a no-op.
*/
public fun deleteUnsentReports()
}
/**
* Exception that gets thrown when an operation on Firebase Crashlytics fails.
*/
public expect open class FirebaseCrashlyticsException : FirebaseException