Begin with Options
Beta release
The Sauce Mobile Beta SDK requires that you call beginWithoutCrashHandler (or begin) to start recording your sessions. However, developers can override the build settings to determine what is enabled during a session recording.
Some commonly used options:
- Video Recording
- Recorded Metrics
- Max Session Length
- Feedback Form
The SDK does not install a crash handler. Crash reporting is provided by Backtrace (Sauce Labs Error Reporting), and the two SDKs are designed to run in the same app. beginWithoutCrashHandler starts the session without a crash handler and forces the enableCrashReporter option (TFSDKEnableCrashReporterKey on iOS) to false even if you pass true in the options. Initialize Backtrace before the SDK. See Using Sauce Mobile Beta with Backtrace.
- Android
- iOS
Video Recording
Sauce Labs Mobile App Distribution provides an option to enable or disable video recording and control the recording parameters. InvokedisableVideo or enableVideo before beginWithoutCrashHandler.Syntax
TestFairy.disableVideo();
TestFairy.enableVideo("<policy>", "<quality>", <frames per second>);
policy and quality values.Code Example
In the following example, video only records when wifi is available. A high-quality video is recorded every 2 seconds.import com.testfairy.TestFairy;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
TestFairy.enableVideo("wifi", "high", 2.0f);
TestFairy.beginWithoutCrashHandler(this, "<sauce-mobile-beta-token>");
}
}
Recorded Metrics
Sauce Labs Mobile App Distribution can collect several different metrics from your app. Developers can override the metrics defined in their app's build settings.Developers can callenableMetric or disableMetric before beginWithoutCrashHandler with the metric they wish to enable or disable recording.Any metric that is enabled or disabled override the settings set in your app's build settings.
Syntax
TestFairy.enableMetric("<metric>");
TestFairy.disableMetric("<metric>");
Code Example
In the following snippet, the CPU metric will be recorded, and the Memory metric will not be recorded, regardless of what's set in the build settings.import com.testfairy.TestFairy;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
TestFairy.enableMetric("cpu");
TestFairy.disableMetric("memory");
TestFairy.beginWithoutCrashHandler(this, "<sauce-mobile-beta-token>");
}
}
Max Session Length
Sauce Labs Mobile App Distribution only records for a fixed period. Developers can override the maximum recording period by callingsetMaxSessionLength before beginWithoutCrashHandler.The value passed into this method must be less than or equal to the value defined in the build settings. A value larger than the one in the build settings will be ignored.
Syntax
TestFairy.setMaxSessionLength(<session length in seconds>);
Code Example
import com.testfairy.TestFairy;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
TestFairy.setMaxSessionLength(10 * 60); // Record for 10 minutes
TestFairy.beginWithoutCrashHandler(this, "<sauce-mobile-beta-token>");
}
}
Feedback Form
Sauce Labs Mobile App Distribution provides an option to enable or disable feedback collection. InvokedisableFeedbackForm or enableFeedbackForm before beginWithoutCrashHandler.Syntax
TestFairy.disableFeedbackForm();
TestFairy.enableFeedbackForm("<method>");
method.Code Example
In the following example, feedback will be enabled when the device is shaken.import com.testfairy.TestFairy;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
TestFairy.enableFeedbackForm("shake");
TestFairy.beginWithoutCrashHandler(this, "<sauce-mobile-beta-token>");
}
}
Video Recording
The Sauce Mobile Beta SDK provides an option to enable or disable video recording and control the recording parameters. InvokedisableVideo or enableVideo before beginWithoutCrashHandler.Syntax
[TestFairy disableVideo];
[TestFairy enableVideo:@"<policy>" quality:@"<quality>" framesPerSecond:<frames per second>];
policy and quality values.Code Example
In the following example, the video will only be recorded when wifi is available. A high-quality video will be recorded every 2 seconds.@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[TestFairy enableVideo:@"wifi" quality:@"high" framesPerSecond:2.0];
[TestFairy beginWithoutCrashHandler:@"<sauce-mobile-beta-token>"];
}
Recorded Metrics
Sauce Labs Mobile App Distribution can collect several different metrics from your app. Developers can override the metrics defined in their app's build settings.Developers can callenableMetric or disableMetric before beginWithoutCrashHandler with the metric they wish to enable or disable recording.Any metric that is enabled or disabled will override the settings set in your app's build settings.
Syntax
[TestFairy enableMetric:@"<metric>"];
[TestFairy disableMetric:@"<metric>"];
Code Example
In the following snippet, the CPU metric will be recorded, and the Memory metric will not be recorded, regardless of what's set in the build settings.@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[TestFairy enableMetric:@"cpu"];
[TestFairy disableMetric:@"memory"];
[TestFairy beginWithoutCrashHandler:@"<sauce-mobile-beta-token>"];
// ...
}
Max Session Length
The Sauce Mobile Beta SDK only records for a fixed period. Developers can override the maximum recording period by callingsetMaxSessionLength before beginWithoutCrashHandler.The value passed into this method must be less than or equal to the value defined in the build settings. A value larger than the one in the build settings will be ignored.
Syntax
[TestFairy setMaxSessionLength:<session length in seconds>];
Code Example
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[TestFairy setMaxSessionLength:(10 * 60)]; // Record for 10 minutes
[TestFairy beginWithoutCrashHandler:@"<sauce-mobile-beta-token>"];
}
Feedback Form
The Sauce Mobile Beta SDK provides an option to enable or disable feedback collection. InvokedisableFeedbackForm or enableFeedbackForm before beginWithoutCrashHandler.Syntax
[TestFairy disableFeedbackForm];
[TestFairy enableFeedbackForm:@"<method>"];
method.Code Example
In the following example, feedback will be enabled when the device is shaken.@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[TestFairy enableFeedbackForm:@"shake|screenshot"];
[TestFairy beginWithoutCrashHandler:@"<sauce-mobile-beta-token>"];
}