You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone,
After updating react-native-firebase from 16.5.0 to 19.2.2, our team noticed that first_open events are no longer being sent on Android devices.Previously we had a ratio of around 1:2 for Android, now we are receiving 0 first_open events on Android.
All other events are functioning as expected, maintaining their usual ratio.
We tried updating to 20.1.0, but during our limited testing, this issue was not resolved.
However, we found that changing "analytics_auto_collection_enabled": false to "analytics_auto_collection_enabled": true resolved the issue, and first_open events are now being sent. Nonetheless, we need to disable it at the start of the app to comply with GDPR requirements
For reference, we are using NX with a bare react native
apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: "kotlin-android"
project.ext.envConfigFiles = [
dev: '.env.dev',
staging: '.env.staging',
production: '.env.production',
stores: '.env.stores',
storybook: '.env.storybook'
]
apply from: project(':react-native-config').projectDir.getPath() +"/dotenv.gradle"
project.ext.vectoricons = [
iconFontNames: [ 'FontAwesome.ttf', 'MaterialIcons.ttf' ] // Name of the font files you want to copy
]
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle");
importcom.android.build.OutputFile
apply plugin: "com.android.application"
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("../../index.ts")
//// 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"]
}
/** * 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
compileSdkVersion rootProject.ext.compileSdkVersion
namespace "com.example.app"
defaultConfig {
applicationId "com.example.app"
resValue "bool", "BATCH_DO_NOT_DISTURB_INITIAL_STATE", "true"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode project.env.get("VERSION_CODE_ANDROID") asInteger
versionName "1.0.0"
multiDexEnabled true
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
resValue "string", "build_config_package", "com.example.app"
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
flavorDimensions "version"
productFlavors {
dev {
dimension "version"
applicationIdSuffix ".dev"
versionNameSuffix "-dev"
resValue "string", "app_name", "Example Dev"
}
staging {
dimension "version"
applicationIdSuffix ".staging"
versionNameSuffix "-staging"
resValue "string", "app_name", "Example Staging"
}
production {
dimension "version"
applicationIdSuffix ".production"
versionNameSuffix "-prod"
resValue "string", "app_name", "Example Prod"
}
stores {
dimension "version"
resValue "string", "app_name", "Example"
}
storybook {
dimension "version"
applicationIdSuffix ".storybook"
versionNameSuffix "-storybook"
resValue "string", "app_name", "Example Storybook"
}
}
splits {
abi {
reset()
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
}
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"
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.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.htmldef 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 =
defaultConfig.versionCode *1000+ versionCodes.get(abi)
}
}
}
}
dependencies {
androidTestImplementation('com.wix:detox:+')
implementation 'androidx.appcompat:appcompat:1.1.0'// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation("com.facebook.react:flipper-integration")
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation platform('com.google.firebase:firebase-bom:25.12.0') // needed if you don't have @react-native-firebase/app
implementation "com.google.firebase:firebase-messaging"// needed if you don't have @react-native-firebase/messaging
implementation "androidx.multidex:multidex:2.0.1"
implementation ('com.batch.android:firebase-dispatcher:3.0.1') {
exclude group: 'com.google.firebase', module: 'firebase-core'
}
implementation project(':react-native-config')
implementation 'com.google.android.gms:play-services-analytics:10.0.1'
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.0"
}
apply plugin: 'com.google.gms.google-services'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
android/settings.gradle:
rootProject.name ='example'
include ':react-native-config'
project(':react-native-config').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-config/android')
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-image-picker'
project(':react-native-image-picker').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
include ':react-native-video'
project(':react-native-video').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-video/android')
include ':react-native-video'
project(':react-native-video').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-video/android')
include ':react-native-orientation'
project(':react-native-orientation').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-orientation/android')
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
include ':@react-native-community_slider'
project(':@react-native-community_slider').projectDir =newFile(rootProject.projectDir, '../node_modules/@react-native-community/slider/android')
include ':react-native-webview'
project(':react-native-webview').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-webview/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':react-native-svg'
project(':react-native-svg').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-svg/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir =newFile(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
include ':app'
includeBuild(["node", "--print", "path.dirname(require.resolve('@react-native/gradle-plugin/package.json'))"].execute(null, rootDir).text.trim())
MainApplication.kt:
packagecom.example.appimportandroid.app.Applicationimportcom.facebook.react.PackageListimportcom.facebook.react.ReactApplicationimportcom.facebook.react.ReactHostimportcom.facebook.react.ReactNativeHostimportcom.facebook.react.ReactPackageimportcom.facebook.react.defaults.DefaultNewArchitectureEntryPoint.loadimportcom.facebook.react.defaults.DefaultReactHost.getDefaultReactHostimportcom.facebook.react.defaults.DefaultReactNativeHostimportcom.facebook.react.flipper.ReactNativeFlipperimportcom.facebook.soloader.SoLoaderimportcom.facebook.react.views.text.ReactFontManagerimportcom.microsoft.codepush.react.CodePushclassMainApplication : Application(), ReactApplication {
overrideval reactNativeHost:ReactNativeHost=object:DefaultReactNativeHost(this) {
overridefungetPackages(): List<ReactPackage> =PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:// add(MyReactNativePackage())
}
overridefungetJSMainModuleName(): String="index"overridefungetUseDeveloperSupport(): Boolean=BuildConfig.DEBUGoverrideval isNewArchEnabled:Boolean=BuildConfig.IS_NEW_ARCHITECTURE_ENABLEDoverrideval isHermesEnabled:Boolean=BuildConfig.IS_HERMES_ENABLEDoverridefungetJSBundleFile(): String {
returnCodePush.getJSBundleFile()
}
}
overrideval reactHost:ReactHost
get() = getDefaultReactHost(this.applicationContext, reactNativeHost)
overridefunonCreate() {
super.onCreate()
ReactFontManager.getInstance().addCustomFont(this, "Montserrat", R.font.montserrat)
SoLoader.init(this, false)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
}
}
Hi there! The first_open event is reserved and automatic, it can only be sent by the underlying firebase-android-sdk. Additionally the toggle that we use to disable analytics is simply carrying the value from firebase.json into the AndroidManifest for you (since most react-native-firebase developers aren't too familiar with editing AndroidManifest.xml...) as documented upstream for disabling collection. Then the API we use to enable it is just a simple wrapper on firebase-android-sdk - as such, I think the natural home for this question is in the firebase-android-sdk repo where they may perhaps be able to explain why the event is not deferred-then-sent after satisfying GDPR consent and enabling on app first_open
Issue
Hello everyone,
After updating react-native-firebase from 16.5.0 to 19.2.2, our team noticed that first_open events are no longer being sent on Android devices.Previously we had a ratio of around 1:2 for Android, now we are receiving 0 first_open events on Android.
All other events are functioning as expected, maintaining their usual ratio.
We tried updating to 20.1.0, but during our limited testing, this issue was not resolved.
However, we found that changing
"analytics_auto_collection_enabled": false
to"analytics_auto_collection_enabled": true
resolved the issue, and first_open events are now being sent. Nonetheless, we need to disable it at the start of the app to comply with GDPR requirementsFor reference, we are using NX with a bare react native
Project Files
Javascript
Click To Expand
handler.ts
:package.json
:firebase.json
for react-native-firebase v6:iOS
Click To Expand
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
Android
Click To Expand
Have you converted to AndroidX?
android/gradle.properties
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:android/app/build.gradle
:android/settings.gradle
:MainApplication.kt
:AndroidManifest.xml
:Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:"@react-native-firebase/analytics": "^20.1.0", "@react-native-firebase/app": "^20.1.0", "@react-native-firebase/dynamic-links": "^20.1.0", "@react-native-firebase/remote-config": "^20.1.0",
Firebase
module(s) you're using that has the issue:"@react-native-firebase/analytics": "^20.1.0"
TypeScript
?Y
&5.4.5
React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: