AI-generated Key Takeaways
-
Google Fit data points have associated data sources that identify the app or device collecting or transforming the data.
-
The REST API allows you to determine which application inserted fitness data, whether it's a session or a dataset.
-
You can attribute data you insert into the fitness store to your application by adding your application details to the
dataSources.applicationproperty and specifying the correctdatasets.dataSourceId.
Every data point in Google Fit has an associated data source. Data sources contain information to identify the app or the device that collects or transforms the data.
The REST API lets you determine which app inserted fitness data. For example, an app that analyzes a variety of data from the user's fitness history may want to present users with the list of fitness sessions included in the analysis, along with information about which app inserted each session.
The REST API also lets you associate data that you insert in the fitness store with your application.
Determine which application inserted data
To obtain the package name of the Android application that inserted a session or the name of the REST application that inserted a session:
- Retrieve the session.
- Read the
session.application.packageNameorsession.application.nameproperty.
To obtain the package name of the Android application or the name of the REST application that inserted a dataset:
- Retrieve the dataset.
- Retrieve the data source by reading the
dataset.dataSourceIdproperty. - Read the
dataSources.application.packageNameordataSources.application.nameproperty.
The application property contains these fields:
name- The name of the application.
packageName- The package name of the Android application.
detailsUrl- (Optional) A URI to link to the application.
When you list all available sessions for a time interval in your application, you can use this information to show your users which app inserted each session.
Provide information about your application
To attribute data you insert into the fitness store to your application, ensure that:
- You add your application details to the
dataSources.applicationproperty when creating data sources. - You specify the correct
datasets.dataSourceIdfor your data source when adding points to datasets.
Applications accessing data you inserted can use this information to attribute that data to your application.