Skip to content

feat: add setIgnoredSources for Apple Health source filtering#16

Open
terra-alex wants to merge 1 commit into
mainfrom
feat/add-set-ignored-sources
Open

feat: add setIgnoredSources for Apple Health source filtering#16
terra-alex wants to merge 1 commit into
mainfrom
feat/add-set-ignored-sources

Conversation

@terra-alex

Copy link
Copy Markdown
Contributor

Summary

  • Adds TerraFlutter.setIgnoredSources(List<String>) to the Dart API
  • iOS bridge calls Terra.setIgnoredSources() from TerraiOS SDK
  • Android bridge returns success as a no-op (iOS-only feature)

Test plan

  • iOS: call setIgnoredSources(["com.whoop.app"]) after initTerra, verify WHOOP-sourced HealthKit data is excluded
  • Android: call setIgnoredSources, verify it completes without error
  • Verify method channel name "setIgnoredSources" matches across Dart/iOS/Android

Claude conversation: /Users/alex/Documents/terra-support-agent

🤖 Generated with Claude Code

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new feature to the Terra Flutter bridge, enabling the filtering of Apple Health data sources by specifying bundle identifiers to be ignored. This functionality is fully implemented for iOS, integrating with the native TerraiOS SDK, while providing a compatible no-op implementation for Android to maintain cross-platform consistency. Additionally, several older methods have been marked for deprecation.

Highlights

  • New setIgnoredSources method: A new static method setIgnoredSources has been added to the TerraFlutter class in Dart, allowing the specification of Apple Health data sources to be ignored.
  • iOS Implementation: The iOS bridge now includes a private function setIgnoredSources that calls the underlying TerraiOS SDK to filter HealthKit data based on provided bundle identifiers.
  • Android No-op: On Android, the setIgnoredSources method is implemented as a no-op, returning a successful result without performing any action, as this feature is iOS-specific.
  • Method Deprecations: Several existing methods related to glucose sensor activation, glucose data reading, and planned workouts have been marked as deprecated in the Dart API.
Changelog
  • android/src/main/java/co/tryterra/terra_flutter_bridge/TerraFlutterPlugin.java
    • Added a new case for the 'setIgnoredSources' method call, returning a successful no-op result.
  • ios/Classes/SwiftTerraFlutterPlugin.swift
    • Implemented a private setIgnoredSources function that calls the TerraiOS SDK with the provided sources.
    • Integrated the setIgnoredSources function into the main handle method to process Flutter method calls.
  • lib/terra_flutter_bridge.dart
    • Added a new static method setIgnoredSources to TerraFlutter for filtering HealthKit data on iOS.
    • Marked activateGlucoseSensor, readGlucoseData, getPlannedWorkouts, deletePlannedWorkout, completePlannedWorkout, and postPlannedWorkout methods as deprecated.
Activity
  • A test plan was outlined to verify the setIgnoredSources functionality on iOS and Android, and to confirm method channel name consistency.
  • The changes were generated with the assistance of Claude Code.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the setIgnoredSources feature as described. The implementation looks good across Dart, iOS, and Android. I've made a couple of suggestions for improvement regarding code conciseness on Android and API consistency in the Dart layer. Additionally, this PR includes several deprecation annotations for other methods. While this is fine, it's generally better to keep pull requests focused on a single concern to make them easier to review and track.

Comment on lines +475 to +477
HashMap<String, Object> ignoredResult = new HashMap<>();
ignoredResult.put("success", true);
result.success(ignoredResult);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For creating a simple, immutable map with a single entry, it's more concise and efficient to use java.util.Collections.singletonMap().

Suggested change
HashMap<String, Object> ignoredResult = new HashMap<>();
ignoredResult.put("success", true);
result.success(ignoredResult);
result.success(java.util.Collections.singletonMap("success", true));

Comment on lines +176 to +180
static Future<void> setIgnoredSources(List<String> sources) async {
await _channel.invokeMethod('setIgnoredSources', {
"sources": sources
});
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For consistency with other methods in this class (like initTerra and initConnection), this method should return a Future<SuccessMessage?> instead of Future<void>. This would involve parsing the response from the native side. While the native implementations currently always return success, this change would make the API more consistent and robust for any future changes where an error might be returned.

Suggested change
static Future<void> setIgnoredSources(List<String> sources) async {
await _channel.invokeMethod('setIgnoredSources', {
"sources": sources
});
}
static Future<SuccessMessage?> setIgnoredSources(List<String> sources) async {
return SuccessMessage.fromJson(Map<String, dynamic>.from(await _channel.invokeMethod('setIgnoredSources', {
"sources": sources
})));
}

Bridges Terra.setIgnoredSources() from the iOS SDK through the Flutter
method channel. Takes a list of bundle identifiers to exclude from
HealthKit reads. Android side is a no-op that returns success.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@terra-alex
terra-alex force-pushed the feat/add-set-ignored-sources branch from 4b7ca86 to 8f1fa27 Compare March 15, 2026 23:51
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.

1 participant