Capture app-observed motion

Forward shakes and accelerometer samples your app already observes into an Ansight session.

Motion capture adds app-observed shakes and accelerometer samples to the session timeline. It is opt-in and app fed: Ansight does not start Core Motion, register an Android sensor listener, or request sensor permissions. Forward observations from handlers your app already owns.

The separate Ansight.Motion, ansight-motion-android, and AnsightMotion packages are included by their platform’s all-in-one SDK. React Native, Flutter, and Capacitor expose the same capability through their SDK APIs.

Enable and forward observations

PlatformEnable in the SDK options builderForward app observations
.NET and MAUIWithMotionCapture()MotionCapture.RecordShake(); MotionCapture.RecordAccelerometer(x, y, z)
AndroidwithMotionCapture()AnsightMotion.recordShake(); AnsightMotion.recordAccelerometer(x, y, z)
iOSwithMotionCapture()AnsightMotion.recordShake(); AnsightMotion.recordAccelerometer(x:y:z:)
React NativecreateOptionsBuilder().withMotionCapture()Ansight.recordShake(); Ansight.recordAccelerometer(x, y, z)
FluttercreateOptionsBuilder().withMotionCapture()Ansight.instance.recordShake(); Ansight.instance.recordAccelerometer(x, y, z)
CapacitorcreateOptionsBuilder().withMotionCapture()Ansight.recordShake(); Ansight.recordAccelerometer(x, y, z)

For example, a .NET app using the all-in-one package can enable motion during initialization and call the forwarding API from its own handler:

using Ansight;
using Ansight.Motion;

var options = Options.CreateBuilder()
    .WithAnsightSdk()
    .WithMotionCapture()
    .Build();

Runtime.InitializeAndActivate(options);

// Call from the app's existing shake handler.
MotionCapture.RecordShake();

// Call from the app's existing accelerometer callback; values are m/s².
MotionCapture.RecordAccelerometer(x, y, z);

On iOS, a UIKit motionEnded(_:with:) handler can forward a shake independently of Core Motion. If an app forwards Core Motion acceleration, convert from g to m/s² by multiplying each axis by 9.80665. Android SensorEvent accelerometer values are already in m/s².

Capture behavior

Enabling motion capture includes shake and accelerometer forwarding by default. Each can be disabled separately. Accelerometer samples are limited to one every 20 ms by default; the configurable interval is clamped to 10–1000 ms. Calls made while the runtime is inactive or motion capture is disabled are ignored.

The SDK records Motion events labeled motion.shake and motion.accelerometer. Accelerometer details include x, y, z, unit: "m/s2", and source: "app". The local host writes them to motion/events.json in the session capture folder and shows them in the motion timeline category.

An iOS Simulator or Android emulator can receive motion injected by the host. That host input is recorded as motion.injected.* evidence when a session is available. To capture app-side handling, forward the resulting observation from the app to the SDK as shown above.