Skip to content

Sentry Next.js stack traces display original typescript code #6621

@InnaAndreeva

Description

@InnaAndreeva

Problem Statement

Hello!
I am using a @sentry/nextjs package to submit build artifacts to Sentry.io. However Sentry displays javascript code because typescript code compiles into javascript. Such traces are quite hard to read for our team.
My tsconfig.json looks like

{
"extends": "./tsconfig",
  "compilerOptions": {
    "sourceMap": true,
    "inlineSources": true,
    "sourceRoot": "/"
  }
}

Where tsconfig is standard Next.js tsconfig.json file.
sentry.client.config.js and sentry.server.config.js files contain integrations property configured such way

import { RewriteFrames } from '@sentry/integrations';

const SENTRY_DSN = 'https://my-awesome-dsn';

Sentry.init({
    dsn: SENTRY_DSN,
    // Adjust this value in production, or use tracesSampler for greater control
    tracesSampleRate: 1.0,
    integrations: [
        new RewriteFrames({
            root: process.cwd(),
        }),
    ],

});

So root property contains the path to the root directory with typescript code.

I use @sentry/nextjs 7.14.2 and next 12.3.1

Could you tell, If it possible to load original typescript files into Sentry and render stack traces with TS code?

Solution Brainstorm

Maybe it is possible to override next.js _next/static/chunks/ directory content with root directory with source code

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions