Enable Suspect Commits & Stack Trace Linking

Sentry uses commit metadata from your source code repositories to help you resolve your issues faster. This is done by suggesting suspect commits that might have introduced an error right in your Issue Details page. It also allows Sentry to display suggested assignees — the list of the authors of those commits — and suggest their assignment to resolve the issue.

Now that you've created a release, you can tell Sentry which commits are associated with this latest version of your code; this is called commit tracking.

Step 1: Integrate your GitHub account and repositories

  1. To integrate GitHub with your Sentry org, follow the instructions in our GitHub documentation.

  2. Add the frontend-monitoring repository from your GitHub account.

    Add project repository

  3. Click the "Code Mappings" tab

  4. Add a code mapping between the frontend-monitoring repository and your Sentry project and the main or master branch depending on your repository. Tell Sentry that your components live in the src/ directory:

    Add code mapping

Step 2: Set commit tracking

Now that you've set up releases in Sentry as part of your CI/CD process and integrated your source code repositories, you can associate commits from your linked repository to your releases.

  1. Open the Makefile in your project.

  2. Add the following target at the bottom of the file:

    Copied
    associate_commits:
        sentry-cli releases -o $(SENTRY_ORG) -p $(SENTRY_PROJECT) set-commits --auto $(REACT_APP_RELEASE_VERSION)

    The command associates commits with the release. The auto flag automatically determines the repository name, and associates commits between the previous release’s commit and the current head commit with the release.

  3. The new target, associate_commits, will be invoked as part of the setup_release target. Add it at the end:

    Copied
    setup_release: create_release upload_sourcemaps associate_commits

    Your Makefile should look like this:

    Updated Makefile

  4. If your terminal is still serving the demo app on localhost, press ^C to shut it down.

  5. Build, serve, and restart the project on your localhost by running:

    Copied
    > npm run deploy

In the terminal log, notice that the sentry-cli identified the GitHub repository.

Updated Makefile

Step 3: Suspect commits and suggested assignees

Now suspect commits and suggested assignees should start appearing on the Issue Details page. Sentry determines these using files observed in the stack trace, authors of those files, and ownership rules.

  1. Refresh the browser and generate an error by adding products to your cart and clicking "Checkout".

  2. Check your email for the alert about the new error. Notice that a new "Suspect Commits" section has been added to the email.

    Suspect Commits email

  3. Click "View on Sentry" to open the Issue Details page.

  4. In the main area of the page, notice the "SUSPECT COMMITS" section now points to a commit that most likely introduced the error. You can click on the commit button to see the actual commit details on GitHub.

  5. In the right side panel, under "Suggested Assignees", you'll see that the author of the suspect commit is listed as a suggested assignee for this issue.

    Suggested Assignees

    You can assign the suggested assignee to the issue by clicking on the icon. However, in this case, the commit originates in the repository upstream, and the suggested assignee is not part of your organization. Alternatively, you can manually assign the issue to other users or teams assigned to the project.

  6. Click on the "ASSIGNEE" dropdown and select one of the project users or teams.

    Suspect Commit

  7. In the main area of the page, under "TAGS", find the release tag and hover over the "i" icon.

  8. In the popup that appears, notice the release now contains the commit data.

    Assign Manually

  9. Click on the release "i" icon to open the Release Details page.

  10. Select the "Commits" tab. Notice that release now contains the associated list of commits.

    Release with Commits

Stack trace links allows you to jump from a stack trace in sentry.io to the corresponding file in your source code provider. This is done by matching the file path in the stack trace to the file path in your source code provider.

  1. Go to the Issue Details page for the error you generated in the previous step.

  2. If the code mapping is set up correctly, in the stack trace you should see a link with "Open this line in GitHub":

    Stacktrace Link

More Information

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").