@react-native-firebase/perf 16.7.0 → 17.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +10 -0
- package/android/src/main/java/io/invertase/firebase/perf/ScreenTrace.java +69 -57
- package/android/src/main/java/io/invertase/firebase/perf/UniversalFirebasePerfModule.java +15 -12
- package/android/src/reactnative/java/io/invertase/firebase/perf/ReactNativeFirebasePerfModule.java +18 -18
- package/ios/RNFBPerf/RNFBPerfModule.m +10 -1
- package/lib/index.d.ts +21 -5
- package/lib/index.js +47 -1
- package/lib/modular/index.js +89 -0
- package/lib/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@
|
|
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
|
+
## [17.1.0](https://github.com/invertase/react-native-firebase/compare/v17.0.0...v17.1.0) (2023-02-09)
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
- **perf:** Expose modular API that matches the Firebase web JS SDK v9 API ([#6771](https://github.com/invertase/react-native-firebase/issues/6771)) ([4e170ea](https://github.com/invertase/react-native-firebase/commit/4e170ead24035cd0154b153dcf1e8d69d6ab7ac9))
|
11
|
+
|
12
|
+
## [17.0.0](https://github.com/invertase/react-native-firebase/compare/v16.7.0...v17.0.0) (2023-02-02)
|
13
|
+
|
14
|
+
**Note:** Version bump only for package @react-native-firebase/perf
|
15
|
+
|
6
16
|
## [16.7.0](https://github.com/invertase/react-native-firebase/compare/v16.6.0...v16.7.0) (2023-01-28)
|
7
17
|
|
8
18
|
### Features
|
@@ -3,53 +3,48 @@ package io.invertase.firebase.perf;
|
|
3
3
|
/**
|
4
4
|
* Copyright 2021 Google Inc. All Rights Reserved.
|
5
5
|
*
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
*
|
8
|
-
* You may obtain a copy of the License at
|
6
|
+
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
7
|
+
* except in compliance with the License. You may obtain a copy of the License at
|
9
8
|
*
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
* <p>http://www.apache.org/licenses/LICENSE-2.0
|
11
10
|
*
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
13
|
-
*
|
14
|
-
*
|
15
|
-
* See the License for the specific language governing permissions and
|
11
|
+
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
|
12
|
+
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
13
|
+
* express or implied. See the License for the specific language governing permissions and
|
16
14
|
* limitations under the License.
|
17
15
|
*/
|
18
|
-
|
19
16
|
import android.app.Activity;
|
20
17
|
import android.os.Build;
|
21
18
|
import android.util.Log;
|
22
19
|
import android.util.SparseIntArray;
|
23
20
|
import android.view.WindowManager;
|
24
|
-
|
25
21
|
import androidx.core.app.FrameMetricsAggregator;
|
26
|
-
|
27
22
|
import com.google.firebase.perf.FirebasePerformance;
|
28
23
|
import com.google.firebase.perf.metrics.Trace;
|
29
24
|
import com.google.firebase.perf.util.Constants;
|
30
25
|
|
31
26
|
/**
|
32
|
-
* Utility class to capture Screen rendering information (Slow/Frozen frames) for the
|
33
|
-
*
|
34
|
-
*
|
35
|
-
*
|
36
|
-
* <p>
|
37
|
-
*
|
38
|
-
*
|
39
|
-
* -
|
40
|
-
*
|
41
|
-
* - https://youtu.be/HXQhu6qfTVU (Rendering Performance)
|
42
|
-
* - https://youtu.be/1iaHxmfZGGc (Understanding VSYNC)
|
43
|
-
*
|
44
|
-
*
|
45
|
-
*
|
46
|
-
* - Fireperf Source Code
|
27
|
+
* Utility class to capture Screen rendering information (Slow/Frozen frames) for the {@code
|
28
|
+
* Activity} passed to the constructor {@link
|
29
|
+
* io.invertase.firebase.perf.ScreenTrace#ScreenTrace(Activity, String)}.
|
30
|
+
*
|
31
|
+
* <p>Learn more at https://firebase.google.com/docs/perf-mon/screen-traces?platform=android.
|
32
|
+
*
|
33
|
+
* <p>A slow screen rendering often leads to a UI Jank which creates a bad user experience. Below
|
34
|
+
* are some tips and references to understand and fix common UI Jank issues: -
|
35
|
+
* https://developer.android.com/topic/performance/vitals/render.html#fixing_jank -
|
36
|
+
* https://youtu.be/CaMTIgxCSqU (Why 60fps?) - https://youtu.be/HXQhu6qfTVU (Rendering Performance)
|
37
|
+
* - https://youtu.be/1iaHxmfZGGc (Understanding VSYNC) -
|
38
|
+
* https://www.youtube.com/playlist?list=PLOU2XLYxmsIKEOXh5TwZEv89aofHzNCiu (Android Performance
|
39
|
+
* Patterns)
|
40
|
+
*
|
41
|
+
* <p>References: - Fireperf Source Code
|
47
42
|
*/
|
48
43
|
public class ScreenTrace {
|
49
44
|
|
50
45
|
private static final String TAG = "RNFirebasePerf";
|
51
46
|
private static final String FRAME_METRICS_AGGREGATOR_CLASSNAME =
|
52
|
-
|
47
|
+
"androidx.core.app.FrameMetricsAggregator";
|
53
48
|
|
54
49
|
private final Activity activity;
|
55
50
|
private final String traceName;
|
@@ -61,8 +56,8 @@ public class ScreenTrace {
|
|
61
56
|
* Default constructor for this class.
|
62
57
|
*
|
63
58
|
* @param activity for which the screen traces should be recorded.
|
64
|
-
* @param tag
|
65
|
-
*
|
59
|
+
* @param tag used as an identifier for the name to be used to log screen rendering information
|
60
|
+
* (like "MyFancyScreen").
|
66
61
|
* @implNote It requires hardware acceleration to be on or it throws.
|
67
62
|
*/
|
68
63
|
public ScreenTrace(Activity activity, String tag) throws IllegalStateException {
|
@@ -75,7 +70,9 @@ public class ScreenTrace {
|
|
75
70
|
boolean isScreenTraceSupported = checkScreenTraceSupport(activity);
|
76
71
|
|
77
72
|
if (!isScreenTraceSupported) {
|
78
|
-
throw new IllegalStateException(
|
73
|
+
throw new IllegalStateException(
|
74
|
+
"Device does not support screen traces. Hardware acceleration must be enabled and Android"
|
75
|
+
+ " must not be 8.0 or 8.1.");
|
79
76
|
}
|
80
77
|
|
81
78
|
frameMetricsAggregator = new FrameMetricsAggregator();
|
@@ -83,9 +80,7 @@ public class ScreenTrace {
|
|
83
80
|
|
84
81
|
// region Public APIs
|
85
82
|
|
86
|
-
/**
|
87
|
-
* Starts recording the frame metrics for the screen traces.
|
88
|
-
*/
|
83
|
+
/** Starts recording the frame metrics for the screen traces. */
|
89
84
|
public void recordScreenTrace() {
|
90
85
|
Log.d(TAG, "Recording screen trace " + traceName);
|
91
86
|
|
@@ -97,7 +92,7 @@ public class ScreenTrace {
|
|
97
92
|
* Stops recording screen traces and dispatches the trace capturing information on %age of
|
98
93
|
* Slow/Frozen frames.
|
99
94
|
*
|
100
|
-
* Inspired by fireperf source.
|
95
|
+
* <p>Inspired by fireperf source.
|
101
96
|
*/
|
102
97
|
public void sendScreenTrace() {
|
103
98
|
if (perfScreenTrace == null) return;
|
@@ -143,12 +138,20 @@ public class ScreenTrace {
|
|
143
138
|
perfScreenTrace.putMetric(Constants.CounterNames.FRAMES_FROZEN.toString(), frozenFrames);
|
144
139
|
}
|
145
140
|
|
146
|
-
Log.d(
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
141
|
+
Log.d(
|
142
|
+
TAG,
|
143
|
+
new StringBuilder()
|
144
|
+
.append("sendScreenTrace ")
|
145
|
+
.append(traceName)
|
146
|
+
.append(", name: ")
|
147
|
+
.append(getScreenTraceName())
|
148
|
+
.append(", total_frames: ")
|
149
|
+
.append(totalFrames)
|
150
|
+
.append(", slow_frames: ")
|
151
|
+
.append(slowFrames)
|
152
|
+
.append(", frozen_frames: ")
|
153
|
+
.append(frozenFrames)
|
154
|
+
.toString());
|
152
155
|
|
153
156
|
// Stop and record trace
|
154
157
|
perfScreenTrace.stop();
|
@@ -161,17 +164,30 @@ public class ScreenTrace {
|
|
161
164
|
private static boolean checkScreenTraceSupport(Activity activity) {
|
162
165
|
boolean isValidSDKVersion = checkSDKVersion();
|
163
166
|
boolean hasFrameMetricsAggregatorClass = checkFrameMetricsAggregatorClass();
|
164
|
-
boolean isActivityHardwareAccelerated =
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
167
|
+
boolean isActivityHardwareAccelerated =
|
168
|
+
activity.getWindow() != null
|
169
|
+
&& ((activity.getWindow().getAttributes().flags
|
170
|
+
& WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED)
|
171
|
+
!= 0);
|
172
|
+
|
173
|
+
boolean supported =
|
174
|
+
isValidSDKVersion && hasFrameMetricsAggregatorClass && isActivityHardwareAccelerated;
|
175
|
+
|
176
|
+
Log.d(
|
177
|
+
TAG,
|
178
|
+
new StringBuilder()
|
179
|
+
.append("isValidSDKVersion: ")
|
180
|
+
.append(isValidSDKVersion)
|
181
|
+
.append("isScreenTraceSupported(")
|
182
|
+
.append(activity)
|
183
|
+
.append("): ")
|
184
|
+
.append(supported)
|
185
|
+
.append(" [hasFrameMetricsAggregatorClass: ")
|
186
|
+
.append(hasFrameMetricsAggregatorClass)
|
187
|
+
.append(", isActivityHardwareAccelerated: ")
|
188
|
+
.append(isActivityHardwareAccelerated)
|
189
|
+
.append("]")
|
190
|
+
.toString());
|
175
191
|
|
176
192
|
return supported;
|
177
193
|
}
|
@@ -184,9 +200,7 @@ public class ScreenTrace {
|
|
184
200
|
return true;
|
185
201
|
}
|
186
202
|
|
187
|
-
/**
|
188
|
-
* Inspired by fireperf source.
|
189
|
-
*/
|
203
|
+
/** Inspired by fireperf source. */
|
190
204
|
private static boolean checkFrameMetricsAggregatorClass() {
|
191
205
|
try {
|
192
206
|
Class<?> initializerClass = Class.forName(FRAME_METRICS_AGGREGATOR_CLASSNAME);
|
@@ -196,9 +210,7 @@ public class ScreenTrace {
|
|
196
210
|
}
|
197
211
|
}
|
198
212
|
|
199
|
-
/**
|
200
|
-
* Inspired by fireperf source.
|
201
|
-
*/
|
213
|
+
/** Inspired by fireperf source. */
|
202
214
|
private String getScreenTraceName() {
|
203
215
|
return Constants.SCREEN_TRACE_PREFIX + traceName;
|
204
216
|
}
|
@@ -55,6 +55,9 @@ public class UniversalFirebasePerfModule extends UniversalFirebaseModule {
|
|
55
55
|
constants.put(
|
56
56
|
"isPerformanceCollectionEnabled",
|
57
57
|
FirebasePerformance.getInstance().isPerformanceCollectionEnabled());
|
58
|
+
constants.put(
|
59
|
+
"isInstrumentationEnabled",
|
60
|
+
true);
|
58
61
|
return constants;
|
59
62
|
}
|
60
63
|
|
@@ -105,24 +108,24 @@ public class UniversalFirebasePerfModule extends UniversalFirebaseModule {
|
|
105
108
|
|
106
109
|
Task<Void> startScreenTrace(Activity activity, int id, String identifier) {
|
107
110
|
return Tasks.call(
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
111
|
+
() -> {
|
112
|
+
ScreenTrace screenTrace = new ScreenTrace(activity, identifier);
|
113
|
+
screenTrace.recordScreenTrace();
|
114
|
+
screenTraces.put(id, screenTrace);
|
112
115
|
|
113
|
-
|
114
|
-
|
116
|
+
return null;
|
117
|
+
});
|
115
118
|
}
|
116
119
|
|
117
120
|
Task<Void> stopScreenTrace(int id) {
|
118
121
|
return Tasks.call(
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
122
|
+
() -> {
|
123
|
+
ScreenTrace trace = screenTraces.get(id);
|
124
|
+
trace.sendScreenTrace();
|
125
|
+
screenTraces.remove(id);
|
123
126
|
|
124
|
-
|
125
|
-
|
127
|
+
return null;
|
128
|
+
});
|
126
129
|
}
|
127
130
|
|
128
131
|
Task<Void> startHttpMetric(int id, String url, String httpMethod) {
|
package/android/src/reactnative/java/io/invertase/firebase/perf/ReactNativeFirebasePerfModule.java
CHANGED
@@ -97,29 +97,29 @@ public class ReactNativeFirebasePerfModule extends ReactNativeFirebaseModule {
|
|
97
97
|
}
|
98
98
|
|
99
99
|
module
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
100
|
+
.startScreenTrace(currentActivity, id, identifier)
|
101
|
+
.addOnCompleteListener(
|
102
|
+
task -> {
|
103
|
+
if (task.isSuccessful()) {
|
104
|
+
promise.resolve(task.getResult());
|
105
|
+
} else {
|
106
|
+
rejectPromiseWithExceptionMap(promise, task.getException());
|
107
|
+
}
|
108
|
+
});
|
109
109
|
}
|
110
110
|
|
111
111
|
@ReactMethod
|
112
112
|
public void stopScreenTrace(int id, Promise promise) {
|
113
113
|
module
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
114
|
+
.stopScreenTrace(id)
|
115
|
+
.addOnCompleteListener(
|
116
|
+
task -> {
|
117
|
+
if (task.isSuccessful()) {
|
118
|
+
promise.resolve(task.getResult());
|
119
|
+
} else {
|
120
|
+
rejectPromiseWithExceptionMap(promise, task.getException());
|
121
|
+
}
|
122
|
+
});
|
123
123
|
}
|
124
124
|
|
125
125
|
@ReactMethod
|
@@ -58,6 +58,8 @@ RCT_EXPORT_MODULE();
|
|
58
58
|
NSMutableDictionary *constants = [NSMutableDictionary new];
|
59
59
|
constants[@"isPerformanceCollectionEnabled"] =
|
60
60
|
@([RCTConvert BOOL:@([FIRPerformance sharedInstance].dataCollectionEnabled)]);
|
61
|
+
constants[@"isInstrumentationEnabled"] =
|
62
|
+
@([RCTConvert BOOL:@([FIRPerformance sharedInstance].instrumentationEnabled)]);
|
61
63
|
return constants;
|
62
64
|
}
|
63
65
|
|
@@ -73,7 +75,6 @@ RCT_EXPORT_METHOD(setPerformanceCollectionEnabled
|
|
73
75
|
: (RCTPromiseResolveBlock)resolve rejecter
|
74
76
|
: (RCTPromiseRejectBlock)reject) {
|
75
77
|
[FIRPerformance sharedInstance].dataCollectionEnabled = (BOOL)enabled;
|
76
|
-
[FIRPerformance sharedInstance].instrumentationEnabled = (BOOL)enabled;
|
77
78
|
resolve([NSNull null]);
|
78
79
|
}
|
79
80
|
|
@@ -203,4 +204,12 @@ RCT_EXPORT_METHOD(stopHttpMetric
|
|
203
204
|
resolve([NSNull null]);
|
204
205
|
}
|
205
206
|
|
207
|
+
RCT_EXPORT_METHOD(instrumentationEnabled
|
208
|
+
: (BOOL)enabled resolver
|
209
|
+
: (RCTPromiseResolveBlock)resolve rejecter
|
210
|
+
: (RCTPromiseRejectBlock)reject) {
|
211
|
+
[FIRPerformance sharedInstance].instrumentationEnabled = (BOOL)enabled;
|
212
|
+
resolve([NSNull null]);
|
213
|
+
}
|
214
|
+
|
206
215
|
@end
|
package/lib/index.d.ts
CHANGED
@@ -426,7 +426,22 @@ export namespace FirebasePerformanceTypes {
|
|
426
426
|
* ```
|
427
427
|
*/
|
428
428
|
isPerformanceCollectionEnabled: boolean;
|
429
|
-
|
429
|
+
/**
|
430
|
+
* Determines whether to collect 'out of the box' (i.e already setup for Firebase Performance) events.
|
431
|
+
* This can be set for iOS. Android will always return "true" as it has to be set at gradle level.
|
432
|
+
*/
|
433
|
+
instrumentationEnabled: boolean;
|
434
|
+
/**
|
435
|
+
* Determines whether performance monitoring is enabled or disabled.
|
436
|
+
*
|
437
|
+
* #### Example
|
438
|
+
*
|
439
|
+
* ```js
|
440
|
+
* const isEnabled = firebase.perf().dataCollectionEnabled;
|
441
|
+
* console.log('Performance collection enabled: ', isEnabled);
|
442
|
+
* ```
|
443
|
+
*/
|
444
|
+
dataCollectionEnabled: boolean;
|
430
445
|
/**
|
431
446
|
* Enables or disables performance monitoring.
|
432
447
|
*
|
@@ -436,8 +451,9 @@ export namespace FirebasePerformanceTypes {
|
|
436
451
|
* // Disable performance monitoring collection
|
437
452
|
* await firebase.perf().setPerformanceCollectionEnabled(false);
|
438
453
|
* ```
|
439
|
-
*
|
440
|
-
* @param enabled Should performance monitoring be enabled
|
454
|
+
* @deprecated prefer setting `dataCollectionEnabled = boolean`.
|
455
|
+
* @param enabled Should performance monitoring be enabled. For iOS only, this also toggles whether instrumentation
|
456
|
+
* is enabled. See: https://firebase.google.com/docs/reference/ios/firebaseperformance/api/reference/Classes/FIRPerformance#instrumentationenabled
|
441
457
|
*/
|
442
458
|
setPerformanceCollectionEnabled(enabled: boolean): Promise<null>;
|
443
459
|
|
@@ -470,7 +486,7 @@ export namespace FirebasePerformanceTypes {
|
|
470
486
|
|
471
487
|
/**
|
472
488
|
* Creates a ScreenTrace instance with the given identifier.
|
473
|
-
* Throws if hardware acceleration is
|
489
|
+
* Throws if hardware acceleration is disabled or if Android is 9.0 or 9.1.
|
474
490
|
*
|
475
491
|
* #### Example
|
476
492
|
*
|
@@ -489,7 +505,7 @@ export namespace FirebasePerformanceTypes {
|
|
489
505
|
|
490
506
|
/**
|
491
507
|
* Creates a ScreenTrace instance with the given identifier and immediately starts it.
|
492
|
-
* Throws if hardware acceleration is
|
508
|
+
* Throws if hardware acceleration is disabled or if Android is 9.0 or 9.1.
|
493
509
|
*
|
494
510
|
* #### Example
|
495
511
|
*
|
package/lib/index.js
CHANGED
@@ -21,11 +21,21 @@ import {
|
|
21
21
|
FirebaseModule,
|
22
22
|
getFirebaseRoot,
|
23
23
|
} from '@react-native-firebase/app/lib/internal';
|
24
|
+
import { Platform } from 'react-native';
|
24
25
|
import HttpMetric from './HttpMetric';
|
25
26
|
import Trace from './Trace';
|
26
27
|
import ScreenTrace from './ScreenTrace';
|
27
28
|
import version from './version';
|
28
29
|
|
30
|
+
export {
|
31
|
+
getPerformance,
|
32
|
+
initializePerformance,
|
33
|
+
trace,
|
34
|
+
httpMetric,
|
35
|
+
newScreenTrace,
|
36
|
+
startScreenTrace,
|
37
|
+
} from './modular/index';
|
38
|
+
|
29
39
|
const statics = {};
|
30
40
|
|
31
41
|
const namespace = 'perf';
|
@@ -48,19 +58,55 @@ class FirebasePerfModule extends FirebaseModule {
|
|
48
58
|
constructor(...args) {
|
49
59
|
super(...args);
|
50
60
|
this._isPerformanceCollectionEnabled = this.native.isPerformanceCollectionEnabled;
|
61
|
+
this._instrumentationEnabled = this.native.isInstrumentationEnabled;
|
51
62
|
}
|
52
63
|
|
53
64
|
get isPerformanceCollectionEnabled() {
|
54
65
|
return this._isPerformanceCollectionEnabled;
|
55
66
|
}
|
56
67
|
|
57
|
-
|
68
|
+
get instrumentationEnabled() {
|
69
|
+
return this._instrumentationEnabled;
|
70
|
+
}
|
71
|
+
|
72
|
+
set instrumentationEnabled(enabled) {
|
73
|
+
if (!isBoolean(enabled)) {
|
74
|
+
throw new Error("firebase.perf().instrumentationEnabled = 'enabled' must be a boolean.");
|
75
|
+
}
|
76
|
+
if (Platform.OS == 'ios') {
|
77
|
+
// We don't change for android as it cannot be set from code, it is set at gradle build time.
|
78
|
+
this._instrumentationEnabled = enabled;
|
79
|
+
// No need to await, as it only takes effect on the next app run.
|
80
|
+
this.native.instrumentationEnabled(enabled);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
get dataCollectionEnabled() {
|
85
|
+
return this._isPerformanceCollectionEnabled;
|
86
|
+
}
|
87
|
+
|
88
|
+
set dataCollectionEnabled(enabled) {
|
89
|
+
if (!isBoolean(enabled)) {
|
90
|
+
throw new Error("firebase.perf().dataCollectionEnabled = 'enabled' must be a boolean.");
|
91
|
+
}
|
92
|
+
this._isPerformanceCollectionEnabled = enabled;
|
93
|
+
this.native.setPerformanceCollectionEnabled(enabled);
|
94
|
+
}
|
95
|
+
|
96
|
+
async setPerformanceCollectionEnabled(enabled) {
|
58
97
|
if (!isBoolean(enabled)) {
|
59
98
|
throw new Error(
|
60
99
|
"firebase.perf().setPerformanceCollectionEnabled(*) 'enabled' must be a boolean.",
|
61
100
|
);
|
62
101
|
}
|
63
102
|
|
103
|
+
if (Platform.OS == 'ios') {
|
104
|
+
// '_instrumentationEnabled' is updated here as well to maintain backward compatibility. See:
|
105
|
+
// https://github.com/invertase/react-native-firebase/commit/b705622e64d6ebf4ee026d50841e2404cf692f85
|
106
|
+
this._instrumentationEnabled = enabled;
|
107
|
+
await this.native.instrumentationEnabled(enabled);
|
108
|
+
}
|
109
|
+
|
64
110
|
this._isPerformanceCollectionEnabled = enabled;
|
65
111
|
return this.native.setPerformanceCollectionEnabled(enabled);
|
66
112
|
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this library except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*
|
16
|
+
*/
|
17
|
+
|
18
|
+
import { isBoolean } from '@react-native-firebase/app/lib/common';
|
19
|
+
import { firebase } from '..';
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Returns a Performance instance for the given app.
|
23
|
+
* @param app - FirebaseApp. Optional.
|
24
|
+
* @returns {Performance}
|
25
|
+
*/
|
26
|
+
export function getPerformance(app) {
|
27
|
+
if (app) {
|
28
|
+
return firebase.app(app.name).perf();
|
29
|
+
}
|
30
|
+
|
31
|
+
return firebase.app().perf();
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Returns a Performance instance for the given app.
|
36
|
+
* @param app - FirebaseApp. Required.
|
37
|
+
* @param settings - PerformanceSettings. Set "dataCollectionEnabled" which will enable/disable Performance collection.
|
38
|
+
* @returns {Performance}
|
39
|
+
*/
|
40
|
+
export async function initializePerformance(app, settings) {
|
41
|
+
const perf = firebase.app(app.name).perf();
|
42
|
+
|
43
|
+
if (settings && isBoolean(settings.dataCollectionEnabled)) {
|
44
|
+
await perf.setPerformanceCollectionEnabled(settings.dataCollectionEnabled);
|
45
|
+
}
|
46
|
+
|
47
|
+
return perf;
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Returns a Trace instance.
|
52
|
+
* @param perf - Performance instance
|
53
|
+
* @param identifier - A String to identify the Trace instance
|
54
|
+
* @returns {Trace}
|
55
|
+
*/
|
56
|
+
export function trace(perf, identifier) {
|
57
|
+
return perf.newTrace(identifier);
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Returns a HttpMetric instance.
|
62
|
+
* @param perf - Performance instance
|
63
|
+
* @param identifier - A String to identify the HttpMetric instance
|
64
|
+
* @returns {HttpMetric}
|
65
|
+
*/
|
66
|
+
export function httpMetric(perf, identifier, httpMethod) {
|
67
|
+
return perf.newHttpMetric(identifier, httpMethod);
|
68
|
+
}
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Creates a ScreenTrace instance with the given identifier.
|
72
|
+
* Throws if hardware acceleration is disabled or if Android is 9.0 or 9.1.
|
73
|
+
* @platform android Android !== 9.0.0 && Android !== 9.1.0
|
74
|
+
* @param perf - Performance instance
|
75
|
+
* @param identifier Name of the trace, no leading or trailing whitespace allowed, no leading underscore '_' character allowed, max length is 100.
|
76
|
+
*/
|
77
|
+
export function newScreenTrace(perf, identifier) {
|
78
|
+
return perf.newScreenTrace(identifier);
|
79
|
+
}
|
80
|
+
/**
|
81
|
+
* Creates a ScreenTrace instance with the given identifier and immediately starts it.
|
82
|
+
* Throws if hardware acceleration is disabled or if Android is 9.0 or 9.1.
|
83
|
+
* @platform android Android !== 9.0.0 && Android !== 9.1.0
|
84
|
+
* @param perf - Performance instance
|
85
|
+
* @param identifier Name of the screen
|
86
|
+
*/
|
87
|
+
export function startScreenTrace(perf, identifier) {
|
88
|
+
return perf.startScreenTrace(identifier);
|
89
|
+
}
|
package/lib/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
// Generated by genversion.
|
2
|
-
module.exports = '
|
2
|
+
module.exports = '17.1.0';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-native-firebase/perf",
|
3
|
-
"version": "
|
3
|
+
"version": "17.1.0",
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
5
5
|
"description": "React Native Firebase - React Native Firebase provides native integration with Performance Monitoring to gain insight into key performance characteristics within your React Native application.",
|
6
6
|
"main": "lib/index.js",
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"performance monitoring"
|
30
30
|
],
|
31
31
|
"peerDependencies": {
|
32
|
-
"@react-native-firebase/app": "
|
32
|
+
"@react-native-firebase/app": "17.1.0"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
35
|
"@expo/config-plugins": "^5.0.4"
|
@@ -37,5 +37,5 @@
|
|
37
37
|
"publishConfig": {
|
38
38
|
"access": "public"
|
39
39
|
},
|
40
|
-
"gitHead": "
|
40
|
+
"gitHead": "635d595389bfb224fc530681627fb2180fea6e26"
|
41
41
|
}
|