As for which types support this capability, check out the HKLiveWorkoutDataSource and inspect the types to collect property. You'll find that the types described by @DTS Engineer are consistent with this approach to double check.
Looking at a workout that Apple Activity app recorded, the 'effort sample' start and stop date are consistent with the workout duration.
Estimated effort score (3).
Start 9:08:21 PM
End 9:32:15 PM
Saved 9:32:15 PM
Workout
Start 9:08:20 PM
End 9:32:15 PM
Saved 9:32:20 PM
If I find some time I'll inspect the milliseconds for these dates and identify the exact order.
I'm curious of there is a timing issue between stopping a workout session, stopping the builder, and ending the session. Like it generates a sample AFTER the builder collection has completed and then gets dropped. It is not exactly easy to record a real workout with the debugger attached or firing up console to sniff out logs. I plan to rewrite all of my code using the async flavor of the APIs where possible instead of nested closures to see if that makes a difference. I can't wait for HKWorkoutSession and HKWorkoutBuilder to be actors and fully async (hopefully in the future)!
FB15315876 - Documentation / HealthKit: Publish documentation about .workoutEffortScore and .estimatedWorkoutEffortScore
Topic:
App & System Services
SubTopic:
Health & Fitness
Tags: