FlourishHealth / ferns-api

Apache License 2.0
1 stars 3 forks source link

Fix Sentry limit logger #377

Closed joshgachnang closed 6 months ago

joshgachnang commented 6 months ago

User description

TS suggested isInitialized was a real function, but that doesn't appear to be true.


Type

bug_fix


Description


Changes walkthrough

Relevant files
Error handling
api.ts
Improved Error Handling for Sentry Message Capturing         

src/api.ts
  • Wrapped Sentry.captureMessage in a try-catch block to handle potential
    errors.
  • Added logging for errors caught when attempting to capture a message
    with Sentry.
  • +3/-1     

    PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codiumai-pr-agent-pro[bot] commented 6 months ago

    PR Description updated to latest commit (https://github.com/FlourishHealth/ferns-api/commit/ad252957fdbaef30eccdd0ad6a358bca41e12cce)

    codiumai-pr-agent-pro[bot] commented 6 months ago

    PR Review

    ⏱️ Estimated effort to review [1-5] 2, because the changes are straightforward and localized to a specific functionality (error handling for Sentry message capturing). The added try-catch block and error logging are simple to understand and review.
    🧪 Relevant tests No
    🔍 Possible issues Error Context: The error logging within the catch block logs the error message but does not provide context about where the error occurred or under what circumstances. It might be beneficial to include more information about the error context to aid in debugging.
    🔒 Security concerns No

    ✨ Review tool usage guide:
    **Overview:** The `review` tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be [added](https://pr-agent-docs.codium.ai/tools/review/#general-configurations) by configuring the tool. The tool can be triggered [automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on any PR. - When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L23) related to the review tool (`pr_reviewer` section), use the following template: ``` /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=... ``` - With a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/), use the following template: ``` [pr_reviewer] some_config1=... some_config2=... ``` See the review [usage page](https://pr-agent-docs.codium.ai/tools/review/) for a comprehensive guide on using this tool.
    codiumai-pr-agent-pro[bot] commented 6 months ago

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Best practice
    Check if Sentry is initialized before capturing messages. ___ **Consider checking if Sentry is initialized before attempting to capture a message. This
    can prevent unnecessary try-catch blocks and ensure that Sentry's state is correctly
    managed before attempting to log messages. This approach is cleaner and more in line with
    Sentry's recommended usage patterns.** [src/api.ts [574-577]](https://github.com/FlourishHealth/ferns-api/pull/377/files#diff-769911c416ccf8514d8fd941ae0abe8fb5c606ade0c218e22151a5f5f9f3d700R574-R577) ```diff -try { +if (Sentry.isInitialized()) { Sentry.captureMessage(msg); -} catch (error) { - logger.error(`Error capturing message: ${error}`); +} else { + logger.warn('Sentry is not initialized.'); } ```

    ✨ Improve tool usage guide:
    **Overview:** The `improve` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered [automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on a PR. - When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L78) related to the improve tool (`pr_code_suggestions` section), use the following template: ``` /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=... ``` - With a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/), use the following template: ``` [pr_code_suggestions] some_config1=... some_config2=... ``` See the improve [usage page](https://pr-agent-docs.codium.ai/tools/improve/) for a comprehensive guide on using this tool.