@honeybadger-io/nextjs 5.3.0 → 5.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,4 +2,5 @@
2
2
  declare const path: any;
3
3
  declare const fs: any;
4
4
  declare const debug: boolean;
5
+ declare function copyErrorJs(): Promise<any>;
5
6
  declare function copyConfigFiles(): Promise<void>;
@@ -3,6 +3,18 @@
3
3
  const path = require('path');
4
4
  const fs = require('fs');
5
5
  const debug = process.env.HONEYBADGER_DEBUG === 'true';
6
+ async function copyErrorJs() {
7
+ const targetPath = path.join('pages', '_error.js');
8
+ const errorJsAlreadyExists = fs.existsSync(targetPath);
9
+ if (errorJsAlreadyExists) {
10
+ // Don't overwrite an existing _error.js file.
11
+ // Create a _error.js.bak file instead.
12
+ const backupPath = path.join('pages', '_error.js.bak');
13
+ await fs.promises.copyFile(targetPath, backupPath);
14
+ }
15
+ const sourcePath = path.resolve(__dirname, '../templates/_error.js');
16
+ return fs.promises.copyFile(sourcePath, targetPath);
17
+ }
6
18
  async function copyConfigFiles() {
7
19
  if (debug) {
8
20
  console.debug('cwd', process.cwd());
@@ -13,7 +25,7 @@ async function copyConfigFiles() {
13
25
  if (debug) {
14
26
  console.debug('copying', file);
15
27
  }
16
- return fs.promises.copyFile(path.join(templateDir, file), file);
28
+ return file === '_error.js' ? copyErrorJs() : fs.promises.copyFile(path.join(templateDir, file), file);
17
29
  });
18
30
  await Promise.all(copyPromises);
19
31
  console.log('Done copying config files.');
@@ -1 +1 @@
1
- {"version":3,"file":"copy-config-files.js","sourceRoot":"","sources":["../src/copy-config-files.ts"],"names":[],"mappings":";;AAEA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAExB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,MAAM,CAAA;AAEtD,KAAK,UAAU,eAAe;IAC5B,IAAI,KAAK,EAAE;QACT,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;KACpC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACrD,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACtC,IAAI,KAAK,EAAE;YACT,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;SAC/B;QACD,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAEhC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAC3C,CAAC;AAED,eAAe,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC9B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nconst path = require('path')\nconst fs = require('fs')\n\nconst debug = process.env.HONEYBADGER_DEBUG === 'true'\n\nasync function copyConfigFiles() {\n if (debug) {\n console.debug('cwd', process.cwd())\n }\n\n const templateDir = path.resolve(__dirname, '../templates');\n const files = await fs.promises.readdir(templateDir);\n const copyPromises = files.map((file) => {\n if (debug) {\n console.debug('copying', file)\n }\n return fs.promises.copyFile(path.join(templateDir, file), file);\n });\n await Promise.all(copyPromises);\n\n console.log('Done copying config files.')\n}\n\ncopyConfigFiles().catch((err) =>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AAI,KAAK,EAAE;YACT,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;SAC/B;QAED,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;IACxG,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAC3C,CAAC;AAED,eAAe,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC9B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nconst path = require('path')\nconst fs = require('fs')\n\nconst debug = process.env.HONEYBADGER_DEBUG === 'true'\n\nasync function copyErrorJs() {\n const targetPath = path.join('pages', '_error.js')\n const errorJsAlreadyExists = fs.existsSync(targetPath)\n if (errorJsAlreadyExists) {\n // Don't overwrite an existing _error.js file.\n // Create a _error.js.bak file instead.\n const backupPath = path.join('pages', '_error.js.bak')\n await fs.promises.copyFile(targetPath, backupPath)\n }\n\n const sourcePath = path.resolve(__dirname, '../templates/_error.js')\n\n return fs.promises.copyFile(sourcePath, targetPath)\n}\n\nasync function copyConfigFiles() {\n if (debug) {\n console.debug('cwd', process.cwd())\n }\n\n const templateDir = path.resolve(__dirname, '../templates')\n const files = await fs.promises.readdir(templateDir)\n const copyPromises = files.map((file) => {\n if (debug) {\n console.debug('copying', file)\n }\n\n return file === '_error.js' ? copyErrorJs() : fs.promises.copyFile(path.join(templateDir, file), file)\n });\n await Promise.all(copyPromises);\n console.log('Done copying config files.')\n}\n\ncopyConfigFiles().catch((err) => {\n console.error(err)\n process.exit(1)\n})\n"]}
@@ -28,14 +28,6 @@ function shouldUploadSourceMaps(honeybadgerNextJsConfig, context) {
28
28
  }
29
29
  return true;
30
30
  }
31
- function setupHoneybadger(config, honeybadgerNextJsConfig) {
32
- var _a;
33
- _silent = (_a = honeybadgerNextJsConfig === null || honeybadgerNextJsConfig === void 0 ? void 0 : honeybadgerNextJsConfig.silent) !== null && _a !== void 0 ? _a : true;
34
- return {
35
- ...config,
36
- webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)
37
- };
38
- }
39
31
  function mergeWithExistingWebpackConfig(nextJsWebpackConfig, honeybadgerNextJsConfig) {
40
32
  return function webpackFunctionMergedWithHb(webpackConfig, context) {
41
33
  const { isServer, dir: projectDir, nextRuntime } = context;
@@ -147,6 +139,14 @@ function getWebpackPluginOptions(honeybadgerNextJsConfig) {
147
139
  silent: _silent,
148
140
  };
149
141
  }
142
+ function setupHoneybadger(config, honeybadgerNextJsConfig) {
143
+ var _a;
144
+ _silent = (_a = honeybadgerNextJsConfig === null || honeybadgerNextJsConfig === void 0 ? void 0 : honeybadgerNextJsConfig.silent) !== null && _a !== void 0 ? _a : true;
145
+ return {
146
+ ...config,
147
+ webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)
148
+ };
149
+ }
150
150
 
