Skip to content

Meal Editor Logging - #645

Closed
lynnfaraday wants to merge 3 commits into
mainfrom
linda/mealedit-logging
Closed

Meal Editor Logging#645
lynnfaraday wants to merge 3 commits into
mainfrom
linda/mealedit-logging

Conversation

@lynnfaraday

Copy link
Copy Markdown
Contributor

Overview

Add custom event logging to the meal editor for troubleshooting image uploads.

Security

Consider potential security impacts and complete the following checklist.
REMINDER: All file contents are public.

  • I have ensured no secure credentials or sensitive information remain in code, metadata, comments, etc.
    • Please verify that you double checked that .storybook/preview.js does not contain your participant access key details.
    • There are no temporary testing changes committed such as API base URLs, access tokens, print/log statements, etc.
  • These changes do not introduce any security risks, or any such risks have been properly mitigated.

Testing

Consider whether the changes might have device-specific behaviors (screen padding, new APIs, etc.) and check one of the following boxes:

  • This change can be adequately tested using the MDH Storybook.
  • This change requires additional testing in the MDH iOS/Android/Web apps. (Create a pre-release tag/build and test in a ViewBuilder PR.)

Test meal editor in web/mobile and ensure custom events are logged.

Documentation

Consider whether there are any documentation impacts and check one of the following boxes:

  • I have added relevant Storybook updates to this PR.
  • If this feature requires a developer doc update, I have tagged @CareEvolution/api-docs.
  • This change does not impact documentation or Storybook.

Reviewers

Assign to the appropriate reviewer(s). Minimally, a second set of eyes is needed ensure no non-public information is published. Consider also including:

  • Subject-matter experts
  • Style/editing reviewers
  • Others requested by the content owner

Consider "Squash and merge" as needed to keep the commit history reasonable on main.

@aws-amplify-us-east-1

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-645.d1xp2kmk6zrv44.amplifyapp.com

@greinard greinard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It may be worth instrumenting a few of the other actions as well, such as on delete, on cancel, on remove image, etc.

You also probably want to target a branch off the v3.21.2 tag so this can be deployed to the Prod ViewBuilder more quickly. The v4.0.0 stuff is going to take a little longer to test/validate for release to VB, so if this is semi-urgent, having it be part of a minor bump will help expedite its rollout.

Comment thread src/components/container/MealEditor/MealEditor.tsx Outdated
Comment thread src/components/container/MealEditor/MealEditor.tsx Outdated
Comment thread src/components/container/MealEditor/MealEditor.tsx Outdated
Comment thread src/components/container/MealEditor/MealEditor.tsx
Comment thread src/components/container/MealEditor/MealEditor.tsx Outdated
Comment thread src/helpers/glucose-and-meals/meals.ts Outdated
Comment thread src/helpers/glucose-and-meals/meals.ts Outdated

@greinard greinard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looking pretty good. Just a few more suggestions. Thanks for addressing the prior feedback.

setImageLoading(!!imageUrl);
} else {
props.onError();
onError(`Can't find meal reference. id=${mealReference.id}`);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nitpick, but the thing we cant find here is the meal itself, not the reference. So I'd use just "Can't find meal." or "Can't find referenced meal."

}
});

MyDataHelps.getDeviceInfo().then(info => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since we would prefer to have this device info available for any of the logging, including when it loads the meal to edit, we can probably move the whole getMealToEdit().then(...) piece inside here after calling setDeviceInfo(info);.

The getDeviceInfo() call should be really fast as I believe it just runs in memory on the device or in the browser (no remote requests).

try {
await uploadMealImageFile(mealToEdit, newImageFile);
} catch {
logMealEvent("image-uploaded", mealToEdit, deviceInfo);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe include the { name: newImageFile.name, size: newImageFile.size } here as well.


saveMeals(startOfDay(mealToEdit.timestamp), updatedMeals).then(props.onDelete);
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably worth adding an onCancel function in here that logs an event and calls props.onCancel(), and then update the cancel button at the bottom to call this onCancel instead of the prop function directly.

Comment thread src/helpers/glucose-and-meals/meals.ts Outdated
return (item2.confidenceScore ?? 0) - (item1.confidenceScore ?? 0);
}

export function logMealEvent(type: string, meal: Meal | undefined, deviceInfo: DeviceInfo | undefined, data: any = {}) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe use unknown for the type on data instead of any.

Comment thread src/helpers/glucose-and-meals/meals.ts Outdated
eventType: "meal-editor",
properties: {
type: type,
body: data,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I like this better with the individual fields we are interested in. Ties it back to the meal and the device info nicely without logging TMI.

Was thinking maybe this field could be named just data or additionalData rather than body, but I don't feel strongly about it if you prefer body.

Comment thread src/helpers/glucose-and-meals/meals.ts Outdated

export function logMealEvent(type: string, meal: Meal | undefined, deviceInfo: DeviceInfo | undefined, data: any = {}) {
MyDataHelps.trackCustomEvent({
eventType: "meal-editor",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh, one more thing. I suppose at some point we might be able to reuse this function across the other meal related components, so maybe we just set the event type to meal-event here (kind of fits the function name better, too).

@lynnfaraday
lynnfaraday changed the base branch from main to release/3.x July 30, 2026 20:06
@lynnfaraday
lynnfaraday changed the base branch from release/3.x to main July 30, 2026 21:40
@lynnfaraday

Copy link
Copy Markdown
Contributor Author

Replaced by #648 due to rebase having a fit.

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