slack-strava icon indicating copy to clipboard operation
slack-strava copied to clipboard

[Enhancement] Add missing Strava API fields to Activity model

Open dblock opened this issue 6 months ago • 1 comments

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:

  1. Enhanced Activity Display: Show trainer/commute status, device used, elevation data
  2. Social Features: Display kudos count, comments, achievements in Slack messages
  3. Better Filtering: Filter out trainer activities, commute activities, etc.
  4. Advanced Analytics: Power data, cadence, temperature for serious athletes
  5. Improved UX: Show photo counts, workout types, elevation profiles

Implementation Approach

Phase 1: Core Enhancement Fields

  1. Add high-priority fields to Activity model
  2. Update attrs_from_strava method to include these fields
  3. Consider database migration for existing data
  4. Update display logic to show relevant fields

Phase 2: Social/Engagement Fields

  1. Add social engagement fields (kudos_count, comment_count, etc.)
  2. Update Slack message formatting to optionally display these

Phase 3: Advanced Metrics

  1. Add power and advanced sensor data fields
  2. Consider conditional display based on team settings

Acceptance Criteria

  • [ ] Review and prioritize which fields to add based on user value
  • [ ] Add selected fields to Activity model with appropriate types
  • [ ] Update attrs_from_strava method 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

  1. Which fields would provide the most value to users?
  2. Should we add all fields at once or implement in phases?
  3. Are there any fields that might have privacy implications?
  4. Should any of these fields be displayed in Slack messages by default?
  5. Do we need database migrations for existing activities?

References

dblock avatar Jul 13 '25 21:07 dblock

Device and gear added in https://github.com/dblock/slack-strava/commit/a7853f1cc923cd369ee2cec8d5b69afd3c701f08.

dblock avatar Oct 14 '25 19:10 dblock