Skip to content

feat(polar): ✨ adding Polar Flow #52#134

Open
dvorka wants to merge 1 commit into
dev/1.58.0from
feat-52/polar-flow
Open

feat(polar): ✨ adding Polar Flow #52#134
dvorka wants to merge 1 commit into
dev/1.58.0from
feat-52/polar-flow

Conversation

@dvorka

@dvorka dvorka commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

This PR brings Polar Flow integration.

Related:

@dvorka dvorka self-assigned this Jul 5, 2026
Copilot AI review requested due to automatic review settings July 5, 2026 20:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Polar Flow integration to MyTraL, covering both incremental sync of newly recorded exercises via Polar AccessLink (transaction model) and historical backfill via the Polar GDPR export ZIP, integrated into the UI, background tasks, and import plugin architecture.

Changes:

  • Added Polar Flow AccessLink API client + OAuth flow, plus tasks to sync new activities and purge/re-sync.
  • Added Polar GDPR export ZIP parser + import task, wired into Tools > Import UI.
  • Added activity-type mapping for Polar sports, feature-flag gating, and a test suite covering credentials, rate limiting, transaction semantics, import mapping, and dedup.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test_tool_polar_flow.py New tests for Polar Flow client/task utilities (credentials, rate-limit backoff, transaction behavior, dedup).
tests/test_plugin_import_polar_flow.py New tests validating plugin mappings for API summaries and GDPR export sessions.
mytral/templates/tools-import.html Adds Polar Flow as an import source plus GDPR export ZIP upload UI (feature-flagged).
mytral/templates/polar-flow-secrets.html New page for configuring Polar Flow client credentials.
mytral/templates/polar-flow-developer.html New developer dashboard for Polar Flow auth status and sync actions.
mytral/templates/layout.html Adds a Polar Flow navbar shortcut icon when feature-flagged and configured.
mytral/tasks/do/polar_flow_sync.py New background task to sync newly available Polar exercises via transactions.
mytral/tasks/do/polar_flow_resync_all.py New background task to purge all Polar-sourced activities and re-pull from AccessLink.
mytral/tasks/do/polar_flow_export_import.py New background task to import historical data from a GDPR export ZIP.
mytral/tasks/do/polar_flow_commons.py Shared sync/pull utilities including recording import and cross-channel dedup.
mytral/settings.py Extends UserProfile persistence model to store Polar Flow credentials/linking fields.
mytral/run.py Registers the new Polar Flow URI space blueprint in the server entrypoint.
mytral/run_desktop.py Registers the new Polar Flow URI space blueprint in the desktop entrypoint.
mytral/releng.py Adds POLAR_FLOW_IMPORT feature flag (default off).
mytral/integrations/polar_flow.py New Polar AccessLink client + OAuth helpers + import plugins for API summaries.
mytral/integrations/polar_flow_export.py New GDPR export ZIP/directory parser that normalizes sessions to AccessLink-like summaries.
mytral/integrations/icommons.py Adds Polar sport-to-activity-type mapping helper.
mytral/forms.py Adds forms for Polar secrets configuration and GDPR export ZIP upload + conflict strategy.
mytral/blueprints/polar_flow_uri_space.py New Polar Flow routes for secrets, auth, sync, resync, and export import task submission.
mytral/blueprints/import_uri_space.py Wires the new Polar export form into the import page rendering context.
docs/ARCHITECTURE.md Updates architecture docs to include Polar Flow as an external integration.
CREDITS.md Adds attribution for Polar AccessLink example repo used as a reference.
CHANGELOG.md Adds release notes describing the new Polar Flow integration and feature flag.

Comment on lines +111 to +114
if flask.request.method == "POST" and form.validate_on_submit():
user_profile.polar_flow_client_id = form.client_id.data.strip()
user_profile.polar_flow_client_secret = form.client_secret.data.strip()
ds.update_profile(user_profile)
Comment on lines +259 to +264
logger.debug("Polar auth-code exchange succeeded")
user_profile.polar_flow_access_token = str(tokens["access_token"])
if tokens.get("x_user_id"):
user_profile.polar_flow_user_id = str(tokens["x_user_id"])
ds.update_profile(user_profile)

Comment on lines +33 to +35
<p class="mb-0">
Your secrets are stored encrypted on disk and are <strong>never</strong> displayed again after saving.
</p>
Comment thread docs/ARCHITECTURE.md
## External Integrations & Plugins

MyTraL integrates with external ecosystems through `integrations/*` and `plugins.py`, including Strava and other import/sync sources used by both direct import routes and background tasks. This component adapts third-party payloads to internal entities so downstream analytics and UI features remain consistent.
MyTraL integrates with external ecosystems through `integrations/*` and `plugins.py`, including Strava, Polar (both the legacy Precision Performance `.hrm`/`.pdd` files and Polar Flow via the AccessLink API plus the GDPR data export ZIP), and other import/sync sources used by both direct import routes and background tasks. This component adapts third-party payloads to internal entities so downstream analytics and UI features remain consistent. See `POLAR_FLOW.md` for the Polar Flow design.
Comment thread CHANGELOG.md
Comment on lines +11 to +16
- Added a Polar Flow integration: sync new training from Polar Flow
(flow.polar.com) via the official Polar AccessLink API (transaction model, no
duplicates), and backfill full history from the Polar "Download your data"
(GDPR) export ZIP. Gated behind the `MYTRAL_FF_POLAR_FLOW_IMPORT` feature flag.
See `POLAR_FLOW.md` for the design and setup steps. This is separate from the
existing Polar Precision Performance (.hrm/.pdd) import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants