Activity history
Shake tracks user's interaction with your app, their network traffic, notifications, logs and system events, and automatically attaches all of those to the ticket.
Setup
User actions
SDK automatically observes taps made on your app's UI elements.
Network traffic
Network traffic logging is disabled by default. Enable it using the following method:
Shake.setNetworkRequestsEnabled(true);
You can add your own custom network requests at any time:
import Shake, { NetworkRequestBuilder } from '@shakebugs/react-native-shake';const networkRequestBuilder = new NetworkRequestBuilder().setMethod('POST').setStatusCode('200').setUrl('https://api.example.com').setRequestBody('Request body').setResponseBody('Response body').setRequestHeaders({header1: 'requestHeader'}).setResponseHeaders({header2: 'responseHeader'}).setDuration(100).setDate(new Date());Shake.insertNetworkRequest(networkRequestBuilder);
System events
System events - also known as app lifecycle events - are tracked automatically and require no additional setup.
Screen changes
Screen changes detection is currently not supported.
Notifications
On iOS, notifications are tracked automatically and require no additional setup.
Android requires you to add ShakeNotificationListenerService
to your AndroidManifest file inside application tag:
<serviceandroid:name="com.shakebugs.shake.ShakeNotificationListenerService"android:exported="false"android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"><intent-filter><action android:name="android.service.notification.NotificationListenerService" /></intent-filter></service>
Additionally, app user must manually grant a permission to listen for notifications. You can show notifications permission settings screen using the following method:
Shake.showNotificationsSettings();
You can add your own custom notification events at any time:
import Shake, { NotificationEventBuilder } from '@shakebugs/react-native-shake';const notificationEventBuilder = new NotificationEventBuilder().setId('0').setTitle('Title').setDescription('Description');Shake.insertNotificationEvent(notificationEventBuilder);
Custom logs
You can add your own logs to Activity history too:
import Shake, { LogLevel } from '@shakebugs/react-native-shake';const sendCustomLog = () => {Shake.log(LogLevel.INFO, 'This is a Shake custom log.');}
You have these log levels at your disposal:
LogLevel.VERBOSELogLevel.DEBUGLogLevel.INFOLogLevel.WARNLogLevel.ERROR
Console logs
On Android, console logs are recorded automatically and require no additional setup. If you want to disable this feature use the method below:
Shake.setConsoleLogsEnabled(false);
For iOS apps, add the following code snippet to your AppDelegate.m to make sure that console logs are recorded by Shake:
#import <React/RCTLog.h>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{RCTSetLogThreshold(RCTLogLevelInfo);RCTAddLogFunction(ShakeLogFunction);...}RCTLogFunction ShakeLogFunction = ^(RCTLogLevel level, __unused RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {NSString *log = RCTFormatLog([NSDate date], level, fileName, lineNumber, message);NSLog(@"%@", log);};
Disable
Activity history is enabled by default, use the method below to disable it altogether:
Shake.setEnableActivityHistory(false);