@react-native-firebase/perf 25.1.0 → 26.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/RNFBPerf.podspec +9 -7
- package/android/build.gradle +19 -0
- package/android/src/main/java/io/invertase/firebase/perf/UniversalFirebasePerfModule.java +88 -0
- package/android/src/reactnative/java/io/invertase/firebase/perf/NativeRNFBTurboPerf.java +108 -0
- package/android/src/reactnative/java/io/invertase/firebase/perf/ReactNativeFirebasePerfPackage.java +1 -1
- package/android/src/reactnative/java/io/invertase/firebase/perf/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboPerfSpec.java +100 -0
- package/android/src/reactnative/java/io/invertase/firebase/perf/generated/jni/CMakeLists.txt +36 -0
- package/android/src/reactnative/java/io/invertase/firebase/perf/generated/jni/RNFBPerfTurboModules-generated.cpp +80 -0
- package/android/src/reactnative/java/io/invertase/firebase/perf/generated/jni/RNFBPerfTurboModules.h +31 -0
- package/android/src/reactnative/java/io/invertase/firebase/perf/generated/jni/react/renderer/components/RNFBPerfTurboModules/RNFBPerfTurboModulesJSI-generated.cpp +94 -0
- package/android/src/reactnative/java/io/invertase/firebase/perf/generated/jni/react/renderer/components/RNFBPerfTurboModules/RNFBPerfTurboModulesJSI.h +267 -0
- package/app.plugin.js +1 -1
- package/dist/module/HttpMetric.js +4 -4
- package/dist/module/HttpMetric.js.map +1 -1
- package/dist/module/ScreenTrace.js +5 -5
- package/dist/module/ScreenTrace.js.map +1 -1
- package/dist/module/Trace.js +4 -4
- package/dist/module/Trace.js.map +1 -1
- package/dist/module/index.js +142 -3
- package/dist/module/index.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/typescript/lib/HttpMetric.d.ts +2 -2
- package/dist/typescript/lib/HttpMetric.d.ts.map +1 -1
- package/dist/typescript/lib/ScreenTrace.d.ts +2 -2
- package/dist/typescript/lib/ScreenTrace.d.ts.map +1 -1
- package/dist/typescript/lib/Trace.d.ts +2 -2
- package/dist/typescript/lib/Trace.d.ts.map +1 -1
- package/dist/typescript/lib/index.d.ts +23 -4
- package/dist/typescript/lib/index.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +12 -16
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/types/perf.d.ts +7 -7
- package/dist/typescript/lib/types/perf.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/ios/RNFBPerf/RNFBPerfModule.h +3 -2
- package/ios/RNFBPerf/RNFBPerfModule.mm +268 -0
- package/ios/RNFBPerf.xcodeproj/project.pbxproj +8 -8
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
- package/ios/generated/RNFBPerfTurboModules/RNFBPerfTurboModules-generated.mm +106 -0
- package/ios/generated/RNFBPerfTurboModules/RNFBPerfTurboModules.h +191 -0
- package/ios/generated/RNFBPerfTurboModulesJSI-generated.cpp +94 -0
- package/ios/generated/RNFBPerfTurboModulesJSI.h +267 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/HttpMetric.ts +6 -6
- package/lib/ScreenTrace.ts +7 -7
- package/lib/Trace.ts +6 -6
- package/lib/index.ts +228 -5
- package/lib/types/internal.ts +12 -24
- package/lib/types/perf.ts +7 -7
- package/lib/version.ts +1 -1
- package/package.json +30 -5
- package/plugin/build/app.plugin.d.ts +2 -0
- package/plugin/build/app.plugin.js +6 -0
- package/plugin/src/app.plugin.ts +3 -0
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/react-native.config.js +10 -0
- package/specs/NativeRNFBTurboPerf.ts +44 -0
- package/typedoc.json +1 -1
- package/android/src/reactnative/java/io/invertase/firebase/perf/ReactNativeFirebasePerfModule.java +0 -158
- package/dist/module/modular.js +0 -93
- package/dist/module/modular.js.map +0 -1
- package/dist/module/namespaced.js +0 -130
- package/dist/module/namespaced.js.map +0 -1
- package/dist/module/types/namespaced.js +0 -65
- package/dist/module/types/namespaced.js.map +0 -1
- package/dist/typescript/lib/modular.d.ts +0 -43
- package/dist/typescript/lib/modular.d.ts.map +0 -1
- package/dist/typescript/lib/namespaced.d.ts +0 -11
- package/dist/typescript/lib/namespaced.d.ts.map +0 -1
- package/dist/typescript/lib/types/namespaced.d.ts +0 -128
- package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
- package/ios/RNFBPerf/RNFBPerfModule.m +0 -215
- package/lib/modular.ts +0 -116
- package/lib/namespaced.ts +0 -200
- package/lib/types/namespaced.ts +0 -162
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
version = "0.78.3"
|
|
7
|
+
source = { :git => 'https://github.com/facebook/react-native.git' }
|
|
8
|
+
if version == '1000.0.0'
|
|
9
|
+
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
|
|
10
|
+
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
|
|
11
|
+
else
|
|
12
|
+
source[:tag] = "v#{version}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Pod::Spec.new do |s|
|
|
16
|
+
s.name = "ReactAppDependencyProvider"
|
|
17
|
+
s.version = version
|
|
18
|
+
s.summary = "The third party dependency provider for the app"
|
|
19
|
+
s.homepage = "https://reactnative.dev/"
|
|
20
|
+
s.documentation_url = "https://reactnative.dev/"
|
|
21
|
+
s.license = "MIT"
|
|
22
|
+
s.author = "Meta Platforms, Inc. and its affiliates"
|
|
23
|
+
s.platforms = min_supported_versions
|
|
24
|
+
s.source = source
|
|
25
|
+
s.source_files = "**/RCTAppDependencyProvider.{h,mm}"
|
|
26
|
+
|
|
27
|
+
# This guard prevent to install the dependencies when we run `pod install` in the old architecture.
|
|
28
|
+
s.pod_target_xcconfig = {
|
|
29
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
30
|
+
"DEFINES_MODULE" => "YES"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
s.dependency "ReactCodegen"
|
|
34
|
+
end
|
package/lib/HttpMetric.ts
CHANGED
|
@@ -87,18 +87,18 @@ export default class HttpMetric extends MetricWithAttributes {
|
|
|
87
87
|
this._responseContentType = contentType;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
start():
|
|
90
|
+
start(): void {
|
|
91
91
|
if (this._started) {
|
|
92
|
-
return
|
|
92
|
+
return;
|
|
93
93
|
}
|
|
94
94
|
this._started = true;
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
this.native.startHttpMetric(this._id, this._url, this._httpMethod);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
stop():
|
|
99
|
+
stop(): void {
|
|
100
100
|
if (this._stopped) {
|
|
101
|
-
return
|
|
101
|
+
return;
|
|
102
102
|
}
|
|
103
103
|
this._stopped = true;
|
|
104
104
|
|
|
@@ -125,6 +125,6 @@ export default class HttpMetric extends MetricWithAttributes {
|
|
|
125
125
|
metricData.responseContentType = this._responseContentType;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
this.native.stopHttpMetric(this._id, metricData);
|
|
129
129
|
}
|
|
130
130
|
}
|
package/lib/ScreenTrace.ts
CHANGED
|
@@ -36,24 +36,24 @@ export default class ScreenTrace {
|
|
|
36
36
|
this._stopped = false;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
start():
|
|
39
|
+
start(): void {
|
|
40
40
|
if (isIOS) {
|
|
41
|
-
|
|
41
|
+
throw new Error('Custom screentraces are currently not supported on iOS.');
|
|
42
42
|
}
|
|
43
43
|
if (this._started) {
|
|
44
|
-
return
|
|
44
|
+
return;
|
|
45
45
|
}
|
|
46
46
|
this._started = true;
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
this.native.startScreenTrace(this._id, this._identifier);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
stop():
|
|
51
|
+
stop(): void {
|
|
52
52
|
if (!this._started || this._stopped) {
|
|
53
|
-
return
|
|
53
|
+
return;
|
|
54
54
|
}
|
|
55
55
|
this._stopped = true;
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
this.native.stopScreenTrace(this._id);
|
|
58
58
|
}
|
|
59
59
|
}
|
package/lib/Trace.ts
CHANGED
|
@@ -87,18 +87,18 @@ export default class Trace extends MetricWithAttributes {
|
|
|
87
87
|
delete this._metrics[metric];
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
start():
|
|
90
|
+
start(): void {
|
|
91
91
|
if (this._started) {
|
|
92
|
-
return
|
|
92
|
+
return;
|
|
93
93
|
}
|
|
94
94
|
this._started = true;
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
this.native.startTrace(this._id, this._identifier);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
stop():
|
|
99
|
+
stop(): void {
|
|
100
100
|
if (this._stopped) {
|
|
101
|
-
return
|
|
101
|
+
return;
|
|
102
102
|
}
|
|
103
103
|
this._stopped = true;
|
|
104
104
|
|
|
@@ -107,6 +107,6 @@ export default class Trace extends MetricWithAttributes {
|
|
|
107
107
|
attributes: Object.assign({}, this._attributes),
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
this.native.stopTrace(this._id, traceData);
|
|
111
111
|
}
|
|
112
112
|
}
|
package/lib/index.ts
CHANGED
|
@@ -15,11 +15,234 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
import { isBoolean, isOneOf, isString } from '@react-native-firebase/app/dist/module/common';
|
|
19
|
+
import type { FirebaseApp } from '@react-native-firebase/app';
|
|
20
|
+
import {
|
|
21
|
+
FirebaseModule,
|
|
22
|
+
getOrCreateModularInstance,
|
|
23
|
+
} from '@react-native-firebase/app/dist/module/internal';
|
|
24
|
+
import type { ModuleConfig } from '@react-native-firebase/app/dist/module/internal';
|
|
25
|
+
import './types/internal';
|
|
26
|
+
import { Platform } from 'react-native';
|
|
27
|
+
|
|
28
|
+
import HttpMetricImpl from './HttpMetric';
|
|
29
|
+
import ScreenTraceImpl from './ScreenTrace';
|
|
30
|
+
import TraceImpl from './Trace';
|
|
31
|
+
import { version } from './version';
|
|
32
|
+
|
|
33
|
+
import type { ReactNativeFirebase } from '@react-native-firebase/app';
|
|
34
|
+
import type {
|
|
35
|
+
FirebasePerformance,
|
|
36
|
+
HttpMetric,
|
|
37
|
+
HttpMethod,
|
|
38
|
+
PerformanceSettings,
|
|
39
|
+
PerformanceTrace,
|
|
40
|
+
ScreenTrace,
|
|
41
|
+
} from './types/perf';
|
|
42
|
+
import type { PerfInternal } from './types/internal';
|
|
43
|
+
|
|
44
|
+
const nativeModuleName = 'NativeRNFBTurboPerf' as const;
|
|
45
|
+
|
|
46
|
+
const VALID_HTTP_METHODS: HttpMethod[] = [
|
|
47
|
+
'CONNECT',
|
|
48
|
+
'DELETE',
|
|
49
|
+
'GET',
|
|
50
|
+
'HEAD',
|
|
51
|
+
'OPTIONS',
|
|
52
|
+
'PATCH',
|
|
53
|
+
'POST',
|
|
54
|
+
'PUT',
|
|
55
|
+
'TRACE',
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
class FirebasePerfModule extends FirebaseModule<typeof nativeModuleName> {
|
|
59
|
+
private _isPerformanceCollectionEnabled: boolean;
|
|
60
|
+
private _instrumentationEnabled: boolean;
|
|
61
|
+
|
|
62
|
+
constructor(
|
|
63
|
+
app: ReactNativeFirebase.FirebaseAppBase,
|
|
64
|
+
config: ModuleConfig,
|
|
65
|
+
customUrlOrRegion?: string | null,
|
|
66
|
+
) {
|
|
67
|
+
super(app, config, customUrlOrRegion);
|
|
68
|
+
this._isPerformanceCollectionEnabled = this.native.isPerformanceCollectionEnabled;
|
|
69
|
+
this._instrumentationEnabled = this.native.isInstrumentationEnabled;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get isPerformanceCollectionEnabled(): boolean {
|
|
73
|
+
return this._isPerformanceCollectionEnabled;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get instrumentationEnabled(): boolean {
|
|
77
|
+
return this._instrumentationEnabled;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
set instrumentationEnabled(enabled: boolean) {
|
|
81
|
+
if (!isBoolean(enabled)) {
|
|
82
|
+
throw new Error("firebase.perf().instrumentationEnabled = 'enabled' must be a boolean.");
|
|
83
|
+
}
|
|
84
|
+
if (Platform.OS === 'ios') {
|
|
85
|
+
// We don't change for android as it cannot be set from code, it is set at gradle build time.
|
|
86
|
+
this._instrumentationEnabled = enabled;
|
|
87
|
+
// No need to await, as it only takes effect on the next app run.
|
|
88
|
+
this.native.instrumentationEnabled(enabled);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get dataCollectionEnabled(): boolean {
|
|
93
|
+
return this._isPerformanceCollectionEnabled;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
set dataCollectionEnabled(enabled: boolean) {
|
|
97
|
+
if (!isBoolean(enabled)) {
|
|
98
|
+
throw new Error("firebase.perf().dataCollectionEnabled = 'enabled' must be a boolean.");
|
|
99
|
+
}
|
|
100
|
+
this._isPerformanceCollectionEnabled = enabled;
|
|
101
|
+
// Keep setter behavior fire-and-forget; callers that need completion should use setPerformanceCollectionEnabled().
|
|
102
|
+
void this.native.setPerformanceCollectionEnabled(enabled);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async setPerformanceCollectionEnabled(enabled: boolean): Promise<null> {
|
|
106
|
+
if (!isBoolean(enabled)) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
"firebase.perf().setPerformanceCollectionEnabled(*) 'enabled' must be a boolean.",
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (Platform.OS === 'ios') {
|
|
113
|
+
// '_instrumentationEnabled' is updated here as well to maintain backward compatibility. See:
|
|
114
|
+
// https://github.com/invertase/react-native-firebase/commit/b705622e64d6ebf4ee026d50841e2404cf692f85
|
|
115
|
+
this._instrumentationEnabled = enabled;
|
|
116
|
+
await this.native.instrumentationEnabled(enabled);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this._isPerformanceCollectionEnabled = enabled;
|
|
120
|
+
return this.native.setPerformanceCollectionEnabled(enabled);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
newTrace(identifier: string): TraceImpl {
|
|
124
|
+
// TODO(VALIDATION): identifier: no leading or trailing whitespace, no leading underscore '_'
|
|
125
|
+
if (!isString(identifier) || identifier.length > 100) {
|
|
126
|
+
throw new Error(
|
|
127
|
+
"firebase.perf().newTrace(*) 'identifier' must be a string with a maximum length of 100 characters.",
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return new TraceImpl(this.native, identifier);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
startTrace(identifier: string): TraceImpl {
|
|
135
|
+
const traceInstance = this.newTrace(identifier);
|
|
136
|
+
traceInstance.start();
|
|
137
|
+
return traceInstance;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
newScreenTrace(identifier: string): ScreenTraceImpl {
|
|
141
|
+
if (!isString(identifier) || identifier.length > 100) {
|
|
142
|
+
throw new Error(
|
|
143
|
+
"firebase.perf().newScreenTrace(*) 'identifier' must be a string with a maximum length of 100 characters.",
|
|
144
|
+
);
|
|
145
|
+
}
|
|
19
146
|
|
|
20
|
-
|
|
147
|
+
return new ScreenTraceImpl(this.native, identifier);
|
|
148
|
+
}
|
|
21
149
|
|
|
22
|
-
|
|
150
|
+
startScreenTrace(identifier: string): ScreenTraceImpl {
|
|
151
|
+
const screenTrace = this.newScreenTrace(identifier);
|
|
152
|
+
screenTrace.start();
|
|
153
|
+
return screenTrace;
|
|
154
|
+
}
|
|
23
155
|
|
|
24
|
-
|
|
25
|
-
|
|
156
|
+
newHttpMetric(url: string, httpMethod: HttpMethod): HttpMetricImpl {
|
|
157
|
+
if (!isString(url)) {
|
|
158
|
+
throw new Error("firebase.perf().newHttpMetric(*, _) 'url' must be a string.");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!isOneOf(httpMethod, VALID_HTTP_METHODS)) {
|
|
162
|
+
throw new Error(
|
|
163
|
+
`firebase.perf().newHttpMetric(_, *) 'httpMethod' must be one of ${VALID_HTTP_METHODS.join(
|
|
164
|
+
', ',
|
|
165
|
+
)}.`,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return new HttpMetricImpl(this.native, url, httpMethod);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const config: ModuleConfig = {
|
|
174
|
+
namespace: 'perf',
|
|
175
|
+
nativeModuleName,
|
|
176
|
+
nativeEvents: false,
|
|
177
|
+
hasMultiAppSupport: false,
|
|
178
|
+
hasCustomUrlOrRegionSupport: false,
|
|
179
|
+
turboModule: true,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export const SDK_VERSION = version;
|
|
183
|
+
|
|
184
|
+
function perfInternal(performance: FirebasePerformance): PerfInternal {
|
|
185
|
+
return performance as PerfInternal;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function getPerformance(app?: FirebaseApp): FirebasePerformance {
|
|
189
|
+
return getOrCreateModularInstance(
|
|
190
|
+
FirebasePerfModule,
|
|
191
|
+
config,
|
|
192
|
+
app,
|
|
193
|
+
) as unknown as FirebasePerformance;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Creates a Performance Monitoring instance and applies optional settings.
|
|
198
|
+
*
|
|
199
|
+
* @remarks Returns **synchronously** on React Native Firebase (unlike some async firebase-js-sdk
|
|
200
|
+
* initialization paths). Settings are applied to the native Performance SDK instance.
|
|
201
|
+
*/
|
|
202
|
+
export function initializePerformance(
|
|
203
|
+
app: FirebaseApp,
|
|
204
|
+
settings?: PerformanceSettings,
|
|
205
|
+
): FirebasePerformance {
|
|
206
|
+
const perf = getPerformance(app);
|
|
207
|
+
|
|
208
|
+
if (settings?.dataCollectionEnabled !== undefined) {
|
|
209
|
+
perf.dataCollectionEnabled = settings.dataCollectionEnabled;
|
|
210
|
+
}
|
|
211
|
+
if (settings?.instrumentationEnabled !== undefined) {
|
|
212
|
+
perf.instrumentationEnabled = settings.instrumentationEnabled;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return perf;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Creates a custom performance trace.
|
|
220
|
+
*
|
|
221
|
+
* @remarks On React Native Firebase, {@link PerformanceTrace.start} and
|
|
222
|
+
* {@link PerformanceTrace.stop} are **synchronous** (in-memory native calls via TurboModules),
|
|
223
|
+
* matching the firebase-js-sdk web `PerformanceTrace`.
|
|
224
|
+
*/
|
|
225
|
+
export function trace(performance: FirebasePerformance, name: string): PerformanceTrace {
|
|
226
|
+
return perfInternal(performance).newTrace(name) as unknown as PerformanceTrace;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export function httpMetric(
|
|
230
|
+
performance: FirebasePerformance,
|
|
231
|
+
url: string,
|
|
232
|
+
httpMethod: HttpMethod,
|
|
233
|
+
): HttpMetric {
|
|
234
|
+
return perfInternal(performance).newHttpMetric(url, httpMethod) as unknown as HttpMetric;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function newScreenTrace(performance: FirebasePerformance, screenName: string): ScreenTrace {
|
|
238
|
+
return perfInternal(performance).newScreenTrace(screenName) as unknown as ScreenTrace;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function startScreenTrace(
|
|
242
|
+
performance: FirebasePerformance,
|
|
243
|
+
screenName: string,
|
|
244
|
+
): ScreenTrace {
|
|
245
|
+
return perfInternal(performance).startScreenTrace(screenName) as unknown as ScreenTrace;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export type * from './types/perf';
|
package/lib/types/internal.ts
CHANGED
|
@@ -23,28 +23,16 @@ import type {
|
|
|
23
23
|
ScreenTrace,
|
|
24
24
|
} from './perf';
|
|
25
25
|
|
|
26
|
-
export type PerfModularDeprecationArg = string;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Namespaced perf instance used by modular entrypoints; methods accept an optional modular deprecation token.
|
|
30
|
-
*/
|
|
31
26
|
export interface PerfInternal extends FirebasePerformance {
|
|
32
27
|
/**
|
|
33
28
|
* @deprecated Prefer assigning {@link FirebasePerformance.dataCollectionEnabled}.
|
|
34
29
|
*/
|
|
35
30
|
setPerformanceCollectionEnabled(enabled: boolean): Promise<null>;
|
|
36
|
-
newTrace(name: string
|
|
37
|
-
startTrace(name: string
|
|
38
|
-
newScreenTrace(screenName: string
|
|
39
|
-
startScreenTrace(
|
|
40
|
-
|
|
41
|
-
deprecationArg?: PerfModularDeprecationArg,
|
|
42
|
-
): Promise<ScreenTrace>;
|
|
43
|
-
newHttpMetric(
|
|
44
|
-
url: string,
|
|
45
|
-
httpMethod: HttpMethod,
|
|
46
|
-
deprecationArg?: PerfModularDeprecationArg,
|
|
47
|
-
): HttpMetric;
|
|
31
|
+
newTrace(name: string): PerformanceTrace;
|
|
32
|
+
startTrace(name: string): PerformanceTrace;
|
|
33
|
+
newScreenTrace(screenName: string): ScreenTrace;
|
|
34
|
+
startScreenTrace(screenName: string): ScreenTrace;
|
|
35
|
+
newHttpMetric(url: string, httpMethod: HttpMethod): HttpMetric;
|
|
48
36
|
}
|
|
49
37
|
|
|
50
38
|
export interface RNFBPerfTraceData {
|
|
@@ -65,16 +53,16 @@ export interface RNFBPerfNativeModule {
|
|
|
65
53
|
isInstrumentationEnabled: boolean;
|
|
66
54
|
setPerformanceCollectionEnabled(enabled: boolean): Promise<null>;
|
|
67
55
|
instrumentationEnabled(enabled: boolean): Promise<null>;
|
|
68
|
-
startTrace(id: number, identifier: string):
|
|
69
|
-
stopTrace(id: number, traceData: RNFBPerfTraceData):
|
|
70
|
-
startHttpMetric(id: number, url: string, httpMethod: HttpMethod):
|
|
71
|
-
stopHttpMetric(id: number, metricData: RNFBPerfHttpMetricData):
|
|
72
|
-
startScreenTrace(id: number, identifier: string):
|
|
73
|
-
stopScreenTrace(id: number):
|
|
56
|
+
startTrace(id: number, identifier: string): void;
|
|
57
|
+
stopTrace(id: number, traceData: RNFBPerfTraceData): void;
|
|
58
|
+
startHttpMetric(id: number, url: string, httpMethod: HttpMethod): void;
|
|
59
|
+
stopHttpMetric(id: number, metricData: RNFBPerfHttpMetricData): void;
|
|
60
|
+
startScreenTrace(id: number, identifier: string): void;
|
|
61
|
+
stopScreenTrace(id: number): void;
|
|
74
62
|
}
|
|
75
63
|
|
|
76
64
|
declare module '@react-native-firebase/app/dist/module/internal/NativeModules' {
|
|
77
65
|
interface ReactNativeFirebaseNativeModules {
|
|
78
|
-
|
|
66
|
+
NativeRNFBTurboPerf: RNFBPerfNativeModule;
|
|
79
67
|
}
|
|
80
68
|
}
|
package/lib/types/perf.ts
CHANGED
|
@@ -44,7 +44,7 @@ export type HttpMethod =
|
|
|
44
44
|
/**
|
|
45
45
|
* A performance trace (aligned with {@link https://firebase.google.com/docs/reference/js/performance.performancetrace | PerformanceTrace} in the Firebase JS SDK).
|
|
46
46
|
*
|
|
47
|
-
* @remarks React Native uses
|
|
47
|
+
* @remarks React Native uses synchronous `start`/`stop` (in-memory native calls via TurboModules), matching the firebase-js-sdk web `PerformanceTrace`. React Native also exposes `getMetrics` and `removeMetric`, which are not on the web `PerformanceTrace` type.
|
|
48
48
|
*/
|
|
49
49
|
export interface PerformanceTrace {
|
|
50
50
|
getAttribute(attr: string): string | undefined;
|
|
@@ -54,16 +54,16 @@ export interface PerformanceTrace {
|
|
|
54
54
|
putMetric(metricName: string, num: number): void;
|
|
55
55
|
incrementMetric(metricName: string, num?: number): void;
|
|
56
56
|
removeMetric(metricName: string): void;
|
|
57
|
-
start():
|
|
58
|
-
stop():
|
|
57
|
+
start(): void;
|
|
58
|
+
stop(): void;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Screen trace for slow/frozen frames (React Native).
|
|
63
63
|
*/
|
|
64
64
|
export interface ScreenTrace {
|
|
65
|
-
start():
|
|
66
|
-
stop():
|
|
65
|
+
start(): void;
|
|
66
|
+
stop(): void;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -78,8 +78,8 @@ export interface HttpMetric {
|
|
|
78
78
|
setRequestPayloadSize(bytes: number | null): void;
|
|
79
79
|
setResponsePayloadSize(bytes: number | null): void;
|
|
80
80
|
setResponseContentType(contentType: string | null): void;
|
|
81
|
-
start():
|
|
82
|
-
stop():
|
|
81
|
+
start(): void;
|
|
82
|
+
stop(): void;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
package/lib/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '
|
|
2
|
+
export const version = '26.1.0';
|
package/package.json
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-firebase/perf",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.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": "./dist/module/index.js",
|
|
7
7
|
"types": "./dist/typescript/lib/index.d.ts",
|
|
8
|
+
"codegenConfig": {
|
|
9
|
+
"name": "RNFBPerfTurboModules",
|
|
10
|
+
"type": "modules",
|
|
11
|
+
"jsSrcsDir": "specs",
|
|
12
|
+
"includesGeneratedCode": true,
|
|
13
|
+
"android": {
|
|
14
|
+
"javaPackageName": "io.invertase.firebase.perf"
|
|
15
|
+
},
|
|
16
|
+
"ios": {
|
|
17
|
+
"modulesProvider": {
|
|
18
|
+
"NativeRNFBTurboPerf": "RNFBPerfModule"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
8
22
|
"scripts": {
|
|
9
23
|
"build": "genversion --esm --semi lib/version.ts",
|
|
10
24
|
"build:clean": "rimraf android/build && rimraf ios/build",
|
|
11
25
|
"build:plugin": "rimraf plugin/build && tsc --build plugin",
|
|
12
26
|
"compile": "bob build",
|
|
13
27
|
"lint:plugin": "eslint plugin/src/*",
|
|
14
|
-
"prepare": "yarn run build && yarn compile && yarn run build:plugin"
|
|
28
|
+
"prepare": "yarn run build && yarn compile && yarn run build:plugin",
|
|
29
|
+
"codegen": "yarn android:codegen && yarn ios:codegen",
|
|
30
|
+
"android:codegen": "npx @react-native-community/cli codegen --platform android --outputPath=./android/src/reactnative/java/io/invertase/firebase/perf/generated",
|
|
31
|
+
"ios:codegen": "npx @react-native-community/cli codegen --platform ios --outputPath=./ios/generated"
|
|
15
32
|
},
|
|
16
33
|
"repository": {
|
|
17
34
|
"type": "git",
|
|
@@ -30,10 +47,11 @@
|
|
|
30
47
|
"performance monitoring"
|
|
31
48
|
],
|
|
32
49
|
"peerDependencies": {
|
|
33
|
-
"@react-native-firebase/app": "
|
|
50
|
+
"@react-native-firebase/app": "26.1.0",
|
|
34
51
|
"expo": ">=47.0.0"
|
|
35
52
|
},
|
|
36
53
|
"devDependencies": {
|
|
54
|
+
"@react-native-firebase/app": "26.1.0",
|
|
37
55
|
"expo": "^55.0.18",
|
|
38
56
|
"react-native-builder-bob": "^0.40.13"
|
|
39
57
|
},
|
|
@@ -52,7 +70,14 @@
|
|
|
52
70
|
"types": "./dist/typescript/lib/index.d.ts",
|
|
53
71
|
"default": "./dist/module/index.js"
|
|
54
72
|
},
|
|
55
|
-
"./app.plugin
|
|
73
|
+
"./app.plugin": {
|
|
74
|
+
"types": "./plugin/build/app.plugin.d.ts",
|
|
75
|
+
"default": "./app.plugin.js"
|
|
76
|
+
},
|
|
77
|
+
"./app.plugin.js": {
|
|
78
|
+
"types": "./plugin/build/app.plugin.d.ts",
|
|
79
|
+
"default": "./app.plugin.js"
|
|
80
|
+
},
|
|
56
81
|
"./package.json": "./package.json"
|
|
57
82
|
},
|
|
58
83
|
"react-native-builder-bob": {
|
|
@@ -77,5 +102,5 @@
|
|
|
77
102
|
"node_modules/",
|
|
78
103
|
"dist/"
|
|
79
104
|
],
|
|
80
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "59d053eca14ab8aa80e5ac76887014925c67e52b"
|
|
81
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/android/applyPlugin.ts","./src/android/buildscriptDependency.ts","./src/android/constants.ts","./src/android/index.ts"],"version":"6.0.3"}
|
|
1
|
+
{"root":["./src/app.plugin.ts","./src/index.ts","./src/android/applyPlugin.ts","./src/android/buildscriptDependency.ts","./src/android/constants.ts","./src/android/index.ts"],"version":"6.0.3"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export type HttpMethod =
|
|
5
|
+
| 'CONNECT'
|
|
6
|
+
| 'DELETE'
|
|
7
|
+
| 'GET'
|
|
8
|
+
| 'HEAD'
|
|
9
|
+
| 'OPTIONS'
|
|
10
|
+
| 'PATCH'
|
|
11
|
+
| 'POST'
|
|
12
|
+
| 'PUT'
|
|
13
|
+
| 'TRACE';
|
|
14
|
+
|
|
15
|
+
export interface TraceData {
|
|
16
|
+
metrics: { [key: string]: number };
|
|
17
|
+
attributes: { [key: string]: string };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface HttpMetricData {
|
|
21
|
+
attributes: { [key: string]: string };
|
|
22
|
+
httpResponseCode?: number;
|
|
23
|
+
requestPayloadSize?: number;
|
|
24
|
+
responsePayloadSize?: number;
|
|
25
|
+
responseContentType?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Spec extends TurboModule {
|
|
29
|
+
getConstants(): {
|
|
30
|
+
isPerformanceCollectionEnabled: boolean;
|
|
31
|
+
isInstrumentationEnabled: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
setPerformanceCollectionEnabled(enabled: boolean): Promise<void>;
|
|
35
|
+
instrumentationEnabled(enabled: boolean): Promise<void>;
|
|
36
|
+
startTrace(id: number, identifier: string): void;
|
|
37
|
+
stopTrace(id: number, traceData: TraceData): void;
|
|
38
|
+
startScreenTrace(id: number, identifier: string): void;
|
|
39
|
+
stopScreenTrace(id: number): void;
|
|
40
|
+
startHttpMetric(id: number, url: string, httpMethod: HttpMethod): void;
|
|
41
|
+
stopHttpMetric(id: number, metricData: HttpMetricData): void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('NativeRNFBTurboPerf');
|
package/typedoc.json
CHANGED