Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): Add Sentry Integeration #133

Merged
merged 21 commits into from
Feb 18, 2024

Conversation

HarshPatel5940
Copy link
Contributor

@HarshPatel5940 HarshPatel5940 commented Feb 10, 2024

User description

Description

This pull request adds the necessary code and configuration to integrate Sentry into the project. It includes the initialization of Sentry, the addition of Sentry handlers, and the setup of the necessary environment variables. Additionally, it includes the necessary scripts to build and upload source maps to Sentry for better error tracking and debugging.

Fixes #109

Dependencies

  • @sentry/profiling-node
  • @sentry/node

Mentions

@rajdip-b

Screenshots of relevant screens

Screenshot 2024-02-10 at 10 00 34 AM
Screenshot 2024-02-10 at 9 59 17 AM
Screenshot 2024-02-10 at 9 57 20 AM

Developer's checklist

  • My PR follows the style guidelines of this project
  • I have performed a self-check on my work
  • I have followed the coding guidelines
  • My changes in code generate no new warnings
  • My changes are breaking another fix/feature of the project
  • I have added test cases to show that my feature works
  • I have added relevant screenshots in my PR
  • There are no UI/UX issues

Documentation Update

  • This PR requires an update to the documentation at docs.keyshade.xyz
  • I have made the necessary updates to the documentation, or no documentation changes are required.

Type

enhancement, configuration changes, dependencies


Description

  • Integrated Sentry for error tracking and performance monitoring in the API application.
  • Added Sentry configuration in .env.example for easy setup.
  • Updated package.json to include Sentry dependencies and a script for source maps upload.
  • Modified tsconfig.base.json to enhance Sentry's issue grouping by adjusting source maps configuration.

Changes walkthrough

Relevant files
Enhancement
main.ts
Integrate Sentry for Enhanced Error Tracking and Performance
Monitoring

apps/api/src/main.ts

  • Initialized Sentry with environment variables and conditional
    enabling.
  • Added Sentry request, tracing, and error handlers in the bootstrap
    function.
  • Wrapped the application bootstrap logic within a Sentry span for
    better tracing.
  • +46/-23 
    Configuration changes
    .env.example
    Add Sentry Configuration Environment Variables                                 

    .env.example

  • Added environment variables for Sentry DSN, traces sample rate, and
    profiles sample rate.
  • +4/-0     
    tsconfig.base.json
    Configure TypeScript for Sentry Source Maps                                       

    tsconfig.base.json

  • Enabled inline sources and set sourceRoot to improve Sentry issue
    grouping.
  • +9/-1     
    Dependencies
    package.json
    Update Dependencies and Scripts for Sentry Integration                 

    package.json

  • Added @sentry/cli, @sentry/node, and @sentry/profiling-node to
    dependencies.
  • Included a new script sentry:sourcemaps for uploading source maps to
    Sentry.
  • +6/-2     

    ✨ Usage guide:

    Overview:
    The describe tool scans the PR code changes, and generates a description for the PR - title, type, summary, walkthrough and labels. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.

    When commenting, to edit configurations related to the describe tool (pr_description section), use the following template:

    /describe --pr_description.some_config1=... --pr_description.some_config2=...
    

    With a configuration file, use the following template:

    [pr_description]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation
    • When you first install the app, the default mode for the describe tool is:
    pr_commands = ["/describe --pr_description.add_original_user_description=true" 
                             "--pr_description.keep_original_user_title=true", ...]
    

    meaning the describe tool will run automatically on every PR, will keep the original title, and will add the original user description above the generated description.

    • Markers are an alternative way to control the generated description, to give maximal control to the user. If you set:
    pr_commands = ["/describe --pr_description.use_description_markers=true", ...]
    

    the tool will replace every marker of the form pr_agent:marker_name in the PR description with the relevant content, where marker_name is one of the following:

    • type: the PR type.
    • summary: the PR summary.
    • walkthrough: the PR walkthrough.

    Note that when markers are enabled, if the original PR description does not contain any markers, the tool will not alter the description at all.

    Custom labels

    The default labels of the describe tool are quite generic: [Bug fix, Tests, Enhancement, Documentation, Other].

    If you specify custom labels in the repo's labels page or via configuration file, you can get tailored labels for your use cases.
    Examples for custom labels:

    • Main topic:performance - pr_agent:The main topic of this PR is performance
    • New endpoint - pr_agent:A new endpoint was added in this PR
    • SQL query - pr_agent:A new SQL query was added in this PR
    • Dockerfile changes - pr_agent:The PR contains changes in the Dockerfile
    • ...

    The list above is eclectic, and aims to give an idea of different possibilities. Define custom labels that are relevant for your repo and use cases.
    Note that Labels are not mutually exclusive, so you can add multiple label categories.
    Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it.

    Inline File Walkthrough 💎

    For enhanced user experience, the describe tool can add file summaries directly to the "Files changed" tab in the PR page.
    This will enable you to quickly understand the changes in each file, while reviewing the code changes (diffs).

    To enable inline file summary, set pr_description.inline_file_summary in the configuration file, possible values are:

    • 'table': File changes walkthrough table will be displayed on the top of the "Files changed" tab, in addition to the "Conversation" tab.
    • true: A collapsable file comment with changes title and a changes summary for each file in the PR.
    • false (default): File changes walkthrough will be added only to the "Conversation" tab.
    Utilizing extra instructions

    The describe tool can be configured with extra instructions, to guide the model to a feedback tailored to the needs of your project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Notice that the general structure of the description is fixed, and cannot be changed. Extra instructions can change the content or style of each sub-section of the PR description.

    Examples for extra instructions:

    [pr_description] 
    extra_instructions="""
    - The PR title should be in the format: '<PR type>: <title>'
    - The title should be short and concise (up to 10 words)
    - ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the describe usage page for a comprehensive guide on using this tool.

    Copy link

    nx-cloud bot commented Feb 10, 2024

    ☁️ Nx Cloud Report

    CI is running/has finished running commands for commit 80734da. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

    📂 See all runs for this CI Pipeline Execution


    ✅ Successfully ran 3 targets

    Sent with 💌 from NxCloud.

    @rajdip-b
    Copy link
    Member

    @HarshPatel5940 Awesome bro! Give me some time to go through the changes and test them.

    @HarshPatel5940
    Copy link
    Contributor Author

    @HarshPatel5940 Awesome bro! Give me some time to go through the changes and test them.

    Definitely!

    Copy link
    Member

    @rajdip-b rajdip-b left a comment

    Choose a reason for hiding this comment

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

    About the logs, can you try to make them similar with what our existing login looks like? Just that it will start with [SENTRY]

    .env.example Outdated Show resolved Hide resolved
    package.json Show resolved Hide resolved
    package.json Outdated Show resolved Hide resolved
    apps/api/src/main.ts Outdated Show resolved Hide resolved
    .gitignore Show resolved Hide resolved
    * it will not be enabled for `test` and `e2e`enviorment
    @HarshPatel5940 HarshPatel5940 marked this pull request as ready for review February 10, 2024 07:02
    Copy link
    Contributor

    PR Description updated to latest commit (fc11cf9)

    Copy link
    Contributor

    codiumai-pr-agent-free bot commented Feb 10, 2024

    PR Review

    (Review updated until commit 4809f31)

         PR feedback                    
    ⏱️ Estimated effort to review [1-5]

    3, because the PR involves integrating Sentry into an existing NestJS application, including configuration changes, environment variable setup, and Sentry-specific code additions. The complexity is moderate, with changes spanning multiple files, including configuration files and the main application bootstrap logic. Understanding the implications of these changes and ensuring they are correctly implemented requires a good understanding of both Sentry and NestJS.

    🧪 Relevant tests

    No

    🔍 Possible issues
    • The Sentry initialization checks for SENTRY_DSN but does not validate other Sentry-related environment variables like SENTRY_ORG, SENTRY_PROJECT, and SENTRY_AUTH_TOKEN, which are crucial for source map uploads and might cause runtime errors if missing or incorrect.
    • The use of process.exit(1) within initializeSentry could abruptly terminate the application without proper shutdown, potentially leading to resource leaks or unfinished asynchronous operations.
    • The Sentry debug mode is enabled based on the SENTRY_ENV starting with 'dev', which might unintentionally enable debug mode for environments not strictly meant for development, such as 'dev-staging'.
    🔒 Security concerns

    No

    Code feedback:
    relevant fileapps/api/src/main.ts
    suggestion      

    Consider validating all required Sentry environment variables (SENTRY_ORG, SENTRY_PROJECT, SENTRY_AUTH_TOKEN) at the start of initializeSentry to ensure they are present for source map uploads and other Sentry functionalities. This can prevent runtime errors and ensure smoother operation. [important]

    relevant lineif (!process.env.SENTRY_DSN) {

    relevant fileapps/api/src/main.ts
    suggestion      

    Instead of using process.exit(1) directly within initializeSentry, consider throwing a custom error or using a more graceful shutdown process. This approach allows for cleanup operations and ensures that resources are properly released before the application terminates. [important]

    relevant lineprocess.exit(1)

    relevant fileapps/api/src/main.ts
    suggestion      

    Refine the condition for enabling Sentry debug mode to explicitly check for a development environment, such as process.env.SENTRY_ENV === 'development', to avoid unintentionally enabling debug mode in non-development environments. [medium]

    relevant linedebug: process.env.SENTRY_ENV.startsWith('dev')

    relevant fileapps/api/webpack.config.js
    suggestion      

    Ensure that the sentryWebpackPlugin configuration includes include and ignore options to specify which files should be uploaded as source maps and which should be ignored. This can help reduce upload time and avoid uploading unnecessary files. [medium]

    relevant linesentryWebpackPlugin({


    ✨ Usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
    When commenting, to edit configurations 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, use the following template:

    [pr_reviewer]
    some_config1=...
    some_config2=...
    
    Utilizing extra instructions

    The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

    Examples for extra instructions:

    [pr_reviewer] # /review #
    extra_instructions="""
    In the 'possible issues' section, emphasize the following:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    How to enable\disable automation
    • When you first install PR-Agent app, the default mode for the review tool is:
    pr_commands = ["/review", ...]
    

    meaning the review tool will run automatically on every PR, with the default configuration.
    Edit this field to enable/disable the tool, or to change the used configurations

    Auto-labels

    The review tool can auto-generate two specific types of labels for a PR:

    • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
    • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
    Extra sub-tools

    The review tool provides a collection of possible feedbacks about a PR.
    It is recommended to review the possible options, and choose the ones relevant for your use case.
    Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
    require_score_review, require_soc2_ticket, and more.

    Auto-approve PRs

    By invoking:

    /review auto_approve
    

    The tool will automatically approve the PR, and add a comment with the approval.

    To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following:

    [pr_reviewer]
    enable_auto_approval = true
    

    (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository)

    You can also enable auto-approval only if the PR meets certain requirements, such as that the estimated_review_effort is equal or below a certain threshold, by adjusting the flag:

    [pr_reviewer]
    maximal_review_effort = 5
    
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the review usage page for a comprehensive guide on using this tool.

    Copy link
    Contributor

    PR Code Suggestions

    Suggestions                                                                                                                                                     
    enhancement
    Use environment variables for port configuration.                            

    Consider using environment variables for setting the port number instead of hardcoding it
    to ensure flexibility across different environments.

    apps/api/src/main.ts [79]

    -const port = 4200
    +const port = process.env.PORT || 4200
     
    Improve naming for clarity in Sentry spans.                                  

    Use a more descriptive name for the main span to clearly indicate its purpose or the
    specific operation it represents.

    apps/api/src/main.ts [59-60]

    -op: 'mainSpan',
    -name: 'My Main Span'
    +op: 'applicationBootstrap',
    +name: 'Application Bootstrap Process'
     
    maintainability
    Refactor Sentry setup into a separate function.                              

    Wrap the Sentry initialization and span creation in a separate function or module to
    improve code organization and readability.

    apps/api/src/main.ts [48-93]

    -Sentry.init({
    -  dsn: process.env.SENTRY_DSN,
    -  ...
    -})
    -await Sentry.startSpan(
    -  {
    -    op: 'mainSpan',
    -    name: 'My Main Span'
    -  },
    -  async () => {
    -    ...
    -  }
    -)
    +initializeSentry();
     
    possible issue
    Correct the Sentry source maps upload command for accuracy.                  

    Ensure that the Sentry source maps upload command includes the correct path to the source
    maps and verify the Sentry project configuration.

    package.json [118]

    -"sentry:sourcemaps": "sentry-cli sourcemaps inject ./dist && sentry-cli sourcemaps upload ./dist"
    +"sentry:sourcemaps": "sentry-cli releases files <RELEASE_NAME> upload-sourcemaps ./dist --url-prefix '~/<PATH_TO_YOUR_SOURCEMAPS>' --validate"
     
    best practice
    Validate necessary environment variables early.                              

    Validate environment variables at the start of the application to ensure all required
    configurations are set.

    apps/api/src/main.ts [48-55]

    +if (!process.env.SENTRY_DSN) {
    +  throw new Error('Missing environment variable: SENTRY_DSN');
    +}
     Sentry.init({
       dsn: process.env.SENTRY_DSN,
       ...
     })
     

    ✨ 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 every time a new PR is opened, or can be invoked manually by commenting on a PR.
    When commenting, to edit configurations 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, use the following template:

    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation

    When you first install the app, the default mode for the improve tool is:

    pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
    

    meaning the improve tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.

    Utilizing extra instructions

    Extra instructions are very important for the improve tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on.

    Examples for extra instructions:

    [pr_code_suggestions] # /improve #
    extra_instructions="""
    Emphasize the following aspects:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    A note on code suggestions quality
    • While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
    • Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
    • Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the custom suggestions 💎 tool
    • With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the improve usage page for a more comprehensive guide on using this tool.

    @HarshPatel5940
    Copy link
    Contributor Author

    image
    image


    This should not be like this right? because all the functions are counted as bootstrap.

    @rajdip-b
    Copy link
    Member

    image image

    This should not be like this right? because all the functions are counted as bootstrap.

    I think it is bound to happen since all the modules are loaded in the AppModule, and it is in turn loaded in init.

    image

    What I wanted as to make sure that I can log the waterfalls, and the application errors. So I think this is good.

    Copy link
    Member

    @rajdip-b rajdip-b left a comment

    Choose a reason for hiding this comment

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

    All looks good, just make these last two changes:

    • Integrate this suggestion:

    Use a more descriptive name for the main span to clearly indicate its purpose or the
    specific operation it represents.
    apps/api/src/main.ts [59-60]
    -op: 'mainSpan',
    -name: 'My Main Span'
    +op: 'applicationBootstrap',
    +name: 'Application Bootstrap Process'

    • Add SENTRY_ORG and SENTRY_DSN in .env.example

    tsconfig.base.json Outdated Show resolved Hide resolved
    @rajdip-b
    Copy link
    Member

    image
    image
    image

    Looks like the profiling worked, but the error wasn't logged :/
    image
    image

    Mind testing out the above thing once?

    @HarshPatel5940
    Copy link
    Contributor Author

    Mind testing out the above thing once?

    umm sure, let me try.

    Copy link
    Contributor

    Persistent review updated to latest commit 4f4f4ec

    @HarshPatel5940
    Copy link
    Contributor Author

    /improve

    Copy link
    Contributor

    codiumai-pr-agent-free bot commented Feb 17, 2024

    PR Code Suggestions

    Suggestions                                                                                                                                                     
    enhancement
    Implement proper error handling for the 'break' endpoint.                    

    Consider implementing proper error handling for the 'break' endpoint. Throwing a generic
    error directly in the controller can lead to unhandled exceptions and affect the stability
    of your application. You might want to use a service to handle the logic and catch errors
    appropriately.

    apps/api/src/app/app.controller.ts [14-18]

     @Get('break')
     @Public()
    -break(): string {
    -  throw new Error('Broken')
    +async break(): Promise<string> {
    +  try {
    +    // Your logic here
    +  } catch (error) {
    +    // Handle error appropriately
    +  }
     }
     
    Improve error handling for Sentry source maps upload script.                 

    Ensure that the Sentry source maps upload script gracefully handles failures without
    breaking the build process. Consider adding more robust error handling or a notification
    mechanism to alert the team when the upload fails.

    package.json [118]

    -"sentry:sourcemaps": "sentry-cli sourcemaps inject ./dist && sentry-cli sourcemaps upload ./dist || echo 'Failed to upload source maps to Sentry'"
    +"sentry:sourcemaps": "sentry-cli sourcemaps inject ./dist && sentry-cli sourcemaps upload ./dist || (echo 'Failed to upload source maps to Sentry' && exit 1)"
     
    security
    Securely manage the Sentry DSN environment variable.                         

    Ensure that the Sentry DSN environment variable is securely managed and not hardcoded or
    exposed in your codebase. It's good practice to load sensitive information from
    environment variables or a secure configuration management system.

    apps/api/src/main.ts [47-51]

    -if (!process.env.SENTRY_DSN) {
    -  Logger.error('Missing environment variable: SENTRY_DSN')
    -  process.exit(1)
    -}
    +// Ensure SENTRY_DSN is loaded from a secure source
     
    best practice
    Ensure correct Sentry Webpack plugin configuration for source map uploads.   

    Verify the Sentry Webpack plugin configuration to ensure that source maps are correctly
    uploaded in production builds. It's crucial for debugging production issues effectively.
    Additionally, consider handling the scenario where process.env.NODE_ENV is not set.

    apps/api/webpack.config.js [6-15]

     plugins: [
    -  ...((process.env.NODE_ENV || 'production') === 'production'
    +  ...((process.env.NODE_ENV === 'production')
         ? sentryWebpackPlugin({
             org: process.env.SENTRY_ORG,
             project: process.env.SENTRY_PROJECT,
             authToken: process.env.SENTRY_AUTH_TOKEN
           })
         : [])
     ]
     
    documentation
    Clarify and correct the description of NODE_ENV in the environment variables documentation.

    Clarify the description of NODE_ENV to remove the redundant "The" and correct the spelling
    of "environment". Also, consider providing more guidance on how this variable affects the
    application's behavior in different environments.

    docs/contributing-to-keyshade/environment-variables.md [11]

    -* **NODE_ENV**: The The environment in which the app is running. It can be either 'development', 'production', or 'test'. Please note that it's not mandatory, it will default to "production" enviroment for the sentry configuration.
    +* **NODE_ENV**: The environment in which the app is running. It can be either 'development', 'production', or 'test'. This variable influences how the application behaves and interacts with other services, such as Sentry, in different environments.
     

    ✨ 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 every time a new PR is opened, or can be invoked manually by commenting on a PR.
    When commenting, to edit configurations 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, use the following template:

    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation

    When you first install the app, the default mode for the improve tool is:

    pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
    

    meaning the improve tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.

    Utilizing extra instructions

    Extra instructions are very important for the improve tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on.

    Examples for extra instructions:

    [pr_code_suggestions] # /improve #
    extra_instructions="""
    Emphasize the following aspects:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    A note on code suggestions quality
    • While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
    • Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
    • Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the custom suggestions 💎 tool
    • With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the improve usage page for a more comprehensive guide on using this tool.

    @rajdip-b
    Copy link
    Member

    ok, nvm I got it to push my updates with 4f4f4ec

    @rajdip-b Do you think this tests before commit can be improvised ? I can't think of anything right now. Maybe run these tests before push, so atleast user can play around locally? idk 🤷🏼

    Yes I think I will remove precommit. it's annoying tbh

    apps/api/src/app/app.controller.ts Outdated Show resolved Hide resolved
    apps/api/src/main.ts Outdated Show resolved Hide resolved
    apps/api/webpack.config.js Outdated Show resolved Hide resolved
    docs/contributing-to-keyshade/environment-variables.md Outdated Show resolved Hide resolved
    package.json Outdated Show resolved Hide resolved
    @rajdip-b
    Copy link
    Member

    @HarshPatel5940 i believe the tests have some caching issues. It usually passes if we re-run it, but we need to somehow fix that flakey test suit. It always happens in event.e2e.spec.ts

    @HarshPatel5940
    Copy link
    Contributor Author

    Will do the changes as soon as time permits.

    @HarshPatel5940 i believe the tests have some caching issues. It usually passes if we re-run it, but we need to somehow fix that flakey test suit. It always happens in event.e2e.spec.ts

    Hmmm, i see.

    @rajdip-b
    Copy link
    Member

    Will do the changes as soon as time permits.

    @HarshPatel5940 i believe the tests have some caching issues. It usually passes if we re-run it, but we need to somehow fix that flakey test suit. It always happens in event.e2e.spec.ts

    Hmmm, i see.

    No rush bro! You can raise a PR for that whenever you feel so!

    * add `sentry_env` instead of `node_env`
    @rajdip-b
    Copy link
    Member

    /review

    Copy link
    Contributor

    Persistent review updated to latest commit 4809f31

    apps/api/src/main.ts Outdated Show resolved Hide resolved
    apps/api/src/main.ts Outdated Show resolved Hide resolved
    @HarshPatel5940
    Copy link
    Contributor Author

    @rajdip-b sorry for the silly mistake at the end. I will be more careful from future to avoid those.

    @rajdip-b
    Copy link
    Member

    @rajdip-b sorry for the silly mistake at the end. I will be more careful from future to avoid those.

    Happens all the time on such major PRs! No issue on that. I'm making some final changes and make a push.

    @HarshPatel5940
    Copy link
    Contributor Author

    Happens all the time on such major PRs! No issue on that. I'm making some final changes and make a push.

    Oh ok. noted.

    Copy link

    sonarcloud bot commented Feb 18, 2024

    Quality Gate Passed Quality Gate passed

    Issues
    0 New issues

    Measures
    0 Security Hotspots
    No data about Coverage
    4.8% Duplication on New Code

    See analysis details on SonarCloud

    Copy link
    Member

    @rajdip-b rajdip-b left a comment

    Choose a reason for hiding this comment

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

    Guess that does it!

    @rajdip-b rajdip-b merged commit 5ae2c92 into keyshade-xyz:develop Feb 18, 2024
    7 of 8 checks passed
    @HarshPatel5940 HarshPatel5940 deleted the hp/feat/implement-sentry branch February 18, 2024 15:43
    rajdip-b pushed a commit that referenced this pull request Feb 18, 2024
    ## [1.2.0](v1.1.0...v1.2.0) (2024-02-18)
    
    ### 🚀 Features
    
    * **api:** Add Sentry Integeration ([#133](#133)) ([5ae2c92](5ae2c92))
    
    ### 🔧 Miscellaneous Chores
    
    * **api:** update dockerfile and ci ([ae2d944](ae2d944))
    * **api:** update sentry log messages ([976026c](976026c))
    * **ci:** update stage-api workflow ([addaa61](addaa61))
    * **husky:** Remove `e2e:api` command from husky ([#144](#144)) ([8a2fa58](8a2fa58))
    * update sentry source map script ([bdc9dc6](bdc9dc6))
    @rajdip-b
    Copy link
    Member

    🎉 This PR is included in version 1.2.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type: enhancement New feature or request
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    Sentry - Add profiling and performance support
    3 participants