@sentry/nextjs
Advanced tools
Comparing version 8.0.0-beta.5 to 8.0.0-beta.6
@@ -51,47 +51,49 @@ var { | ||
return core.withIsolationScope(isolationScope, () => { | ||
isolationScope.setTransactionName(`${componentType}.${generationFunctionIdentifier} (${componentRoute})`); | ||
isolationScope.setSDKProcessingMetadata({ | ||
request: { | ||
headers: headers ? utils.winterCGHeadersToDict(headers) : undefined, | ||
}, | ||
}); | ||
return core.withScope(scope => { | ||
scope.setTransactionName(`${componentType}.${generationFunctionIdentifier} (${componentRoute})`); | ||
isolationScope.setSDKProcessingMetadata({ | ||
request: { | ||
headers: headers ? utils.winterCGHeadersToDict(headers) : undefined, | ||
}, | ||
}); | ||
core.getCurrentScope().setExtra('route_data', data); | ||
core.getCurrentScope().setPropagationContext(propagationContext); | ||
scope.setExtra('route_data', data); | ||
scope.setPropagationContext(propagationContext); | ||
return core.startSpanManual( | ||
{ | ||
op: 'function.nextjs', | ||
name: `${componentType}.${generationFunctionIdentifier} (${componentRoute})`, | ||
forceTransaction: true, | ||
attributes: { | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
return core.startSpanManual( | ||
{ | ||
op: 'function.nextjs', | ||
name: `${componentType}.${generationFunctionIdentifier} (${componentRoute})`, | ||
forceTransaction: true, | ||
attributes: { | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
}, | ||
}, | ||
}, | ||
span => { | ||
return core.handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
err => { | ||
if (nextNavigationErrorUtils.isNotFoundNavigationError(err)) { | ||
// We don't want to report "not-found"s | ||
span.setStatus({ code: core.SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else if (nextNavigationErrorUtils.isRedirectNavigationError(err)) { | ||
// We don't want to report redirects | ||
span.setStatus({ code: core.SPAN_STATUS_OK }); | ||
} else { | ||
span.setStatus({ code: core.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
core.captureException(err, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
} | ||
}, | ||
() => { | ||
span.end(); | ||
}, | ||
); | ||
}, | ||
); | ||
span => { | ||
return core.handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
err => { | ||
if (nextNavigationErrorUtils.isNotFoundNavigationError(err)) { | ||
// We don't want to report "not-found"s | ||
span.setStatus({ code: core.SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else if (nextNavigationErrorUtils.isRedirectNavigationError(err)) { | ||
// We don't want to report redirects | ||
span.setStatus({ code: core.SPAN_STATUS_OK }); | ||
} else { | ||
span.setStatus({ code: core.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
core.captureException(err, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
} | ||
}, | ||
() => { | ||
span.end(); | ||
}, | ||
); | ||
}, | ||
); | ||
}); | ||
}); | ||
@@ -98,0 +100,0 @@ }); |
@@ -40,53 +40,55 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
return core.withIsolationScope(isolationScope, async () => { | ||
isolationScope.setTransactionName(`${method} ${parameterizedRoute}`); | ||
core.getCurrentScope().setPropagationContext(propagationContext); | ||
try { | ||
return core.startSpan( | ||
{ | ||
name: `${method} ${parameterizedRoute}`, | ||
attributes: { | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server', | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
return core.withIsolationScope(isolationScope, () => { | ||
return core.withScope(async scope => { | ||
scope.setTransactionName(`${method} ${parameterizedRoute}`); | ||
scope.setPropagationContext(propagationContext); | ||
try { | ||
return core.startSpan( | ||
{ | ||
name: `${method} ${parameterizedRoute}`, | ||
attributes: { | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server', | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
}, | ||
forceTransaction: true, | ||
}, | ||
forceTransaction: true, | ||
}, | ||
async span => { | ||
const response = await core.handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
error => { | ||
// Next.js throws errors when calling `redirect()`. We don't wanna report these. | ||
if (nextNavigationErrorUtils.isRedirectNavigationError(error)) { | ||
// Don't do anything | ||
} else if (nextNavigationErrorUtils.isNotFoundNavigationError(error) && span) { | ||
span.setStatus({ code: core.SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else { | ||
core.captureException(error, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
async span => { | ||
const response = await core.handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
error => { | ||
// Next.js throws errors when calling `redirect()`. We don't wanna report these. | ||
if (nextNavigationErrorUtils.isRedirectNavigationError(error)) { | ||
// Don't do anything | ||
} else if (nextNavigationErrorUtils.isNotFoundNavigationError(error) && span) { | ||
span.setStatus({ code: core.SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else { | ||
core.captureException(error, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
} | ||
}, | ||
); | ||
try { | ||
if (span && response.status) { | ||
core.setHttpStatus(span, response.status); | ||
} | ||
}, | ||
); | ||
try { | ||
if (span && response.status) { | ||
core.setHttpStatus(span, response.status); | ||
} catch (e) { | ||
// best effort - response may be undefined? | ||
} | ||
} catch (e) { | ||
// best effort - response may be undefined? | ||
} | ||
return response; | ||
}, | ||
); | ||
} finally { | ||
if (!platformSupportsStreaming.platformSupportsStreaming() || process.env.NEXT_RUNTIME === 'edge') { | ||
// 1. Edge transport requires manual flushing | ||
// 2. Lambdas require manual flushing to prevent execution freeze before the event is sent | ||
await responseEnd.flushQueue(); | ||
return response; | ||
}, | ||
); | ||
} finally { | ||
if (!platformSupportsStreaming.platformSupportsStreaming() || process.env.NEXT_RUNTIME === 'edge') { | ||
// 1. Edge transport requires manual flushing | ||
// 2. Lambdas require manual flushing to prevent execution freeze before the event is sent | ||
await responseEnd.flushQueue(); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
@@ -93,0 +95,0 @@ }); |
@@ -44,43 +44,46 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
return core.withIsolationScope(isolationScope, () => { | ||
isolationScope.setTransactionName(`${componentType} Server Component (${componentRoute})`); | ||
core.getCurrentScope().setPropagationContext(propagationContext); | ||
return core.startSpanManual( | ||
{ | ||
op: 'function.nextjs', | ||
name: `${componentType} Server Component (${componentRoute})`, | ||
forceTransaction: true, | ||
attributes: { | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component', | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
return core.withScope(scope => { | ||
scope.setTransactionName(`${componentType} Server Component (${componentRoute})`); | ||
scope.setPropagationContext(propagationContext); | ||
return core.startSpanManual( | ||
{ | ||
op: 'function.nextjs', | ||
name: `${componentType} Server Component (${componentRoute})`, | ||
forceTransaction: true, | ||
attributes: { | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component', | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
}, | ||
}, | ||
}, | ||
span => { | ||
return core.handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
error => { | ||
if (nextNavigationErrorUtils.isNotFoundNavigationError(error)) { | ||
// We don't want to report "not-found"s | ||
span.setStatus({ code: core.SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else if (nextNavigationErrorUtils.isRedirectNavigationError(error)) { | ||
// We don't want to report redirects | ||
span.setStatus({ code: core.SPAN_STATUS_OK }); | ||
} else { | ||
span.setStatus({ code: core.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
core.captureException(error, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
} | ||
}, | ||
() => { | ||
span.end(); | ||
span => { | ||
return core.handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
error => { | ||
if (nextNavigationErrorUtils.isNotFoundNavigationError(error)) { | ||
// We don't want to report "not-found"s | ||
span.setStatus({ code: core.SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else if (nextNavigationErrorUtils.isRedirectNavigationError(error)) { | ||
// We don't want to report redirects | ||
span.setStatus({ code: core.SPAN_STATUS_OK }); | ||
} else { | ||
span.setStatus({ code: core.SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
core.captureException(error, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
} | ||
}, | ||
() => { | ||
span.end(); | ||
// flushQueue should not throw | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
responseEnd.flushQueue(); | ||
}, | ||
); | ||
}, | ||
); | ||
// flushQueue should not throw | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
responseEnd.flushQueue(); | ||
}, | ||
); | ||
}, | ||
); | ||
}); | ||
}); | ||
@@ -87,0 +90,0 @@ }); |
@@ -487,3 +487,4 @@ var { | ||
/** | ||
* Searches for old `sentry.(server|edge).config.ts` files and warns if it finds any. | ||
* Searches for old `sentry.(server|edge).config.ts` files and Next.js instrumentation hooks and warns if there are "old" | ||
* config files and no signs of them inside the instrumentation hook. | ||
* | ||
@@ -494,5 +495,28 @@ * @param projectDir The root directory of the project, where config files would be located | ||
function warnAboutDeprecatedConfigFiles(projectDir, platform) { | ||
const possibilities = [`sentry.${platform}.config.ts`, `sentry.${platform}.config.js`]; | ||
const hasInstrumentationHookWithIndicationsOfSentry = [ | ||
['src', 'instrumentation.ts'], | ||
['src', 'instrumentation.js'], | ||
['instrumentation.ts'], | ||
['instrumentation.js'], | ||
].some(potentialInstrumentationHookPathSegments => { | ||
try { | ||
const instrumentationHookContent = fs.readFileSync( | ||
path.resolve(projectDir, ...potentialInstrumentationHookPathSegments), | ||
{ encoding: 'utf-8' }, | ||
); | ||
for (const filename of possibilities) { | ||
return ( | ||
instrumentationHookContent.includes('@sentry/') || | ||
instrumentationHookContent.match(/sentry\.(server|edge)\.config\.(ts|js)/) | ||
); | ||
} catch (e) { | ||
return false; | ||
} | ||
}); | ||
if (hasInstrumentationHookWithIndicationsOfSentry) { | ||
return; | ||
} | ||
for (const filename of [`sentry.${platform}.config.ts`, `sentry.${platform}.config.js`]) { | ||
if (fs.existsSync(path.resolve(projectDir, filename))) { | ||
@@ -499,0 +523,0 @@ // eslint-disable-next-line no-console |
import { _nullishCoalesce, _optionalChain } from '@sentry/utils'; | ||
import { withIsolationScope, getCurrentScope, startSpanManual, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, handleCallbackErrors, SPAN_STATUS_ERROR, SPAN_STATUS_OK, captureException, getClient } from '@sentry/core'; | ||
import { withIsolationScope, withScope, startSpanManual, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, handleCallbackErrors, SPAN_STATUS_ERROR, SPAN_STATUS_OK, captureException, getClient } from '@sentry/core'; | ||
import { propagationContextFromHeaders, winterCGHeadersToDict } from '@sentry/utils'; | ||
@@ -45,47 +45,49 @@ import { isNotFoundNavigationError, isRedirectNavigationError } from './nextNavigationErrorUtils.js'; | ||
return withIsolationScope(isolationScope, () => { | ||
isolationScope.setTransactionName(`${componentType}.${generationFunctionIdentifier} (${componentRoute})`); | ||
isolationScope.setSDKProcessingMetadata({ | ||
request: { | ||
headers: headers ? winterCGHeadersToDict(headers) : undefined, | ||
}, | ||
}); | ||
return withScope(scope => { | ||
scope.setTransactionName(`${componentType}.${generationFunctionIdentifier} (${componentRoute})`); | ||
isolationScope.setSDKProcessingMetadata({ | ||
request: { | ||
headers: headers ? winterCGHeadersToDict(headers) : undefined, | ||
}, | ||
}); | ||
getCurrentScope().setExtra('route_data', data); | ||
getCurrentScope().setPropagationContext(propagationContext); | ||
scope.setExtra('route_data', data); | ||
scope.setPropagationContext(propagationContext); | ||
return startSpanManual( | ||
{ | ||
op: 'function.nextjs', | ||
name: `${componentType}.${generationFunctionIdentifier} (${componentRoute})`, | ||
forceTransaction: true, | ||
attributes: { | ||
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | ||
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
return startSpanManual( | ||
{ | ||
op: 'function.nextjs', | ||
name: `${componentType}.${generationFunctionIdentifier} (${componentRoute})`, | ||
forceTransaction: true, | ||
attributes: { | ||
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | ||
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
}, | ||
}, | ||
}, | ||
span => { | ||
return handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
err => { | ||
if (isNotFoundNavigationError(err)) { | ||
// We don't want to report "not-found"s | ||
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else if (isRedirectNavigationError(err)) { | ||
// We don't want to report redirects | ||
span.setStatus({ code: SPAN_STATUS_OK }); | ||
} else { | ||
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
captureException(err, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
} | ||
}, | ||
() => { | ||
span.end(); | ||
}, | ||
); | ||
}, | ||
); | ||
span => { | ||
return handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
err => { | ||
if (isNotFoundNavigationError(err)) { | ||
// We don't want to report "not-found"s | ||
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else if (isRedirectNavigationError(err)) { | ||
// We don't want to report redirects | ||
span.setStatus({ code: SPAN_STATUS_OK }); | ||
} else { | ||
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
captureException(err, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
} | ||
}, | ||
() => { | ||
span.end(); | ||
}, | ||
); | ||
}, | ||
); | ||
}); | ||
}); | ||
@@ -92,0 +94,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import { withIsolationScope, getCurrentScope, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, handleCallbackErrors, SPAN_STATUS_ERROR, captureException, setHttpStatus } from '@sentry/core'; | ||
import { withIsolationScope, withScope, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, handleCallbackErrors, SPAN_STATUS_ERROR, captureException, setHttpStatus } from '@sentry/core'; | ||
import { winterCGHeadersToDict, propagationContextFromHeaders } from '@sentry/utils'; | ||
@@ -38,53 +38,55 @@ import { isRedirectNavigationError, isNotFoundNavigationError } from './nextNavigationErrorUtils.js'; | ||
return withIsolationScope(isolationScope, async () => { | ||
isolationScope.setTransactionName(`${method} ${parameterizedRoute}`); | ||
getCurrentScope().setPropagationContext(propagationContext); | ||
try { | ||
return startSpan( | ||
{ | ||
name: `${method} ${parameterizedRoute}`, | ||
attributes: { | ||
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | ||
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server', | ||
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
return withIsolationScope(isolationScope, () => { | ||
return withScope(async scope => { | ||
scope.setTransactionName(`${method} ${parameterizedRoute}`); | ||
scope.setPropagationContext(propagationContext); | ||
try { | ||
return startSpan( | ||
{ | ||
name: `${method} ${parameterizedRoute}`, | ||
attributes: { | ||
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'route', | ||
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'http.server', | ||
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
}, | ||
forceTransaction: true, | ||
}, | ||
forceTransaction: true, | ||
}, | ||
async span => { | ||
const response = await handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
error => { | ||
// Next.js throws errors when calling `redirect()`. We don't wanna report these. | ||
if (isRedirectNavigationError(error)) { | ||
// Don't do anything | ||
} else if (isNotFoundNavigationError(error) && span) { | ||
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else { | ||
captureException(error, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
async span => { | ||
const response = await handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
error => { | ||
// Next.js throws errors when calling `redirect()`. We don't wanna report these. | ||
if (isRedirectNavigationError(error)) { | ||
// Don't do anything | ||
} else if (isNotFoundNavigationError(error) && span) { | ||
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else { | ||
captureException(error, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
} | ||
}, | ||
); | ||
try { | ||
if (span && response.status) { | ||
setHttpStatus(span, response.status); | ||
} | ||
}, | ||
); | ||
try { | ||
if (span && response.status) { | ||
setHttpStatus(span, response.status); | ||
} catch (e) { | ||
// best effort - response may be undefined? | ||
} | ||
} catch (e) { | ||
// best effort - response may be undefined? | ||
} | ||
return response; | ||
}, | ||
); | ||
} finally { | ||
if (!platformSupportsStreaming() || process.env.NEXT_RUNTIME === 'edge') { | ||
// 1. Edge transport requires manual flushing | ||
// 2. Lambdas require manual flushing to prevent execution freeze before the event is sent | ||
await flushQueue(); | ||
return response; | ||
}, | ||
); | ||
} finally { | ||
if (!platformSupportsStreaming() || process.env.NEXT_RUNTIME === 'edge') { | ||
// 1. Edge transport requires manual flushing | ||
// 2. Lambdas require manual flushing to prevent execution freeze before the event is sent | ||
await flushQueue(); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
@@ -91,0 +93,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import { withIsolationScope, getCurrentScope, startSpanManual, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, handleCallbackErrors, SPAN_STATUS_ERROR, SPAN_STATUS_OK, captureException } from '@sentry/core'; | ||
import { withIsolationScope, withScope, startSpanManual, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, handleCallbackErrors, SPAN_STATUS_ERROR, SPAN_STATUS_OK, captureException } from '@sentry/core'; | ||
import { winterCGHeadersToDict, propagationContextFromHeaders } from '@sentry/utils'; | ||
@@ -42,43 +42,46 @@ import { isNotFoundNavigationError, isRedirectNavigationError } from './nextNavigationErrorUtils.js'; | ||
return withIsolationScope(isolationScope, () => { | ||
isolationScope.setTransactionName(`${componentType} Server Component (${componentRoute})`); | ||
getCurrentScope().setPropagationContext(propagationContext); | ||
return startSpanManual( | ||
{ | ||
op: 'function.nextjs', | ||
name: `${componentType} Server Component (${componentRoute})`, | ||
forceTransaction: true, | ||
attributes: { | ||
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component', | ||
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
return withScope(scope => { | ||
scope.setTransactionName(`${componentType} Server Component (${componentRoute})`); | ||
scope.setPropagationContext(propagationContext); | ||
return startSpanManual( | ||
{ | ||
op: 'function.nextjs', | ||
name: `${componentType} Server Component (${componentRoute})`, | ||
forceTransaction: true, | ||
attributes: { | ||
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'component', | ||
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.function.nextjs', | ||
}, | ||
}, | ||
}, | ||
span => { | ||
return handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
error => { | ||
if (isNotFoundNavigationError(error)) { | ||
// We don't want to report "not-found"s | ||
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else if (isRedirectNavigationError(error)) { | ||
// We don't want to report redirects | ||
span.setStatus({ code: SPAN_STATUS_OK }); | ||
} else { | ||
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
captureException(error, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
} | ||
}, | ||
() => { | ||
span.end(); | ||
span => { | ||
return handleCallbackErrors( | ||
() => originalFunction.apply(thisArg, args), | ||
error => { | ||
if (isNotFoundNavigationError(error)) { | ||
// We don't want to report "not-found"s | ||
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'not_found' }); | ||
} else if (isRedirectNavigationError(error)) { | ||
// We don't want to report redirects | ||
span.setStatus({ code: SPAN_STATUS_OK }); | ||
} else { | ||
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' }); | ||
captureException(error, { | ||
mechanism: { | ||
handled: false, | ||
}, | ||
}); | ||
} | ||
}, | ||
() => { | ||
span.end(); | ||
// flushQueue should not throw | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
flushQueue(); | ||
}, | ||
); | ||
}, | ||
); | ||
// flushQueue should not throw | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
flushQueue(); | ||
}, | ||
); | ||
}, | ||
); | ||
}); | ||
}); | ||
@@ -85,0 +88,0 @@ }); |
@@ -481,3 +481,4 @@ import { _nullishCoalesce, _optionalChain } from '@sentry/utils'; | ||
/** | ||
* Searches for old `sentry.(server|edge).config.ts` files and warns if it finds any. | ||
* Searches for old `sentry.(server|edge).config.ts` files and Next.js instrumentation hooks and warns if there are "old" | ||
* config files and no signs of them inside the instrumentation hook. | ||
* | ||
@@ -488,5 +489,28 @@ * @param projectDir The root directory of the project, where config files would be located | ||
function warnAboutDeprecatedConfigFiles(projectDir, platform) { | ||
const possibilities = [`sentry.${platform}.config.ts`, `sentry.${platform}.config.js`]; | ||
const hasInstrumentationHookWithIndicationsOfSentry = [ | ||
['src', 'instrumentation.ts'], | ||
['src', 'instrumentation.js'], | ||
['instrumentation.ts'], | ||
['instrumentation.js'], | ||
].some(potentialInstrumentationHookPathSegments => { | ||
try { | ||
const instrumentationHookContent = fs.readFileSync( | ||
path.resolve(projectDir, ...potentialInstrumentationHookPathSegments), | ||
{ encoding: 'utf-8' }, | ||
); | ||
for (const filename of possibilities) { | ||
return ( | ||
instrumentationHookContent.includes('@sentry/') || | ||
instrumentationHookContent.match(/sentry\.(server|edge)\.config\.(ts|js)/) | ||
); | ||
} catch (e) { | ||
return false; | ||
} | ||
}); | ||
if (hasInstrumentationHookWithIndicationsOfSentry) { | ||
return; | ||
} | ||
for (const filename of [`sentry.${platform}.config.ts`, `sentry.${platform}.config.js`]) { | ||
if (fs.existsSync(path.resolve(projectDir, filename))) { | ||
@@ -493,0 +517,0 @@ // eslint-disable-next-line no-console |
@@ -0,3 +1,3 @@ | ||
export { withSentryConfig } from './config/withSentryConfig.js'; | ||
export { ErrorBoundary, createReduxEnhancer, init, showReportDialog, withErrorBoundary } from './server/index.js'; | ||
export { withSentryConfig } from './config/withSentryConfig.js'; | ||
export { captureUnderscoreErrorException } from './common/_error.js'; | ||
@@ -4,0 +4,0 @@ export { wrapApiHandlerWithSentry } from './common/wrapApiHandlerWithSentry.js'; |
{ | ||
"name": "@sentry/nextjs", | ||
"version": "8.0.0-beta.5", | ||
"version": "8.0.0-beta.6", | ||
"description": "Official Sentry SDK for Next.js", | ||
@@ -68,11 +68,11 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@opentelemetry/instrumentation-http": "0.48.0", | ||
"@opentelemetry/instrumentation-http": "0.51.0", | ||
"@rollup/plugin-commonjs": "24.0.0", | ||
"@sentry/core": "8.0.0-beta.5", | ||
"@sentry/node": "8.0.0-beta.5", | ||
"@sentry/opentelemetry": "8.0.0-beta.5", | ||
"@sentry/react": "8.0.0-beta.5", | ||
"@sentry/types": "8.0.0-beta.5", | ||
"@sentry/utils": "8.0.0-beta.5", | ||
"@sentry/vercel-edge": "8.0.0-beta.5", | ||
"@sentry/core": "8.0.0-beta.6", | ||
"@sentry/node": "8.0.0-beta.6", | ||
"@sentry/opentelemetry": "8.0.0-beta.6", | ||
"@sentry/react": "8.0.0-beta.6", | ||
"@sentry/types": "8.0.0-beta.6", | ||
"@sentry/utils": "8.0.0-beta.6", | ||
"@sentry/vercel-edge": "8.0.0-beta.6", | ||
"@sentry/webpack-plugin": "2.16.0", | ||
@@ -79,0 +79,0 @@ "chalk": "3.0.0", |
@@ -7,3 +7,3 @@ import { SentrySpan } from '@sentry/core'; | ||
componentRoute: string; | ||
componentType: string; | ||
componentType: 'Page' | 'Layout' | 'Head' | 'Not-found' | 'Loading' | 'Unknown'; | ||
headers?: WebFetchHeaders; | ||
@@ -10,0 +10,0 @@ }; |
@@ -7,3 +7,3 @@ import type { SentrySpan } from '@sentry/core'; | ||
componentRoute: string; | ||
componentType: string; | ||
componentType: 'Page' | 'Layout' | 'Head' | 'Not-found' | 'Loading' | 'Unknown'; | ||
headers?: WebFetchHeaders; | ||
@@ -10,0 +10,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1715923
10430
+ Added@opentelemetry/api-logs@0.51.0(transitive)
+ Added@opentelemetry/core@1.24.0(transitive)
+ Added@opentelemetry/instrumentation@0.51.0(transitive)
+ Added@opentelemetry/instrumentation-http@0.51.0(transitive)
+ Added@opentelemetry/instrumentation-ioredis@0.40.0(transitive)
+ Added@opentelemetry/redis-common@0.36.2(transitive)
+ Added@opentelemetry/semantic-conventions@1.24.0(transitive)
+ Added@sentry-internal/browser-utils@8.0.0-beta.6(transitive)
+ Added@sentry-internal/feedback@8.0.0-beta.6(transitive)
+ Added@sentry-internal/replay@8.0.0-beta.6(transitive)
+ Added@sentry-internal/replay-canvas@8.0.0-beta.6(transitive)
+ Added@sentry/browser@8.0.0-beta.6(transitive)
+ Added@sentry/core@8.0.0-beta.6(transitive)
+ Added@sentry/node@8.0.0-beta.6(transitive)
+ Added@sentry/opentelemetry@8.0.0-beta.6(transitive)
+ Added@sentry/react@8.0.0-beta.6(transitive)
+ Added@sentry/types@8.0.0-beta.6(transitive)
+ Added@sentry/utils@8.0.0-beta.6(transitive)
+ Added@sentry/vercel-edge@8.0.0-beta.6(transitive)
- Removed@opentelemetry/api@1.7.0(transitive)
- Removed@opentelemetry/core@1.21.0(transitive)
- Removed@opentelemetry/instrumentation-http@0.48.0(transitive)
- Removed@opentelemetry/semantic-conventions@1.21.0(transitive)
- Removed@sentry-internal/browser-utils@8.0.0-beta.5(transitive)
- Removed@sentry-internal/feedback@8.0.0-beta.5(transitive)
- Removed@sentry-internal/replay@8.0.0-beta.5(transitive)
- Removed@sentry-internal/replay-canvas@8.0.0-beta.5(transitive)
- Removed@sentry/browser@8.0.0-beta.5(transitive)
- Removed@sentry/core@8.0.0-beta.5(transitive)
- Removed@sentry/node@8.0.0-beta.5(transitive)
- Removed@sentry/opentelemetry@8.0.0-beta.5(transitive)
- Removed@sentry/react@8.0.0-beta.5(transitive)
- Removed@sentry/types@8.0.0-beta.5(transitive)
- Removed@sentry/utils@8.0.0-beta.5(transitive)
- Removed@sentry/vercel-edge@8.0.0-beta.5(transitive)
Updated@sentry/core@8.0.0-beta.6
Updated@sentry/node@8.0.0-beta.6
Updated@sentry/react@8.0.0-beta.6
Updated@sentry/types@8.0.0-beta.6
Updated@sentry/utils@8.0.0-beta.6