Skip to content

Commit 8836c01

Browse files
feat(analytics, config): expose automatic screenview reporting toggle (#5948)
* Adds automatic screen reporting in firebase.json Automatic screenview tracking can now be disabled/enabled via firebase.json through "google_analytics_automatic_screen_reporting_enabled" property. Co-authored-by: Mike Hardy <github@mikehardy.net>
1 parent 051f4a6 commit 8836c01

File tree

8 files changed

+38
-3
lines changed

8 files changed

+38
-3
lines changed

.spellcheck.dict.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ RNFirebase
138138
SafetyNet
139139
Salakar
140140
scalable
141+
screenview
141142
scrollable
142143
SDK
143144
SDK.
@@ -163,6 +164,7 @@ timezones
163164
triaging
164165
TypeDoc
165166
UI
167+
UIViewController
166168
uid
167169
uncomment
168170
unhandled

docs/analytics/usage/index.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,17 @@ import { firebase } from '@react-native-firebase/analytics';
181181
// ...
182182
await firebase.analytics().setAnalyticsCollectionEnabled(true);
183183
```
184+
185+
## Disable screenview tracking
186+
187+
Analytics automatically tracks some information about screens in your application, such as the class name of the UIViewController or Activity that is currently in focus.
188+
Automatic screenview reporting can be turned off/on through `google_analytics_automatic_screen_reporting_enabled` property of `firebase.json` file.
189+
190+
```json
191+
// <project-root>/firebase.json
192+
{
193+
"react-native": {
194+
"google_analytics_automatic_screen_reporting_enabled": false
195+
}
196+
}
197+
```

packages/analytics/android/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ String collectionDeactivated = 'false'
7070
String adidEnabled = 'true'
7171
String ssaidEnabled = 'true'
7272
String personalizationEnabled = 'true'
73+
String automaticScreenReportingEnabled = 'true'
7374

7475
// If nothing is defined, data collection defaults to true
7576
String dataCollectionEnabled = 'true'
@@ -102,6 +103,9 @@ if (rootProject.ext && rootProject.ext.firebaseJson) {
102103
if (rnfbConfig.isFlagEnabled('analytics_default_allow_ad_personalization_signals', true) == false) {
103104
personalizationEnabled = 'false'
104105
}
106+
if (rnfbConfig.isFlagEnabled('google_analytics_automatic_screen_reporting_enabled', true) == false) {
107+
automaticScreenReportingEnabled = 'false'
108+
}
105109
}
106110

107111
android {
@@ -112,7 +116,8 @@ android {
112116
firebaseJsonCollectionDeactivated: collectionDeactivated,
113117
firebaseJsonAdidEnabled: adidEnabled,
114118
firebaseJsonSsaidEnabled: ssaidEnabled,
115-
firebaseJsonPersonalizationEnabled: personalizationEnabled
119+
firebaseJsonPersonalizationEnabled: personalizationEnabled,
120+
firebaseJsonAutomaticScreenReportingEnabled: automaticScreenReportingEnabled
116121
]
117122
}
118123
lintOptions {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
<meta-data android:name="google_analytics_adid_collection_enabled" android:value="${firebaseJsonAdidEnabled}" />
1313
<meta-data android:name="google_analytics_ssaid_collection_enabled" android:value="${firebaseJsonSsaidEnabled}" />
1414
<meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="${firebaseJsonPersonalizationEnabled}" />
15+
<meta-data android:name="google_analytics_automatic_screen_reporting_enabled" android:value="${firebaseJsonAutomaticScreenReportingEnabled}" />
1516
</application>
1617
</manifest>

packages/app/firebase-schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"description": "If you wish to disable collection of SSAID (Settings.Secure.ANDROID_ID) in your Android app,.\n This cannot be altered at runtime once set in the config.",
2626
"type": "boolean"
2727
},
28+
"google_analytics_automatic_screen_reporting_enabled": {
29+
"description": "If you wish to disable automatic screen reporting in your app.\n This cannot be altered at runtime once set in the config.",
30+
"type": "boolean"
31+
},
2832
"analytics_default_allow_ad_personalization_signals": {
2933
"description": "Configure whether a user's Analytics data may be used for personalized advertising in other products.\n If set, may be overridden at runtime by calling setUserProperty on the key 'allow_personalized_ads'",
3034
"type": "boolean"
@@ -54,7 +58,7 @@
5458
"type": "boolean"
5559
},
5660
"crashlytics_javascript_exception_handler_chaining_enabled": {
57-
"description": "By default React Native Firebase Crashlytics will preserve existing global javascript-level uhandled exception handlers by reporting to Crashlytics then passing the exception on for further handling. This could lead to duplicate reports, for example a fatal javascript-level report and a fatal native level report for the same crash. Set to false to terminate error handling after logging the javascript-level crash.",
61+
"description": "By default React Native Firebase Crashlytics will preserve existing global javascript-level unhandled exception handlers by reporting to Crashlytics then passing the exception on for further handling. This could lead to duplicate reports, for example a fatal javascript-level report and a fatal native level report for the same crash. Set to false to terminate error handling after logging the javascript-level crash.",
5862
"type": "boolean"
5963
},
6064
"crashlytics_ndk_enabled": {

packages/app/ios_config.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ if [[ ${_SEARCH_RESULT} ]]; then
126126
_PLIST_ENTRY_VALUES+=("$(jsonBoolToYesNo "$_ANALYTICS_PERSONALIZATION")")
127127
fi
128128

129+
# config.google_analytics_automatic_screen_reporting_enabled
130+
_ANALYTICS_AUTO_SCREEN_REPORTING=$(getFirebaseJsonKeyValue "$_JSON_OUTPUT_RAW" "google_analytics_automatic_screen_reporting_enabled")
131+
if [[ $_ANALYTICS_AUTO_SCREEN_REPORTING ]]; then
132+
_PLIST_ENTRY_KEYS+=("FirebaseAutomaticScreenReportingEnabled")
133+
_PLIST_ENTRY_TYPES+=("bool")
134+
_PLIST_ENTRY_VALUES+=("$(jsonBoolToYesNo "$_ANALYTICS_AUTO_SCREEN_REPORTING")")
135+
fi
136+
129137
# config.perf_auto_collection_enabled
130138
_PERF_AUTO_COLLECTION=$(getFirebaseJsonKeyValue "$_JSON_OUTPUT_RAW" "perf_auto_collection_enabled")
131139
if [[ $_PERF_AUTO_COLLECTION ]]; then

tests/firebase.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"analytics_idfv_collection_enabled": false,
2626
"google_analytics_adid_collection_enabled": true,
2727
"google_analytics_ssaid_collection_enabled": true,
28+
"google_analytics_automatic_screen_reporting_enabled": true,
2829
"analytics_default_allow_ad_personalization_signals": true,
2930

3031
"perf_auto_collection_enabled": false,

tests/ios/testing.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)