getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.97k stars 1.57k forks source link

Typescript Source maps aren't linking #3883

Closed suneettipirneni closed 3 years ago

suneettipirneni commented 3 years ago

Package + Version

Version:

6.11.0

Link to issue: https://sentry.io/organizations/knight-hacks/issues/2563023410/?project=5898063&query=is%3Aunresolved

Description

I followed the steps outlined in docs for enabling source maps with typescript:

src/index.ts

/* eslint-disable @typescript-eslint/no-namespace */
/* eslint-disable @typescript-eslint/ban-ts-comment */
import * as Sentry from '@sentry/node';
import { RewriteFrames } from '@sentry/integrations';

// This allows TypeScript to detect our global value
declare global {
  namespace NodeJS {
    interface Global {
      __rootdir__: string;
    }
  }
}

// @ts-ignore
global.__rootdir__ = __dirname || process.cwd();

Sentry.init({
    dsn: process.env.SENTRY_DSN,
    environment: process.env.NODE_ENV,
    release: '0.3',
    integrations: [
      new RewriteFrames({
        // @ts-ignore
        root: global.__rootdir__,
      }),
    ],
  });

In addition I'm using the reccomended tsconfig production file:

tsconfig.production.json

{
  "extends": "./tsconfig",
  "compilerOptions": {
    "sourceMap": true,
    "inlineSources": true,
    "sourceRoot": "/",
  },
  "exclude": ["node_modules", "dist"]
}

I'm then releasing my source maps via:

sentry-cli releases files "0.3" upload-sourcemaps ./dist

However I still get errors reported in the compiled JS files, and the stack traces aren't linked.

For example here is my error path:

Screen Shot 2021-08-09 at 1 54 49 PM

And here is the corresponding script and sourcemap path(s):

Screen Shot 2021-08-09 at 1 55 54 PM

But for some reason it's not linking. I followed the solution given #3189, and I had no avail.

suneettipirneni commented 3 years ago

Figured it out, I wasn't using a Transaction with my error.

depombo commented 2 years ago

Figured it out, I wasn't using a Transaction with my error.

@suneettipirneni I'm running into this issue and replicated your setup. However, I am not sure what you mean by using a Transaction for your error. Can you please elaborate?