diff --git a/.nvmrc b/.nvmrc index 209e3ef4b..2edeafb09 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20 +20 \ No newline at end of file diff --git a/.storybook/main.ts b/.storybook/main.ts index 5d3cb75a2..74b3cdfee 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -23,6 +23,15 @@ export default { docs: { autodocs: true }, + typescript: { + check: false, + checkOptions: {}, + reactDocgen: 'react-docgen-typescript', + reactDocgenTypescriptOptions: { + shouldExtractLiteralValuesFromEnum: true, + propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true), + }, + }, webpackFinal: async (config) => { if (config.resolve) { config.resolve.plugins = [ @@ -34,4 +43,4 @@ export default { } return config; } -} satisfies StorybookConfig; +} satisfies StorybookConfig; \ No newline at end of file diff --git a/netlify.toml b/netlify.toml index c6ba16b5d..4cbeb5d5e 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,5 +1,6 @@ [build] publish = ".next" + command = "NODE_OPTIONS=--max_old_space_size=4096 npm run build" [[plugins]] package = "@netlify/plugin-nextjs" @@ -18,4 +19,4 @@ "node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/router-context*", "node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/amp-context*", "node_modules/next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context*", - ] + ] \ No newline at end of file diff --git a/next.config.js b/next.config.js index 25525f662..b10cddd52 100644 --- a/next.config.js +++ b/next.config.js @@ -2,6 +2,9 @@ const withBundleAnalyzer = require("@next/bundle-analyzer")({ enabled: process.env.ANALYZE === "true" }); +// Initialize Sentry for frontend error tracking +const { withSentryConfig } = require("@sentry/nextjs"); + /** * @type {import('next').NextConfig} */ @@ -93,7 +96,35 @@ const config = { esmExternals: "loose", optimizePackageImports: ["@flanksource/icons"] }, - transpilePackages: ["monaco-editor"] + transpilePackages: ["monaco-editor"], + sentry: { + // Use `hidden-source-map` rather than `source-map` as the Webpack `devtool` + // for client-side builds. (This will be the default starting in + // `@sentry/nextjs` version 8.0.0.) See: + // https://webpack.js.org/configuration/devtool/ + // + // You can also use `hidden-nosources-source-map` to hide the source maps + // completely, but still get stack traces. + hideSourceMaps: true, + + // This option will automatically add release information to your + // Sentry events. + autoInstrumentServerFunctions: true, + } +}; + +// Make sure adding Sentry options is the last code to run before exporting +const sentryWebpackPluginOptions = { + // Additional config options for the Sentry webpack plugin. Keep in mind that + // the following options are set automatically, and overriding them is not + // recommended: + // release, url, org, project, authToken, configFile, stripPrefix, + // urlPrefix, include, ignore + silent: true, // Suppresses all logs }; -module.exports = withBundleAnalyzer(config); +// Export modified config - first with bundle analyzer, then with Sentry +module.exports = withSentryConfig( + withBundleAnalyzer(config), + sentryWebpackPluginOptions +); \ No newline at end of file diff --git a/package.json b/package.json index 21488d5e2..8305a336d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@next/bundle-analyzer": "^14.2.5", "@ory/client": "^1.2.11", "@ory/integrations": "^1.1.5", + "@sentry/nextjs": "^7.101.1", "@storybook/client-api": "^7.6.17", "@storybook/theming": "^7.6.17", "@tailwindcss/forms": "^0.5.2", @@ -104,7 +105,7 @@ "yup": "^0.32.11" }, "dependecyComments": { - "@headlessui/react": "We are using insiders version to use `by` property on `Combobox`. Without `by`, selected item logic was difficult to achieve.", + "@headlressui/react": "We are using insiders version to headlessui/react, for the `by` property on `Combobox`. Without `by`, selected item logic was difficult to achieve.", "@tanstack/react-query-devtools": "React Query Devtools are only included in bundles when process.env.NODE_ENV === 'development', so we don't have to exclude it from production build. Check it's docs." }, "proxy": "https://incident-commander.canary.lab.flanksource.com", @@ -223,4 +224,4 @@ "msw": { "workerDirectory": "public" } -} +} \ No newline at end of file diff --git a/sentry.client.config.js b/sentry.client.config.js new file mode 100644 index 000000000..f05633f86 --- /dev/null +++ b/sentry.client.config.js @@ -0,0 +1,30 @@ +// This file configures the initialization of Sentry on the client. +// The config you add here will be used whenever a users loads a page in their browser. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, + + // Adjust this value in production, or use tracesSampler for finer control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, + + replaysOnErrorSampleRate: 1.0, + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // You can remove this option if you're not planning to use the Sentry Session Replay feature: + integrations: [ + new Sentry.Replay({ + // Additional Replay configuration goes here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); \ No newline at end of file diff --git a/sentry.edge.config.js b/sentry.edge.config.js new file mode 100644 index 000000000..0caaf6d2a --- /dev/null +++ b/sentry.edge.config.js @@ -0,0 +1,16 @@ +// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on). +// The config you add here will be used whenever one of the edge features is loaded. +// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, + + // Adjust this value in production, or use tracesSampler for finer control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, +}); \ No newline at end of file diff --git a/sentry.server.config.js b/sentry.server.config.js new file mode 100644 index 000000000..8bde4bf8d --- /dev/null +++ b/sentry.server.config.js @@ -0,0 +1,15 @@ +// This file configures the initialization of Sentry on the server. +// The config you add here will be used whenever the server handles a request. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, + + // Adjust this value in production, or use tracesSampler for finer control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, +}); \ No newline at end of file