Hi,
I’m trying to create custom activity fields that automatically read data from a labelled interval within an activity.
For example, I have an interval in the activity timeline labelled:
tramo_control_z2
The interval is correctly displayed in the activity and contains valid data, such as:
- Elapsed time: 19:20
- Average power: 233 W
- Average heart rate, etc.
My goal is for a custom activity field to find that interval by its label and retrieve values such as elapsed time, average power, EF, RPP, etc.
I tried the following code:
{
let duration
for (let iv of activity.icu_intervals) {
if (iv.label === "tramo_control_z2") {
duration = iv.elapsed_time
break
}
}
duration
}
However, it always returns nothing.
On the other hand, if I access the interval by its position, it works correctly:
{
activity.icu_intervals && activity.icu_intervals[1]
? activity.icu_intervals[1].elapsed_time
: null
}
This returns the expected value (19:20).
So it seems that:
activity.icu_intervalsexists.- The correct interval is inside
activity.icu_intervals. elapsed_timeworks correctly.- But I can’t identify the interval using
iv.label.
I’ve also re-analysed the activity several times while keeping the intervals.
My questions are:
- Is
iv.labelthe correct property to access the visible interval label? - Should
iv.labelwork inside a custom activity field? - Is there a way to inspect or print all the properties of an interval (for example,
activity.icu_intervals[1])? - Is there any documentation listing all the available properties for
activity,activity.icu_intervals, and the interval objects?
Thank you very much!