invertase / react-native-firebase

πŸ”₯ A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.7k stars 2.22k forks source link

[πŸ›] πŸ”₯ @react-native-firebase/perf fails to track my custom trace #6017

Closed samuelhulla closed 2 years ago

samuelhulla commented 2 years ago

Issue

I'm trying to implement firebase performance monitoring for @react-native-firebase. I have followed the official installation guide and it sees to have worked, as inside my firebase console I can now view the automated performance tracking metrics.

Next I tried implementing some custom traces with the following code:

import perf, { FirebasePerformanceTypes } from '@react-native-firebase/perf'

export type TraceType = {
  name: string,
  component: string,
  userId: string,
  userType: 'manager' | 'staffer' | 'superadmin',
}

export const stopTrace = async (traceObject: FirebasePerformanceTypes.Trace) => {
  try {
    await traceObject.stop()
  } catch (_e) {
    console.error('[Perf]: Unable to unsubscribe from trace object', traceObject)
  }
}

export const trace = async (traceData: TraceType) => {
  const {
    name,
    component,
    userId,
    userType,
  } = traceData

  // This begins tracing a custom trace metric
  const traceObject = await perf().startTrace(name)

  // Now we add attributes we want to track
  traceObject.putAttribute('component', component)
  traceObject.putAttribute('userId', userId)
  traceObject.putAttribute('userType', userType)

  return traceObject
}

export default {
  trace,
  stopTrace,
}

Pretty standard stuff - now when I tried tracking a simple method inside a component in the following way.

// ... rest of component here but skipped for readability. This is one of componenet mehtods:

  toggleAgreedToBilling = async (checked: boolean) => {
    const traceObject = await trace({
      name: 'test_Billing_toggle',
      component: 'SetupStafferProfile_AgreedBillingToggle',
      userId: this.props.staffer.id,
      userType: 'staffer',
    })
    // ... there's some internal logic here but i'll simplify it to single async call for readability
    await madeUpCall()
    await stopTrace(traceObject)
  }

The method itself in the build fires correctly and does not produce any errors. However when I open the firebase console and view custom traces, it only shows the default ones.

image

Any idea what am I doing wrong?

