robiningelbrecht / strava-activities-template
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 40
Watchers: 3
Forks: 0
Open Issues: 4
Language:HTML
Requires
- php: ^8.2
- ext-json: *
- doctrine/dbal: ^3.7
- doctrine/migrations: ^3.6
- doctrine/orm: ^2.16
- guzzlehttp/guzzle: ^7.0
- lcobucci/clock: ^2.2
- league/flysystem: ^3.0
- nesbot/carbon: ^2.67
- php-di/php-di: ^6.4
- php-di/slim-bridge: ^3.2
- ramsey/uuid: ^4.3
- slim/psr7: ^1.5
- slim/slim: ^4.11
- symfony/cache: ^7.0
- symfony/console: ^7.0
- symfony/finder: ^7.0
- thecodingmachine/safe: ^2.2
- twig/twig: ^3.4
- vlucas/phpdotenv: ^5.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^10.0
- spatie/phpunit-snapshot-assertions: ^5.0
This package is auto-updated.
Last update: 2024-12-16 13:39:17 UTC
README
Strava activities template
This repository is deprecated. Please use the new docker image: https://github.com/robiningelbrecht/strava-statistics
This repository contains the template code to generate your own Strava statistics pages. Just follow the steps below. If you experience any issues with any of the steps, feel free to open an issue. I'll be glad to help you out 💅.
🦄 Examples
- Markdown version: https://github.com/robiningelbrecht/strava-activities
- HTML version: https://strava-statistics.robiningelbrecht.be/
🪄 What you'll need
- A Strava API key
- A GitHub account
🛠️ Installation
- Make sure your logged in with your GitHub account
- Start off by showing some ❤️ and give this repo a star
- Create a new repository using this template by clicking HERE and filling out the required fields
- Navigate to your newly created repository
Actions secrets and variables
page (https://github.com/[YOUR-GITHUB-USERNAME]/[REPOSITORY-NAME]/settings/secrets/actions) Keep this page open, you will need to add several secrets here - Next, navigate to your Strava API settings page.
Copy the
client ID
andclient secret
- Create two new repository secrets
- name: STRAVA_CLIENT_ID, value:
client ID
copied from Strava API settings page - name: STRAVA_CLIENT_SECRET, value:
client secret
copied from Strava API settings page
- name: STRAVA_CLIENT_ID, value:
- Now you need to obtain a
Strava API refresh token
. This might be the hardest step.- Navigate to https://developers.strava.com/docs/getting-started/#d-how-to-authenticate and scroll down to "For demonstration purposes only, here is how to reproduce the graph above with cURL:"
- Follow the 11 steps explained there
- Make sure you set the
scope
in step 2 toactivity:read_all
to make sure your refresh token has access to all activities - Create a repository secret with the refresh token you obtained: name: STRAVA_REFRESH_TOKEN, value: The
refresh token
you just obtained
- You should end up with these repository secrets:
- After this you need to make sure the automated workflow is able to push changes to your repo.
- Navigate to https://github.com/[YOUR-GITHUB-USERNAME]/[REPOSITORY-NAME]/settings/actions
- Scroll down to
Workflow permissions
and make sureRead and write permissions
is checked
- The last thing you need to do is edit the workflow files
update-strava-activities.yml
,update-ftp.yml
andupdate-key-value-store.yml
:-
Navigate to https://github.com/[YOUR-GITHUB-USERNAME]/[REPOSITORY-NAME]/edit/master/.github/workflows
-
Uncomment line 4 and 5 by removing the
#
character -
Scroll down to:
name: Initialize GIT run: | git config --global user.name 'YOUR_GITHUB_USERNAME' git config --global user.email 'YOUR_GITHUB_USERNAME@users.noreply.github.com'
- Replace
YOUR_GITHUB_USERNAME
with your own username - Click
commit changes
at the top right-hand corner
- Replace
-
Do this again for the other 2 files
-
Configuration
Before running the first activity import, you need to
!!! It's important you wait until a workflow is done, before running another one !!!
- Set your birthday. This is required to 1) accurately calculate the intensity of your activities
in case no power data is available, 2) determine your heart rate zones
- Navigate to https://github.com/[YOUR-GITHUB-USERNAME]/[REPOSITORY-NAME]/actions/workflows/update-key-value-store.yml
- Fill out your birthday using date format
YYYY-MM-DD
and run the workflow
- (Optional, but recommended) Configure your FTP (= Functional Threshold Power) history.
- Navigate to https://github.com/[YOUR-GITHUB-USERNAME]/[REPOSITORY-NAME]/actions/workflows/update-ftp.yml
- Fill out the FTP and the date (
YYYY-MM-DD
) you've set the FTP on and run the workflow - Do this for every FTP you've set
- (Optional) Strava does not allow to fetch all your completed challenges and trophies (see Some things to consider),
but there's a little workaround if you'd like to import those:
- Navigate to https://www.strava.com/athletes/[YOUR_ATHLETE_ID]/trophy-case
- Open the page's source code and copy everything
- Next navigate to https://github.com/[YOUR-GITHUB-USERNAME]/[REPOSITORY-NAME]/edit/master/files/strava-challenge-history.html
- Paste the source code you just copied and
commit changes
at the top right-hand corner - On the next run of the
import activities
workflow, all your challenges will be imported
☁️ Hosting the HTML version
There's also a HTML versions available with a lot more features. You can easily host this for free on https://vercel.com:
- Create an account and login
- Make sure your connect to your GirHub account (https://vercel.com/account/login-connections)
- Create a new project and reference your repository
- For the
Framework preset
setting useOther
- Make sure the
Root directory
is set tobuild/html
- You can uncheck the option
Include source files outside of the Root Directory in the Build Step.
- You should be good to go
🧐 Some things to consider
- Any new feature or update added to the template, will automatically end up in your repository 🪄
- Only (virtual) bike rides are imported, other sports are not relevant for these stats
- Because of technical (Strava) limitations, not all Strava challenges can be imported. Only the visible ones on your public profile can be imported (please be sure that your profile is public, otherwise this won't work)
- Strava statistics will be re-calculated once a day. If you want to
re-calculate these manually, navigate to https://github.com/[YOUR-GITHUB-USERNAME]/[REPOSITORY-NAME]/actions/workflows/update-strava-activities.yml
and click
Run workflow
at the right-hand side - Running the import for the first time can take a while, depending on how many activities you have on Strava. Strava's API has a rate limit of 100 request per 15 minutes and a 1000 requests per day. We have to make sure this limit is not exceeded. See https://developers.strava.com/docs/rate-limits/. If you have more than 500 activities, you might run into the daily rate limit. If you do so, the app will import the remaining activities the next day(s).
- If you get following error
App\Infrastructure\Exception\EntityNotFound: KeyValue "athlete_birthday" not found
, it means that you have not set your birthday. Run the "Update athlete birthday" workflow
❌ Getting errors while updating FTP / KeyValue store?
This is because I introduced breaking changes without realising it. Yeah, I know stupid. GitHub does not allow you to automatically update workflow files from a template, so you'll have to do this manually.
Update the following files in your own repository to the latest versions:
- https://github.com/robiningelbrecht/strava-activities-template/blob/master/.github/workflows/update-ftp.yml
- https://github.com/robiningelbrecht/strava-activities-template/blob/master/.github/workflows/update-key-value-store.yml
💡 Feature request?
For any feedback, help or feature requests, please open a new issue
💻 Local development
If you want to add features or fix bugs yourself, you can do this by setting up the project on your local machine. Just clone this git repository and you should be good to go.
The project can be run in a single Docker
container which uses PHP.
There's also a Make
file to... make things easier:
# Run a docker-compose command. make dc cmd="run" # Run "composer" command in the php-cli container. make dcr cmd="composer" # Run an app console command make console arg="app:some:command" # Run the test suite. make phpunit # Run PHPStan make phpstan
For other useful Make
commands, check Makefile
📓 Change Log
All notable changes to this project will be documented in this file.
[2023-01-17]
- Added hours of riding to weekly stats chart
- Fixed bug where importing of segments crashed on first run (thanks to dylix for reporting)
[2023-01-13]
- Added yearly stats
[2023-01-05]
- Refactored activity and segment overview to be way faster
[2023-01-01]
- Added first version of heatmap
[2023-12-28]
- Show segments in activity modal
- Several small improvements and bug fixes
[2023-12-24]
- Fix bug where rendering of HTML crashed on non-Zwift virtual activities. (thanks to pdoteter)
[2023-12-23]
- Delete orphaned activities (thanks to mdleye)
[2023-12-21]
- Split up database into multiple databases, one for each year there is data for. (thanks to pdoteter for testing with huge dataset)
[2023-12-19]
- Render and display segments and efforts
[2023-12-18]
- Reduced DB size by over 50%
- Import and process segments
[2023-12-03]
- Added challenge consistency table (thanks to rubenbuysse)
[2023-12-01]
- Added a monthly calendar view for activities
- Fixed bug in router
[2023-11-25]
- Moved gear stats to separate page
[2023-11-18]
- Added Power and heart rate distribution charts
[2023-11-13]
- Changed activity drawer with modal
[2023-11-09]
- Added average speed and distance to multiple stats
[2023-11-07]
- Allow to import challenge/trophy case history
- Fix import of double challenges
[2023-11-04]
- Better masonry layout
- Show number of photos on tabs
- Fixed workflow database errors (thanks to mdleye)
[2023-11-02]
- Added "Time in heart rate zone" charts
- Optimized existing charts
[2023-10-30]
- Render FTP history chart
[2023-10-29]
- Show FTP history
- More accurate calculation of activity intensity
[2023-10-26]
- Better moving time formatting
[2023-10-25]
- Added better tooltips to charts
[2023-10-25]
- Show longest consecutive streak
[2023-10-24]
- Added activity stream chart in activity drawer
[2023-10-21]
- Migrated weather data to separate field
[2023-10-20]
- Added distance breakdown table
- Added daytime stats
- Monthly stats: filter out months that have no activities (thanks to mdleye)
- Add sorting to the activity list
- Reworked weekday stats
[2023-10-19]
- Fixed bug when deploying new template version
[2023-10-15]
- Initial stable release of the template
[2023-10-12]
- Bug fixes while importing large sets of Strava activities (thanks to rubenbuysse for testing)