-
I am currently using "@sentry/nextjs": "7.118.0", due to our next js version being outdated ( "next": "13.1.2"). Im trying to test out the sentry's capabilities on my trial mode before committing to a plan, yet I'm really struggling to get it work (assuming what I'm trying to do is achievable). Docs are very minimal and quite hard to follow as they contain very basic info/examples. It this thing that I'm doing even possible with the version Im using? Sentry Debug log Returns: Sentry Logger [error]: Transport disabled here are my following configs. //next.config.js
const nextConfig = { //..mynextconfigs its very long }
const sentryOptions = {
org: //myorgnamegoeshere,
project: //myprojectgoeshere,
// // An auth token is required for uploading source maps.
// authToken: process.env.SENTRY_AUTH_TOKEN,
silent: false, // Can be used to suppress logs
hideSourceMaps: true, // Hide source maps to prevent the built files from containing a sourceMappingURL comment
disableLogger: true, // Disable the Sentry SDK Debug Logger to save bundle size
};
module.exports = withSentryConfig(nextConfig, sentryOptions); // sentry.client.config.js
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: process.env.SECRET_SENTRY_DSN,
// Replay may only be enabled for the client-side
integrations: [Sentry.replayIntegration()],
/** @sentryOptions Recommend adjusting this value in production. @sentryOptions */
// This option is required for capturing headers and cookies.
// sendDefaultPii: true,
/**
* @function TraceSampleRate
* @description Provides an even cross-section of transactions, no matter where in your app or under what circumstances they occur.
*/
tracesSampleRate: 1.0, // 0 = 0%, 0.5 = 50%, 1.0 = 100%,
/**
* @function sampleRate
* @description Samples different transactions at different rates
*/
// sampleRate: 0.5, // 0 = 0%, 0.5 = 50%, 1.0 = 100%,
/**
* @function ReplaySessions/Errors
* @description Captures Replay for 0% of all session, and 100% session with an Error
*/
// replaysSessionSampleRate: 0,
// replaysOnErrorSampleRate: 1.0,
debug: true,
// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
// that it will also get attached to your source maps
}); // RTK base query
const baseQueryWithErrorHandling = async (args, api, extraOptions) => {
const result = await baseQueryConfig(args, api, extraOptions);
if (result.error && result.error.status >= 400) {
const errorMessage = result.error.data ? result.error.data.message : result.error.error;
console.log(errorMessage) // successfully logs the actual message or error.
// This is not working.... idk
Sentry.captureException(new Error(`API Error: ${errorMessage}`), {
tags: {
endpoint: args.url,
method: args.method || 'unknown',
},
extra: {
status: result.error.status,
body: result.error.data || result.error,
},
});
}
return result;
};
//reset of slice code here...
export const cypherApiSlice = createApi({
reducerPath: 'cypher',
tagTypes,
baseQuery: baseQueryWithErrorHandling,
// ...rest of query/builders...
}) ** I've tried and testing it with a simple button press that throws an error ** // test button component
const throwError = () => {
try {
throw new Error('Test error for Sentry');
} catch (error) {
console.log(error, 'ERROR'); // LOGS THE ERROR!
// not working
Sentry.captureException(error);
}
};
// component
<Stack onClick={throwError}>
<Typography>Test</Typography>
</Stack> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Fixed my issue. it is due to the DSN. process.env.SECRET_SENTRY_DSN when it should have a prefix of NEXT_PUBLIC_*. |
Beta Was this translation helpful? Give feedback.
Fixed my issue. it is due to the DSN. process.env.SECRET_SENTRY_DSN when it should have a prefix of NEXT_PUBLIC_*.