Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit d5a6167

Browse files
#449 Mark init and getRemoteConfig for profiling
1 parent 53e9f4c commit d5a6167

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

firebase.android.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ var utils = require("utils/utils");
33
var frame = require("ui/frame");
44
var fs = require("file-system");
55
var firebase = require("./firebase-common");
6-
var profile = require("profiling").profile;
6+
7+
// this may fail if tns-core-modules doesn't include it (can be removed in about a year), see https://github.com/EddyVerbruggen/nativescript-plugin-firebase/pull/449
8+
var profile;
9+
try {
10+
profile = require("profiling").profile;
11+
} catch (ignore) {}
12+
713

814
firebase._launchNotification = null;
915

@@ -179,7 +185,7 @@ firebase.authStateListener = null;
179185
firebase.init = function (arg) {
180186
return new Promise(function (resolve, reject) {
181187

182-
const _resolve = profile("firebase.init resolve", function _resolve() {
188+
function runInit() {
183189
if (firebase.instance !== null) {
184190
reject("You already ran init");
185191
return;
@@ -260,8 +266,9 @@ firebase.init = function (arg) {
260266
}
261267

262268
resolve(firebase.instance);
263-
});
269+
}
264270

271+
var _resolve = profile === undefined ? runInit : profile("firebase.init resolve", runInit);
265272
try {
266273
if (appModule.android.foregroundActivity) {
267274
_resolve();
@@ -658,7 +665,7 @@ firebase.getRemoteConfig = function (arg) {
658665
return;
659666
}
660667

661-
const _resolve = profile("firebase.getRemoteConfig resolve", function _resolve() {
668+
function runGetRemoteConfig() {
662669
if (!firebase._isGooglePlayServicesAvailable()) {
663670
reject("Google Play services is required for this feature, but not available on this device");
664671
return;
@@ -721,7 +728,9 @@ firebase.getRemoteConfig = function (arg) {
721728
firebaseRemoteConfig.fetch(expirationDuration)
722729
.addOnSuccessListener(onSuccessListener)
723730
.addOnFailureListener(onFailureListener);
724-
});
731+
}
732+
733+
var _resolve = profile === undefined ? runGetRemoteConfig : profile("firebase.getRemoteConfig resolve", runGetRemoteConfig);
725734

726735
try {
727736
if (appModule.android.foregroundActivity) {

0 commit comments

Comments
 (0)