Apple Healthkit sleep data includes two different data types: "InBed" and "Asleep". The iPhone itself can only track time in bed (value: InBed) while the Apple Watch tracks time asleep (Value: Asleep) and also in bed.
A visual representation of the two Apple sleep data types:
The iPhone calculates "InBed" by analyzing your motion and device usage, using the parameters the user sets in the Apple BedTime app. The Apple Watch calculates "Asleep" time using movement and also your heart rate. By comparing the start and end times of these samples, a number of secondary statistics can be calculated by projects: the amount of time it took for the user to fall asleep, the percentage of time in bed that the user actually spent sleeping, the number of times the user woke while in bed, and the total amount of time spent both in bed and asleep.
3rd party (non-Apple) applications can also write data to the "InBed" or "Asleep" Apple Healthkit variables (using sensors and methodology of their choosing). However, the source "identifier" listed in RKStudio (i.e. in the participant viewer Apple Healthkit tab) would be different - that is, iOS first-party should have an identifier “com.apple.Health” or “com.apple.Health.(random identifier)”. An example of a 3rd party app would be “com.tenminutewait.PinnacleApp” (a workout app called Pinnacle).
Note that as of the date of this article, Apple does not track sleep stages (i.e. light, deep, REM). If you are conducting a study that requires this level of granularity, we recommend researching FitBit devices.