Skip to content

Feat/207 integration disconnect delete - #245

Open
Nayira wants to merge 2 commits into
oss-slu:mainfrom
Nayira:feat/207-integration-disconnect-delete
Open

Nayira wants to merge 2 commits into
oss-slu:mainfrom
Nayira:feat/207-integration-disconnect-delete

Conversation

@Nayira

@Nayira Nayira commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Lets users disconnect a health app and permanently delete the data imported from it, from a new "Connected health apps" section in Account Settings, with clear privacy messaging.

Closes #207
Part of #151

Stacked PR: based on #202 (feat/202-integration-architecture), which isn't merged yet. Until it is, this PR also shows the #202 commit. Please review only the top commit, "feat: add disconnect, delete-imported-data and privacy flows (#207)".

Changes Made

  • Added POST /api/v1/users/me/connections/{id}/disconnect. It stops all future imports, keeps already imported data by default, and can delete it in the same step with { "delete_imported_data": true }. Disconnecting twice is not an error.
  • Added DELETE /api/v1/users/me/connections/{id}/measurements, which permanently deletes that connection's imported records and returns deleted_count. Manually entered data is never touched.
  • Both actions are scoped to the signed-in user. Other users' connections return the same 404 CONNECTION_NOT_FOUND as missing ones, so IDs cannot be probed.
  • Both actions work without health consent and with the feature flag off, so users can always withdraw access and remove imported data.
  • Connections now include imported_count.
  • The user data export ([Small Rock] Add user data export and privacy controls #200) now includes connections and imported measurements (schema 1.2), so users can download a copy before deleting.
  • Added a "Connected health apps" section to Account Settings → Privacy and your data. For each connection it shows the provider, status, allowed data types and imported record count, with Disconnect and Delete imported data buttons.
  • Both actions need confirmation:
    • The disconnect dialog offers to delete imported data in the same step.
    • The delete dialog warns that deletion is permanent, and that a still-connected app may import again.
  • The section handles loading, empty, load-failure with retry, success, failure, and connection-no-longer-exists states.
  • Accessibility:
    • Results are announced through status and alert regions.
    • Dialogs open with Cancel focused, close on Escape and keep keyboard focus inside.
    • Focus returns to a sensible place after each action.
    • Buttons have provider-specific accessible names.
  • Extended the shared ConfirmDialog with optional extra content, Escape to cancel, a focus trap and an initialFocus option. Its default behaviour is unchanged.
  • Added translations for English, Spanish, Hindi, Arabic and Chinese, including plural forms. Updated the retention and export text so it no longer says no self-service deletion exists.
  • Updated docs/integrations.md and docs/user-data-export.md.

Testing

  • Full backend test suite passed (89 tests), including 14 new tests covering:
    • disconnecting, with and without deletion
    • disconnecting twice
    • deleting only one connection's records
    • deleting when there is nothing to delete
    • ownership (404 for other users)
    • malformed IDs
    • working without consent or the flag
    • authentication
    • reconnecting
    • the export section
  • Full frontend test suite passed (209 tests), including 24 new tests covering every state, both flows, keyboard behaviour, Arabic right-to-left with plural forms, and a check that every locale has every connected-apps string.
  • Frontend lint and production build passed.
  • All 5 locale files validated as JSON.

Checklist

  • The code follows project conventions
  • Documentation has been updated if needed
  • No sensitive information is included
  • Breaking changes are clearly documented
  • Reviewers have enough context to review this PR

Additional Notes

  • There is no "connect a provider" screen yet. That belongs to the provider and device integration issues under [Big Rock] Add optional connected-health integrations #151. Until then, the section shows its empty state for real users.
  • To try the flows locally, set INTEGRATIONS_ENABLED=true, grant a connection and import sample values through /docs, then open Account Settings.
  • Deleting imported data does not change anything in the provider's own app.
  • No breaking changes. The export schema_version moves from 1.1 to 1.2, adding a new integrations section.

Part of oss-slu#151. Define the integration boundary, provenance and permission
rules for optional connected-health imports:

- IntegrationConnection stores a user's explicit, read-only grant per
  provider and measurement type; allows() is the permission check.
- ImportedMeasurement requires provider, connection, unit and
  recorded_at so every value keeps its source and timestamp.
- integrations.py holds the provider registry and adapter protocol so
  pages and endpoints never depend on provider-specific code.
- INTEGRATIONS_ENABLED flag (off by default) keeps integrations optional.
- Endpoints to list providers, list own connections, and grant a
  connection, with tests and docs/integrations.md.
…#207)

Give users control over connected-health data:

- POST /users/me/connections/{id}/disconnect revokes access, optionally
  deleting imported data in the same step.
- DELETE /users/me/connections/{id}/measurements removes a connection's
  imported records and reports how many were deleted.
- Both are scoped to the signed-in user (404 otherwise) and are not
  gated by health consent or the integrations flag.
- Connections now report imported_count, and the data export (schema
  1.2) includes connections and imported measurements.
- Account Settings gains a Connected health apps section with
  confirmation dialogs and loading, empty, success and failure states,
  localized in all five languages.
- ConfirmDialog supports extra content, Escape to cancel, a focus trap
  and focusing Cancel first for destructive actions.
@sonarqubecloud

Copy link
Copy Markdown

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.

[Small Rock] Add disconnect, delete-imported-data, privacy, and test flows

1 participant