Skip to content

Commit 9a24ecd

Browse files
author
gewfy
authored
feat(analytics): add support for analytics_auto_collection_enabled in firebase.json (#4730)
1 parent 2efb5c2 commit 9a24ecd

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

packages/analytics/android/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,22 @@ project.ext {
6363
])
6464
}
6565

66+
apply from: file("./../../app/android/firebase-json.gradle")
67+
68+
def autoCollectionEnabled = "true"
69+
70+
if (rootProject.ext && rootProject.ext.firebaseJson) {
71+
if (rootProject.ext.firebaseJson.isFlagEnabled("analytics_auto_collection_enabled") == false) {
72+
autoCollectionEnabled = "false"
73+
}
74+
}
75+
6676
android {
6777
defaultConfig {
6878
multiDexEnabled true
79+
manifestPlaceholders = [
80+
firebaseJsonAutoCollectionEnabled: autoCollectionEnabled
81+
]
6982
}
7083
lintOptions {
7184
disable 'GradleCompatible'

packages/analytics/android/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,10 @@
55
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
66
<uses-permission android:name="android.permission.INTERNET" />
77
<uses-permission android:name="android.permission.WAKE_LOCK" />
8+
9+
<application>
10+
<meta-data
11+
android:name="firebase_analytics_collection_enabled"
12+
android:value="${firebaseJsonAutoCollectionEnabled}"/>
13+
</application>
814
</manifest>

packages/app/ios_config.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ if [[ ${_SEARCH_RESULT} ]]; then
8686
_PLIST_ENTRY_TYPES+=("string")
8787
_PLIST_ENTRY_VALUES+=("$_JSON_OUTPUT_BASE64")
8888

89+
# config.analytics_auto_collection_enabled
90+
_ANALYTICS_AUTO_COLLECTION=$(getFirebaseJsonKeyValue "$_JSON_OUTPUT_RAW" "analytics_auto_collection_enabled")
91+
if [[ $_ANALYTICS_AUTO_COLLECTION ]]; then
92+
_PLIST_ENTRY_KEYS+=("FIREBASE_ANALYTICS_COLLECTION_ENABLED")
93+
_PLIST_ENTRY_TYPES+=("bool")
94+
_PLIST_ENTRY_VALUES+=("$(jsonBoolToYesNo "$_ANALYTICS_AUTO_COLLECTION")")
95+
fi
96+
8997
# config.messaging_auto_init_enabled
9098
_MESSAGING_AUTO_INIT=$(getFirebaseJsonKeyValue "$_JSON_OUTPUT_RAW" "messaging_auto_init_enabled")
9199
if [[ $_MESSAGING_AUTO_INIT ]]; then

tests/firebase.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"messaging_android_notification_color": "@color/hotpink",
1616
"messaging_ios_auto_register_for_remote_messages": true,
1717

18-
"TODO_analytics_auto_collection_enabled": true,
18+
"analytics_auto_collection_enabled": true,
19+
1920
"TODO_perf_auto_collection_enabled": true,
2021
"TODO_in_app_messaging_auto_collection_enabled": true,
2122
"TODO_database_persistence_enabled": true,

0 commit comments

Comments
 (0)