Closed MajStc closed 6 days ago
Hi there - with apologies you'll have to take this up on stackoverflow with appropriate firebase tags to engage official product support from firebase team. As you can see by adding an Xcode-level flag this is something handled entirely within the firebase-ios-sdk, there is no ability to control (or mishandle!) analytics debug information at the react-native-firebase level - it's below us, in the SDK proper and will have to be handled there for any support
They may be wary of taking on support if it is based on react-native-firebase as a reproduction, I suggest creating a minimal quickstart for use when engaging them: https://github.com/firebase/quickstart-ios/tree/main/analytics
While we cannot affect debug analytics here it may be useful to document any findings so circling back here with any lessons learned could have value for a docs update
Issue
Testing logEvent function using debug view on both android and ios does not work properly on latter. Some events are reported, some are not, often order is not proper.
The setup is most basic created by following official rnfirebase docs.
Few times I had the same problem on Android, but trying to reproduce it since an hour I gave up, still no 100% trust in that.
Including screenshots + xcode logs, the app is runned pressing the RUN button in XCode and having following arguments set.
On the screenshots and logs you can see the following event sequence was triggered 2 > 1 > 2 > 1 > 2 > 1 That worked properly (first time in an hour...) Then I tried again doing 1 > 1 > 1 > 2 > 2 > 2 This time the last "2" was not reported even though xcode logs say it was
Sometimes I can see a warning in xcode saying
But it doesn't seem that it's related to my issues, there is no pattern in not reported event and this message
Project Files
Javascript
Click To Expand
#### `package.json`: ```json { "name": "X", "version": "0.0.1", "private": true, "scripts": { "cc": "rimraf node_modules/.cache/babel-loader/* & rimraf $TMPDIR/haste-map-* & rimraf $TMPDIR/metro-cache & watchman watch-del-all", "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start:storybook": "yarn cc && NODE_ENV=storybook react-native start", "start:debug": "yarn cc && NODE_ENV=debug react-native start", "start:dev": "yarn cc && NODE_ENV=development react-native start", "start:prod": "yarn cc && NODE_ENV=production react-native start", "run:android:release": "yarn cc && NODE_ENV=production react-native run-android --mode release", "run:ios:release": "yarn cc && NODE_ENV=production react-native run-ios --mode Release", "test": "jest", "storybook-generate": "sb-rn-get-stories" }, "dependencies": { "@react-native-firebase/analytics": "^21.4.0", "@react-native-firebase/app": "21.4.0", "react": "18.3.1", "react-native": "0.76.1" }, "devDependencies": { "@babel/core": "^7.25.2", "@babel/preset-env": "^7.25.3", "@babel/runtime": "^7.25.0", "@gorhom/bottom-sheet": "^5.0.5", "@react-native-async-storage/async-storage": "^2.0.0", "@react-native-community/cli": "15.0.0", "@react-native-community/cli-platform-android": "15.0.0", "@react-native-community/cli-platform-ios": "15.0.0", "@react-native-community/datetimepicker": "^8.2.0", "@react-native-community/slider": "^4.5.5", "@react-native/babel-preset": "0.76.1", "@react-native/eslint-config": "0.76.1", "@react-native/metro-config": "0.76.1", "@react-native/typescript-config": "0.76.1", "@storybook/addon-ondevice-actions": "^8.4.1", "@storybook/addon-ondevice-controls": "^8.4.1", "@storybook/react-native": "^8.4.1", "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", "babel-loader": "^8.4.1", "eslint": "^8.19.0", "jest": "^29.6.3", "prettier": "2.8.8", "react-native-dotenv": "^3.4.11", "react-native-gesture-handler": "^2.20.2", "react-native-reanimated": "^3.16.1", "react-native-safe-area-context": "^4.14.0", "react-native-svg": "^15.8.0", "react-test-renderer": "18.3.1", "typescript": "5.0.4" }, "engines": { "node": ">=18" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ``` #### analytics hook ```js import { useCallback } from 'react' import analytics, { FirebaseAnalyticsTypes, } from '@react-native-firebase/analytics' type LogEventType = { event_name: string params?: { [key: string]: any } options?: FirebaseAnalyticsTypes.AnalyticsCallOptions } export const useAnalytics = () => { const logEvent = useCallback( async ({ event_name, params, options }: LogEventType) => { console.log(new Date(), 'heelo', event_name, Platform.OS) try { await analytics().logEvent( event_name, { event_name, ...params }, options, ) } catch (e) { console.log(e) } }, [], ) return { logEvent } } ``` #### analytics usage ```js function App(): React.JSX.Element { const { logEvent } = useAnalytics() return (
iOS
Click To Expand
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby use_frameworks! :linkage => :static $RNFirebaseAsStaticFramework = true $RNFirebaseAnalyticsWithoutAdIdSupport = true # Resolve react_native_pods.rb with node to allow for hoisting require Pod::Executable.execute_command('node', ['-p', 'require.resolve( "react-native/scripts/react_native_pods.rb", {paths: [process.argv[1]]}, )', __dir__]).strip platform :ios, min_ios_version_supported prepare_react_native_project! linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym end target 'X' do config = use_native_modules! use_react_native!( :path => config[:reactNativePath], # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) target 'XTests' do inherit! :complete # Pods for testing end post_install do |installer| # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 react_native_post_install( installer, config[:reactNativePath], :mac_catalyst_enabled => false, # :ccache_enabled => true ) end end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" #import
#import
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
self.moduleName = @"X";
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [self bundleURL];
}
- (NSURL *)bundleURL
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
```
Android
Click To Expand
#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] 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 buildscript { ext { buildToolsVersion = "35.0.0" minSdkVersion = 24 compileSdkVersion = 35 targetSdkVersion = 34 ndkVersion = "26.1.10909125" kotlinVersion = "1.9.24" } repositories { google() mavenCentral() } dependencies { classpath("com.android.tools.build:gradle") classpath("com.facebook.react:react-native-gradle-plugin") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") classpath 'com.google.gms:google-services:4.4.2' } } apply plugin: "com.facebook.react.rootproject" ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" apply plugin: 'com.google.gms.google-services' /** * This is the configuration block to customize your React Native Android app. * By default you don't need to apply any configuration, just uncomment the lines you need. */ react { /* Folders */ // The root of your project, i.e. where "package.json" lives. Default is '../..' // root = file("../../") // The folder where the react-native NPM package is. Default is ../../node_modules/react-native // reactNativeDir = file("../../node_modules/react-native") // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen // codegenDir = file("../../node_modules/@react-native/codegen") // The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js // cliFile = file("../../node_modules/react-native/cli.js") /* Variants */ // The list of variants to that are debuggable. For those we're going to // skip the bundling of the JS bundle and the assets. By default is just 'debug'. // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. // debuggableVariants = ["liteDebug", "prodDebug"] /* Bundling */ // A list containing the node command and its flags. Default is just 'node'. // nodeExecutableAndArgs = ["node"] // // The command to run when bundling. By default is 'bundle' // bundleCommand = "ram-bundle" // // The path to the CLI configuration file. Default is empty. // bundleConfig = file(../rn-cli.config.js) // // The name of the generated asset file containing your JS bundle // bundleAssetName = "MyApplication.android.bundle" // // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' // entryFile = file("../js/MyApplication.android.js") // // A list of extra flags to pass to the 'bundle' commands. // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle // extraPackagerArgs = [] /* Hermes Commands */ // The hermes compiler command to run. By default it is 'hermesc' // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" // // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" // hermesFlags = ["-O", "-output-source-map"] /* Autolinking */ autolinkLibrariesWithApp() } /** * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore (JSC) * * 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:+' android { ndkVersion rootProject.ext.ndkVersion buildToolsVersion rootProject.ext.buildToolsVersion compileSdk rootProject.ext.compileSdkVersion namespace "com.X" defaultConfig { applicationId "com.X" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } 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.debug minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } } dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } } ``` #### `android/settings.gradle`: ```groovy pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") } plugins { id("com.facebook.react.settings") } extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() } rootProject.name = 'X' include ':app' includeBuild('../node_modules/@react-native/gradle-plugin') ``` #### `MainApplication.kt`: ```kotlin package com.X import android.app.Application import com.facebook.react.PackageList import com.facebook.react.ReactApplication import com.facebook.react.ReactHost import com.facebook.react.ReactNativeHost import com.facebook.react.ReactPackage import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost import com.facebook.react.defaults.DefaultReactNativeHost import com.facebook.react.soloader.OpenSourceMergedSoMapping import com.facebook.soloader.SoLoader class MainApplication : Application(), ReactApplication { override val reactNativeHost: ReactNativeHost = object : DefaultReactNativeHost(this) { override fun getPackages(): List =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
}
override fun getJSMainModuleName(): String = "index"
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
override val reactHost: ReactHost
get() = getDefaultReactHost(applicationContext, reactNativeHost)
override fun onCreate() {
super.onCreate()
SoLoader.init(this, OpenSourceMergedSoMapping)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
}
}
```
#### `AndroidManifest.xml`:
```xml
```
Environment
Click To Expand
**`react-native info` output:** ``` System: OS: macOS 14.6.1 CPU: (8) arm64 Apple M2 Memory: 69.77 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 22.7.0 path: /opt/homebrew/bin/node Yarn: version: 1.22.22 path: ~/.yarn/bin/yarn npm: version: 10.8.2 path: /opt/homebrew/bin/npm Watchman: version: 2024.08.26.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.14.3 path: /Users/prv/.rbenv/shims/pod SDKs: iOS SDK: Platforms: - DriverKit 23.5 - iOS 17.5 - macOS 14.5 - tvOS 17.5 - visionOS 1.2 - watchOS 10.5 Android SDK: Not Found IDEs: Android Studio: 2024.1 AI-241.19072.14.2412.12360217 Xcode: version: 15.4/15F31d path: /usr/bin/xcodebuild Languages: Java: version: 17.0.12 path: /usr/bin/javac Ruby: version: 2.7.6 path: /Users/prv/.rbenv/shims/ruby npmPackages: "@react-native-community/cli": installed: 15.0.0 wanted: 15.0.0 react: installed: 18.3.1 wanted: 18.3.1 react-native: installed: 0.76.1 wanted: 0.76.1 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: true iOS: hermesEnabled: true newArchEnabled: true ``` - **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:** - `21.4.0` - **`Firebase` module(s) you're using that has the issue:** - `app + analytics` - **Are you using `TypeScript`?** - `Y` & `5.0.4`
React Native Firebase
andInvertase
on Twitter for updates on the library.