Skip to content

[docs] Docs for handleError Sentry usage is invalid #9577

@danawoodman

Description

@danawoodman

Describe the bug

The docs example of how to use handleError hook improperly uses the Sentry Node.js captureException method.

This may lead to confusion for users who copy things over and find out they don't work as-is, using the latest @sentry/node library.

I cannot find any mention of errorId in their docs and no examples show passing an errorId or an event so I'm assuming the intention is to instead pass these to extra?

Current docs:
image

Error when trying to pass event into captureException:
image

CaptureContext type for the second arg to captureException:
image

I believe the proper usage would likely be the following:

Sentry.captureException(error, { extra: { event, errorId } });

Also worth noting is in my experience, using @sentry/node will fail in local development and any non-node environment like CloudFlare Workers, so using @sentry/browser seems to be the approach that works cross platform.

Reproduction

See above

Logs

n/a

System Info

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M2
    Memory: 449.41 MB / 24.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/Library/Caches/fnm_multishells/62837_1680285009501/bin/node
    npm: 9.5.0 - ~/Library/Caches/fnm_multishells/62837_1680285009501/bin/npm
  Browsers:
    Brave Browser: 106.1.44.112
    Chrome: 111.0.5563.146
    Firefox: 103.0
    Safari: 16.3

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions