Repository navigation
feat(healthkit): add wasUserEntered filter option to exclude manual entries - #399
Open
michaelyta wants to merge 1 commit into
Open
michaelyta wants to merge 1 commit into
michaelyta wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: a242ddf The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
michaelyta
force-pushed
the
feat/filter-was-user-entered
branch
from
October 9, 2026 19:18
b9f1ee3 to
a242ddf
Compare
michaelyta
marked this pull request as ready for review
October 9, 2026 19:50
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a top-level
wasUserEntered?: booleanoption toFilterForSamplesBase(which flows through toqueryStatisticsForQuantity,queryStatisticsCollectionForQuantity,queryQuantitySamples, and workouts) and exportsMetadataKeyWasUserEntered.When
wasUserEntered: falseis passed, the native predicate matches samples whereHKMetadataKeyWasUserEntered != true, which correctly excludes user-entered samples while including both explicitly non-manual and omitted metadata (such as Apple Watch and iPhone pedometer sensor data).API Reference
FilterForSamplesBase/FilterForSampleswasUserEnteredboolean | undefinedfalse: Matches samples not entered manually (HKMetadataKeyWasUserEntered != true), which includes sensor and automated data while omitting manual entries.true: Matches manually entered samples exclusively.undefined/ omitted: No filter is applied (default HealthKit behavior).Supported across queries that accept
filter, including:queryStatisticsForQuantity(identifier, options, { filter })queryStatisticsCollectionForQuantity(identifier, options, anchorDate, interval, { filter })queryQuantitySamples(identifier, { filter, ... })queryQuantitySamplesWithAnchor(identifier, { filter, ... })queryWorkoutSamples({ filter, ... })queryWorkoutSamplesWithAnchor({ filter, ... })Why add this option if generic metadata filter exists?
While filtering out manual entries is technically achievable via:
having a dedicated
wasUserEntered: booleanoption is significantly cleaner and more ergonomic:'HKMetadataKeyWasUserEntered', know to look forComparisonPredicateOperator, and realize that it must benotEqualTo: true(rather thanequalTo: false, which would return zero results because sensor data omits the key) is unintuitive.filter.(Note: If maintainers feel strongly that metadata filters should exclusively be handled through the generic
metadataproperty rather than dedicated shortcuts, happy to discuss and hear thoughts!)Testing
Physical Device Testing
wasUserEntered: false: correctly excluded manually entered steps and kept automatically recorded steps.wasUserEntered: true: exclusively returned the manual entries.Automated Testing
src/hooks/queryStatisticsForQuantity.test.ts:wasUserEntered: falseis correctly forwarded to the native module when executingqueryStatisticsForQuantity.MetadataKeyWasUserEnteredconstant exports'HKMetadataKeyWasUserEntered'.bun test(14/14 passing).tsc --noEmit) covering both core library and type tests.