Data Collection

The Moonsense SDK is here to collect sensor data. This article will walk through exactly how to do that and some things to know about how it goes about it.

Sessions

The SDK records data into sessions. Sessions are kicked off through calling the startSession(...) method of the initialized SDK. Sessions are recorded for up to the duration specified in the startSession(...) call. This call will return a Session object that provides some insight into what is happening with the session and provides some level of control over the session. The Session can be terminated prior to the set duration by calling the stopAllSessions() method on the SDK or by calling stopSession() on the Session Object.

Starting a Session kicks off the recording of all available sensors and will show a new Session inside the Console. More than one session can be recorded simulatneously.

The application makes a best effort attempt to pause all sessions being recorded when the implementing application is backgrounded and resume all previously started sessions when the application returns to the foreground. This is done in accordance with best practices for background application usage and privacy.

Session Groups

By default sessions represent individual recordings. However, when starting a Session a ClientSessionGroupId can be set that will then allow sessions to be viewed as group. This feature can be useful when tracking different parts of a user flow as a contiguous experience made up of multiple sessions.

What's Happening in the Background

In the background, the SDK is handling the data being generated and coordinating the transfer of data with the Moonsense Cloud. It does this by communicating with the Moonsense Data and Control planes. The Control Plane provides a centralized method for handling the management of all sessions while the Data Plane provides regional endpoints to fast-track the handling of sensor data. After a session is created, all data from that point is being sent to the closest available Data Plane to the device where the recording is being performed. You do not need to do anything in the configuration to make this happen. The SDK handles it for you.

Data Plane Regions

The Data Planes are currently located in the following regions:

  • Central United States: Council Bluffs, Iowa, North America (us-central1)
  • Western Europe: St. Ghislain, Belgium, Europe (europe-west1)
  • Northeast Asia: Tokyo, Japan, APAC (asia-northeast1)
  • Southern Asia: Mumbai, India APAC (asia-south1)

The data is received within a region and queued for processing. The data is processed to create the metrics seen in the Console. This includes counts of the number of data points sent, as well as, CDFs on specific metrics to show a statistical breakdown of the data being sent.

Data Storage

Data is accumulated and stored in the region in which the data is received. The data can be downloaded for any Session by clicking the download button in the Console or by accessing the data through the Python SDK.