Note, all the @react-native-firebase/* packages are at the current 14.2.2 version


Project Files

Javascript

Click To Expand

#### `package.json`: ```json { "name": "staffers", "version": "1.0.0", "private": true, "scripts": { // removed for readability }, "lint-staged": { "linters": { "*.{js,jsx}": "eslint" } }, "dependencies": { "@invertase/react-native-apple-authentication": "2.1.0", "@ptomasroos/react-native-multi-slider": "2.2.2", "@react-native-community/async-storage": "1.12.1", "@react-native-community/datetimepicker": "3.0.6", "@react-native-community/geolocation": "2.0.2", "@react-native-community/push-notification-ios": "1.6.1", "@react-native-firebase/analytics": "14.2.2", "@react-native-firebase/app": "14.2.2", "@react-native-firebase/auth": "14.2.2", "@react-native-firebase/crashlytics": "14.2.2", "@react-native-firebase/database": "14.2.2", "@react-native-firebase/dynamic-links": "14.2.2", "@react-native-firebase/firestore": "14.2.2", "@react-native-firebase/functions": "14.2.2", "@react-native-firebase/messaging": "14.2.2", "@react-native-firebase/perf": "14.2.2", "@react-native-firebase/storage": "14.2.2", "@react-native-picker/picker": "2.1.0", "@webscopeio/react-firebase-messenger": "git+https://github.com/webscopeio/react-firebase-messenger", "awesome-debounce-promise": "2.1.0", "d3-format": "2.0.0", "geofirestore": "2.4.0", "hoist-non-react-statics": "3.3.2", "intl": "^1.2.5", "jwt-decode": "3.0.0", "moment": "2.29.1", "moment-holiday": "1.5.1", "moment-range": "4.0.2", "moment-timezone": "^0.5.34", "prop-types": "15.7.2", "ramda": "0.26.1", "react": "16.13.1", "react-firestore-connect": "1.1.13", "react-native": "0.63.3", "react-native-app-settings": "2.0.1", "react-native-calendars": "1.403.0", "react-native-camera": "3.40.0", "react-native-contacts": "6.0.3", "react-native-country-picker-modal": "0.8.0", "react-native-device-info": "6.2.1", "react-native-document-picker": "7.1.1", "react-native-exception-handler": "2.10.8", "react-native-face-pile": "1.9.0", "react-native-fbsdk-next": "4.2.0", "react-native-get-random-values": "1.5.0", "react-native-gifted-chat": "0.16.3", "react-native-google-places-autocomplete": "1.3.9", "react-native-image-crop-picker": "0.34.1", "react-native-intercom": "21.1.1", "react-native-keyboard-aware-scroll-view": "0.9.3", "react-native-linear-gradient": "2.5.6", "react-native-map-link": "2.7.19", "react-native-maps": "0.27.1", "react-native-material-textfield": "git+https://github.com/webscopeio/react-native-material-textfield.git", "react-native-modal": "11.5.6", "react-native-modal-datetime-picker": "9.1.0", "react-native-modal-selector": "2.0.3", "react-native-navigation": "7.21.0", "react-native-permissions": "1.2.0", "react-native-phone-input": "0.2.4", "react-native-rate": "1.2.4", "react-native-scroll-into-view": "1.0.3", "react-native-sectioned-multi-select": "0.8.0", "react-native-simple-toast": "^1.1.3", "react-native-splash-screen": "3.2.0", "react-native-stopwatch-timer": "0.0.21", "react-native-svg": "12.1.0", "react-native-svg-charts": "5.4.0", "react-native-swipe-gestures": "1.0.5", "react-native-vector-icons": "7.1.0", "react-native-video": "5.1.0-alpha8", "react-native-video-player": "0.10.1", "react-native-view-pdf": "0.11.0", "rn-fetch-blob": "0.12.0", "toggle-switch-react-native": "2.3.0", "utility-types": "^3.10.0", "uuid": "8.3.1", "validator": "13.1.17" }, "devDependencies": { "@babel/core": "7.11.6", "@babel/runtime": "7.11.2", "@react-native-community/eslint-config": "2.0.0", "@typescript-eslint/eslint-plugin": "^2.34.0", "@typescript-eslint/parser": "^2.34.0", "@webscopeio/eslint-config": "1.0.3", "babel-jest": "26.5.2", "eslint": "7.11.0", "eslint-plugin-import": "2.22.1", "eslint-plugin-jsx-a11y": "6.3.1", "flow-bin": "0.136.0", "flow-watch": "2.0.0", "husky": "4.3.0", "jest": "26.5.3", "metro-react-native-babel-preset": "0.63.0", "patch-package": "5.1.1", "react-test-renderer": "16.13.1", "typescript": "^4.4.2" }, "jest": { "preset": "react-native" } } ``` #### `firebase.json` for react-native-firebase v6: ```json ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [ ] I'm using Pods and my Podfile looks like: ```ruby require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '12.3' target 'staffers' do rn_maps_path = '../node_modules/react-native-maps' pod 'react-native-google-maps', :path => rn_maps_path pod 'GoogleMaps' pod 'Google-Maps-iOS-Utils' config = use_native_modules! use_react_native!(:path => config["reactNativePath"]) target 'staffersTests' do inherit! :complete # Pods for testing end # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable these next few lines. # use_flipper! post_install do |installer| flipper_post_install(installer) end end target 'staffers-tvOS' do # Pods for staffers-tvOS target 'staffers-tvOSTests' do inherit! :search_paths # Pods for testing end end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" #import #import #import #import "Intercom/Intercom.h" #import #import #import #import #import "RNSplashScreen.h" #import #import #import #ifdef FB_SONARKIT_ENABLED #import #import #import #import #import #import static void InitializeFlipper(UIApplication *application) { FlipperClient *client = [FlipperClient sharedClient]; SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; [client addPlugin:[FlipperKitReactPlugin new]]; [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; [client start]; } #endif @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [GMSServices provideAPIKey:@"AIzaSyCzt1dNIFx6cnbp675t4NGDUlf2I6fNDys"]; #ifdef FB_SONARKIT_ENABLED InitializeFlipper(application); #endif if ([FIRApp defaultApp] == nil) { [FIRApp configure]; } [ReactNativeNavigation bootstrapWithDelegate:self launchOptions:launchOptions]; // Intercom [Intercom setApiKey:@"ios_sdk-362d26616f909771e20c5b420b89da57efc3ef90" forAppId:@"mpr6jfl3"]; // Facebook Login SDK [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]; // Define UNUserNotificationCenter [RNSplashScreen show]; // here UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; center.delegate = self; return YES; } //Called when a notification is delivered to a foreground app. -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge); } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(nonnull NSDictionary *)options { [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url options:options]; return [RCTLinkingManager application:application openURL:url options:options]; } - (NSArray> *)extraModulesForBridge:(RCTBridge *)bridge { return [ReactNativeNavigation extraModulesForBridge:bridge]; } // Required to register for notifications - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings]; } // Required for the register event. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; // Intercom [Intercom setDeviceToken:deviceToken]; } // Required for the notification event. You must call the completion handler after handling the remote notification. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; if ([Intercom isIntercomPushNotification:userInfo]) { [Intercom handleIntercomPushNotification:userInfo]; completionHandler(UIBackgroundFetchResultNoData); } } // Required for the registrationError event. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error]; } // IOS 10+ Required for localNotification event - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler { [RNCPushNotificationIOS didReceiveNotificationResponse:response]; completionHandler(); } // IOS 4-10 Required for the localNotification event. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [RNCPushNotificationIOS didReceiveLocalNotification:notification]; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; #else return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; #endif } - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler { return [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; } @end ```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [X] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { RNNKotlinVersion = "1.3.61" buildToolsVersion = "29.0.2" minSdkVersion = 21 compileSdkVersion = 30 targetSdkVersion = 30 playServicesVersion = "17.0.0" androidMapsUtilsVersion = "2.2.0" } repositories { google() jcenter() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61" classpath("com.android.tools.build:gradle:4.0.1") classpath "com.google.gms:google-services:4.3.3" classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0' classpath 'com.google.firebase:perf-plugin:1.4.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } maven { url "https://maven.google.com" } google() jcenter() maven { url 'https://www.jitpack.io' } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply plugin: "com.google.gms.google-services" apply plugin: 'com.google.firebase.firebase-perf' apply plugin: 'com.google.firebase.crashlytics' import com.android.build.OutputFile /** * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle * bundleAssetName: "index.android.bundle", * * // the entry file for bundle generation. If none specified and * // "index.android.js" exists, it will be used. Otherwise "index.js" is * // default. Can be overridden with ENTRY_FILE environment variable. * entryFile: "index.android.js", * * // https://reactnative.dev/docs/performance#enable-the-ram-format * bundleCommand: "ram-bundle", * * // whether to bundle JS and assets in debug mode * bundleInDebug: false, * * // whether to bundle JS and assets in release mode * bundleInRelease: true, * * // whether to bundle JS and assets in another build variant (if configured). * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants * // The configuration property can be in the following formats * // 'bundleIn${productFlavor}${buildType}' * // 'bundleIn${buildType}' * // bundleInFreeDebug: true, * // bundleInPaidRelease: true, * // bundleInBeta: true, * * // whether to disable dev mode in custom build variants (by default only disabled in release) * // for example: to disable dev mode in the staging build type (if configured) * devDisabledInStaging: true, * // The configuration property can be in the following formats * // 'devDisabledIn${productFlavor}${buildType}' * // 'devDisabledIn${buildType}' * * // the root of your project, i.e. where "package.json" lives * root: "../../", * * // where to put the JS bundle asset in debug mode * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", * * // where to put the JS bundle asset in release mode * jsBundleDirRelease: "$buildDir/intermediates/assets/release", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in debug mode * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", * * // where to put drawable resources / React Native assets, e.g. the ones you use via * // require('./image.png')), in release mode * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", * * // by default the gradle tasks are skipped if none of the JS files or assets change; this means * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to * // date; if you have any other folders that you want to ignore for performance reasons (gradle * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ * // for example, you might want to remove it from here. * inputExcludes: ["android/**", "ios/**"], * * // override which node gets called and with what additional arguments * nodeExecutableAndArgs: ["node"], * * // supply additional arguments to the packager * extraPackagerArgs: [] * ] */ project.ext.react = [ enableHermes: false, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", false); android { compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "com.staffersas.staffers" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 234 versionName "1.233" multiDexEnabled true missingDimensionStrategy 'react-native-camera', 'general' vectorDrawables.useSupportLibrary = true } dexOptions { javaMaxHeapSize "3g" } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } release { if (project.hasProperty('RELEASE_STORE_FILE')) { storeFile file(RELEASE_STORE_FILE) storePassword RELEASE_STORE_PASSWORD keyAlias RELEASE_KEY_ALIAS keyPassword RELEASE_KEY_PASSWORD } } } buildTypes { debug { signingConfig signingConfigs.debug } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'io.intercom.android:intercom-sdk-base:9.+' implementation 'io.intercom.android:intercom-sdk:9.+' implementation 'com.google.firebase:firebase-messaging:20.+' //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation 'com.android.support:multidex:1.0.3' implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" implementation project(':react-native-splash-screen') // Splash screen debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group:'com.facebook.flipper' } if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'staffers' include ':react-native-splash-screen' project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android') apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':react-native-splash-screen' project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android') include ':app' ``` #### `MainApplication.java`: ```java package com.staffersas.staffers; import android.app.Application; import android.content.Context; import org.devio.rn.splashscreen.SplashScreenReactPackage; import com.facebook.react.PackageList; import com.reactnativenavigation.NavigationApplication; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.reactnativenavigation.react.NavigationReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; import java.lang.reflect.InvocationTargetException; import java.util.List; import com.robinpowered.react.Intercom.IntercomPackage; import io.intercom.android.sdk.Intercom; public class MainApplication extends NavigationApplication { private final ReactNativeHost mReactNativeHost = new NavigationReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); return packages; } @Override protected String getJSMainModuleName() { return "index"; } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); // Intercom - THIS NEEDS TO BE RIGHT AFTER super.onCreate(); !!! Intercom.initialize(this, "#censored api ", "#censored api"); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } /** * Loads Flipper in React Native templates. Call this in the onCreate method with something like * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); * * @param context * @param reactInstanceManager */ private static void initializeFlipper( Context context, ReactInstanceManager reactInstanceManager) { if (BuildConfig.DEBUG) { try { /* We use reflection here to pick up the class that initializes Flipper, since Flipper library is not available in release mode */ Class aClass = Class.forName("com.staffersas.staffers.ReactNativeFlipper"); aClass .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) .invoke(null, context, reactInstanceManager); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } } ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [X] Both - **`react-native-firebase` version you're using that has this issue:** - `e.g. 14.4.2 - **`Firebase` module(s) you're using that has the issue:** - `14.4.2` - **Are you using `TypeScript`?** - `Y` & `^4.4.2`


mikehardy commented 2 years ago

Probably not related but I noticed this you use react-native-splash-screen - careful with that one:

https://github.com/crazycodeboy/react-native-splash-screen/issues/289 - repo was fully dead from 2019 until just this December so it doesn't develop quickly either. Suggest react-native-bootsplash

Also, react-native < 0.65 is very worrisome, it does not even build with Xcode 12.5+ or on M1 macs, I would be suprised if react-native 0.63 worked correctly on Android 12 ? It might, but...I'd hop on https://react-native-community.github.io/upgrade-helper/ and get up to date, there aren't many difficult changes from 0.63 forward.

classpath "com.google.gms:google-services:4.3.3" classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'

Those are out of date, but the perf plugin is up to date, and it's the one that should matter the most. Plus you are receiving some traces, so that's a good sign.

Those are all possibly of interest, but likely have no bearing on the actual problem, which is unfortunate - as it means it needs more investigation and I have not personally used custom traces so I'm not as familiar with them and likely won't have time to test locally for a while.

We do test this locally in our e2e harness:

https://github.com/invertase/react-native-firebase/blob/main/packages/perf/e2e/Trace.e2e.js

But there is no external verification of trace delivery to the backend, so it could be false positive on the tests. There were issues with analytics debug mode attributes not showing in debug mode on the console, but showing up later once some unknown backend post-processing had happened, which I mention as anecdote to leave open the possibility that the console itself is malfunctioning somehow, beyond our control.

Separate avenue of inquiry, if this is happening on just one platform (android, or apple), or on both but you want to focus on one where you definitely reproduce then combining the native sdk issue list for that platform may be informative. Also checking the native logs during reproduction (xcode console while running on real device, or adb logcat for android) may yield something. Reaching directly into node_modules and adding logging prior to any native perf API calls (including all params) and logging all return values may also yield something, for low effort

samuelhulla commented 2 years ago

@mikehardy Yeah, unfortunately this is a legacy project with a lot of outdated dependencies with multiple people working on it and updating would cause breaking changes, but it is on the backlog at least, but you know how the project planning goes.

Complaints aside, for some reason, changing the version of the simulator target from iPhone 11 to iPhone 12 in combination with upgrading $FirebaseSDK in Podfile did resolve the issue on my end - albeit I might note this may just be pure coincidence and this was simply analytics debug mode attirbutes not showing in console and showing up later, as your comment claims on annecdotal evidence.

I was prompted to do this, as I received this warning which previously did not show in the console:

image

I wish I could provide further info for anyone with similar issues, but probably your best shot is upgrading react-native-firebase versions and firebase sdk and then rebuilding the project via coca-pods with pod install --repo-update.


Also as a quick mention for anyone still struggling:

One last thing which also took me a short moment to figure out is to make sure you have the correct platform selected in performance mode in console, as I did stupidly for the first time did look through the Android build, which is selected by default despite testing on iOS

image

This was not the issue on my end, but it's relatively easy to miss, so just in case you missed it, make sure you have the correct platform selected.

mikehardy commented 2 years ago

Thanks for posting how you were able to resolve it, this stuff is tricky but perhaps your info will help a future person. And yes I have fallen for that platform selection issue before. Same for crashlytics...