151
151
  exports.setupHoneybadger = setupHoneybadger;
152
152
  //# sourceMappingURL=honeybadger-nextjs.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"honeybadger-nextjs.cjs.js","sources":["../../build/index.js"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport HoneybadgerSourceMapPlugin from '@honeybadger-io/webpack';\nlet _silent = true;\nfunction log(type, msg) {\n if (type === 'error' || !_silent) {\n console[type]('[HoneybadgerNextJs]', msg);\n }\n}\nfunction shouldUploadSourceMaps(honeybadgerNextJsConfig, context) {\n const { dev } = context;\n if (honeybadgerNextJsConfig.disableSourceMapUpload) {\n return false;\n }\n if (dev || process.env.NODE_ENV === 'development') {\n return false;\n }\n return true;\n}\nexport function setupHoneybadger(config, honeybadgerNextJsConfig) {\n var _a;\n _silent = (_a = honeybadgerNextJsConfig === null || honeybadgerNextJsConfig === void 0 ? void 0 : honeybadgerNextJsConfig.silent) !== null && _a !== void 0 ? _a : true;\n return {\n ...config,\n webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)\n };\n}\nfunction mergeWithExistingWebpackConfig(nextJsWebpackConfig, honeybadgerNextJsConfig) {\n return function webpackFunctionMergedWithHb(webpackConfig, context) {\n const { isServer, dir: projectDir, nextRuntime } = context;\n const configType = isServer ? (nextRuntime === 'edge' ? 'edge' : 'server') : 'browser';\n log('debug', `reached webpackFunctionMergedWithHb isServer[${isServer}] configType[${configType}]`);\n let result = { ...webpackConfig };\n if (typeof nextJsWebpackConfig === 'function') {\n result = nextJsWebpackConfig(result, context);\n }\n const originalEntry = result.entry;\n result.entry = async () => injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType);\n if (shouldUploadSourceMaps(honeybadgerNextJsConfig, context)) {\n // `result.devtool` must be 'hidden-source-map' or 'source-map' to properly pass sourcemaps.\n // Next.js uses regular `source-map` which doesnt pass its sourcemaps to Webpack.\n // https://github.com/vercel/next.js/blob/89ec21ed686dd79a5770b5c669abaff8f55d8fef/packages/next/build/webpack/config/blocks/base.ts#L40\n // Use the hidden-source-map option when you don't want the source maps to be\n // publicly available on the servers, only to the error reporting\n result.devtool = 'hidden-source-map';\n if (!result.plugins) {\n result.plugins = [];\n }\n const options = getWebpackPluginOptions(honeybadgerNextJsConfig);\n if (options) {\n result.plugins.push(new HoneybadgerSourceMapPlugin(options));\n }\n }\n return result;\n };\n}\nasync function injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType) {\n const hbConfigFile = getHoneybadgerConfigFile(projectDir, configType);\n if (!hbConfigFile) {\n return originalEntry;\n }\n const hbConfigFileRelativePath = `./${hbConfigFile}`;\n const result = typeof originalEntry === 'function' ? await originalEntry() : { ...originalEntry };\n if (!Object.keys(result).length) {\n log('debug', `no entry points for configType[${configType}]`);\n }\n for (const entryName in result) {\n addHoneybadgerConfigToEntry(result, entryName, hbConfigFileRelativePath, configType);\n }\n return result;\n}\nfunction addHoneybadgerConfigToEntry(entry, entryName, hbConfigFile, configType) {\n log('debug', `adding entry[${entryName}] to configType[${configType}]`);\n switch (configType) {\n case 'server':\n if (!entryName.startsWith('pages/')) {\n return;\n }\n break;\n case 'browser':\n if (!['pages/_app', 'main-app'].includes(entryName)) {\n return;\n }\n break;\n case 'edge':\n // nothing?\n break;\n }\n const currentEntryPoint = entry[entryName];\n let newEntryPoint = currentEntryPoint;\n if (typeof currentEntryPoint === 'string') {\n newEntryPoint = [hbConfigFile, currentEntryPoint];\n }\n else if (Array.isArray(currentEntryPoint)) {\n newEntryPoint = [hbConfigFile, ...currentEntryPoint];\n } // descriptor object (webpack 5+)\n else if (typeof currentEntryPoint === 'object' && currentEntryPoint && 'import' in currentEntryPoint) {\n const currentImportValue = currentEntryPoint['import'];\n const newImportValue = [hbConfigFile];\n if (typeof currentImportValue === 'string') {\n newImportValue.push(currentImportValue);\n }\n else {\n newImportValue.push(...(currentImportValue));\n }\n newEntryPoint = {\n ...currentEntryPoint,\n import: newImportValue,\n };\n }\n else {\n log('error', 'Could not inject Honeybadger config to entry point: ' + JSON.stringify(currentEntryPoint, null, 2));\n }\n entry[entryName] = newEntryPoint;\n}\nfunction getHoneybadgerConfigFile(projectDir, configType) {\n const possibilities = [`honeybadger.${configType}.config.ts`, `honeybadger.${configType}.config.js`];\n for (const filename of possibilities) {\n if (fs.existsSync(path.resolve(projectDir, filename))) {\n return filename;\n }\n }\n log('debug', `could not find config file in ${projectDir} for ${configType}`);\n return null;\n}\nfunction getWebpackPluginOptions(honeybadgerNextJsConfig) {\n var _a, _b, _c;\n const apiKey = ((_a = honeybadgerNextJsConfig.webpackPluginOptions) === null || _a === void 0 ? void 0 : _a.apiKey) || process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY;\n const assetsUrl = ((_b = honeybadgerNextJsConfig.webpackPluginOptions) === null || _b === void 0 ? void 0 : _b.assetsUrl) || process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL;\n if (!apiKey || !assetsUrl) {\n log('error', 'Missing Honeybadger required configuration for webpack plugin. Source maps will not be uploaded to Honeybadger.');\n return null;\n }\n return {\n ...honeybadgerNextJsConfig.webpackPluginOptions,\n apiKey,\n assetsUrl,\n revision: ((_c = honeybadgerNextJsConfig.webpackPluginOptions) === null || _c === void 0 ? void 0 : _c.revision) || process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,\n silent: _silent,\n };\n}\n//# sourceMappingURL=index.js.map"],"names":["HoneybadgerSourceMapPlugin","fs","path"],"mappings":";;;;;;;;;;;;;;AAGA,IAAI,OAAO,GAAG,IAAI,CAAC;AACnB,SAAS,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE;AACxB,IAAI,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,OAAO,EAAE;AACtC,QAAQ,OAAO,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;AAClD,KAAK;AACL,CAAC;AACD,SAAS,sBAAsB,CAAC,uBAAuB,EAAE,OAAO,EAAE;AAClE,IAAI,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAC5B,IAAI,IAAI,uBAAuB,CAAC,sBAAsB,EAAE;AACxD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,IAAI,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;AACvD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,IAAI,CAAC;AAChB,CAAC;AACM,SAAS,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE;AAClE,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,OAAO,GAAG,CAAC,EAAE,GAAG,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+BAA+B,CAAC;AACvK,IAAI,MAAM,SAAS,GAAG,CAAC,CAAC,EAAE,GAAG,uBAAuB,CAAC,oBAAoB,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,KAAK,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC;AAChL,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE;AAC/B,QAAQ,GAAG,CAAC,OAAO,EAAE,iHAAiH,CAAC,CAAC;AACxI,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,OAAO;AACX,QAAQ,GAAG,uBAAuB,CAAC,oBAAoB;AACvD,QAAQ,MAAM;AACd,QAAQ,SAAS;AACjB,QAAQ,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,uBAAuB,CAAC,oBAAoB,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,KAAK,OAAO,CAAC,GAAG,CAAC,gCAAgC;AACxK,QAAQ,MAAM,EAAE,OAAO;AACvB,KAAK,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"honeybadger-nextjs.cjs.js","sources":["../../build/index.js"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport HoneybadgerSourceMapPlugin from '@honeybadger-io/webpack';\nlet _silent = true;\nfunction log(type, msg) {\n if (type === 'error' || !_silent) {\n console[type]('[HoneybadgerNextJs]', msg);\n }\n}\nfunction shouldUploadSourceMaps(honeybadgerNextJsConfig, context) {\n const { dev } = context;\n if (honeybadgerNextJsConfig.disableSourceMapUpload) {\n return false;\n }\n if (dev || process.env.NODE_ENV === 'development') {\n return false;\n }\n return true;\n}\nfunction mergeWithExistingWebpackConfig(nextJsWebpackConfig, honeybadgerNextJsConfig) {\n return function webpackFunctionMergedWithHb(webpackConfig, context) {\n const { isServer, dir: projectDir, nextRuntime } = context;\n const configType = isServer ? (nextRuntime === 'edge' ? 'edge' : 'server') : 'browser';\n log('debug', `reached webpackFunctionMergedWithHb isServer[${isServer}] configType[${configType}]`);\n let result = { ...webpackConfig };\n if (typeof nextJsWebpackConfig === 'function') {\n result = nextJsWebpackConfig(result, context);\n }\n const originalEntry = result.entry;\n result.entry = async () => injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType);\n if (shouldUploadSourceMaps(honeybadgerNextJsConfig, context)) {\n // `result.devtool` must be 'hidden-source-map' or 'source-map' to properly pass sourcemaps.\n // Next.js uses regular `source-map` which doesnt pass its sourcemaps to Webpack.\n // https://github.com/vercel/next.js/blob/89ec21ed686dd79a5770b5c669abaff8f55d8fef/packages/next/build/webpack/config/blocks/base.ts#L40\n // Use the hidden-source-map option when you don't want the source maps to be\n // publicly available on the servers, only to the error reporting\n result.devtool = 'hidden-source-map';\n if (!result.plugins) {\n result.plugins = [];\n }\n const options = getWebpackPluginOptions(honeybadgerNextJsConfig);\n if (options) {\n result.plugins.push(new HoneybadgerSourceMapPlugin(options));\n }\n }\n return result;\n };\n}\nasync function injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType) {\n const hbConfigFile = getHoneybadgerConfigFile(projectDir, configType);\n if (!hbConfigFile) {\n return originalEntry;\n }\n const hbConfigFileRelativePath = `./${hbConfigFile}`;\n const result = typeof originalEntry === 'function' ? await originalEntry() : { ...originalEntry };\n if (!Object.keys(result).length) {\n log('debug', `no entry points for configType[${configType}]`);\n }\n for (const entryName in result) {\n addHoneybadgerConfigToEntry(result, entryName, hbConfigFileRelativePath, configType);\n }\n return result;\n}\nfunction addHoneybadgerConfigToEntry(entry, entryName, hbConfigFile, configType) {\n log('debug', `adding entry[${entryName}] to configType[${configType}]`);\n switch (configType) {\n case 'server':\n if (!entryName.startsWith('pages/')) {\n return;\n }\n break;\n case 'browser':\n if (!['pages/_app', 'main-app'].includes(entryName)) {\n return;\n }\n break;\n case 'edge':\n // nothing?\n break;\n }\n const currentEntryPoint = entry[entryName];\n let newEntryPoint = currentEntryPoint;\n if (typeof currentEntryPoint === 'string') {\n newEntryPoint = [hbConfigFile, currentEntryPoint];\n }\n else if (Array.isArray(currentEntryPoint)) {\n newEntryPoint = [hbConfigFile, ...currentEntryPoint];\n } // descriptor object (webpack 5+)\n else if (typeof currentEntryPoint === 'object' && currentEntryPoint && 'import' in currentEntryPoint) {\n const currentImportValue = currentEntryPoint['import'];\n const newImportValue = [hbConfigFile];\n if (typeof currentImportValue === 'string') {\n newImportValue.push(currentImportValue);\n }\n else {\n newImportValue.push(...(currentImportValue));\n }\n newEntryPoint = {\n ...currentEntryPoint,\n import: newImportValue,\n };\n }\n else {\n log('error', 'Could not inject Honeybadger config to entry point: ' + JSON.stringify(currentEntryPoint, null, 2));\n }\n entry[entryName] = newEntryPoint;\n}\nfunction getHoneybadgerConfigFile(projectDir, configType) {\n const possibilities = [`honeybadger.${configType}.config.ts`, `honeybadger.${configType}.config.js`];\n for (const filename of possibilities) {\n if (fs.existsSync(path.resolve(projectDir, filename))) {\n return filename;\n }\n }\n log('debug', `could not find config file in ${projectDir} for ${configType}`);\n return null;\n}\nfunction getWebpackPluginOptions(honeybadgerNextJsConfig) {\n var _a, _b, _c;\n const apiKey = ((_a = honeybadgerNextJsConfig.webpackPluginOptions) === null || _a === void 0 ? void 0 : _a.apiKey) || process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY;\n const assetsUrl = ((_b = honeybadgerNextJsConfig.webpackPluginOptions) === null || _b === void 0 ? void 0 : _b.assetsUrl) || process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL;\n if (!apiKey || !assetsUrl) {\n log('error', 'Missing Honeybadger required configuration for webpack plugin. Source maps will not be uploaded to Honeybadger.');\n return null;\n }\n return {\n ...honeybadgerNextJsConfig.webpackPluginOptions,\n apiKey,\n assetsUrl,\n revision: ((_c = honeybadgerNextJsConfig.webpackPluginOptions) === null || _c === void 0 ? void 0 : _c.revision) || process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,\n silent: _silent,\n };\n}\nexport function setupHoneybadger(config, honeybadgerNextJsConfig) {\n var _a;\n _silent = (_a = honeybadgerNextJsConfig === null || honeybadgerNextJsConfig === void 0 ? void 0 : honeybadgerNextJsConfig.silent) !== null && _a !== void 0 ? _a : true;\n return {\n ...config,\n webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)\n };\n}\n//# sourceMappingURL=index.js.map"],"names":["HoneybadgerSourceMapPlugin","fs","path"],"mappings":";;;;;;;;;;;;;;AAGA,IAAI,OAAO,GAAG,IAAI,CAAC;AACnB,SAAS,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE;AACxB,IAAI,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,OAAO,EAAE;AACtC,QAAQ,OAAO,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;AAClD,KAAK;AACL,CAAC;AACD,SAAS,sBAAsB,CAAC,uBAAuB,EAAE,OAAO,EAAE;AAClE,IAAI,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAC5B,IAAI,IAAI,uBAAuB,CAAC,sBAAsB,EAAE;AACxD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,IAAI,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;AACvD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,IAAI,CAAC;AAChB,CAAC;AACD,SAAS,8BAA8B,CAAC,mBAAmB,EAAE,uBAAuB,EAAE;AACtF,IAAI,OAAO,SAAS,2BAA2B,CAAC,aAAa,EAAE,OAAO,EAAE;AACxE,QAAQ,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;AACnE,QAAQ,MAAM,UAAU,GAAG,QAAQ,IAAI,WAAW,KAAK,MAAM,GAAG,MAAM,GAAG,QAAQ,IAAI,SAAS,CAAC;AAC/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O,CAAC,GAAG,CAAC,gCAAgC;AACxK,QAAQ,MAAM,EAAE,OAAO;AACvB,KAAK,CAAC;AACN,CAAC;AACM,SAAS,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE;AAClE,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,OAAO,GAAG,CAAC,EAAE,GAAG,uBAAuB,KAAK,IAAI,IAAI,uBAAuB,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,uBAAuB,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5K,IAAI,OAAO;AACX,QAAQ,GAAG,MAAM;AACjB,QAAQ,OAAO,EAAE,8BAA8B,CAAC,MAAM,CAAC,OAAO,EAAE,uBAAuB,CAAC;AACxF,KAAK,CAAC;AACN;;;;"}
@@ -18,14 +18,6 @@ function shouldUploadSourceMaps(honeybadgerNextJsConfig, context) {
18
18
  }
19
19
  return true;
20
20
  }
21
- function setupHoneybadger(config, honeybadgerNextJsConfig) {
22
- var _a;
23
- _silent = (_a = honeybadgerNextJsConfig === null || honeybadgerNextJsConfig === void 0 ? void 0 : honeybadgerNextJsConfig.silent) !== null && _a !== void 0 ? _a : true;
24
- return {
25
- ...config,
26
- webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)
27
- };
28
- }
29
21
  function mergeWithExistingWebpackConfig(nextJsWebpackConfig, honeybadgerNextJsConfig) {
30
22
  return function webpackFunctionMergedWithHb(webpackConfig, context) {
31
23
  const { isServer, dir: projectDir, nextRuntime } = context;
@@ -137,6 +129,14 @@ function getWebpackPluginOptions(honeybadgerNextJsConfig) {
137
129
  silent: _silent,
138
130
  };
139
131
  }
132
+ function setupHoneybadger(config, honeybadgerNextJsConfig) {
133
+ var _a;
134
+ _silent = (_a = honeybadgerNextJsConfig === null || honeybadgerNextJsConfig === void 0 ? void 0 : honeybadgerNextJsConfig.silent) !== null && _a !== void 0 ? _a : true;
135
+ return {
136
+ ...config,
137
+ webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)
138
+ };
139
+ }
140
140
 
141
141
  export { setupHoneybadger };
142
142
  //# sourceMappingURL=honeybadger-nextjs.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"honeybadger-nextjs.esm.js","sources":["../../build/index.js"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport HoneybadgerSourceMapPlugin from '@honeybadger-io/webpack';\nlet _silent = true;\nfunction log(type, msg) {\n if (type === 'error' || !_silent) {\n console[type]('[HoneybadgerNextJs]', msg);\n }\n}\nfunction shouldUploadSourceMaps(honeybadgerNextJsConfig, context) {\n const { dev } = context;\n if (honeybadgerNextJsConfig.disableSourceMapUpload) {\n return false;\n }\n if (dev || process.env.NODE_ENV === 'development') {\n return false;\n }\n return true;\n}\nexport function setupHoneybadger(config, honeybadgerNextJsConfig) {\n var _a;\n _silent = (_a = honeybadgerNextJsConfig === null || honeybadgerNextJsConfig === void 0 ? void 0 : honeybadgerNextJsConfig.silent) !== null && _a !== void 0 ? _a : true;\n return {\n ...config,\n webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)\n };\n}\nfunction mergeWithExistingWebpackConfig(nextJsWebpackConfig, honeybadgerNextJsConfig) {\n return function webpackFunctionMergedWithHb(webpackConfig, context) {\n const { isServer, dir: projectDir, nextRuntime } = context;\n const configType = isServer ? (nextRuntime === 'edge' ? 'edge' : 'server') : 'browser';\n log('debug', `reached webpackFunctionMergedWithHb isServer[${isServer}] configType[${configType}]`);\n let result = { ...webpackConfig };\n if (typeof nextJsWebpackConfig === 'function') {\n result = nextJsWebpackConfig(result, context);\n }\n const originalEntry = result.entry;\n result.entry = async () => injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType);\n if (shouldUploadSourceMaps(honeybadgerNextJsConfig, context)) {\n // `result.devtool` must be 'hidden-source-map' or 'source-map' to properly pass sourcemaps.\n // Next.js uses regular `source-map` which doesnt pass its sourcemaps to Webpack.\n // https://github.com/vercel/next.js/blob/89ec21ed686dd79a5770b5c669abaff8f55d8fef/packages/next/build/webpack/config/blocks/base.ts#L40\n // Use the hidden-source-map option when you don't want the source maps to be\n // publicly available on the servers, only to the error reporting\n result.devtool = 'hidden-source-map';\n if (!result.plugins) {\n result.plugins = [];\n }\n const options = getWebpackPluginOptions(honeybadgerNextJsConfig);\n if (options) {\n result.plugins.push(new HoneybadgerSourceMapPlugin(options));\n }\n }\n return result;\n };\n}\nasync function injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType) {\n const hbConfigFile = getHoneybadgerConfigFile(projectDir, configType);\n if (!hbConfigFile) {\n return originalEntry;\n }\n const hbConfigFileRelativePath = `./${hbConfigFile}`;\n const result = typeof originalEntry === 'function' ? await originalEntry() : { ...originalEntry };\n if (!Object.keys(result).length) {\n log('debug', `no entry points for configType[${configType}]`);\n }\n for (const entryName in result) {\n addHoneybadgerConfigToEntry(result, entryName, hbConfigFileRelativePath, configType);\n }\n return result;\n}\nfunction addHoneybadgerConfigToEntry(entry, entryName, hbConfigFile, configType) {\n log('debug', `adding entry[${entryName}] to configType[${configType}]`);\n switch (configType) {\n case 'server':\n if (!entryName.startsWith('pages/')) {\n return;\n }\n break;\n case 'browser':\n if (!['pages/_app', 'main-app'].includes(entryName)) {\n return;\n }\n break;\n case 'edge':\n // nothing?\n break;\n }\n const currentEntryPoint = entry[entryName];\n let newEntryPoint = currentEntryPoint;\n if (typeof currentEntryPoint === 'string') {\n newEntryPoint = [hbConfigFile, currentEntryPoint];\n }\n else if (Array.isArray(currentEntryPoint)) {\n newEntryPoint = [hbConfigFile, ...currentEntryPoint];\n } // descriptor object (webpack 5+)\n else if (typeof currentEntryPoint === 'object' && currentEntryPoint && 'import' in currentEntryPoint) {\n const currentImportValue = currentEntryPoint['import'];\n const newImportValue = [hbConfigFile];\n if (typeof currentImportValue === 'string') {\n newImportValue.push(currentImportValue);\n }\n else {\n newImportValue.push(...(currentImportValue));\n }\n newEntryPoint = {\n ...currentEntryPoint,\n import: newImportValue,\n };\n }\n else {\n log('error', 'Could not inject Honeybadger config to entry point: ' + JSON.stringify(currentEntryPoint, null, 2));\n }\n entry[entryName] = newEntryPoint;\n}\nfunction getHoneybadgerConfigFile(projectDir, configType) {\n const possibilities = [`honeybadger.${configType}.config.ts`, `honeybadger.${configType}.config.js`];\n for (const filename of possibilities) {\n if (fs.existsSync(path.resolve(projectDir, filename))) {\n return filename;\n }\n }\n log('debug', `could not find config file in ${projectDir} for ${configType}`);\n return null;\n}\nfunction getWebpackPluginOptions(honeybadgerNextJsConfig) {\n var _a, _b, _c;\n const apiKey = ((_a = honeybadgerNextJsConfig.webpackPluginOptions) === null || _a === void 0 ? void 0 : _a.apiKey) || process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY;\n const assetsUrl = ((_b = honeybadgerNextJsConfig.webpackPluginOptions) === null || _b === void 0 ? void 0 : _b.assetsUrl) || process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL;\n if (!apiKey || !assetsUrl) {\n log('error', 'Missing Honeybadger required configuration for webpack plugin. Source maps will not be uploaded to Honeybadger.');\n return null;\n }\n return {\n ...honeybadgerNextJsConfig.webpackPluginOptions,\n apiKey,\n assetsUrl,\n revision: ((_c = honeybadgerNextJsConfig.webpackPluginOptions) === null || _c === void 0 ? void 0 : _c.revision) || process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,\n silent: _silent,\n };\n}\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;AAGA,IAAI,OAAO,GAAG,IAAI,CAAC;AACnB,SAAS,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE;AACxB,IAAI,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,OAAO,EAAE;AACtC,QAAQ,OAAO,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;AAClD,KAAK;AACL,CAAC;AACD,SAAS,sBAAsB,CAAC,uBAAuB,EAAE,OAAO,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fs';\nimport path from 'path';\nimport HoneybadgerSourceMapPlugin from '@honeybadger-io/webpack';\nlet _silent = true;\nfunction log(type, msg) {\n if (type === 'error' || !_silent) {\n console[type]('[HoneybadgerNextJs]', msg);\n }\n}\nfunction shouldUploadSourceMaps(honeybadgerNextJsConfig, context) {\n const { dev } = context;\n if (honeybadgerNextJsConfig.disableSourceMapUpload) {\n return false;\n }\n if (dev || process.env.NODE_ENV === 'development') {\n return false;\n }\n return true;\n}\nfunction mergeWithExistingWebpackConfig(nextJsWebpackConfig, honeybadgerNextJsConfig) {\n return function webpackFunctionMergedWithHb(webpackConfig, context) {\n const { isServer, dir: projectDir, nextRuntime } = context;\n const configType = isServer ? (nextRuntime === 'edge' ? 'edge' : 'server') : 'browser';\n log('debug', `reached webpackFunctionMergedWithHb isServer[${isServer}] configType[${configType}]`);\n let result = { ...webpackConfig };\n if (typeof nextJsWebpackConfig === 'function') {\n result = nextJsWebpackConfig(result, context);\n }\n const originalEntry = result.entry;\n result.entry = async () => injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType);\n if (shouldUploadSourceMaps(honeybadgerNextJsConfig, context)) {\n // `result.devtool` must be 'hidden-source-map' or 'source-map' to properly pass sourcemaps.\n // Next.js uses regular `source-map` which doesnt pass its sourcemaps to Webpack.\n // https://github.com/vercel/next.js/blob/89ec21ed686dd79a5770b5c669abaff8f55d8fef/packages/next/build/webpack/config/blocks/base.ts#L40\n // Use the hidden-source-map option when you don't want the source maps to be\n // publicly available on the servers, only to the error reporting\n result.devtool = 'hidden-source-map';\n if (!result.plugins) {\n result.plugins = [];\n }\n const options = getWebpackPluginOptions(honeybadgerNextJsConfig);\n if (options) {\n result.plugins.push(new HoneybadgerSourceMapPlugin(options));\n }\n }\n return result;\n };\n}\nasync function injectHoneybadgerConfigToEntry(originalEntry, projectDir, configType) {\n const hbConfigFile = getHoneybadgerConfigFile(projectDir, configType);\n if (!hbConfigFile) {\n return originalEntry;\n }\n const hbConfigFileRelativePath = `./${hbConfigFile}`;\n const result = typeof originalEntry === 'function' ? await originalEntry() : { ...originalEntry };\n if (!Object.keys(result).length) {\n log('debug', `no entry points for configType[${configType}]`);\n }\n for (const entryName in result) {\n addHoneybadgerConfigToEntry(result, entryName, hbConfigFileRelativePath, configType);\n }\n return result;\n}\nfunction addHoneybadgerConfigToEntry(entry, entryName, hbConfigFile, configType) {\n log('debug', `adding entry[${entryName}] to configType[${configType}]`);\n switch (configType) {\n case 'server':\n if (!entryName.startsWith('pages/')) {\n return;\n }\n break;\n case 'browser':\n if (!['pages/_app', 'main-app'].includes(entryName)) {\n return;\n }\n break;\n case 'edge':\n // nothing?\n break;\n }\n const currentEntryPoint = entry[entryName];\n let newEntryPoint = currentEntryPoint;\n if (typeof currentEntryPoint === 'string') {\n newEntryPoint = [hbConfigFile, currentEntryPoint];\n }\n else if (Array.isArray(currentEntryPoint)) {\n newEntryPoint = [hbConfigFile, ...currentEntryPoint];\n } // descriptor object (webpack 5+)\n else if (typeof currentEntryPoint === 'object' && currentEntryPoint && 'import' in currentEntryPoint) {\n const currentImportValue = currentEntryPoint['import'];\n const newImportValue = [hbConfigFile];\n if (typeof currentImportValue === 'string') {\n newImportValue.push(currentImportValue);\n }\n else {\n newImportValue.push(...(currentImportValue));\n }\n newEntryPoint = {\n ...currentEntryPoint,\n import: newImportValue,\n };\n }\n else {\n log('error', 'Could not inject Honeybadger config to entry point: ' + JSON.stringify(currentEntryPoint, null, 2));\n }\n entry[entryName] = newEntryPoint;\n}\nfunction getHoneybadgerConfigFile(projectDir, configType) {\n const possibilities = [`honeybadger.${configType}.config.ts`, `honeybadger.${configType}.config.js`];\n for (const filename of possibilities) {\n if (fs.existsSync(path.resolve(projectDir, filename))) {\n return filename;\n }\n }\n log('debug', `could not find config file in ${projectDir} for ${configType}`);\n return null;\n}\nfunction getWebpackPluginOptions(honeybadgerNextJsConfig) {\n var _a, _b, _c;\n const apiKey = ((_a = honeybadgerNextJsConfig.webpackPluginOptions) === null || _a === void 0 ? void 0 : _a.apiKey) || process.env.NEXT_PUBLIC_HONEYBADGER_API_KEY;\n const assetsUrl = ((_b = honeybadgerNextJsConfig.webpackPluginOptions) === null || _b === void 0 ? void 0 : _b.assetsUrl) || process.env.NEXT_PUBLIC_HONEYBADGER_ASSETS_URL;\n if (!apiKey || !assetsUrl) {\n log('error', 'Missing Honeybadger required configuration for webpack plugin. Source maps will not be uploaded to Honeybadger.');\n return null;\n }\n return {\n ...honeybadgerNextJsConfig.webpackPluginOptions,\n apiKey,\n assetsUrl,\n revision: ((_c = honeybadgerNextJsConfig.webpackPluginOptions) === null || _c === void 0 ? void 0 : _c.revision) || process.env.NEXT_PUBLIC_HONEYBADGER_REVISION,\n silent: _silent,\n };\n}\nexport function setupHoneybadger(config, honeybadgerNextJsConfig) {\n var _a;\n _silent = (_a = honeybadgerNextJsConfig === null || honeybadgerNextJsConfig === void 0 ? void 0 : honeybadgerNextJsConfig.silent) !== null && _a !== void 0 ? _a : true;\n return {\n ...config,\n webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)\n };\n}\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;AAGA,IAAI,OAAO,GAAG,IAAI,CAAC;AACnB,SAAS,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE;AACxB,IAAI,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,OAAO,EAAE;AACtC,QAAQ,OAAO,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;AAClD,KAAK;AACL,CAAC;AACD,SAAS,sBAAsB,CAAC,uBAAuB,EAAE,OAAO,EAAE;AAClE,IAAI,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAC5B,IAAI,IAAI,uBAAuB,CAAC,sBAAsB,EAAE;AACxD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,IAAI,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;AACvD,QAAQ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AI,CAAC,SAAS,EAAE;AAC/B,QAAQ,GAAG,CAAC,OAAO,EAAE,iHAAiH,CAAC,CAAC;AACxI,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,OAAO;AACX,QAAQ,GAAG,uBAAuB,CAAC,oBAAoB;AACvD,QAAQ,MAAM;AACd,QAAQ,SAAS;AACjB,QAAQ,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,uBAAuB,CAAC,oBAAoB,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,KAAK,OAAO,CAAC,GAAG,CAAC,gCAAgC;AACxK,QAAQ,MAAM,EAAE,OAAO;AACvB,KAAK,CAAC;AACN,CAAC;AACM,SAAS,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE;AAClE,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,OAAO,GAAG,CAAC,EAAE,GAAG,uBAAuB,KAAK,IAAI,IAAI,uBAAuB,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,uBAAuB,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5K,IAAI,OAAO;AACX,QAAQ,GAAG,MAAM;AACjB,QAAQ,OAAO,EAAE,8BAA8B,CAAC,MAAM,CAAC,OAAO,EAAE,uBAAuB,CAAC;AACxF,KAAK,CAAC;AACN;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honeybadger-io/nextjs",
