@react-native-firebase/perf 24.1.1 → 25.0.1
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 +29 -0
- package/dist/module/HttpMetric.js +91 -0
- package/dist/module/HttpMetric.js.map +1 -0
- package/dist/module/MetricWithAttributes.js +51 -0
- package/dist/module/MetricWithAttributes.js.map +1 -0
- package/{lib → dist/module}/ScreenTrace.js +3 -6
- package/dist/module/ScreenTrace.js.map +1 -0
- package/{lib → dist/module}/Trace.js +8 -23
- package/dist/module/Trace.js.map +1 -0
- package/dist/module/index.js +23 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/modular.js +93 -0
- package/dist/module/modular.js.map +1 -0
- package/{lib/index.js → dist/module/namespaced.js} +28 -72
- package/dist/module/namespaced.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/dist/module/types/internal.js +4 -0
- package/dist/module/types/internal.js.map +1 -0
- package/dist/module/types/namespaced.js +65 -0
- package/dist/module/types/namespaced.js.map +1 -0
- package/dist/module/types/perf.js +4 -0
- package/dist/module/types/perf.js.map +1 -0
- package/dist/module/version.js +5 -0
- package/dist/module/version.js.map +1 -0
- package/dist/typescript/lib/HttpMetric.d.ts +21 -0
- package/dist/typescript/lib/HttpMetric.d.ts.map +1 -0
- package/dist/typescript/lib/MetricWithAttributes.d.ts +11 -0
- package/dist/typescript/lib/MetricWithAttributes.d.ts.map +1 -0
- package/dist/typescript/lib/ScreenTrace.d.ts +12 -0
- package/dist/typescript/lib/ScreenTrace.d.ts.map +1 -0
- package/dist/typescript/lib/Trace.d.ts +17 -0
- package/dist/typescript/lib/Trace.d.ts.map +1 -0
- package/dist/typescript/lib/index.d.ts +6 -0
- package/dist/typescript/lib/index.d.ts.map +1 -0
- package/dist/typescript/lib/modular.d.ts +43 -0
- package/dist/typescript/lib/modular.d.ts.map +1 -0
- package/dist/typescript/lib/namespaced.d.ts +11 -0
- package/dist/typescript/lib/namespaced.d.ts.map +1 -0
- package/dist/typescript/lib/types/internal.d.ts +45 -0
- package/dist/typescript/lib/types/internal.d.ts.map +1 -0
- package/dist/typescript/lib/types/namespaced.d.ts +128 -0
- package/dist/typescript/lib/types/namespaced.d.ts.map +1 -0
- package/dist/typescript/lib/types/perf.d.ts +72 -0
- package/dist/typescript/lib/types/perf.d.ts.map +1 -0
- package/dist/typescript/lib/version.d.ts +2 -0
- package/dist/typescript/lib/version.d.ts.map +1 -0
- package/dist/typescript/package.json +1 -0
- package/lib/{HttpMetric.js → HttpMetric.ts} +21 -8
- package/lib/{MetricWithAttributes.js → MetricWithAttributes.ts} +14 -4
- package/lib/ScreenTrace.ts +59 -0
- package/lib/Trace.ts +112 -0
- package/lib/index.ts +25 -0
- package/lib/modular.ts +116 -0
- package/lib/namespaced.ts +200 -0
- package/lib/types/internal.ts +80 -0
- package/lib/types/namespaced.ts +162 -0
- package/lib/types/perf.ts +99 -0
- package/lib/version.ts +2 -0
- package/package.json +40 -8
- package/plugin/tsconfig.json +2 -1
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/tsconfig.json +20 -0
- package/typedoc.json +2 -2
- package/lib/index.d.ts +0 -583
- package/lib/modular/index.d.ts +0 -89
- package/lib/modular/index.js +0 -103
- package/lib/version.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,35 @@
|
|
|
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
|
+
## [25.0.1](https://github.com/invertase/react-native-firebase/compare/v25.0.0...v25.0.1) (2026-06-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @react-native-firebase/perf
|
|
9
|
+
|
|
10
|
+
## [25.0.0](https://github.com/invertase/react-native-firebase/compare/v24.0.0...v25.0.0) (2026-06-23)
|
|
11
|
+
|
|
12
|
+
### ⚠ BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
- **perf:** perf types now match firebase-js-sdk as closely as possible
|
|
15
|
+
|
|
16
|
+
Please see https://rnfirebase.io/migrating-to-v25 for help migrating if needed.
|
|
17
|
+
|
|
18
|
+
react-native-firebase has a goal to be a drop-in replacement for firebase-js-sdk, with native extensions and performance. It has always worked that way at the javascript level but the typescript types have been divergent.
|
|
19
|
+
|
|
20
|
+
We are fixing that as we refactor to typescript. Please bear with us as we get closer to our goal of react-native-firebase matching firebase-js-sdk both in functionality where possible, but also in exact typescript typing.
|
|
21
|
+
|
|
22
|
+
Specifics for Performance:
|
|
23
|
+
|
|
24
|
+
- changed modular `initializePerformance(app, settings)` to return `FirebasePerformance` synchronously instead of `Promise<Performance>`, matching firebase-js-sdk; TypeScript consumers that call `.then(...)` on it will need to use the returned instance directly.
|
|
25
|
+
- aligned the modular `FirebasePerformance` type with firebase-js-sdk, so it no longer exposes older namespaced instance-style methods such as `newTrace`, `startTrace`, `newHttpMetric`, `newScreenTrace`, `startScreenTrace`, or `setPerformanceCollectionEnabled` in the modular typings; use `trace(perf, name)`, `httpMetric(perf, url, method)`, `newScreenTrace(perf, name)`, `startScreenTrace(perf, name)`, and the `dataCollectionEnabled` property instead.
|
|
26
|
+
- changed `PerformanceSettings` to the firebase-js-sdk shape, with optional `dataCollectionEnabled` and `instrumentationEnabled`.
|
|
27
|
+
- changed modular trace and metric `getAttribute(...)` typings from `string | null` to `string | undefined`, matching firebase-js-sdk.
|
|
28
|
+
- kept React Native-only modular exports for native functionality: `httpMetric`, `newScreenTrace`, `startScreenTrace`, plus `HttpMethod`, `HttpMetric`, and `ScreenTrace`.
|
|
29
|
+
- kept the deprecated namespaced API under `FirebasePerformanceTypes`, but split it from the modular public types and marked it as deprecated for compatibility.
|
|
30
|
+
|
|
31
|
+
### Code Refactoring
|
|
32
|
+
|
|
33
|
+
- **perf:** migrate to TypeScript ([4aedfe8](https://github.com/invertase/react-native-firebase/commit/4aedfe883a5439b5c97b389c708a7c4cec9dc62d))
|
|
34
|
+
|
|
6
35
|
## [24.1.1](https://github.com/invertase/react-native-firebase/compare/v24.1.0...v24.1.1) (2026-06-10)
|
|
7
36
|
|
|
8
37
|
**Note:** Version bump only for package @react-native-firebase/perf
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { isNull, isNumber, isString } from '@react-native-firebase/app/dist/module/common';
|
|
21
|
+
import MetricWithAttributes from "./MetricWithAttributes.js";
|
|
22
|
+
export default class HttpMetric extends MetricWithAttributes {
|
|
23
|
+
constructor(native, url, httpMethod) {
|
|
24
|
+
super(native);
|
|
25
|
+
this._url = url;
|
|
26
|
+
this._httpMethod = httpMethod;
|
|
27
|
+
this._httpResponseCode = null;
|
|
28
|
+
this._requestPayloadSize = null;
|
|
29
|
+
this._responsePayloadSize = null;
|
|
30
|
+
this._responseContentType = null;
|
|
31
|
+
this._started = false;
|
|
32
|
+
this._stopped = false;
|
|
33
|
+
}
|
|
34
|
+
setHttpResponseCode(code) {
|
|
35
|
+
if (!isNumber(code) && !isNull(code)) {
|
|
36
|
+
throw new Error("firebase.perf.HttpMetric.setHttpResponseCode(*) 'code' must be a number or null.");
|
|
37
|
+
}
|
|
38
|
+
this._httpResponseCode = code;
|
|
39
|
+
}
|
|
40
|
+
setRequestPayloadSize(bytes) {
|
|
41
|
+
if (!isNumber(bytes) && !isNull(bytes)) {
|
|
42
|
+
throw new Error("firebase.perf.HttpMetric.setRequestPayloadSize(*) 'bytes' must be a number or null.");
|
|
43
|
+
}
|
|
44
|
+
this._requestPayloadSize = bytes;
|
|
45
|
+
}
|
|
46
|
+
setResponsePayloadSize(bytes) {
|
|
47
|
+
if (!isNumber(bytes) && !isNull(bytes)) {
|
|
48
|
+
throw new Error("firebase.perf.HttpMetric.setResponsePayloadSize(*) 'bytes' must be a number or null.");
|
|
49
|
+
}
|
|
50
|
+
this._responsePayloadSize = bytes;
|
|
51
|
+
}
|
|
52
|
+
setResponseContentType(contentType) {
|
|
53
|
+
if (!isString(contentType) && !isNull(contentType)) {
|
|
54
|
+
throw new Error("firebase.perf.HttpMetric.setResponseContentType(*) 'contentType' must be a string or null.");
|
|
55
|
+
}
|
|
56
|
+
this._responseContentType = contentType;
|
|
57
|
+
}
|
|
58
|
+
start() {
|
|
59
|
+
if (this._started) {
|
|
60
|
+
return Promise.resolve(null);
|
|
61
|
+
}
|
|
62
|
+
this._started = true;
|
|
63
|
+
return this.native.startHttpMetric(this._id, this._url, this._httpMethod);
|
|
64
|
+
}
|
|
65
|
+
stop() {
|
|
66
|
+
if (this._stopped) {
|
|
67
|
+
return Promise.resolve(null);
|
|
68
|
+
}
|
|
69
|
+
this._stopped = true;
|
|
70
|
+
const metricData = {
|
|
71
|
+
attributes: Object.assign({}, this._attributes)
|
|
72
|
+
};
|
|
73
|
+
if (!isNull(this._httpResponseCode)) {
|
|
74
|
+
metricData.httpResponseCode = this._httpResponseCode;
|
|
75
|
+
} else {
|
|
76
|
+
// eslint-disable-next-line no-console
|
|
77
|
+
console.warn(`Warning: A firebase.perf.HttpMetric (${this._httpMethod}: ${this._url}) failed to provide a httpResponseCode; this metric will not be visible on the Firebase console.`);
|
|
78
|
+
}
|
|
79
|
+
if (!isNull(this._requestPayloadSize)) {
|
|
80
|
+
metricData.requestPayloadSize = this._requestPayloadSize;
|
|
81
|
+
}
|
|
82
|
+
if (!isNull(this._responsePayloadSize)) {
|
|
83
|
+
metricData.responsePayloadSize = this._responsePayloadSize;
|
|
84
|
+
}
|
|
85
|
+
if (!isNull(this._responseContentType)) {
|
|
86
|
+
metricData.responseContentType = this._responseContentType;
|
|
87
|
+
}
|
|
88
|
+
return this.native.stopHttpMetric(this._id, metricData);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=HttpMetric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isNull","isNumber","isString","MetricWithAttributes","HttpMetric","constructor","native","url","httpMethod","_url","_httpMethod","_httpResponseCode","_requestPayloadSize","_responsePayloadSize","_responseContentType","_started","_stopped","setHttpResponseCode","code","Error","setRequestPayloadSize","bytes","setResponsePayloadSize","setResponseContentType","contentType","start","Promise","resolve","startHttpMetric","_id","stop","metricData","attributes","Object","assign","_attributes","httpResponseCode","console","warn","requestPayloadSize","responsePayloadSize","responseContentType","stopHttpMetric"],"sourceRoot":"../../lib","sources":["HttpMetric.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,+CAA+C;AAE1F,OAAOC,oBAAoB,MAAM,2BAAwB;AAKzD,eAAe,MAAMC,UAAU,SAASD,oBAAoB,CAAC;EAU3DE,WAAWA,CAACC,MAA4B,EAAEC,GAAW,EAAEC,UAAsB,EAAE;IAC7E,KAAK,CAACF,MAAM,CAAC;IAEb,IAAI,CAACG,IAAI,GAAGF,GAAG;IACf,IAAI,CAACG,WAAW,GAAGF,UAAU;IAE7B,IAAI,CAACG,iBAAiB,GAAG,IAAI;IAC7B,IAAI,CAACC,mBAAmB,GAAG,IAAI;IAC/B,IAAI,CAACC,oBAAoB,GAAG,IAAI;IAChC,IAAI,CA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ACpB,IAAI,EAAE,IAAI,CAACC,WAAW,CAAC;EAC3E;EAEAoB,IAAIA,CAAA,EAAkB;IACpB,IAAI,IAAI,CAACd,QAAQ,EAAE;MACjB,OAAOU,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;IAC9B;IACA,IAAI,CAACX,QAAQ,GAAG,IAAI;IAEpB,MAAMe,UAAkC,GAAG;MACzCC,UAAU,EAAEC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAACC,WAAW;IAChD,CAAC;IAED,IAAI,CAACnC,MAAM,CAAC,IAAI,CAACW,iBAAiB,CAAC,EAAE;MACnCoB,UAAU,CAACK,gBAAgB,GAAG,IAAI,CAACzB,iBAAiB;IACtD,CAAC,MAAM;MACL;MACA0B,OAAO,CAACC,IAAI,CACV,wCAAwC,IAAI,CAAC5B,WAAW,KAAK,IAAI,CAACD,IAAI,kGACxE,CAAC;IACH;IAEA,IAAI,CAACT,MAAM,CAAC,IAAI,CAACY,mBAAmB,CAAC,EAAE;MACrCmB,UAAU,CAACQ,kBAAkB,GAAG,IAAI,CAAC3B,mBAAmB;IAC1D;IACA,IAAI,CAACZ,MAAM,CAAC,IAAI,CAACa,oBAAoB,CAAC,EAAE;MACtCkB,UAAU,CAACS,mBAAmB,GAAG,IAAI,CAAC3B,oBAAoB;IAC5D;IACA,IAAI,CAACb,MAAM,CAAC,IAAI,CAACc,oBAAoB,CAAC,EAAE;MACtCiB,UAAU,CAACU,mBAAmB,GAAG,IAAI,CAAC3B,oBAAoB;IAC5D;IAEA,OAAO,IAAI,CAACR,MAAM,CAACoC,cAAc,CAAC,IAAI,CAACb,GAAG,EAAEE,UAAU,CAAC;EACzD;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { hasOwnProperty, isString } from '@react-native-firebase/app/dist/module/common';
|
|
21
|
+
let id = 0;
|
|
22
|
+
export default class MetricWithAttributes {
|
|
23
|
+
constructor(native) {
|
|
24
|
+
this._id = id++;
|
|
25
|
+
this.native = native;
|
|
26
|
+
this._attributes = {};
|
|
27
|
+
}
|
|
28
|
+
getAttribute(attribute) {
|
|
29
|
+
if (!isString(attribute)) {
|
|
30
|
+
throw new Error("firebase.perf.*.getAttribute(*) 'attribute' must be a string.");
|
|
31
|
+
}
|
|
32
|
+
return hasOwnProperty(this._attributes, attribute) ? this._attributes[attribute] : null;
|
|
33
|
+
}
|
|
34
|
+
getAttributes() {
|
|
35
|
+
return Object.assign({}, this._attributes);
|
|
36
|
+
}
|
|
37
|
+
putAttribute(attribute, value) {
|
|
38
|
+
// TODO(VALIDATION): attribute: no leading or trailing whitespace, no leading underscore '_'
|
|
39
|
+
if (!isString(attribute) || attribute.length > 40) {
|
|
40
|
+
throw new Error("firebase.perf.*.putAttribute(*, _) 'attribute' must be a string with a maximum length of 40 characters.");
|
|
41
|
+
}
|
|
42
|
+
if (!isString(value) || value.length > 100) {
|
|
43
|
+
throw new Error("firebase.perf.*.putAttribute(_, *) 'value' must be a string with a maximum length of 100 characters.");
|
|
44
|
+
}
|
|
45
|
+
if (!hasOwnProperty(this._attributes, attribute) && Object.keys(this._attributes).length > 4) {
|
|
46
|
+
throw new Error('firebase.perf.*.putAttribute(_, _) the maximum number of attributes (5) has been reached.');
|
|
47
|
+
}
|
|
48
|
+
this._attributes[attribute] = value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=MetricWithAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hasOwnProperty","isString","id","MetricWithAttributes","constructor","native","_id","_attributes","getAttribute","attribute","Error","getAttributes","Object","assign","putAttribute","value","length","keys"],"sourceRoot":"../../lib","sources":["MetricWithAttributes.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,EAAEC,QAAQ,QAAQ,+CAA+C;AAIxF,IAAIC,EAAE,GAAG,CAAC;AAEV,eAAe,MAAMC,oBAAoB,CAAC;EAKxCC,WAAWA,CAACC,MAA4B,EAAE;IACxC,IAAI,CAACC,GAAG,GAAGJ,EAAE,EAAE;IACf,IAAI,CAACG,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,WAAW,GAAG,CAAC,CAAC;EACvB;EAEAC,YAAYA,CAACC,SAAiB,EAAiB;IAC7C,IAAI,CAACR,QAAQ,CAACQ,SAAS,CAAC,EAAE;MACxB,MAAM,IAAIC,KAAK,CAAC,+DAA+D,CAAC;IAClF;IACA,OAAOV,cAAc,CAAC,IAAI,CAACO,WAAW,EAAEE,SAAS,CAAC,GAAG,IAAI,CAACF,WAAW,CAACE,SAAS,CAAC,GAAI,IAAI;EAC1F;EAEAE,aAAaA,CAAA,EAA2B;IACtC,OAAOC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAACN,WAAW,CAAC;EAC5C;EAEAO,YAAYA,CAACL,SAAiB,EAAEM,KAAa,EAAQ;IACnD;IACA,IAAI,CAACd,QAAQ,CAACQ,SAAS,CAAC,IAAIA,SAAS,CAACO,MAAM,GAAG,EAAE,EAAE;MACjD,MAAM,IAAIN,KAAK,CACb,yGACF,CAAC;IACH;IAEA,IAAI,CAACT,QAAQ,CAACc,KAAK,CAAC,IAAIA,KAAK,CAACC,MAAM,GAAG,GAAG,EAAE;MAC1C,MAAM,IAAIN,KAAK,CACb,sGACF,CAAC;IACH;IAEA,IAAI,CAACV,cAAc,CAAC,IAAI,CAACO,WAAW,EAAEE,SAAS,CAAC,IAAIG,MAAM,CAACK,IAAI,CAAC,IAAI,CAACV,WAAW,CAAC,CAACS,MAAM,GAAG,CAAC,EAAE;MAC5F,MAAM,IAAIN,KAAK,CACb,2FACF,CAAC;IACH;IAEA,IAAI,CAACH,WAAW,CAACE,SAAS,CAAC,GAAGM,KAAK;EACrC;AACF","ignoreList":[]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
/*
|
|
2
4
|
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
5
|
*
|
|
@@ -16,9 +18,7 @@
|
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
20
|
import { isIOS } from '@react-native-firebase/app/dist/module/common';
|
|
19
|
-
|
|
20
21
|
let id = 0;
|
|
21
|
-
|
|
22
22
|
export default class ScreenTrace {
|
|
23
23
|
constructor(native, identifier) {
|
|
24
24
|
this.native = native;
|
|
@@ -27,7 +27,6 @@ export default class ScreenTrace {
|
|
|
27
27
|
this._started = false;
|
|
28
28
|
this._stopped = false;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
30
|
start() {
|
|
32
31
|
if (isIOS) {
|
|
33
32
|
return Promise.reject(new Error('Custom screentraces are currently not supported on iOS.'));
|
|
@@ -36,16 +35,14 @@ export default class ScreenTrace {
|
|
|
36
35
|
return Promise.resolve(null);
|
|
37
36
|
}
|
|
38
37
|
this._started = true;
|
|
39
|
-
|
|
40
38
|
return this.native.startScreenTrace(this._id, this._identifier);
|
|
41
39
|
}
|
|
42
|
-
|
|
43
40
|
stop() {
|
|
44
41
|
if (!this._started || this._stopped) {
|
|
45
42
|
return Promise.resolve(null);
|
|
46
43
|
}
|
|
47
44
|
this._stopped = true;
|
|
48
|
-
|
|
49
45
|
return this.native.stopScreenTrace(this._id);
|
|
50
46
|
}
|
|
51
47
|
}
|
|
48
|
+
//# sourceMappingURL=ScreenTrace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isIOS","id","ScreenTrace","constructor","native","identifier","_identifier","_id","_started","_stopped","start","Promise","reject","Error","resolve","startScreenTrace","stop","stopScreenTrace"],"sourceRoot":"../../lib","sources":["ScreenTrace.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,+CAA+C;AAIrE,IAAIC,EAAE,GAAG,CAAC;AAEV,eAAe,MAAMC,WAAW,CAAC;EAO/BC,WAAWA,CAACC,MAA4B,EAAEC,UAAkB,EAAE;IAC5D,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACE,WAAW,GAAGD,UAAU;IAC7B,IAAI,CAACE,GAAG,GAAGN,EAAE,EAAE;IACf,IAAI,CAACO,QAAQ,GAAG,KAAK;IACrB,IAAI,CAACC,QAAQ,GAAG,KAAK;EACvB;EAEAC,KAAKA,CAAA,EAAkB;IACrB,IAAIV,KAAK,EAAE;MACT,OAAOW,OAAO,CAACC,MAAM,CAAC,IAAIC,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7F;IACA,IAAI,IAAI,CAACL,QAAQ,EAAE;MACjB,OAAOG,OAAO,CAACG,OAAO,CAAC,IAAI,CAAC;IAC9B;IACA,IAAI,CAACN,QAAQ,GAAG,IAAI;IAEpB,OAAO,IAAI,CAACJ,MAAM,CAACW,gBAAgB,CAAC,IAAI,CAACR,GAAG,EAAE,IAAI,CAACD,WAAW,CAAC;EACjE;EAEAU,IAAIA,CAAA,EAAkB;IACpB,IAAI,CAAC,IAAI,CAACR,QAAQ,IAAI,IAAI,CAACC,QAAQ,EAAE;MACnC,OAAOE,OAAO,CAACG,OAAO,CAAC,IAAI,CAAC;IAC9B;IACA,IAAI,CAACL,QAAQ,GAAG,IAAI;IAEpB,OAAO,IAAI,CAACL,MAAM,CAACa,eAAe,CAAC,IAAI,CAACV,GAAG,CAAC;EAC9C;AACF","ignoreList":[]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
/*
|
|
2
4
|
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
5
|
*
|
|
@@ -16,87 +18,70 @@
|
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
20
|
import { hasOwnProperty, isNumber, isString } from '@react-native-firebase/app/dist/module/common';
|
|
19
|
-
import MetricWithAttributes from
|
|
20
|
-
|
|
21
|
+
import MetricWithAttributes from "./MetricWithAttributes.js";
|
|
21
22
|
export default class Trace extends MetricWithAttributes {
|
|
22
23
|
constructor(native, identifier) {
|
|
23
24
|
super(native);
|
|
24
25
|
this._identifier = identifier;
|
|
25
|
-
|
|
26
26
|
this._metrics = {};
|
|
27
|
-
|
|
28
27
|
this._started = false;
|
|
29
28
|
this._stopped = false;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
30
|
getMetric(metricName) {
|
|
33
31
|
if (!isString(metricName)) {
|
|
34
32
|
throw new Error("firebase.perf.Trace.getMetric(*) 'metricName' must be a string.");
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
return hasOwnProperty(this._metrics, metricName) ? this._metrics[metricName] : 0;
|
|
38
35
|
}
|
|
39
|
-
|
|
40
36
|
getMetrics() {
|
|
41
37
|
return Object.assign({}, this._metrics);
|
|
42
38
|
}
|
|
43
|
-
|
|
44
39
|
putMetric(metricName, value) {
|
|
45
40
|
// TODO(VALIDATION): metricName: no leading or trailing whitespace, no leading underscore '_' character, max length is 32 characters
|
|
46
41
|
// TODO(VALIDATION): value: >= 0
|
|
47
42
|
if (!isString(metricName)) {
|
|
48
43
|
throw new Error("firebase.perf.Trace.putMetric(*, _) 'metricName' must be a string.");
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
if (!isNumber(value)) {
|
|
52
46
|
throw new Error("firebase.perf.Trace.putMetric(_, *) 'value' must be a number.");
|
|
53
47
|
}
|
|
54
|
-
|
|
55
48
|
this._metrics[metricName] = value;
|
|
56
49
|
}
|
|
57
|
-
|
|
58
|
-
incrementMetric(metricName, incrementBy) {
|
|
50
|
+
incrementMetric(metricName, num) {
|
|
59
51
|
// TODO(VALIDATION): metricName: no leading or trailing whitespace, no leading underscore '_' character, max length is 32 characters
|
|
60
52
|
// TODO(VALIDATION): value: >= 0
|
|
61
53
|
if (!isString(metricName)) {
|
|
62
54
|
throw new Error("firebase.perf.Trace.incrementMetric(*, _) 'metricName' must be a string.");
|
|
63
55
|
}
|
|
64
|
-
|
|
56
|
+
const incrementBy = num ?? 1;
|
|
65
57
|
if (!isNumber(incrementBy)) {
|
|
66
|
-
throw new Error("firebase.perf.Trace.incrementMetric(_, *) '
|
|
58
|
+
throw new Error("firebase.perf.Trace.incrementMetric(_, *) 'num' must be a number.");
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
this._metrics[metricName] = this.getMetric(metricName) + incrementBy;
|
|
70
61
|
}
|
|
71
|
-
|
|
72
62
|
removeMetric(metric) {
|
|
73
63
|
if (!isString(metric)) {
|
|
74
64
|
throw new Error("firebase.perf.Trace.removeMetric(*) 'metric' must be a string.");
|
|
75
65
|
}
|
|
76
|
-
|
|
77
66
|
delete this._metrics[metric];
|
|
78
67
|
}
|
|
79
|
-
|
|
80
68
|
start() {
|
|
81
69
|
if (this._started) {
|
|
82
70
|
return Promise.resolve(null);
|
|
83
71
|
}
|
|
84
72
|
this._started = true;
|
|
85
|
-
|
|
86
73
|
return this.native.startTrace(this._id, this._identifier);
|
|
87
74
|
}
|
|
88
|
-
|
|
89
75
|
stop() {
|
|
90
76
|
if (this._stopped) {
|
|
91
77
|
return Promise.resolve(null);
|
|
92
78
|
}
|
|
93
79
|
this._stopped = true;
|
|
94
|
-
|
|
95
80
|
const traceData = {
|
|
96
81
|
metrics: Object.assign({}, this._metrics),
|
|
97
|
-
attributes: Object.assign({}, this._attributes)
|
|
82
|
+
attributes: Object.assign({}, this._attributes)
|
|
98
83
|
};
|
|
99
|
-
|
|
100
84
|
return this.native.stopTrace(this._id, traceData);
|
|
101
85
|
}
|
|
102
86
|
}
|
|
87
|
+
//# sourceMappingURL=Trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hasOwnProperty","isNumber","isString","MetricWithAttributes","Trace","constructor","native","identifier","_identifier","_metrics","_started","_stopped","getMetric","metricName","Error","getMetrics","Object","assign","putMetric","value","incrementMetric","num","incrementBy","removeMetric","metric","start","Promise","resolve","startTrace","_id","stop","traceData","metrics","attributes","_attributes","stopTrace"],"sourceRoot":"../../lib","sources":["Trace.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,+CAA+C;AAElG,OAAOC,oBAAoB,MAAM,2BAAwB;AAIzD,eAAe,MAAMC,KAAK,SAASD,oBAAoB,CAAC;EAMtDE,WAAWA,CAACC,MAA4B,EAAEC,UAAkB,EAAE;IAC5D,KAAK,CAACD,MAAM,CAAC;IACb,IAAI,CAACE,WAAW,GAAGD,UAAU;IAE7B,IAAI,CAACE,QAAQ,GAAG,CAAC,CAAC;IAElB,IAAI,CAACC,QAAQ,GAAG,KAAK;IACrB,IAAI,CAACC,QAAQ,GAAG,KAAK;EACvB;EAEAC,SAASA,CAACC,UAAkB,EAAU;IACpC,IAAI,CAACX,QAAQ,CAACW,UAAU,CAAC,EAAE;MACzB,MAAM,IAAIC,KAAK,CAAC,iEAAiE,CAAC;IACpF;IAEA,OAAOd,cAAc,CAAC,IAAI,CAACS,Q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AO,CAAC,IAAI,CAAC;IAC9B;IACA,IAAI,CAACjB,QAAQ,GAAG,IAAI;IAEpB,OAAO,IAAI,CAACJ,MAAM,CAACsB,UAAU,CAAC,IAAI,CAACC,GAAG,EAAE,IAAI,CAACrB,WAAW,CAAC;EAC3D;EAEAsB,IAAIA,CAAA,EAAkB;IACpB,IAAI,IAAI,CAACnB,QAAQ,EAAE;MACjB,OAAOe,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;IAC9B;IACA,IAAI,CAAChB,QAAQ,GAAG,IAAI;IAEpB,MAAMoB,SAAS,GAAG;MAChBC,OAAO,EAAEhB,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAACR,QAAQ,CAAC;MACzCwB,UAAU,EAAEjB,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAACiB,WAAW;IAChD,CAAC;IAED,OAAO,IAAI,CAAC5B,MAAM,CAAC6B,SAAS,CAAC,IAAI,CAACN,GAAG,EAAEE,SAAS,CAAC;EACnD;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export * from "./modular.js";
|
|
21
|
+
export * from "./namespaced.js";
|
|
22
|
+
export { default } from "./namespaced.js";
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default"],"sourceRoot":"../../lib","sources":["index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,cAAc,cAAW;AAIzB,cAAc,iBAAc;AAC5B,SAASA,OAAO,QAAQ,iBAAc","ignoreList":[]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { getApp } from '@react-native-firebase/app';
|
|
21
|
+
import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/dist/module/common';
|
|
22
|
+
function perfInternal(performance) {
|
|
23
|
+
return performance;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns a {@link FirebasePerformance} instance for the given app.
|
|
28
|
+
* @param app - The FirebaseApp to use. Optional; defaults to the default app.
|
|
29
|
+
*/
|
|
30
|
+
export function getPerformance(app) {
|
|
31
|
+
if (app) {
|
|
32
|
+
return getApp(app.name).perf();
|
|
33
|
+
}
|
|
34
|
+
return getApp().perf();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Returns a {@link FirebasePerformance} instance for the given app (aligned with the Firebase JS SDK).
|
|
39
|
+
* Can only be called once per app during initialization in typical usage.
|
|
40
|
+
*
|
|
41
|
+
* @param app - The FirebaseApp to use.
|
|
42
|
+
* @param settings - Optional {@link PerformanceSettings}.
|
|
43
|
+
*/
|
|
44
|
+
export function initializePerformance(app, settings) {
|
|
45
|
+
const perf = getPerformance(app);
|
|
46
|
+
if (settings?.dataCollectionEnabled !== undefined) {
|
|
47
|
+
perf.dataCollectionEnabled = settings.dataCollectionEnabled;
|
|
48
|
+
}
|
|
49
|
+
if (settings?.instrumentationEnabled !== undefined) {
|
|
50
|
+
perf.instrumentationEnabled = settings.instrumentationEnabled;
|
|
51
|
+
}
|
|
52
|
+
return perf;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Returns a new {@link PerformanceTrace} instance.
|
|
57
|
+
* @param performance - The {@link FirebasePerformance} instance to use.
|
|
58
|
+
* @param name - The name of the trace.
|
|
59
|
+
*/
|
|
60
|
+
export function trace(performance, name) {
|
|
61
|
+
return perfInternal(performance).newTrace(name, MODULAR_DEPRECATION_ARG);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Creates an {@link HttpMetric} for a URL and HTTP method (React Native).
|
|
66
|
+
* @param performance - The {@link FirebasePerformance} instance to use.
|
|
67
|
+
* @param url - Request URL.
|
|
68
|
+
* @param httpMethod - HTTP method.
|
|
69
|
+
*/
|
|
70
|
+
export function httpMetric(performance, url, httpMethod) {
|
|
71
|
+
return perfInternal(performance).newHttpMetric(url, httpMethod, MODULAR_DEPRECATION_ARG);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a {@link ScreenTrace} with the given screen name.
|
|
76
|
+
* Android only; throws if hardware acceleration is disabled or if Android is 9.0 or 9.1.
|
|
77
|
+
* @param performance - The {@link FirebasePerformance} instance to use.
|
|
78
|
+
* @param screenName - Screen name; no leading/trailing whitespace, no leading `_`, max length 100.
|
|
79
|
+
*/
|
|
80
|
+
export function newScreenTrace(performance, screenName) {
|
|
81
|
+
return perfInternal(performance).newScreenTrace(screenName, MODULAR_DEPRECATION_ARG);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates a {@link ScreenTrace} and starts it immediately.
|
|
86
|
+
* Android only; throws if hardware acceleration is disabled or if Android is 9.0 or 9.1.
|
|
87
|
+
* @param performance - The {@link FirebasePerformance} instance to use.
|
|
88
|
+
* @param screenName - Name of the screen.
|
|
89
|
+
*/
|
|
90
|
+
export function startScreenTrace(performance, screenName) {
|
|
91
|
+
return perfInternal(performance).startScreenTrace(screenName, MODULAR_DEPRECATION_ARG);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=modular.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getApp","MODULAR_DEPRECATION_ARG","perfInternal","performance","getPerformance","app","name","perf","initializePerformance","settings","dataCollectionEnabled","undefined","instrumentationEnabled","trace","newTrace","httpMetric","url","httpMethod","newHttpMetric","newScreenTrace","screenName","startScreenTrace"],"sourceRoot":"../../lib","sources":["modular.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,4BAA4B;AACnD,SAASC,uBAAuB,QAAQ,+CAA+C;AAcvF,SAASC,YAAYA,CAACC,WAAgC,EAAgB;EACpE,OAAOA,WAAW;AACpB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,GAAiB,EAAuB;EACrE,IAAIA,GAAG,EAAE;IACP,OAAOL,MAAM,CAACK,GAAG,CAACC,IAAI,CAAC,CAACC,IAAI,CAAC,CAAC;EACh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","ignoreList":[]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
1
3
|
/*
|
|
2
4
|
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
5
|
*
|
|
@@ -16,146 +18,100 @@
|
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
20
|
import { isBoolean, isOneOf, isString } from '@react-native-firebase/app/dist/module/common';
|
|
19
|
-
import {
|
|
20
|
-
createModuleNamespace,
|
|
21
|
-
FirebaseModule,
|
|
22
|
-
getFirebaseRoot,
|
|
23
|
-
} from '@react-native-firebase/app/dist/module/internal';
|
|
21
|
+
import { createModuleNamespace, FirebaseModule, getFirebaseRoot } from '@react-native-firebase/app/dist/module/internal';
|
|
24
22
|
import { Platform } from 'react-native';
|
|
25
|
-
import HttpMetric from
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import version from
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
import HttpMetric from "./HttpMetric.js";
|
|
24
|
+
import ScreenTrace from "./ScreenTrace.js";
|
|
25
|
+
import Trace from "./Trace.js";
|
|
26
|
+
import { version } from "./version.js";
|
|
27
|
+
const statics = {
|
|
28
|
+
SDK_VERSION: version
|
|
29
|
+
};
|
|
32
30
|
const namespace = 'perf';
|
|
33
|
-
|
|
34
31
|
const nativeModuleName = 'RNFBPerfModule';
|
|
35
|
-
|
|
36
|
-
const VALID_HTTP_METHODS = [
|
|
37
|
-
'CONNECT',
|
|
38
|
-
'DELETE',
|
|
39
|
-
'GET',
|
|
40
|
-
'HEAD',
|
|
41
|
-
'OPTIONS',
|
|
42
|
-
'PATCH',
|
|
43
|
-
'POST',
|
|
44
|
-
'PUT',
|
|
45
|
-
'TRACE',
|
|
46
|
-
];
|
|
47
|
-
|
|
32
|
+
const VALID_HTTP_METHODS = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
|
|
48
33
|
class FirebasePerfModule extends FirebaseModule {
|
|
49
|
-
constructor(
|
|
50
|
-
super(
|
|
34
|
+
constructor(app, config, customUrlOrRegion) {
|
|
35
|
+
super(app, config, customUrlOrRegion);
|
|
51
36
|
this._isPerformanceCollectionEnabled = this.native.isPerformanceCollectionEnabled;
|
|
52
37
|
this._instrumentationEnabled = this.native.isInstrumentationEnabled;
|
|
53
38
|
}
|
|
54
|
-
|
|
55
39
|
get isPerformanceCollectionEnabled() {
|
|
56
40
|
return this._isPerformanceCollectionEnabled;
|
|
57
41
|
}
|
|
58
|
-
|
|
59
42
|
get instrumentationEnabled() {
|
|
60
43
|
return this._instrumentationEnabled;
|
|
61
44
|
}
|
|
62
|
-
|
|
63
45
|
set instrumentationEnabled(enabled) {
|
|
64
46
|
if (!isBoolean(enabled)) {
|
|
65
47
|
throw new Error("firebase.perf().instrumentationEnabled = 'enabled' must be a boolean.");
|
|
66
48
|
}
|
|
67
|
-
if (Platform.OS
|
|
49
|
+
if (Platform.OS === 'ios') {
|
|
68
50
|
// We don't change for android as it cannot be set from code, it is set at gradle build time.
|
|
69
51
|
this._instrumentationEnabled = enabled;
|
|
70
52
|
// No need to await, as it only takes effect on the next app run.
|
|
71
53
|
this.native.instrumentationEnabled(enabled);
|
|
72
54
|
}
|
|
73
55
|
}
|
|
74
|
-
|
|
75
56
|
get dataCollectionEnabled() {
|
|
76
57
|
return this._isPerformanceCollectionEnabled;
|
|
77
58
|
}
|
|
78
|
-
|
|
79
59
|
set dataCollectionEnabled(enabled) {
|
|
80
60
|
if (!isBoolean(enabled)) {
|
|
81
61
|
throw new Error("firebase.perf().dataCollectionEnabled = 'enabled' must be a boolean.");
|
|
82
62
|
}
|
|
83
63
|
this._isPerformanceCollectionEnabled = enabled;
|
|
84
|
-
|
|
64
|
+
// Keep setter behavior fire-and-forget; callers that need completion should use setPerformanceCollectionEnabled().
|
|
65
|
+
void this.native.setPerformanceCollectionEnabled(enabled);
|
|
85
66
|
}
|
|
86
|
-
|
|
87
67
|
async setPerformanceCollectionEnabled(enabled) {
|
|
88
68
|
if (!isBoolean(enabled)) {
|
|
89
|
-
throw new Error(
|
|
90
|
-
"firebase.perf().setPerformanceCollectionEnabled(*) 'enabled' must be a boolean.",
|
|
91
|
-
);
|
|
69
|
+
throw new Error("firebase.perf().setPerformanceCollectionEnabled(*) 'enabled' must be a boolean.");
|
|
92
70
|
}
|
|
93
|
-
|
|
94
|
-
if (Platform.OS == 'ios') {
|
|
71
|
+
if (Platform.OS === 'ios') {
|
|
95
72
|
// '_instrumentationEnabled' is updated here as well to maintain backward compatibility. See:
|
|
96
73
|
// https://github.com/invertase/react-native-firebase/commit/b705622e64d6ebf4ee026d50841e2404cf692f85
|
|
97
74
|
this._instrumentationEnabled = enabled;
|
|
98
75
|
await this.native.instrumentationEnabled(enabled);
|
|
99
76
|
}
|
|
100
|
-
|
|
101
77
|
this._isPerformanceCollectionEnabled = enabled;
|
|
102
78
|
return this.native.setPerformanceCollectionEnabled(enabled);
|
|
103
79
|
}
|
|
104
|
-
|
|
105
80
|
newTrace(identifier) {
|
|
106
81
|
// TODO(VALIDATION): identifier: no leading or trailing whitespace, no leading underscore '_'
|
|
107
82
|
if (!isString(identifier) || identifier.length > 100) {
|
|
108
|
-
throw new Error(
|
|
109
|
-
"firebase.perf().newTrace(*) 'identifier' must be a string with a maximum length of 100 characters.",
|
|
110
|
-
);
|
|
83
|
+
throw new Error("firebase.perf().newTrace(*) 'identifier' must be a string with a maximum length of 100 characters.");
|
|
111
84
|
}
|
|
112
|
-
|
|
113
85
|
return new Trace(this.native, identifier);
|
|
114
86
|
}
|
|
115
|
-
|
|
116
87
|
startTrace(identifier) {
|
|
117
|
-
const
|
|
118
|
-
return
|
|
88
|
+
const traceInstance = this.newTrace(identifier);
|
|
89
|
+
return traceInstance.start().then(() => traceInstance);
|
|
119
90
|
}
|
|
120
|
-
|
|
121
91
|
newScreenTrace(identifier) {
|
|
122
92
|
if (!isString(identifier) || identifier.length > 100) {
|
|
123
|
-
throw new Error(
|
|
124
|
-
"firebase.perf().newScreenTrace(*) 'identifier' must be a string with a maximum length of 100 characters.",
|
|
125
|
-
);
|
|
93
|
+
throw new Error("firebase.perf().newScreenTrace(*) 'identifier' must be a string with a maximum length of 100 characters.");
|
|
126
94
|
}
|
|
127
|
-
|
|
128
95
|
return new ScreenTrace(this.native, identifier);
|
|
129
96
|
}
|
|
130
|
-
|
|
131
97
|
startScreenTrace(identifier) {
|
|
132
98
|
const screenTrace = this.newScreenTrace(identifier);
|
|
133
99
|
return screenTrace.start().then(() => screenTrace);
|
|
134
100
|
}
|
|
135
|
-
|
|
136
101
|
newHttpMetric(url, httpMethod) {
|
|
137
102
|
if (!isString(url)) {
|
|
138
103
|
throw new Error("firebase.perf().newHttpMetric(*, _) 'url' must be a string.");
|
|
139
104
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
throw new Error(
|
|
143
|
-
`firebase.perf().newHttpMetric(_, *) 'httpMethod' must be one of ${VALID_HTTP_METHODS.join(
|
|
144
|
-
', ',
|
|
145
|
-
)}.`,
|
|
146
|
-
);
|
|
105
|
+
if (!isOneOf(httpMethod, VALID_HTTP_METHODS)) {
|
|
106
|
+
throw new Error(`firebase.perf().newHttpMetric(_, *) 'httpMethod' must be one of ${VALID_HTTP_METHODS.join(', ')}.`);
|
|
147
107
|
}
|
|
148
|
-
|
|
149
108
|
return new HttpMetric(this.native, url, httpMethod);
|
|
150
109
|
}
|
|
151
110
|
}
|
|
152
111
|
|
|
153
112
|
// import { SDK_VERSION } from '@react-native-firebase/perf';
|
|
154
113
|
export const SDK_VERSION = version;
|
|
155
|
-
|
|
156
|
-
// import perf from '@react-native-firebase/perf';
|
|
157
|
-
// perf().X(...);
|
|
158
|
-
export default createModuleNamespace({
|
|
114
|
+
const defaultExport = createModuleNamespace({
|
|
159
115
|
statics,
|
|
160
116
|
version,
|
|
161
117
|
namespace,
|
|
@@ -163,12 +119,12 @@ export default createModuleNamespace({
|
|
|
163
119
|
nativeEvents: false,
|
|
164
120
|
hasMultiAppSupport: false,
|
|
165
121
|
hasCustomUrlOrRegionSupport: false,
|
|
166
|
-
ModuleClass: FirebasePerfModule
|
|
122
|
+
ModuleClass: FirebasePerfModule
|
|
167
123
|
});
|
|
168
|
-
|
|
169
|
-
export * from './modular';
|
|
124
|
+
export default defaultExport;
|
|
170
125
|
|
|
171
126
|
// import perf, { firebase } from '@react-native-firebase/perf';
|
|
172
127
|
// perf().X(...);
|
|
173
128
|
// firebase.perf().X(...);
|
|
174
129
|
export const firebase = getFirebaseRoot();
|
|
130
|
+
//# sourceMappingURL=namespaced.js.map
|