feat: serialize HKWorkoutEvent.metadata in workout queries#333
Closed
sh940701 wants to merge 4 commits intokingstinct:masterfrom
Closed
feat: serialize HKWorkoutEvent.metadata in workout queries#333sh940701 wants to merge 4 commits intokingstinct:masterfrom
sh940701 wants to merge 4 commits intokingstinct:masterfrom
Conversation
Add optional metadata field to WorkoutEvent interface and pass event.metadata through serializeMetadata() in WorkoutProxy.swift. This exposes per-event metadata from HealthKit workout queries, most notably HKSwimmingStrokeStyle on swimming lap events. Closes kingstinct#332
Serialize HKWorkoutEvent.metadata using the existing serializeMetadata() helper, making per-event metadata available to JS consumers. This is particularly useful for swimming workouts where lap events carry HKSwimmingStrokeStyle in their metadata.
|
commit: |
Contributor
Author
|
Closing to resubmit with a clean commit history — the branch had intermediate commits that shouldn't be in the final PR. |
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.
Summary
This PR adds
metadataserialization toWorkoutEvent, making per-event metadata fromHKWorkoutEventavailable to JS consumers.Closes #332
Changes
packages/react-native-healthkit/src/types/Workouts.tsAdded optional
metadatafield toWorkoutEventinterface usingAnyMapfromreact-native-nitro-modules, consistent with howBaseObject.metadatais typed:packages/react-native-healthkit/ios/WorkoutProxy.swiftPass
event.metadatathrough the existingserializeMetadata()helper in theeventscomputed property:Motivation
Apple's HKWorkoutEvent has a
metadata: [String: Any]?property. For swimming workouts, Apple documents that HKMetadataKeySwimmingStrokeStyle should be "set on workout lap events". Without event metadata, consumers cannot access per-lap stroke style through the documented path.Backward compatibility
metadatais optional (AnyMap?) — existing consumers are unaffectedserializeMetadata()helper (already used for workout metadata, sample metadata, and route metadata)serializeMetadata()handlesnilinput gracefully (returns empty map)Note
I haven't run
bun codegenlocally since Nitrogen may need to regenerate types for the newmetadatafield onWorkoutEvent. Happy to update if the generated output needs adjustment — just let me know.