Intervals.icu now supports custom activity fields either manually captured, computed using JavaScript code or read from FIT files. This is the first giant leap towards a programmable Intervals.icu!
You can click the play button to execute your script in the context of the selected activity to test.
The script has access to the following objects:
- activity: the activity being analysed
- athlete: for the activity
- streams: the power, heart rate and so on traces for the activity
- sportSettings: for the sport of the activity
- field: the field being evaluated
- icu: Provides access to other things loaded on demand
The icu object provides:
- wellness: for the day of the activity
- powerCurve (power duration curve)
- powerCurveFatigued0 (power curve after some KJ of work done)
- powerCurveFatigued1 (power curve after more KJ of work done)
- hrCurve (heart rate duration curve)
- paceCurve (distance vs time curve)
- gapCurve (distance vs time using gradient adjusted pace)
The last expression in the script is the value stored for the field. The script can also update many fields on the activity which are also saved (e.g. icu_training_load for a custom load calc).
{
let v = .. custom training load calc ..
activity.icu_training_load = v
v
}
Variables are implicitly declared. Don’t use ‘let’ or ‘var’ etc… The scrips for all fields for an activity share the same sandbox this fails if they declare variables.
If you do need to declare things wrap the script in a block:
{
let factor = 2
activity.average_stride * factor
}
The JavaScript code runs in a sandbox on the server when the activity is analysed. If anyone figures out how to escape that sandbox I want to know first!
The data model is here:
This post has more info on custom activity fields:
Similar functionality is available for interval fields:
You can plot custom activity fields on the fitness and compare pages. If there are multiple activities on the same day then values are combined according to the aggregate setting on the description tab:
You can map custom activity fields to session fields from the FIT file:
You can write scripts that directly process all the fit file messages:
Activity (and custom fields in general) can be converted before they are displayed. Fields with values in meters/second, meters and seconds are supported: