Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@
"test": "run-s test:unit test:integration",
"test:watch": "jest --watch",
"test:unit": "jest",
"test:integration": "run-s test:integration:build test:integration:server test:integration:client",
"test:integration:build": "cd test/integration && yarn && yarn build && cd ../..",
"test:integration:server": "node test/integration/test/server.js --silent",
"test:integration:client": "node test/integration/test/client.js --silent",
"test:integration": "run-s test:integration:clean test:integration:build test:integration:server test:integration:client",
"test:integration:clean": "cd test/integration && rimraf node_modules .next .env.local",
"test:integration:build": "cd test/integration && yarn && yarn build",
"test:integration:server": "cd test/integration && node test/server.js --silent",
"test:integration:client": "cd test/integration && node test/client.js --silent",
"pack": "npm pack",
"vercel:branch": "source vercel/set-up-branch-for-test-app-use.sh",
"vercel:project": "source vercel/make-project-use-current-branch.sh"
Expand Down
12 changes: 8 additions & 4 deletions packages/nextjs/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as path from 'path';

const SENTRY_CLIENT_CONFIG_FILE = './sentry.client.config.js';
const SENTRY_SERVER_CONFIG_FILE = './sentry.server.config.js';
// this is where the transpiled/bundled version of `USER_SERVER_CONFIG_FILE` will end up
// this is where the transpiled/bundled version of `SENTRY_SERVER_CONFIG_FILE` will end up
export const SERVER_SDK_INIT_PATH = 'sentry/initServerSDK.js';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -21,7 +21,7 @@ type WebpackConfig = {
devtool: string;
plugins: PlainObject[];
entry: EntryProperty;
output: { path: string };
output: { filename: string; path: string };
target: string;
context: string;
};
Expand Down Expand Up @@ -156,9 +156,13 @@ export function withSentryConfig(
// if we're building server code, store the webpack output path as an env variable, so we know where to look for the
// webpack-processed version of `sentry.server.config.js` when we need it
if (config.target === 'node') {
const serverSDKInitOutputPath = path.join(config.output.path, SERVER_SDK_INIT_PATH);
const outputLocation = path.dirname(path.join(config.output.path, config.output.filename));
const serverSDKInitOutputPath = path.join(outputLocation, SERVER_SDK_INIT_PATH);
const projectDir = config.context;
setRuntimeEnvVars(projectDir, { SENTRY_SERVER_INIT_PATH: serverSDKInitOutputPath });
setRuntimeEnvVars(projectDir, {
// ex: .next/server/sentry/initServerSdk.js
SENTRY_SERVER_INIT_PATH: path.relative(projectDir, serverSDKInitOutputPath),
});
}

let newConfig = config;
Expand Down
9 changes: 6 additions & 3 deletions packages/nextjs/src/utils/instrumentServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fill, isString, logger, stripUrlQueryAndFragment } from '@sentry/utils'
import * as domain from 'domain';
import * as http from 'http';
import { default as createNextServer } from 'next';
import * as path from 'path';
import * as querystring from 'querystring';
import * as url from 'url';

Expand Down Expand Up @@ -114,11 +115,13 @@ function makeWrappedHandlerGetter(origHandlerGetter: HandlerGetter): WrappedHand
try {
// `SENTRY_SERVER_INIT_PATH` is set at build time, and points to a webpack-processed version of the user's
// `sentry.server.config.js`. Requiring it starts the SDK.
require(process.env.SENTRY_SERVER_INIT_PATH as string);
require(path.resolve(process.env.SENTRY_SERVER_INIT_PATH as string));
} catch (err) {
// Log the error but don't bail - we still want the wrapping to happen, in case the user is doing something weird
// and manually calling `Sentry.init()` somewhere else.
logger.error(`[Sentry] Could not initialize SDK. Received error:\n${err}`);
// and manually calling `Sentry.init()` somewhere else. We log to console instead of using logger from utils
// because Sentry is not initialized.
// eslint-disable-next-line no-console
console.error(`[Sentry] Could not initialize SDK. Received error:\n${err}`);
}

// stash this in the closure so that `makeWrappedReqHandler` can use it
Expand Down
152 changes: 76 additions & 76 deletions packages/nextjs/test/integration/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@
resolved "https://registry.yarnpkg.com/@opentelemetry/context-base/-/context-base-0.14.0.tgz#c67fc20a4d891447ca1a855d7d70fa79a3533001"
integrity sha512-sDOAZcYwynHFTbLo6n8kIbLiVF3a3BLkrmehJUyEbT9F+Smbi47kLGS2gG2g0fjBLR/Lr1InPD7kXL7FaTqEkw==

"@sentry/[email protected].0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.5.0.tgz#2382493691c3fac5d8b652ae46f09f1b29d288ef"
integrity sha512-n1e8hNKwuVP4bLqRK5J0DHFqnnnrbv6h6+Bc1eNRbf32/e6eZ3Cb36PTplqDCxwnMnnIEEowd5F4ZWeTLPPY3A==
dependencies:
"@sentry/core" "6.5.0"
"@sentry/types" "6.5.0"
"@sentry/utils" "6.5.0"
"@sentry/[email protected].1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.5.1.tgz#9a6ed5607b3b0f4e83f38720e3e202906f8c5bdb"
integrity sha512-iVLCdEFwsoWAzE/hNknexPQjjDpMQV7mmaq9Z1P63bD6MfhwVTx4hG4pHn8HEvC38VvCVf1wv0v/LxtoODAYXg==
dependencies:
"@sentry/core" "6.5.1"
"@sentry/types" "6.5.1"
"@sentry/utils" "6.5.1"
tslib "^1.9.3"

"@sentry/cli@^1.63.1":
Expand All @@ -125,106 +125,106 @@
progress "^2.0.3"
proxy-from-env "^1.1.0"

"@sentry/[email protected].0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.5.0.tgz#03ecbad7845b31f03a84eddf4884877c999bb6be"
integrity sha512-Hx/WvhM5bXcXqfIiz+505TjYYfPjQ8mrxby/EWl+L7dYUCyI/W6IZKTc/MoHlLuM+JPUW9c1bw/97TzbgTzaAA==
"@sentry/[email protected].1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.5.1.tgz#c8b6c3ed86ed07b193c95d599c1b9a4a161e500e"
integrity sha512-Mh3sl/iUOT1myHmM6RlDy2ARzkUClx/g4DAt1rJ/IpQBOlDYQraplXSIW80i/hzRgQDfwhwgf4wUa5DicKBjKw==
dependencies:
"@sentry/hub" "6.5.0"
"@sentry/minimal" "6.5.0"
"@sentry/types" "6.5.0"
"@sentry/utils" "6.5.0"
"@sentry/hub" "6.5.1"
"@sentry/minimal" "6.5.1"
"@sentry/types" "6.5.1"
"@sentry/utils" "6.5.1"
tslib "^1.9.3"

"@sentry/[email protected].0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.5.0.tgz#ad3c9bcf83050ea217f3c25cc625e6b447f1d9d7"
integrity sha512-vEChnLoozOJzEJoTUvaAsK/n7IHoQFx8P1TzQmnR+8XGZJZmGHG6bBXUH0iS2a9hhR1WkoEBeiL+t96R9uyf0A==
"@sentry/[email protected].1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.5.1.tgz#135ef09d07d32e87a53f664c0ae8fcc4f5963519"
integrity sha512-lBRMBVMYP8B4PfRiM70murbtJAXiIAao/asDEMIRNGMP6pI2ArqXfJCBYDkStukhikYD0Kqb4trXq+JYF07Hbg==
dependencies:
"@sentry/types" "6.5.0"
"@sentry/utils" "6.5.0"
"@sentry/types" "6.5.1"
"@sentry/utils" "6.5.1"
tslib "^1.9.3"

"@sentry/[email protected].0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-6.5.0.tgz#b97702f5d5e5456b9fae225b60141bd014671662"
integrity sha512-pI8DESNTbsj60CDtLzIdLHex59NGzjTBR9Wpt7SG8NPhgEAuS3tUU4Thjyib7sGb7mxRw1sSQt/FsjDd7vMjLg==
"@sentry/[email protected].1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-6.5.1.tgz#e7016f3023a98e2ef893daba18ba74bd8d62654b"
integrity sha512-NYiW0rH7fwv7aRtrRnfCSIiwulfV2NoLjhmghCONsyo10DNtYmOpogLotCytZFWLDnTJW1+pmTomq8UW/OSTcQ==
dependencies:
"@sentry/types" "6.5.0"
"@sentry/utils" "6.5.0"
"@sentry/types" "6.5.1"
"@sentry/utils" "6.5.1"
localforage "^1.8.1"
tslib "^1.9.3"

"@sentry/[email protected].0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.5.0.tgz#aa89b8e24c88aa85c99ef64e0b460497c90133f9"
integrity sha512-MT83ONaBhTCFUlDIQFpsG/lq3ZjGK7jwQ10qxGadSg1KW6EvtQRg+OBwULeQ7C+nNEAhseNrC/qomZMT8brncg==
"@sentry/[email protected].1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.5.1.tgz#b8c1b382c2ea788eec3d32d203e5081b00eb6838"
integrity sha512-q9Do/oreu1RP695CXCLowVDuQyk7ilE6FGdz2QLpTXAfx8247qOwk6+zy9Kea/Djk93+BoSDVQUSneNiVwl0nQ==
dependencies:
"@sentry/hub" "6.5.0"
"@sentry/types" "6.5.0"
"@sentry/hub" "6.5.1"
"@sentry/types" "6.5.1"
tslib "^1.9.3"

"@sentry/nextjs@file:../..":
version "6.5.0"
dependencies:
"@sentry/core" "6.5.0"
"@sentry/integrations" "6.5.0"
"@sentry/node" "6.5.0"
"@sentry/react" "6.5.0"
"@sentry/tracing" "6.5.0"
"@sentry/utils" "6.5.0"
version "6.5.1"
dependencies:
"@sentry/core" "6.5.1"
"@sentry/integrations" "6.5.1"
"@sentry/node" "6.5.1"
"@sentry/react" "6.5.1"
"@sentry/tracing" "6.5.1"
"@sentry/utils" "6.5.1"
"@sentry/webpack-plugin" "1.15.0"
tslib "^1.9.3"

"@sentry/[email protected].0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.5.0.tgz#4c043792bae0b84de7c485fad605fd871be050a5"
integrity sha512-KSypDtc8XPoyMdL1BCdkNokNmEaf+AZhD4HTElmIKHpIyiYvM1bSqiOpVohnwR3E+5qNeVVBPoVjDpHWRaNzQg==
"@sentry/[email protected].1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.5.1.tgz#a572b380858de5aeaf98eade6d8d3afcba13d364"
integrity sha512-Yh8J/QJ5e8gRBVL9VLCDpUvmiaxsxVZm0CInPHw3V/smgMkrzSKEiqxSeMq8ImPlaJrCFECqdpv4gnvYKI+mQQ==
dependencies:
"@sentry/core" "6.5.0"
"@sentry/hub" "6.5.0"
"@sentry/tracing" "6.5.0"
"@sentry/types" "6.5.0"
"@sentry/utils" "6.5.0"
"@sentry/core" "6.5.1"
"@sentry/hub" "6.5.1"
"@sentry/tracing" "6.5.1"
"@sentry/types" "6.5.1"
"@sentry/utils" "6.5.1"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
tslib "^1.9.3"

"@sentry/[email protected].0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.5.0.tgz#db2067e080cac24da046af24865b82d3567adbf4"
integrity sha512-NyH+v8MwX+nzuhPRGy3+DHSB0es5yaCUNrtAdCtbe8EhERSoYvqAyWIQ+Fp5++PGjfAtYbz0W0IpsjguZbnT2Q==
"@sentry/[email protected].1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.5.1.tgz#1c7019fc3d8b1168c1ab8936cb65971b314d060d"
integrity sha512-YeGi7FzInhMZQxiy5fKqb7kS6W+u4NfsjzsVV3bLjJ1kiVtbpzZ2gs+ObHqW3zVE622V4nL7A4P8/CBHbcm5PA==
dependencies:
"@sentry/browser" "6.5.0"
"@sentry/minimal" "6.5.0"
"@sentry/types" "6.5.0"
"@sentry/utils" "6.5.0"
"@sentry/browser" "6.5.1"
"@sentry/minimal" "6.5.1"
"@sentry/types" "6.5.1"
"@sentry/utils" "6.5.1"
hoist-non-react-statics "^3.3.2"
tslib "^1.9.3"

"@sentry/[email protected].0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.5.0.tgz#4d8efce53362a820d002838495f0ef446150aefc"
integrity sha512-6jpmYM3Lt4w6dOeK8keGAis722ooLtX5UcPbekkTufXiqKRR5VWg8DLUp7z7oD6h4GLrLbeNtCiH6h20ZW2ggw==
"@sentry/[email protected].1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.5.1.tgz#a5f3e497d4f1f319f36475df050e135cf65af750"
integrity sha512-y1W/xFC2hAuKqSuuaovkElHY4pbli3XoXrreesg8PtO7ilX6ZbatOQbHsEsHQyoUv0F6aVA+MABOxWH2jt7tfw==
dependencies:
"@sentry/hub" "6.5.0"
"@sentry/minimal" "6.5.0"
"@sentry/types" "6.5.0"
"@sentry/utils" "6.5.0"
"@sentry/hub" "6.5.1"
"@sentry/minimal" "6.5.1"
"@sentry/types" "6.5.1"
"@sentry/utils" "6.5.1"
tslib "^1.9.3"

"@sentry/[email protected].0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.5.0.tgz#2cdb50875bb73d87708b9c0a80d4ca057b3596b5"
integrity sha512-yQpTCIYxBsYT0GenqHNNKeXV8CSkkYlAxB1IGV2eac4IKC5ph5GW6TfDGwvlzQSQ297RsRmOSA8o3I5gGPd2yA==
"@sentry/[email protected].1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.5.1.tgz#0a34ecfd1ae9275a416a105640eb4bed45a46a1d"
integrity sha512-b/7a6CMoytaeFPx4IBjfxPw3nPvsQh7ui1C8Vw0LxNNDgBwVhPLzUOWeLWbo5YZCVbGEMIWwtCUQYWxneceZSA==

"@sentry/[email protected].0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.5.0.tgz#8722542b9a901623195cffaab5d18ce176c1e459"
integrity sha512-CcHuaQN6vRuAsIC+3sA23NmWLRmUN0x/HNQxk0DHJylvYQdEA0AUNoLXogykaXh6NrCx4DNq9yCQTNTSC3mFxg==
"@sentry/[email protected].1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.5.1.tgz#046baf7d1a6564d6d555437ad3674dba9bc0806a"
integrity sha512-Wv86JYGQH+ZJ5XGFQX7h6ijl32667ikenoL9EyXMn8UoOYX/MLwZoQZin1P60wmKkYR9ifTNVmpaI9OoTaH+UQ==
dependencies:
"@sentry/types" "6.5.0"
"@sentry/types" "6.5.1"
tslib "^1.9.3"

"@sentry/[email protected]":
Expand Down