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`;
Sentry.init({
integrations: [
const integrations: Integration[] = [
new RewriteFrames({
iteratee: (frame: any) => {
frame.filename = frame.filename.replace(distDir, "app:///_next");
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,
tracesSampleRate: 0.5,
dsn: process.env.SENTRY_DSN,
beforeSend(event, hint) {
const error = hint?.originalException;

60
package-lock.json generated
View File

@ -4034,17 +4034,51 @@
}
},
"@sentry/tracing": {
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.11.0.tgz",
"integrity": "sha512-9VA1/SY++WeoMQI4K6n/sYgIdRtCu9NLWqmGqu/5kbOtESYFgAt1DqSyqGCr00ZjQiC2s7tkDkTNZb38K6KytQ==",
"version": "6.12.0",
"resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.12.0.tgz",
"integrity": "sha512-u10QHNknPBzbWSUUNMkvuH53sQd5NaBo6YdNPj4p5b7sE7445Sh0PwBpRbY3ZiUUiwyxV59fx9UQ4yVnPGxZQA==",
"requires": {
"@sentry/hub": "6.11.0",
"@sentry/minimal": "6.11.0",
"@sentry/types": "6.11.0",
"@sentry/utils": "6.11.0",
"@sentry/hub": "6.12.0",
"@sentry/minimal": "6.12.0",
"@sentry/types": "6.12.0",
"@sentry/utils": "6.12.0",
"tslib": "^1.9.3"
},
"dependencies": {
"@sentry/hub": {
"version": "6.12.0",
"resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-6.12.0.tgz",
"integrity": "sha512-yR/UQVU+ukr42bSYpeqvb989SowIXlKBanU0cqLFDmv5LPCnaQB8PGeXwJAwWhQgx44PARhmB82S6Xor8gYNxg==",
"requires": {
"@sentry/types": "6.12.0",
"@sentry/utils": "6.12.0",
"tslib": "^1.9.3"
}
},
"@sentry/minimal": {
"version": "6.12.0",
"resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-6.12.0.tgz",
"integrity": "sha512-r3C54Q1KN+xIqUvcgX9DlcoWE7ezWvFk2pSu1Ojx9De81hVqR9u5T3sdSAP2Xma+um0zr6coOtDJG4WtYlOtsw==",
"requires": {
"@sentry/hub": "6.12.0",
"@sentry/types": "6.12.0",
"tslib": "^1.9.3"
}
},
"@sentry/types": {
"version": "6.12.0",
"resolved": "https://registry.npmjs.org/@sentry/types/-/types-6.12.0.tgz",
"integrity": "sha512-urtgLzE4EDMAYQHYdkgC0Ei9QvLajodK1ntg71bGn0Pm84QUpaqpPDfHRU+i6jLeteyC7kWwa5O5W1m/jrjGXA=="
},
"@sentry/utils": {
"version": "6.12.0",
"resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-6.12.0.tgz",
"integrity": "sha512-oRHQ7TH5TSsJqoP9Gqq25Jvn9LKexXfAh/OoKwjMhYCGKGhqpDNUIZVgl9DWsGw5A5N5xnQyLOxDfyRV5RshdA==",
"requires": {
"@sentry/types": "6.12.0",
"tslib": "^1.9.3"
}
},
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
@ -16465,6 +16499,18 @@
"tslib": "^1.9.3"
}
},
"@sentry/tracing": {
"version": "6.11.0",
"resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-6.11.0.tgz",
"integrity": "sha512-9VA1/SY++WeoMQI4K6n/sYgIdRtCu9NLWqmGqu/5kbOtESYFgAt1DqSyqGCr00ZjQiC2s7tkDkTNZb38K6KytQ==",
"requires": {
"@sentry/hub": "6.11.0",
"@sentry/minimal": "6.11.0",
"@sentry/types": "6.11.0",
"@sentry/utils": "6.11.0",
"tslib": "^1.9.3"
}
},
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",

View File

@ -52,6 +52,7 @@
"@sentry/browser": "6.12.0",
"@sentry/integrations": "6.12.0",
"@sentry/node": "6.12.0",
"@sentry/tracing": "6.12.0",
"@sentry/webpack-plugin": "1.17.1",
"@tailwindcss/forms": "0.3.3",
"@tailwindcss/line-clamp": "0.2.1",