Begin with Options
TestFairy requires that you call 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:
- Crash Reporting
- Video Recording
- Recorded Metrics
- Max Session Length
- Feedback Form
- Android
- iOS
Crash Reporting
TestFairy provides a means of capturing and recording stack traces if your application crashes. Stack traces can be vital to understanding any underlying bugs in your app. However, some apps may want to disable TestFairy's crash handling. InvokeenableCrashHandler
or disableCrashHandler
before calling begin
.Once you enable the TestFairy crash handler, it cannot be disabled unless the app is restarted.Syntax
TestFairy.enableCrashHandler();
TestFairy.disableCrashHandler();
Code Example
In the following example, the TestFairy crash handler will be disabled.import com.testfairy.TestFairy;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
TestFairy.disableCrashHandler();
TestFairy.begin(this, "<app token>");
}
}
Video Recording
TestFairy provides an option to enable or disable video recording and control the recording parameters. InvokedisableVideo
or enableVideo
before begin
.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.0);
TestFairy.begin(this, "<app token>");
}
}
Recorded Metrics
TestFairy 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 invoking begin
with the metric they wish to enable or disable recording.note
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.begin(this, "<app token>");
}
}
Max Session Length
TestFairy only records for a fixed period. Developers can override the maximum recording period by callingsetMaxSessionLength
before calling begin
.note
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.begin(this, "<app token>");
}
}
Feedback Form
TestFairy provides an option to enable or disable feedback collection. InvokedisableFeedbackForm
or enableFeedbackForm
before begin
.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.begin(this, "<app token>");
}
}
Crash Reporting
TestFairy provides a means of capturing and recording stack traces if your application crashes. Stack traces can be vital to understanding any underlying bugs in your app. However, some apps may want to disable TestFairy's crash handling. InvokeenableCrashHandler
or disableCrashHandler
before calling begin
.Once you enable the TestFairy crash handler, it cannot be disabled unless the app is restarted.Syntax
[TestFairy enableCrashHandler];
[TestFairy disableCrashHandler];
Code Example
In the following example, the TestFairy crash handler will be disabled.@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[TestFairy disableCrashHandler];
[TestFairy begin:@"<app token>"];
}
Video Recording
TestFairy provides an option to enable or disable video recording and control the recording parameters. InvokedisableVideo
or enableVideo
before begin
.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 begin: @"<app token>"];
}
Recorded Metrics
TestFairy 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 invoking begin
with the metric they wish to enable or disable recording.note
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 begin: @"<app token>"];
// ...
}
Max Session Length
TestFairy only records for a fixed period. Developers can override the maximum recording period by callingsetMaxSessionLength
before calling begin
.note
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 begin:@"<app token>"];
}
Feedback Form
TestFairy provides an option to enable or disable feedback collection. InvokedisableFeedbackForm
or enableFeedbackForm
before begin
.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 begin: @"<app token>"];
}