Skip to content

Conversation

@s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Jul 8, 2024

Reports errors thrown in nitro. Tests will be added when adding the E2E test application.

closes #12795

@s1gr1d s1gr1d requested review from Lms24, andreiborza and lforst July 8, 2024 12:55
@s1gr1d s1gr1d force-pushed the sig/nuxt-server branch from 48c34df to 85359f8 Compare July 8, 2024 12:57
@s1gr1d s1gr1d requested a review from AbhiPrasad July 8, 2024 14:28

if (context) {
captureException(error, {
captureContext: { contexts: { nuxt: context } },
Copy link
Contributor

Choose a reason for hiding this comment

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

m: I would be more selective in what we record here instead of dumping the entire context object in here. It could become a problem if context suddenly starts containing PII, becomes very large, or circular in a future nitro update.

Copy link
Member

Choose a reason for hiding this comment

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

yes ideally we:

  1. We parse the incoming nuxt context and extract the fields we care about
  2. We put that in a nuxt context attached to the sentry event
  3. Document the nuxt context in the develop docs

@s1gr1d s1gr1d requested a review from lforst July 9, 2024 08:35
@s1gr1d s1gr1d added the Package: nuxt Issues related to the Sentry Nuxt SDK label Jul 9, 2024
Copy link
Contributor

@lforst lforst left a comment

Choose a reason for hiding this comment

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

:shipit:

Comment on lines 8 to 13
// Do not handle 404 and 422
if (error instanceof H3Error) {
if (error.statusCode === 404 || error.statusCode === 422) {
return;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

l/m: We could arguably skip all 4xxs (also 3xxs if that can ever happen).

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Two optional suggestion to streamline the code but otherwise LGTM! (feel free to merge and streamline in a follow-up PR or not at all)

Comment on lines 15 to 24
if (errorContext) {
const structuredContext = extractErrorContext(errorContext);

captureException(error, {
captureContext: { contexts: { nuxt: structuredContext } },
mechanism: { handled: false },
});
} else {
captureException(error, { mechanism: { handled: false } });
}
Copy link
Member

Choose a reason for hiding this comment

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

l (feel free to disregard): WDYT about calling captureException only once and setting captureContext depending on errorContext

tags: undefined,
};

if (errorContext) {
Copy link
Member

Choose a reason for hiding this comment

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

l: do we need this guard? i.e. can CapturedErrorContext be undefined?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Package: nuxt Issues related to the Sentry Nuxt SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add server (nitro) instrumentation

5 participants