@react-native-firebase/crashlytics 20.3.0 → 20.4.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [20.4.0](https://github.com/invertase/react-native-firebase/compare/v20.3.0...v20.4.0) (2024-08-13)
7
+
8
+ **Note:** Version bump only for package @react-native-firebase/crashlytics
9
+
6
10
  ## [20.3.0](https://github.com/invertase/react-native-firebase/compare/v20.2.1...v20.3.0) (2024-07-19)
7
11
 
8
12
  **Note:** Version bump only for package @react-native-firebase/crashlytics
@@ -1,6 +1,21 @@
1
1
  import { describe, expect, it } from '@jest/globals';
2
2
 
3
- import { firebase } from '../lib';
3
+ import {
4
+ firebase,
5
+ getCrashlytics,
6
+ isCrashlyticsCollectionEnabled,
7
+ checkForUnsentReports,
8
+ deleteUnsentReports,
9
+ didCrashOnPreviousExecution,
10
+ crash,
11
+ log,
12
+ recordError,
13
+ sendUnsentReports,
14
+ setUserId,
15
+ setAttribute,
16
+ setAttributes,
17
+ setCrashlyticsCollectionEnabled,
18
+ } from '../lib';
4
19
 
5
20
  describe('Crashlytics', function () {
6
21
  describe('namespace', function () {
@@ -10,4 +25,58 @@ describe('Crashlytics', function () {
10
25
  expect(app.crashlytics().app).toEqual(app);
11
26
  });
12
27
  });
28
+
29
+ describe('modular', function () {
30
+ it('`getCrashlytics` function is properly exposed to end user', function () {
31
+ expect(getCrashlytics).toBeDefined();
32
+ });
33
+
34
+ it('`isCrashlyticsCollectionEnabled` function is properly exposed to end user', function () {
35
+ expect(isCrashlyticsCollectionEnabled).toBeDefined();
36
+ });
37
+
38
+ it('`checkForUnsentReports` function is properly exposed to end user', function () {
39
+ expect(checkForUnsentReports).toBeDefined();
40
+ });
41
+
42
+ it('`deleteUnsentReports` function is properly exposed to end user', function () {
43
+ expect(deleteUnsentReports).toBeDefined();
44
+ });
45
+
46
+ it('`didCrashOnPreviousExecution` function is properly exposed to end user', function () {
47
+ expect(didCrashOnPreviousExecution).toBeDefined();
48
+ });
49
+
50
+ it('`crash` function is properly exposed to end user', function () {
51
+ expect(crash).toBeDefined();
52
+ });
53
+
54
+ it('`log` function is properly exposed to end user', function () {
55
+ expect(log).toBeDefined();
56
+ });
57
+
58
+ it('`recordError` function is properly exposed to end user', function () {
59
+ expect(recordError).toBeDefined();
60
+ });
61
+
62
+ it('`sendUnsentReports` function is properly exposed to end user', function () {
63
+ expect(sendUnsentReports).toBeDefined();
64
+ });
65
+
66
+ it('`setUserId` function is properly exposed to end user', function () {
67
+ expect(setUserId).toBeDefined();
68
+ });
69
+
70
+ it('`setAttribute` function is properly exposed to end user', function () {
71
+ expect(setAttribute).toBeDefined();
72
+ });
73
+
74
+ it('`setAttributes` function is properly exposed to end user', function () {
75
+ expect(setAttributes).toBeDefined();
76
+ });
77
+
78
+ it('`setCrashlyticsCollectionEnabled` function is properly exposed to end user', function () {
79
+ expect(setCrashlyticsCollectionEnabled).toBeDefined();
80
+ });
81
+ });
13
82
  });
package/lib/index.d.ts CHANGED
@@ -266,6 +266,8 @@ export const firebase: ReactNativeFirebase.Module & {
266
266
 
267
267
  export default defaultExport;
268
268
 
269
+ export * from './modular';
270
+
269
271
  /**
270
272
  * Attach namespace to `firebase.` and `FirebaseApp.`.
271
273
  */
@@ -1,11 +1,16 @@
1
1
  import { firebase } from '..';
2
2
 
3
3
  /**
4
- * @typedef {import("..").FirebaseApp} FirebaseApp
5
- * @typedef {import("..").FirebaseCrashlyticsTypes.Module} FirebaseCrashlytics
4
+ * @typedef {import('@firebase/app').FirebaseApp} FirebaseApp
5
+ * @typedef {import('..').FirebaseCrashlyticsTypes.Module} FirebaseCrashlytics
6
6
  */
7
7
 
8
8
  /**
9
+ * Returns Crashlytics instance.
10
+ * #### Example
11
+ * ```js
12
+ * const crashlytics = getCrashlytics();
13
+ * ```
9
14
  * @param {FirebaseApp} app
10
15
  * @returns {FirebaseCrashlytics}
11
16
  */
@@ -14,6 +19,14 @@ export function getCrashlytics() {
14
19
  }
15
20
 
16
21
  /**
22
+ * Whether Crashlytics reporting is enabled.
23
+ *
24
+ * #### Example
25
+ *
26
+ * ```js
27
+ * const crashlytics = getCrashlytics();
28
+ * const isEnabled = isCrashlyticsCollectionEnabled(crashlytics);
29
+ * ```
17
30
  * @param {FirebaseCrashlytics} crashlytics
18
31
  * @returns {boolean}
19
32
  */
@@ -22,6 +35,20 @@ export function isCrashlyticsCollectionEnabled(crashlytics) {
22
35
  }
23
36
 
24
37
  /**
38
+ * Determines whether there are any unsent crash reports cached on the device. The callback only executes
39
+ * if automatic data collection is disabled.
40
+ *
41
+ * #### Example
42
+ *
43
+ * ```js
44
+ * async checkReports() {
45
+ * // returns boolean value
46
+ * const crashlytics = getCrashlytics();
47
+ * const unsentReports = await checkForUnsentReports(crashlytics);
48
+ * }
49
+ *
50
+ * checkReports();
51
+ * ```
25
52
  * @param {FirebaseCrashlytics} crashlytics
26
53
  * @returns {Promise<boolean>}
27
54
  */
@@ -30,6 +57,15 @@ export function checkForUnsentReports(crashlytics) {
30
57
  }
31
58
 
32
59
  /**
60
+ * Deletes any unsent reports on the device. This method only applies if automatic data collection is
61
+ * disabled.
62
+ *
63
+ * #### Example
64
+ *
65
+ * ```js
66
+ * const crashlytics = getCrashlytics();
67
+ * deleteUnsentReports(crashlytics);
68
+ * ```
33
69
  * @param {FirebaseCrashlytics} crashlytics
34
70
  * @returns {Promise<void>}
35
71
  */
@@ -38,6 +74,19 @@ export function deleteUnsentReports(crashlytics) {
38
74
  }
39
75
 
40
76
  /**
77
+ * Returns a boolean value indicating whether the app crashed during the previous execution.
78
+ *
79
+ * #### Example
80
+ *
81
+ * ```js
82
+ * async didCrashPreviously() {
83
+ * // returns boolean value
84
+ * const crashlytics = getCrashlytics();
85
+ * const didCrash = await didCrashOnPreviousExecution(crashlytics);
86
+ * }
87
+ *
88
+ * didCrashPreviously();
89
+ * ```
41
90
  * @param {FirebaseCrashlytics} crashlytics
42
91
  * @returns {Promise<boolean>}
43
92
  */
@@ -46,6 +95,16 @@ export function didCrashOnPreviousExecution(crashlytics) {
46
95
  }
47
96
 
48
97
  /**
98
+ * Cause your app to crash for testing purposes. This is a native crash and will not contain a javascript stack trace.
99
+ * Note that crashes are intercepted by debuggers on iOS so no report will be seen under those conditions. Additionally
100
+ * if it is a debug build you will need to ensure your firebase.json is configured to enable crashlytics even in debug mode.
101
+ *
102
+ * #### Example
103
+ *
104
+ * ```js
105
+ * const crashlytics = getCrashlytics();
106
+ * crash(crashlytics);
107
+ * ```
49
108
  * @param {FirebaseCrashlytics} crashlytics
50
109
  * @returns {void}
51
110
  */
@@ -54,6 +113,15 @@ export function crash(crashlytics) {
54
113
  }
55
114
 
56
115
  /**
116
+ * Log a message that will appear in any subsequent Crash or Non-fatal error reports.
117
+ *
118
+ * #### Example
119
+ *
120
+ * ```js
121
+ * const crashlytics = getCrashlytics();
122
+ * log(crashlytics, 'Testing a crash');
123
+ * crash(crashlytics);
124
+ * ```
57
125
  * @param {FirebaseCrashlytics} crashlytics
58
126
  * @param {string} message
59
127
  * @returns {void}
@@ -63,6 +131,21 @@ export function log(crashlytics, message) {
63
131
  }
64
132
 
65
133
  /**
134
+ * Record a JavaScript Error.
135
+ *
136
+ * The JavaScript stack trace is converted into a mock native iOS or Android exception before submission.
137
+ * The line numbers in the stack trace (if available) will be relative to the javascript bundle built by your packager,
138
+ * after whatever transpilation or minimization steps happen. You will need to maintain sourcemaps to decode them if desired.
139
+ *
140
+ * #### Example
141
+ *
142
+ * ```js
143
+ * const crashlytics = getCrashlytics();
144
+ * recordError(
145
+ * crashlytics,
146
+ * new Error('An error was caught')
147
+ * );
148
+ * ```
66
149
  * @param {FirebaseCrashlytics} crashlytics
67
150
  * @param {Error} error
68
151
  * @param {string | undefined} jsErrorName
@@ -73,6 +156,15 @@ export function recordError(crashlytics, error, jsErrorName) {
73
156
  }
74
157
 
75
158
  /**
159
+ * Enqueues any unsent reports on the device to upload to Crashlytics. This method only applies if
160
+ * automatic data collection is disabled.
161
+ *
162
+ * #### Example
163
+ *
164
+ * ```js
165
+ * const crashlytics = getCrashlytics();
166
+ * sendUnsentReports(crashlytics);
167
+ * ```
76
168
  * @param {FirebaseCrashlytics} crashlytics
77
169
  * @returns {void}
78
170
  */
@@ -81,6 +173,24 @@ export function sendUnsentReports(crashlytics) {
81
173
  }
82
174
 
83
175
  /**
176
+ * Specify a user identifier which will be visible in the Firebase Crashlytics console.
177
+ *
178
+ * It is recommended for privacy purposes that this value be a value that's meaningless to a third-party
179
+ * observer; such as an arbitrary string that ties an end-user to a record in your system e.g. a database record id.
180
+ *
181
+ * #### Example
182
+ *
183
+ * ```js
184
+ * const auth = getAuth();
185
+ * const crashlytics = getCrashlytics();
186
+ * // Custom user id
187
+ * await setUserId(crashlytics, '123456789');
188
+ * // Firebase auth uid
189
+ * await setUserId(
190
+ * crashlytics,
191
+ * auth.currentUser.uid
192
+ * );
193
+ * ```
84
194
  * @param {FirebaseCrashlytics} crashlytics
85
195
  * @param {string} userId
86
196
  * @returns {Promise<null>}
@@ -90,6 +200,14 @@ export function setUserId(crashlytics, userId) {
90
200
  }
91
201
 
92
202
  /**
203
+ * Sets a string value to be associated with the given attribute name which will be visible in the Firebase Crashlytics console.
204
+ *
205
+ * #### Example
206
+ *
207
+ * ```js
208
+ * const crashlytics = getCrashlytics();
209
+ * await setAttribute(crashlytics, 'role', 'admin');
210
+ * ```
93
211
  * @param {FirebaseCrashlytics} crashlytics
94
212
  * @param {string} name
95
213
  * @param {string} value
@@ -100,6 +218,17 @@ export function setAttribute(crashlytics, name, value) {
100
218
  }
101
219
 
102
220
  /**
221
+ * Like `setAttribute` but for multiple attributes.
222
+ *
223
+ * #### Example
224
+ *
225
+ * ```js
226
+ * const crashlytics = getCrashlytics();
227
+ * await setAttributes(crashlytics, {
228
+ * role: 'admin',
229
+ * followers: '13',
230
+ * });
231
+ * ```
103
232
  * @param {FirebaseCrashlytics} crashlytics
104
233
  * @param {{ [key: string]: string }} attributes
105
234
  * @returns {Promise<null>}
@@ -109,6 +238,17 @@ export function setAttributes(crashlytics, attributes) {
109
238
  }
110
239
 
111
240
  /**
241
+ * Enable/disable Crashlytics reporting.
242
+ *
243
+ * Use this for opt-in first user data collection flows combined with `firebase.json` settings to disable auto collection.
244
+ *
245
+ * #### Example
246
+ *
247
+ * ```js
248
+ * const crashlytics = getCrashlytics();
249
+ * // Disable crash reporting
250
+ * await setCrashlyticsCollectionEnabled(crashlytics, false);
251
+ * ```
112
252
  * @param {FirebaseCrashlytics} crashlytics
113
253
  * @param {boolean} enabled
114
254
  * @returns {Promise<null>}
package/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '20.3.0';
2
+ module.exports = '20.4.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/crashlytics",
3
- "version": "20.3.0",
3
+ "version": "20.4.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - Firebase Crashlytics is a lightweight, realtime crash reporter that helps you track, prioritize, and fix stability issues that erode your app quality. React Native Firebase provides automatic crash reporting for both native and JavaScript errors, including unhandled promise rejections.",
6
6
  "main": "lib/index.js",
@@ -29,7 +29,7 @@
29
29
  "crashlytics"
30
30
  ],
31
31
  "peerDependencies": {
32
- "@react-native-firebase/app": "20.3.0",
32
+ "@react-native-firebase/app": "20.4.0",
33
33
  "expo": ">=47.0.0"
34
34
  },
35
35
  "dependencies": {
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "a916b37b022cf40588fa0fd915b7ab901e2458d0"
49
+ "gitHead": "3ac3e9623674a8db52c111b4aa0a85a883260116"
50
50
  }