Error Analysis
Prerequisites
Section titled PrerequisitesContentsquare SDK is included
Section titled Contentsquare SDK is includedYou must include the Contentsquare SDK first using the same integration method and understand how the SDK works.
Update to the latest SDK version
Section titled Update to the latest SDK versionIn order to enable Error Analysis in your app and get the most stable version, it is required to upgrade the SDK to its latest version.
Screen tracking implemented
Section titled Screen tracking implementedTracking will start at the 1st screenview event, it is required to have screen tracking implemented. Make sure to follow the React Native Track screens sections.
Reminder about User consent
Section titled Reminder about User consentIf you are in the process of implementing the SDK for the 1st time (or choose to take this update as an opportunity to review your Privacy related implementation), make sure to follow the React Native Privacy section and use the Opt-in API to get the user consent, otherwise no data will be collected.
Get Started
Section titled Get StartedAdd Contentsquare Error Analysis to your app
Section titled Add Contentsquare Error Analysis to your appIf you have already integrated the Contentsquare SDK and enabled Error Analysis on CS Apps Analytics, the Error Analysis SDK should seamlessly function. However, note that additional configuration is required specifically for Android apps.
Add Gradle plugin on Android
Section titled Add Gradle plugin on AndroidWith the use of a Gradle plugin, an instrumentation of your code will be performed to collect the data about network errors.
Using the plugins DSL:
plugins { id "com.contentsquare.error.analysis.network" version "1.1.0"}
Using legacy plugin application:
buildscript { repositories { maven { url "https://plugins.gradle.org/m2" } } dependencies { classpath "com.contentsquare.gradle:error-analysis-network:1.2.0" }}
apply plugin: "com.contentsquare.error.analysis.network"
Using the plugins DSL:
plugins { id("com.contentsquare.error.analysis.network") version "1.2.0"}
Using legacy plugin application:
buildscript { repositories { maven { url = uri("https://plugins.gradle.org/m2") } } dependencies { classpath("com.contentsquare.gradle:error-analysis-network:1.2.0") }}
apply(plugin = "com.contentsquare.error.analysis.network")
Start the SDK
Section titled Start the SDKYou do not need to do anything to start the Error Analysis SDK, it will start itself with Contentsquare SDK.
Validate SDK integration
Section titled Validate SDK integrationWhen the SDK starts, you should see a log like this one:
// success caseCSLIB ℹ️ Info: Contentsquare Error Analysis [SDKVersionNumber] starting in app : [your.app.packageName]
// fail case// << No public fail log
Sample App
Section titled Sample AppFor best implementation practices of our library, explore the Contentsquare for React Native sample app.
API Errors
Section titled API ErrorsAutomatic network inspection
Section titled Automatic network inspectionAPI Errors automatically collects failed network requests.
Removing Personal Data in request URL path
Section titled Removing Personal Data in request URL pathBy default, the API Errors feature collects the URL path of the failed API requests. To prevent the collection of Personal Data in the URL path, you can rewrite the request URL path with the ErrorAnalysis.setUrlMaskingPatterns
SDK API.
Simply replace a step of the path - meaning between two slashes (/) - containing Personal Data with a variable:
:user_id
becomes CS_ANONYMIZED_USER_ID:address
becomes CS_ANONYMIZED_ADDRESS
Example
Section titled Exampleimport { ErrorAnalysis } from '@contentsquare/react-native-bridge';
ErrorAnalysis.setURLMaskingPatterns([ 'https://www.contentsquare.com/users/:user_id/address/:address',]);
Result
Section titled ResultURL before masking | URL after masking |
---|---|
https://www.contentsquare.com/users/123/address/castle+black | https://www.contentsquare.com/users/CS_ANONYMIZED_USER_ID/address/CS_ANONYMIZED_ADDRESS |
Debugging and Logging
Section titled Debugging and LoggingIf in-app features are enabled, a info log should appear with the details of the event (see React Native Debugging and Logging section):
CSLIB ℹ️ Info: API Error - GET 401 https://api.client.com
How API Errors works
Section titled How API Errors worksInitialization
Section titled InitializationThe way our SDK works is by auto-starting with the application launch and automatically collects failed network requests.
Configuration
Section titled ConfigurationOnce started, our SDK fetches its config from our servers. It will start collecting data from network events if the API Errors setting is enabled in the config (this is handled by the Contentsquare team).
Tracking
Section titled TrackingThe SDK monitors only the API Errors with response code above 400, and generates analytics data. These events are then locally stored, and eventually sent to our servers in batches.
Sending data
Section titled Sending dataFor each network error, a new event will be sent in analytics and Session Replay data. Check the following sections to learn more about how data is processed and sent:
API Troubleshooting Details
Section titled API Troubleshooting DetailsAPI Errors troubleshooting details enables you to collect more information about API errors so you can troubleshoot errors faster.
With this feature you will be able to see three types of additional API error details in the Event Stream of Session Replay.
- The HTTP headers of the request and the response.
- The body (the data sent by the request or received in the response).
- The query parameters of the request endpoint (of the URL of the information you request for).
See API Troubleshooting Details for more details.
Mask API Error By Template URL
Section titled Mask API Error By Template URLThis method will mask URLs of failing API calls to URLs that match the template URL.
Use colon (:
) to indicate a dynamic parameter.
import { ErrorAnalysis } from '@contentsquare/react-native-bridge';
ErrorAnalysis.setURLMaskingPatterns([ 'https://<domain>/:status_code/person/:person_id/store/:store_id',]);
Collected data points
Section titled Collected data pointsOnly network calls in error (response code above 400) will be collected.
Here the exhaustive list of data collected:
- URL (without query strings)
- HTTP method
- Response code
- Timestamp of the request
- Timestamp of the response
- HTTP headers of the request
- HTTP headers of the response
- HTTP body of the request
- HTTP body of the response
- Query parameters of the request endpoint
Known limitations and recommendations
Section titled Known limitations and recommendationsConflict with Firebase Performance Monitoring
Section titled Conflict with Firebase Performance MonitoringAndroid
Section titled AndroidContentsquare Error Analysis is not compatible with Firebase Performance Monitoring auto-collection. Only one of the two will log events, and usually, the events will be automatically logged by the Contentsquare Error Analysis. To log events to Firebase Performance Monitoring, we suggest logging it manually.
Contentsquare Error Analysis is compatible with Firebase Performance auto-collection, but the HTTP body from the response won’t be collected by the Error Analysis SDK.
Workaround: Disable Firebase automatic monitoring:
// <project-root>/firebase.json{ "react-native": { "perf_auto_collection_enabled": false }}
Contentsquare Error Analysis may not be compatible with other network auto-collection tools.