Skip to content

Commit

Permalink
feat(analytics, config): expose automatic screenview reporting toggle (
Browse files Browse the repository at this point in the history
…#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>
  • Loading branch information
se09deluca and mikehardy authored Dec 18, 2021
1 parent 051f4a6 commit 8836c01
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .spellcheck.dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ RNFirebase
SafetyNet
Salakar
scalable
screenview
scrollable
SDK
SDK.
Expand All @@ -163,6 +164,7 @@ timezones
triaging
TypeDoc
UI
UIViewController
uid
uncomment
unhandled
Expand Down
14 changes: 14 additions & 0 deletions docs/analytics/usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,17 @@ import { firebase } from '@react-native-firebase/analytics';
// ...
await firebase.analytics().setAnalyticsCollectionEnabled(true);
```

## Disable screenview tracking

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.
Automatic screenview reporting can be turned off/on through `google_analytics_automatic_screen_reporting_enabled` property of `firebase.json` file.

```json
// <project-root>/firebase.json
{
"react-native": {
"google_analytics_automatic_screen_reporting_enabled": false
}
}
```
7 changes: 6 additions & 1 deletion packages/analytics/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ String collectionDeactivated = 'false'
String adidEnabled = 'true'
String ssaidEnabled = 'true'
String personalizationEnabled = 'true'
String automaticScreenReportingEnabled = 'true'

// If nothing is defined, data collection defaults to true
String dataCollectionEnabled = 'true'
Expand Down Expand Up @@ -102,6 +103,9 @@ if (rootProject.ext && rootProject.ext.firebaseJson) {
if (rnfbConfig.isFlagEnabled('analytics_default_allow_ad_personalization_signals', true) == false) {
personalizationEnabled = 'false'
}
if (rnfbConfig.isFlagEnabled('google_analytics_automatic_screen_reporting_enabled', true) == false) {
automaticScreenReportingEnabled = 'false'
}
}

android {
Expand All @@ -112,7 +116,8 @@ android {
firebaseJsonCollectionDeactivated: collectionDeactivated,
firebaseJsonAdidEnabled: adidEnabled,
firebaseJsonSsaidEnabled: ssaidEnabled,
firebaseJsonPersonalizationEnabled: personalizationEnabled
firebaseJsonPersonalizationEnabled: personalizationEnabled,
firebaseJsonAutomaticScreenReportingEnabled: automaticScreenReportingEnabled
]
}
lintOptions {
Expand Down
1 change: 1 addition & 0 deletions packages/analytics/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<meta-data android:name="google_analytics_adid_collection_enabled" android:value="${firebaseJsonAdidEnabled}" />
<meta-data android:name="google_analytics_ssaid_collection_enabled" android:value="${firebaseJsonSsaidEnabled}" />
<meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="${firebaseJsonPersonalizationEnabled}" />
<meta-data android:name="google_analytics_automatic_screen_reporting_enabled" android:value="${firebaseJsonAutomaticScreenReportingEnabled}" />
</application>
</manifest>
6 changes: 5 additions & 1 deletion packages/app/firebase-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"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.",
"type": "boolean"
},
"google_analytics_automatic_screen_reporting_enabled": {
"description": "If you wish to disable automatic screen reporting in your app.\n This cannot be altered at runtime once set in the config.",
"type": "boolean"
},
"analytics_default_allow_ad_personalization_signals": {
"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'",
"type": "boolean"
Expand Down Expand Up @@ -54,7 +58,7 @@
"type": "boolean"
},
"crashlytics_javascript_exception_handler_chaining_enabled": {
"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.",
"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.",
"type": "boolean"
},
"crashlytics_ndk_enabled": {
Expand Down
8 changes: 8 additions & 0 deletions packages/app/ios_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ if [[ ${_SEARCH_RESULT} ]]; then
_PLIST_ENTRY_VALUES+=("$(jsonBoolToYesNo "$_ANALYTICS_PERSONALIZATION")")
fi

# config.google_analytics_automatic_screen_reporting_enabled
_ANALYTICS_AUTO_SCREEN_REPORTING=$(getFirebaseJsonKeyValue "$_JSON_OUTPUT_RAW" "google_analytics_automatic_screen_reporting_enabled")
if [[ $_ANALYTICS_AUTO_SCREEN_REPORTING ]]; then
_PLIST_ENTRY_KEYS+=("FirebaseAutomaticScreenReportingEnabled")
_PLIST_ENTRY_TYPES+=("bool")
_PLIST_ENTRY_VALUES+=("$(jsonBoolToYesNo "$_ANALYTICS_AUTO_SCREEN_REPORTING")")
fi

# config.perf_auto_collection_enabled
_PERF_AUTO_COLLECTION=$(getFirebaseJsonKeyValue "$_JSON_OUTPUT_RAW" "perf_auto_collection_enabled")
if [[ $_PERF_AUTO_COLLECTION ]]; then
Expand Down
1 change: 1 addition & 0 deletions tests/firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"analytics_idfv_collection_enabled": false,
"google_analytics_adid_collection_enabled": true,
"google_analytics_ssaid_collection_enabled": true,
"google_analytics_automatic_screen_reporting_enabled": true,
"analytics_default_allow_ad_personalization_signals": true,

"perf_auto_collection_enabled": false,
Expand Down
2 changes: 1 addition & 1 deletion tests/ios/testing.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 comment on commit 8836c01

@vercel
Copy link

@vercel vercel bot commented on 8836c01 Dec 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.