enable apdex

This commit is contained in:
m5r
2021-09-07 04:58:31 +08:00
parent bdac93d7e1
commit fab4ef56bc
3 changed files with 72 additions and 15 deletions

View File

@ -1,19 +1,29 @@
import * as Sentry from "@sentry/node";
import getConfig from "next/config";
import type { Integration } from "@sentry/types";
import { RewriteFrames } from "@sentry/integrations";
import { Integrations as TracingIntegrations } from "@sentry/tracing";
if (process.env.SENTRY_DSN) {
const config = getConfig();
const distDir = `${config.serverRuntimeConfig.rootDir}/.next`;
const integrations: Integration[] = [
new RewriteFrames({
iteratee: (frame) => {
frame.filename = frame.filename!.replace(distDir, "app:///_next");
return frame;
},
}),
];
if (typeof window !== "undefined") {
integrations.push(new TracingIntegrations.BrowserTracing());
} else {
integrations.push(new Sentry.Integrations.Http({ tracing: true }));
}
Sentry.init({
integrations: [
new RewriteFrames({
iteratee: (frame: any) => {
frame.filename = frame.filename.replace(distDir, "app:///_next");
return frame;
},
}),
],
integrations,
tracesSampleRate: 0.5,
dsn: process.env.SENTRY_DSN,
beforeSend(event, hint) {
const error = hint?.originalException;