[Enhancement] Add missing Strava API fields to Activity model
Description
Currently, the Activity.attrs_from_strava method only captures a subset of the fields available in the Strava API v3 activity response. Many potentially valuable fields are being ignored that could enhance the functionality and user experience of slack-strava.
Context
After reviewing the official Strava API v3 documentation, I identified numerous fields that are available in the API response but not currently captured in our attrs_from_strava method in slack-strava/models/activity.rb.
Current State
The current implementation captures these fields:
- ✅
strava_id,name,calories,distance,moving_time,elapsed_time - ✅
average_speed,max_speed,average_heartrate,max_heartrate - ✅
pr_count,type,total_elevation_gain,private,visibility,description
Missing Fields
High Priority (Potentially High Value)
-
trainer- Boolean indicating indoor trainer activity -
commute- Boolean indicating commute activity -
device_name- Name of device used to record activity -
elev_high/elev_low- Elevation high/low points -
start_latlng/end_latlng- Start/end coordinates -
timezone- Activity timezone -
workout_type- Workout type classification
Medium Priority (Social/Engagement)
-
achievement_count- Number of achievements on segments -
kudos_count- Number of kudos received -
comment_count- Number of comments -
photo_count/total_photo_count- Photo counts
Lower Priority (Power/Advanced Metrics)
-
average_watts/max_watts/weighted_average_watts- Power metrics -
kilojoules- Energy expenditure -
device_watts- Boolean indicating power meter vs estimated -
average_cadence- RPM data -
average_temp- Temperature data -
has_heartrate- Boolean indicating HR data presence -
suffer_score- Heart rate intensity (premium only)
Metadata
-
manual- Boolean indicating manual entry -
flagged- Boolean indicating flagged activity -
embed_token- Token for embedding activities -
gear_id- Associated gear identifier -
has_kudoed- Boolean for authenticated athlete interaction
Potential Benefits
Adding these fields could enable:
- Enhanced Activity Display: Show trainer/commute status, device used, elevation data
- Social Features: Display kudos count, comments, achievements in Slack messages
- Better Filtering: Filter out trainer activities, commute activities, etc.
- Advanced Analytics: Power data, cadence, temperature for serious athletes
- Improved UX: Show photo counts, workout types, elevation profiles
Implementation Approach
Phase 1: Core Enhancement Fields
- Add high-priority fields to
Activitymodel - Update
attrs_from_stravamethod to include these fields - Consider database migration for existing data
- Update display logic to show relevant fields
Phase 2: Social/Engagement Fields
- Add social engagement fields (
kudos_count,comment_count, etc.) - Update Slack message formatting to optionally display these
Phase 3: Advanced Metrics
- Add power and advanced sensor data fields
- Consider conditional display based on team settings
Acceptance Criteria
- [ ] Review and prioritize which fields to add based on user value
- [ ] Add selected fields to
Activitymodel with appropriate types - [ ] Update
attrs_from_stravamethod to capture new fields - [ ] Ensure backward compatibility with existing data
- [ ] Add tests for new field extraction
- [ ] Update documentation if needed
- [ ] Consider whether any fields should be displayed in Slack messages
Questions for Discussion
- Which fields would provide the most value to users?
- Should we add all fields at once or implement in phases?
- Are there any fields that might have privacy implications?
- Should any of these fields be displayed in Slack messages by default?
- Do we need database migrations for existing activities?
References
- Strava API v3 Activities Documentation
- Current implementation:
slack-strava/models/activity.rb:53-71
Device and gear added in https://github.com/dblock/slack-strava/commit/a7853f1cc923cd369ee2cec8d5b69afd3c701f08.