Skip to content

feat: Sync External Activities via Strava Webhook (Pull) #173

Description

@SoNdA11

Description:
Currently, the system already authenticates via OAuth2 and exports natively recorded workouts to Strava. To build an accurate performance analysis model (calculating CTL, fatigue, and weekly volume), the software needs a holistic view of the athlete's efforts.

This issue aims to implement the retrieval of Strava data into our local database, capturing activities not performed directly within the Argus Cyclist app (such as Zwift workouts or outdoor rides).

Objectives:

  • Register a Webhook with the Strava API for the Argus Cyclist application.
  • Receive asynchronous notifications for new activities.
  • Fetch the detailed metrics of these activities and persist them in our local database.
  • Prevent data duplication for round-trip workouts (upload via Argus -> Strava Webhook -> Argus).

Implementation Checklist:

Webhooks & Backend (Go):

  • Create an HTTP callback endpoint for Strava to validate the Webhook creation (initial handshake via GET).
  • Create an HTTP endpoint to receive Event Updates (JSON payload via POST) sent by Strava.
  • Implement queues or goroutines for asynchronous processing of received webhooks, acknowledging and releasing the Strava request quickly (return 200 OK immediately).

Integration & Business Logic (internal/service/strava/):

  • Create a GET /activities/{id} request function for the Strava API to fetch the summary and main metrics of the activity received in the webhook.
  • Deduplication: Implement logic to ignore creation webhooks for workouts that Argus Cyclist itself just uploaded (e.g., check device ID, source application name, or match timestamp/duration).

Persistence & Domain (internal/domain/ and internal/service/storage/):

  • Write a parser/adapter to convert the Strava activity JSON to the internal domain.Workout struct.
  • Persist the workout in the local SQLite database to be accounted for in the statistics dashboard.

Acceptance Criteria:

  • Upon finishing an outdoor ride or using a third-party simulator, the Strava notification is successfully received and processed in the background.
  • The new workout appears consolidated in the statistics dashboard and app history without requiring any manual trigger from the user.
  • A workout executed natively in Argus Cyclist and exported to Strava does not cause a duplication of the training load in the local database.Here are the English translations for the Milestone and the complete Issue, formatted and ready for you to copy and paste into your repository.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status
Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions