RewriteFrames

允许您对堆栈跟踪的每一帧应用转换。

Import name: Sentry.rewriteFramesIntegration

此集成允许您对堆栈跟踪的每一帧应用转换。在简化场景中,它可以用于更改帧来源文件的名称,或者可以通过迭代函数应用任意转换。

在 Windows 机器上,您必须使用 Unix 路径并在 root 选项中省略卷字母以启用它。例如,C:\\Program Files\\Apache\\www 不会工作,但 /Program Files/Apache/www 会。

Copied
import * as Sentry from "@sentry/node";

Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  integrations: [Sentry.rewriteFramesIntegration(
    {
      // root path that will be stripped from the current frame's filename by the default iteratee if the filename is an absolute path
      root: string;

      // a custom prefix that will be used by the default iteratee (default: `app://`)
      prefix: string;

      // function that takes the frame, applies a transformation, and returns it
      iteratee: (frame) => frame;
    }
  )],
});

Type: string

根路径,如果文件名是绝对路径,默认迭代器会从当前帧的文件名中剥离该路径。

Type: string

默认迭代器将使用的自定义前缀。 默认值:app://

Type: (frame) => frame

接收帧、应用转换并返回帧的函数。

例如,如果您的文件的完整路径是 /www/src/app/file.js

用法堆栈跟踪中的路径描述
rewriteFramesIntegration()app:///file.js默认行为是替换绝对路径(保留文件名),并使用默认前缀 (app:///) 进行前缀。
rewriteFramesIntegration({prefix: 'foo/'})foo/file.js使用前缀 foo/ 替代默认前缀 app:///
rewriteFramesIntegration({root: '/www'})app:///src/app/file.jsroot 定义为 /www,因此仅从路径开头修剪该部分。