3
- "version": "5.3.0",
3
+ "version": "5.3.2",
4
4
  "description": "Next.js integration for Honeybadger",
5
5
  "keywords": [
6
6
  "nextjs",
@@ -12,7 +12,7 @@
12
12
  "name": "Pangratios Cosma",
13
13
  "email": "pangratios.cosma@honeybadger.io"
14
14
  },
15
- "homepage": "https://github.com/honeybadger-io/honeybadger-js/packages/nextjs#readme",
15
+ "homepage": "https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/nextjs",
16
16
  "license": "MIT",
17
17
  "main": "dist/honeybadger-nextjs.cjs.js",
18
18
  "module": "dist/honeybadger-nextjs.esm.js",
@@ -57,5 +57,5 @@
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "1a6914ba49db1854bba26833074e59aea53ec04c"
60
+ "gitHead": "a39a9e94505e9869601a1f253a5a9d7d9a8ab729"
61
61
  }
@@ -5,21 +5,36 @@ const fs = require('fs')
5
5
 
6
6
  const debug = process.env.HONEYBADGER_DEBUG === 'true'
7
7
 
8
+ async function copyErrorJs() {
9
+ const targetPath = path.join('pages', '_error.js')
10
+ const errorJsAlreadyExists = fs.existsSync(targetPath)
11
+ if (errorJsAlreadyExists) {
12
+ // Don't overwrite an existing _error.js file.
13
+ // Create a _error.js.bak file instead.
14
+ const backupPath = path.join('pages', '_error.js.bak')
15
+ await fs.promises.copyFile(targetPath, backupPath)
16
+ }
17
+
18
+ const sourcePath = path.resolve(__dirname, '../templates/_error.js')
19
+
20
+ return fs.promises.copyFile(sourcePath, targetPath)
21
+ }
22
+
8
23
  async function copyConfigFiles() {
9
24
  if (debug) {
10
25
  console.debug('cwd', process.cwd())
11
26
  }
12
27
 
13
- const templateDir = path.resolve(__dirname, '../templates');
14
- const files = await fs.promises.readdir(templateDir);
28
+ const templateDir = path.resolve(__dirname, '../templates')
29
+ const files = await fs.promises.readdir(templateDir)
15
30
  const copyPromises = files.map((file) => {
16
31
  if (debug) {
17
32
  console.debug('copying', file)
18
33
  }
19
- return fs.promises.copyFile(path.join(templateDir, file), file);
34
+
35
+ return file === '_error.js' ? copyErrorJs() : fs.promises.copyFile(path.join(templateDir, file), file)
20
36
  });
21
37
  await Promise.all(copyPromises);
22
-
23
38
  console.log('Done copying config files.')
24
39
  }
