Skip to main content

Protect sensitive data

As with any third-party service, it’s important for you to understand and have the ability to manage what data is sent to Shake servers. Shake SDK allows you to filter out sensitive data on the mobile device itself, so it never reaches the Shake servers.

Automatically redacted sensitive data

Shake automatically redacts these sensitive data from your notifications, touch events and network requests:

  • email addresses
  • IP addresses
  • credit card numbers
  • bearer tokens

Shake also redacts network header values if the header key is:

  • password
  • secret
  • passwd
  • api_key
  • apikey
  • access_token
  • auth_token
  • credentials
  • mysql_pwd
  • stripetoken
  • Authorization
  • Proxy-Authorization
  • card[number]
  • token

To disable this privacy feature, use the method below:

App.js
Shake.setSensitiveDataRedactionEnabled(false);

Views

Private views

You can mark any view as private, and it'll automatically be deleted from the auto screenshot. Private views are stored as a weak reference. They get cleared from the memory when not used anymore.

note

These methods won't delete sensitive views from auto screen recording — only from the auto screenshot.

note

When marking a View as private, also add the collapsable={false} flag to it in order to avoid the "Trying to resolve view with tag number which doesn’t exist" error.

Let's suppose you're building a shopping app and you want to delete the name and the credit card number views from the auto screenshot:

App.js
<Text ref={r => this.cardNumber = r} style={styles.cardNumber}>{this.state.cardNumber}</Text>
<Text ref={r => this.cardName = r} style={styles.cardName}>{this.state.cardName}</Text>

This is how you mark views as private:

App.js
import Shake from '@shakebugs/react-native-shake';
const maskSensitiveData = () => {
Shake.addPrivateView(cardNumber);
Shake.addPrivateView(cardName);
}

To remove a view from private views use the following method:

App.js
Shake.removePrivateView(viewRef);

If you want to delete an entire screen from the auto screenshot, simply mark the root of the screen as private.

To clear all the private views, use the following method:

App.js
Shake.clearPrivateViews();

Touch events

Marking a view as private will automatically delete its touch events' text properties too. Consequently, you'll see them as data_redacted strings in ticket's Activity history. The view's ID, accessibility labels and tags remain visible.

Network requests

Network requests may contain sensitive data which you may not want to send to Shake servers. Use the Shake.setNetworkRequestsFilter() method to obfuscate sensitive parts of those requests, or to entirely prevent certain network requests from being logged. As an example, if you'd like to obfuscate the Authorization header in all network requests sent from your app, do this:

App.js
import Shake from '@shakebugs/react-native-shake';
const setupNetworkFilter = () => {
Shake.setNetworkRequestsFilter((networkRequest) => {
let headers = networkRequest.getRequestHeaders();
if (headers.Authorization) {
headers.Authorization = '***';
}
return networkRequest;
});
}

If you don't want to log specific network requests, return null from the NetworkRequestsFilter as shown below:

App.js
import Shake from '@shakebugs/react-native-shake';
const setupNetworkFilter = () => {
Shake.setNetworkRequestsFilter((networkRequest) => {
if (networkRequest.getUrl().startsWith('https://api.myapp.com/cards')) {
return null;
}
return networkRequest;
});
}

To clear the network requests filter, use Shake.setNetworkRequestsFilter(null).

Notification events

If your app notifications contain sensitive data, use the Shake.setNotificationEventsFilter() method to fully or partially obfuscate those notifications.

For example, if you'd like to obfuscate the description of the notification event that contains an email, do this:

App.js
import Shake from '@shakebugs/react-native-shake';
const setupNotificationsFilter = () => {
Shake.setNotificationEventsFilter((notificationEvent) => {
if (notificationEvent.getTitle() === 'E-mail changed') {
notificationEvent.setDescription('***@gmail.com');
}
return notificationEvent;
});
}

If you do not want to track a specific notification event, return null from the NotificationEventsFilter like below:

App.js
import Shake from '@shakebugs/react-native-shake';
const setupNotificationsFilter = () => {
Shake.setNotificationEventsFilter((notificationEvent) => {
if (notificationEvent.getTitle() === 'E-mail changed') {
return null;
}
return notificationEvent;
});
}

To clear the notification events filter, use Shake.setNotificationEventsFilter(null).