Default SDK Events

In this document we detail the collection of events recorded by every Moonsense SDK Session in addition to the raw sensor data. We consider these events default since they provide the necessary context that help represent the data collected by the Session. These events are:

  1. Viewport Size
  2. App Lifecycle
  3. Permissions

Let's go over each of them in detail.

Viewport Size

The Viewport Size records a snapshot of the current native viewport or window of the device. Here is an example of an event:

[ { "determined_at": "1212220276", "device_physical_width": "1080", "device_physical_height": "2116", "device_logical_width": "392", "device_logical_height": "769", "device_pixel_ratio": 2.75, "viewport_orientation": "PORTRAIT_PRIMARY" } ]

The event reports the physical pixel width and height of the device's viewport in addition to the logical width and height. Logical pixels approximate a grid with about 38 pixels per centimeter, or 96 pixels per inch, at a device pixel ratio of 1.0. It should be noted that this can vary across manufacturers and devices. The logical width and height is used when interpreting touch events as it helps recognize the touch coordinates in relation to the device screen. Additional information in the event includes the pixel ratio and the viewport orientation.

A Viewport Size event is fired by the SDK whenever a Session is started by the user. For situations where the device is rotated, or the application viewport changes(via a user interaction like click and drag), the SDK reports a new Viewport Size event with the updated co-ordinates and a new timestamp.

App Lifecycle

The App Lifecycle in a nutshell describes the state of the application that the SDK is operating on. Here is an example of the event:

[ { "determined_at": "972", "app_life_cycle_status": "FOREGROUND" }, { "determined_at": "3242", "app_life_cycle_status": "BACKGROUND" }, { "determined_at": "4600", "app_life_cycle_status": "FOREGROUND" }, { "determined_at": "6762", "app_life_cycle_status": "DESTROY" } ]

The event reports a timestamped state of the application when backgrounded, foregrounded or destroyed(shut down/browser tab closed). As mentioned in the Data Collection document, the SDK stops recording data when in the application is in the background(i.e. not active). We therefore can correlate the absence of any data in the Session with the corresponding BACKGROUND event reported by the SDK.


When a Session is started with multiple sensors to record, the Permissions event returns the level of access that the SDK has for every sensor requested by the Session. Here is an example of the event:

[ { "determined_at": "7057", "sensor_type": "ACCELEROMETER", "permission_status": "ALLOWED" }, { "determined_at": "7050", "sensor_type": "CLICK", "permission_status": "ALLOWED" }, { "determined_at": "7057", "sensor_type": "LINEAR_ACCELEROMETER", "permission_status": "ALLOWED" }, { "determined_at": "7057", "sensor_type": "ORIENTATION", "permission_status": "ALLOWED" }, { "determined_at": "7057", "sensor_type": "GYROSCOPE", "permission_status": "ALLOWED" }, { "determined_at": "7057", "sensor_type": "MAGNETOMETER", "permission_status": "DENIED" } ]

The event records each sensor type requested and reports whether the permission falls in one of the following categories:

  • Allowed: The user has given permission.
  • Denied: The user has denied permission.
  • Undermined by user: The user has not yet given or denied permission. This means the user would need to be prompted for permission before the sensor would be able to be used. Data will not be collected.
  • Requires prompt to determine: Checking the status of the permission would trigger a user prompt and cannot be determined another way. This is currently only used for Safari by the Web SDK. Data will attempt to be collected but is not guaranteed.
  • Sensor not available: The application has permission to use the sensor but the sensor is currently unavailable. This is typically due to the sensor not existing on the device when using the Web SDK.

The last three categories are reported only by the web SDK.