25
40
 
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs'
2
2
  import path from 'path'
3
3
  import HoneybadgerSourceMapPlugin from '@honeybadger-io/webpack'
4
- import type { WebpackConfigContext } from 'next/dist/server/config-shared';
4
+ import type { WebpackConfigContext } from 'next/dist/server/config-shared'
5
5
  import { HoneybadgerNextJsConfig, NextJsRuntime, HoneybadgerWebpackPluginOptions } from './types'
6
6
 
7
7
  let _silent = true
@@ -25,15 +25,6 @@ function shouldUploadSourceMaps(honeybadgerNextJsConfig: HoneybadgerNextJsConfig
25
25
  return true
26
26
  }
27
27
 
28
- export function setupHoneybadger(config, honeybadgerNextJsConfig: HoneybadgerNextJsConfig) {
29
- _silent = honeybadgerNextJsConfig?.silent ?? true
30
-
31
- return {
32
- ...config,
33
- webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)
34
- }
35
- }
36
-
37
28
  function mergeWithExistingWebpackConfig(nextJsWebpackConfig, honeybadgerNextJsConfig: HoneybadgerNextJsConfig) {
38
29
  return function webpackFunctionMergedWithHb(webpackConfig, context: WebpackConfigContext) {
39
30
 
@@ -167,3 +158,12 @@ function getWebpackPluginOptions(honeybadgerNextJsConfig: HoneybadgerNextJsConfi
167
158
  silent: _silent,
168
159
  }
169
160
  }
161
+
162
+ export function setupHoneybadger(config, honeybadgerNextJsConfig: HoneybadgerNextJsConfig) {
163
+ _silent = honeybadgerNextJsConfig?.silent ?? true
164
+
165
+ return {
166
+ ...config,
167
+ webpack: mergeWithExistingWebpackConfig(config.webpack, honeybadgerNextJsConfig)
168
+ }
169
+ }
@@ -0,0 +1,37 @@
1
+ import NextErrorComponent from 'next/error'
2
+ import { Honeybadger } from '@honeybadger-io/react'
3
+ /**
4
+ * This component is called when:
5
+ * - on the server, when data fetching methods throw or reject
6
+ * - on the client, when getInitialProps throws or rejects
7
+ * - on the client, when a React lifecycle method (render, componentDidMount, etc) throws or rejects
8
+ * and was caught by the built-in Next.js error boundary
9
+ */
10
+ const CustomErrorComponent = props => {
11
+ return <NextErrorComponent statusCode={props.statusCode} />
12
+ }
13
+
14
+ CustomErrorComponent.getInitialProps = async contextData => {
15
+ const { req, res, err } = contextData
16
+
17
+ // exclude 40x except when this component is rendered from a routing error or a custom server
18
+ // https://nextjs.org/docs/advanced-features/custom-error-page#caveats
19
+ const statusCode = (res && res.statusCode) || contextData.statusCode;
20
+ if (statusCode && statusCode < 500) {
21
+ Honeybadger.config.logger.debug(`_error.js skipping because statusCode is ${statusCode}: ${req && req.url}`)
22
+ }
23
+ else {
24
+ await Honeybadger.notifyAsync(err || `_error.js called with falsy error (${err})`, {
25
+ context:
26
+ {
27
+ url: req.url,
28
+ method: req.method,
29
+ statusCode: res.statusCode,
30
+ }
31
+ })
32
+ }
33
+
34
+ return NextErrorComponent.getInitialProps(contextData)
35
+ }
36
+
37
+ export default CustomErrorComponent