From fab4ef56bc45925b0de3ff8cae8e96810b5475d2 Mon Sep 17 00:00:00 2001 From: m5r Date: Tue, 7 Sep 2021 04:58:31 +0800 Subject: [PATCH] enable apdex --- integrations/sentry.ts | 26 ++++++++++++------ package-lock.json | 60 +++++++++++++++++++++++++++++++++++++----- package.json | 1 + 3 files changed, 72 insertions(+), 15 deletions(-) diff --git a/integrations/sentry.ts b/integrations/sentry.ts index 1471d45..84d0287 100644 --- a/integrations/sentry.ts +++ b/integrations/sentry.ts @@ -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; diff --git a/package-lock.json b/package-lock.json index e21b56a..35a0364 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index c74dca4..41905b8 100644 --- a/package.json +++ b/package.json @@ -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",