ActivityInsights
Comprehensive analytics data for a time window of activities, including aggregated statistics, trends, and visualizations.
Start of the analysis time window
End of the analysis time window
Whether the data is incomplete for the window
Daily activity data for heatmap visualization
View model for rendering heatmap UI
Total number of activities in the window
Total distance covered in miles
Total hours spent moving across all activities
Total elevation gain in meters
Total kudos received across all activities
Current active streak in days
Longest streak achieved in days
Weekly training volume breakdown
trainingRhythm
[TrainingRhythmCell]
required
Heatmap of training patterns by weekday and hour
Maximum activity count in any training rhythm cell
typeBreakdown
[ActivityTypeBreakdown]
required
Distribution of activities by type
Days with highest metrics
Individual activities with standout performance
Pace data points for trend analysis (default: [])
Effort/suffer score data points (default: [])
Weekly effort metrics (default: [])
Example
let insights = ActivityInsights(
windowStart: startDate,
windowEnd: endDate,
isPartial: false,
heatmapDays: heatmapData,
heatmapView: viewModel,
totalActivities: 145,
totalMiles: 523.4,
totalMovingHours: 68.5,
totalElevationGainMeters: 12450.0,
totalKudos: 892,
currentStreakDays: 12,
longestStreakDays: 34,
weeklyVolumes: volumes,
trainingRhythm: rhythmData,
maxRhythmCount: 15,
typeBreakdown: breakdown,
peakDays: peaks,
peakActivities: topActivities,
pacePoints: paceData,
effortPoints: effortData,
weeklyEffort: weeklyEffortData
)
Show ActivityTypeBreakdown
Distribution statistics for a specific activity type.Number of activities of this type
Percentage share of total activities (0.0 to 1.0)
let breakdown = ActivityTypeBreakdown(
type: .run,
activityCount: 45,
share: 0.31
)
Activity data for a specific weekday and hour combination.Day of week (1 = Sunday, 7 = Saturday)
Number of activities started in this time slot
Total moving time in seconds
let cell = TrainingRhythmCell(
weekday: 3, // Tuesday
hour: 17, // 5 PM
activityCount: 8,
movingSeconds: 14400
)
Training volume metrics for a single week.Start date of the week (typically Monday)
Total miles covered during the week
Number of days with at least one activity
Total activities during the week
let volume = WeeklyVolume(
weekStart: weekDate,
miles: 45.2,
activeDays: 5,
activityCount: 7
)
A day with exceptional metrics (implements Identifiable).String identifier for the date (also serves as id)
Number of activities completed
Total elevation gain in meters
let peakDay = PeakDay(
date: Date(),
dateKey: "2024-01-15",
miles: 26.2,
activityCount: 1,
elevationGainMeters: 450.0,
kudosCount: 42
)
print(peakDay.id) // "2024-01-15"
A single activity with standout performance (implements Identifiable).Type of activity (optional)
let peakActivity = PeakActivity(
id: 123456789,
name: "Morning Marathon",
date: Date(),
miles: 26.2,
elevationGainMeters: 450.0,
kudosCount: 42,
movingTimeSeconds: 9360,
activityType: .run
)
Pace data for a single activity, used in pace trend charts.Average pace in seconds per mile
Distance covered in miles
Type of activity (default: nil)
let pacePoint = PacePoint(
date: Date(),
paceSecondsPerMile: 480.0, // 8:00 min/mile
activityName: "Tuesday Tempo Run",
miles: 6.2,
activityType: .run
)
Suffer score data for a single activity.Strava suffer score indicating effort level
let effortPoint = EffortPoint(
date: Date(),
sufferScore: 142,
activityName: "Hill Repeats"
)
Aggregated effort metrics for a week.Sum of suffer scores for all activities
Number of activities with suffer scores
let weeklyEffort = WeeklyEffort(
weekStart: weekDate,
totalSufferScore: 845,
activityCount: 6
)