Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(analytics): expose native automatic screenview reporting toggle #5948

Merged
merged 6 commits into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .spellcheck.dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ RNFirebase
SafetyNet
Salakar
scalable
screenview
scrollable
SDK
SDK.
Expand All @@ -162,6 +163,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.