Overview
ActivityInsightsBuilder is an enum that provides static methods to build ActivityInsights from collections of Strava activities. It aggregates activity data into various metrics including heatmaps, streaks, weekly volumes, training rhythms, and peak performances.
Methods
build
Builds complete activity insights from an array of Strava activities.Parameters
Array of Strava activities to analyze. Activities outside the time window will be filtered out.
End date of the analysis window. Defaults to the current date.
Number of days to include in the analysis window, counting backwards from
windowEnd.Number of weeks to display in the heatmap view.
Maximum number of peak days to include in the results.
Maximum number of peak activities to include in the results.
Returns
A comprehensive insights object containing aggregated metrics and analytics.
Example
buildPartial
Builds partial activity insights from pre-computed heatmap data. This method provides limited insights when full activity data is unavailable.Parameters
Pre-computed daily activity aggregations
End date of the analysis window
Number of days to include in the analysis window
Number of weeks to display in the heatmap view
Maximum number of peak days to include
Returns
A partial insights object with
isPartial set to true. The following fields will have default/empty values:totalMovingHours: 0totalElevationGainMeters: 0totalKudos: 0trainingRhythm: empty arraymaxRhythmCount: 0typeBreakdown: empty arraypeakActivities: empty arraypacePoints: empty arrayeffortPoints: empty arrayweeklyEffort: empty array
Example
Notes
- All distance values are converted from meters to miles using the conversion factor 1609.344 meters per mile
- Elevation gain is converted from meters to feet using the conversion factor 3.28084 feet per meter
- Activities are filtered by local start date to ensure correct timezone handling
- Training rhythm uses UTC calendar to properly extract hour and weekday from Strava’s local time format
- Pace points only include activities with distance > 500 meters and positive moving time
- Effort points only include activities with available suffer scores
- Streaks count consecutive days with at least one activity