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.67k stars 2.21k forks source link

[🐛] analytics().logScreenView is not a function / undefined #4602

Closed rakiop closed 3 years ago

rakiop commented 3 years ago

Issue

I updated react-native-firebase version from 6.3.4 to 10.0.0. After the update analytics().logScreenView is undefined. The same behaviour occures with version 8.0.0. Method logEvent seems to work fine (no warning/error seen in the console). Additionally I enabled Google Analytics for Firebase Analytics recently in the console, if that might be connected.


Project Files

android/build.gradle

buildscript {
  dependencies: {
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
  }
}

android/app/build.gradle

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

android: {
    buildTypes {
        debug {
            firebaseCrashlytics {
                strippedNativeLibsDir "build/ndklibs/obj"
                unstrippedNativeLibsDir "build/ndklibs/libs"
            }
        }
        release {
            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
                strippedNativeLibsDir "build/ndklibs/obj"
                unstrippedNativeLibsDir "build/ndklibs/libs"
            }
        }
    }
}

Javascript

Click To Expand

#### `package.json`: ```json dependencies: { "@react-native-firebase/analytics": "^10.0.0", "@react-native-firebase/app": "^10.0.0", "@react-native-firebase/crashlytics": "^10.0.0", "@react-native-firebase/messaging": "^10.0.0", "react": "^16.9.0", "react-native": "^0.61.5" } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [X] 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 // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 } repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:3.4.2") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1' } } allprojects { repositories { maven{ url 'https://maven.google.com' } 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") } google() jcenter() maven { url 'https://jitpack.io' } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" import com.android.build.OutputFile project.ext.react = [ entryFile: "index.js", enableHermes: false, // clean and rebuild if changing ] // START CUSTOM modules apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) // @todo this do not work so file was copied to /app/src/main/assets/fonts manually // project.ext.vectoricons = [ // iconFontNames: [ 'Ionicons.ttf' ] // ] // apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.firebase.crashlytics' // END CUSTOM modules 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 = true /** * 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 } dexOptions { javaMaxHeapSize "3g" } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk true // 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' } } buildTypes { debug { signingConfig signingConfigs.debug firebaseCrashlytics { strippedNativeLibsDir "build/ndklibs/obj" unstrippedNativeLibsDir "build/ndklibs/libs" } } release { // Caution! In production, you need to generate your own keystore file. // see https://facebook.github.io/react-native/docs/signed-apk-android. minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" firebaseCrashlytics { nativeSymbolUploadEnabled true strippedNativeLibsDir "build/ndklibs/obj" unstrippedNativeLibsDir "build/ndklibs/libs" } } } flavorDimensions "env" productFlavors { dev { dimension "env" applicationIdSuffix ".dev" versionNameSuffix "-dev" } } // 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 'com.android.support:multidex:1.0.3' implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.facebook.react:react-native:+" // From node_modules implementation "androidx.appcompat:appcompat:1.0.0" implementation platform('com.google.firebase:firebase-bom:26.1.0') // implementation 'com.google.firebase:firebase-crashlytics:17.3.0' // implementation 'com.google.firebase:firebase-analytics:18.0.0' 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' } ``` #### `android/settings.gradle`: ```groovy apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' ``` #### `MainApplication.java`: ```java // N/A ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: Windows 10 10.0.18363 CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz Memory: 42.00 GB / 63.82 GB Binaries: Node: 12.16.1 - C:\Program Files\nodejs\node.EXE npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.6.0.0 AI-192.7142.36.36.6200805 npmPackages: react: ^16.9.0 => 16.9.0 react-native: ^0.61.5 => 0.61.5 ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [X] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `e.g. 5.4.3` - **`Firebase` module(s) you're using that has the issue:** - `Analytics` - **Are you using `TypeScript`?** - `Y` & `3.5.3`


mikehardy commented 3 years ago

It exists and is tested and working

https://github.com/invertase/react-native-firebase/blob/bda2d67ddaf7f12ac3143b564e7e94974e8356db/packages/analytics/lib/index.js#L197-L208

https://github.com/invertase/react-native-firebase/blob/bda2d67ddaf7f12ac3143b564e7e94974e8356db/packages/analytics/__tests__/analytics.test.ts#L141-L148

https://github.com/invertase/react-native-firebase/blob/bda2d67ddaf7f12ac3143b564e7e94974e8356db/packages/analytics/e2e/analytics.e2e.js#L99-L105

Something must be wrong with your integration, attempt to build a skeleton then compare usage between your project and the skeleton: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

We can re-open if you can reproduce with an App.js dropped into the result of that demo script, just post the App.js up here