@sentry/wizard 3.34.2 → 3.34.4
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.
- package/CHANGELOG.md +9 -0
- package/dist/e2e-tests/jest.config.d.ts +1 -0
- package/dist/e2e-tests/jest.config.js +5 -0
- package/dist/e2e-tests/jest.config.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs.test.d.ts +1 -0
- package/dist/e2e-tests/tests/nextjs.test.js +221 -0
- package/dist/e2e-tests/tests/nextjs.test.js.map +1 -0
- package/dist/e2e-tests/tests/remix.test.js +47 -43
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.d.ts +1 -0
- package/dist/e2e-tests/tests/sveltekit.test.js +186 -0
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -0
- package/dist/e2e-tests/utils/index.d.ts +13 -2
- package/dist/e2e-tests/utils/index.js +45 -13
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/package.json +5 -7
- package/dist/src/apple/templates.d.ts +1 -1
- package/dist/src/apple/templates.js +6 -2
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.js +2 -1
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +68 -47
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +1 -0
- package/dist/src/nextjs/templates.js +5 -1
- package/dist/src/nextjs/templates.js.map +1 -1
- package/e2e-tests/.env.example +11 -0
- package/e2e-tests/jest.config.ts +8 -1
- package/e2e-tests/package.json +14 -0
- package/e2e-tests/run.sh +15 -0
- package/e2e-tests/test-applications/nextjs-test-app/next.config.mjs +4 -0
- package/e2e-tests/test-applications/nextjs-test-app/package.json +22 -0
- package/e2e-tests/test-applications/nextjs-test-app/src/app/layout.tsx +20 -0
- package/e2e-tests/test-applications/nextjs-test-app/src/app/page.tsx +90 -0
- package/e2e-tests/test-applications/sveltekit-test-app/package.json +21 -0
- package/e2e-tests/test-applications/sveltekit-test-app/src/app.d.ts +13 -0
- package/e2e-tests/test-applications/sveltekit-test-app/src/app.html +11 -0
- package/e2e-tests/test-applications/sveltekit-test-app/src/lib/index.ts +1 -0
- package/e2e-tests/test-applications/sveltekit-test-app/src/routes/+page.svelte +2 -0
- package/e2e-tests/test-applications/sveltekit-test-app/svelte.config.js +18 -0
- package/e2e-tests/test-applications/sveltekit-test-app/vite.config.ts +6 -0
- package/e2e-tests/tests/nextjs.test.ts +161 -0
- package/e2e-tests/tests/remix.test.ts +35 -44
- package/e2e-tests/tests/sveltekit.test.ts +154 -0
- package/e2e-tests/utils/index.ts +54 -11
- package/package.json +5 -7
- package/src/apple/templates.ts +5 -1
- package/src/apple/xcode-manager.ts +2 -0
- package/src/nextjs/nextjs-wizard.ts +31 -6
- package/src/nextjs/templates.ts +15 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nextjs/templates.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAC1B,oDAAuD;AAWvD,SAAgB,kCAAkC,CAAC,EAOzB;QANxB,OAAO,aAAA,EACP,WAAW,iBAAA,EACX,UAAU,gBAAA,EACV,WAAW,iBAAA,EACX,wBAAwB,8BAAA,EACxB,SAAS,eAAA;IAET,OAAO,qIAIG,OAAO,iCACH,WAAW,gBACvB,UAAU,CAAC,CAAC,CAAC,6BAAqB,SAAS,QAAI,CAAC,CAAC,CAAC,EAAE,+VAWlD,wBAAwB;QACtB,CAAC,CAAC,6KAIH;QACC,CAAC,CAAC,EAAE,wBAIN,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,qUAK5C,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,6gBAa1B,CAAC;AACL,CAAC;AAtDD,gFAsDC;AAED,SAAgB,0BAA0B,CACxC,+BAAuC;IA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D,eAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC,eAC9C,eAAK,CAAC,KAAK,CAAC,oCAAoC,CAAC,qDAEb,eAAK,CAAC,KAAK,CAAC,WAAW,CAAC,oBAC1D,eAAK,CAAC,KAAK,CAAC,wEAED,CAAC,kIAUf,CAAC;KACC;AACH,CAAC;AA9CD,wEA8CC","sourcesContent":["import chalk from 'chalk';\nimport { makeCodeSnippet } from '../utils/clack-utils';\n\ntype WithSentryConfigOptions = {\n orgSlug: string;\n projectSlug: string;\n selfHosted: boolean;\n sentryUrl: string;\n tunnelRoute: boolean;\n reactComponentAnnotation: boolean;\n};\n\nexport function getWithSentryConfigOptionsTemplate({\n orgSlug,\n projectSlug,\n selfHosted,\n tunnelRoute,\n reactComponentAnnotation,\n sentryUrl,\n}: WithSentryConfigOptions): string {\n return `{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",${\n selfHosted ? `\\n sentryUrl: \"${sentryUrl}\",` : ''\n }\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,${\n reactComponentAnnotation\n ? `\\n\n // Automatically annotate React components to show their full name in breadcrumbs and session replay\n reactComponentAnnotation: {\n enabled: true,\n },`\n : ''\n }\n\n // ${\n tunnelRoute ? 'Route' : 'Uncomment to route'\n } browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n ${tunnelRoute ? '' : '// '}tunnelRoute: \"/monitoring\",\n\n // Hides source maps from generated client bundles\n hideSourceMaps: true,\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }`;\n}\n\nexport function getNextjsConfigCjsTemplate(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `const { withSentryConfig } = require(\"@sentry/nextjs\");\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nmodule.exports = withSentryConfig(\n nextConfig,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigCjsAppendix(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `\n\n// Injected content via Sentry wizard below\n\nconst { withSentryConfig } = require(\"@sentry/nextjs\");\n\nmodule.exports = withSentryConfig(\n module.exports,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigEsmCopyPasteSnippet(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `\n\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs\";\n\nexport default withSentryConfig(\n yourNextConfig,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nfunction getClientIntegrationsSnippet(features: { replay: boolean }) {\n if (features.replay) {\n return `\n\n // Add optional integrations for additional features\n integrations: [\n Sentry.replayIntegration(),\n ],`;\n }\n\n return '';\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'server' | 'client' | 'edge',\n selectedFeaturesMap: {\n replay: boolean;\n performance: boolean;\n },\n): string {\n let primer;\n if (config === 'server') {\n primer = `// This file configures the initialization of Sentry on the server.\n// The config you add here will be used whenever the server handles a request.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'client') {\n primer = `// This file configures the initialization of Sentry on the client.\n// The config you add here will be used whenever a users loads a page in their browser.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'edge') {\n primer = `// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n// The config you add here will be used whenever one of the edge features is loaded.\n// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n }\n\n const integrationsOptions = getClientIntegrationsSnippet({\n replay: config === 'client' && selectedFeaturesMap.replay,\n });\n\n let replayOptions = '';\n if (config === 'client') {\n if (selectedFeaturesMap.replay) {\n replayOptions += `\n\n // Define how likely Replay events are sampled.\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // Define how likely Replay events are sampled when an error occurs.\n replaysOnErrorSampleRate: 1.0,`;\n }\n }\n\n let performanceOptions = '';\n if (selectedFeaturesMap.performance) {\n performanceOptions += `\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,`;\n }\n\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n return `${primer}\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"${dsn}\",${integrationsOptions}${performanceOptions}${replayOptions}\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n sentryUrl: string;\n orgSlug: string;\n projectId: string;\n useClient: boolean;\n}): string {\n const issuesPageLink = options.selfHosted\n ? `${options.sentryUrl}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `${\n options.useClient ? '\"use client\";\\n\\n' : ''\n }import Head from \"next/head\";\nimport * as Sentry from \"@sentry/nextjs\";\n\nexport default function Page() {\n return (\n <div>\n <Head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your Next.js app!\" />\n </Head>\n\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n <svg\n style={{\n height: \"1em\",\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 200 44\"\n >\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n ></path>\n </svg>\n </h1>\n\n <p>Get started by sending us a sample error:</p>\n <button\n type=\"button\"\n style={{\n padding: \"12px\",\n cursor: \"pointer\",\n backgroundColor: \"#AD6CAA\",\n borderRadius: \"4px\",\n border: \"none\",\n color: \"white\",\n fontSize: \"14px\",\n margin: \"18px\",\n }}\n onClick={async () => {\n await Sentry.startSpan({\n name: 'Example Frontend Span',\n op: 'test'\n }, async () => {\n const res = await fetch(\"/api/sentry-example-api\");\n if (!res.ok) {\n throw new Error(\"Sentry Example Frontend Error\");\n }\n });\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style={{ marginTop: \"24px\" }}>\n For more information, see{\" \"}\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nextjs/\">\n https://docs.sentry.io/platforms/javascript/guides/nextjs/\n </a>\n </p>\n </main>\n </div>\n );\n}\n`;\n}\n\nexport function getSentryExamplePagesDirApiRoute() {\n return `// A faulty API route to test Sentry's error monitoring\nexport default function handler(_req, res) {\n throw new Error(\"Sentry Example API Route Error\");\n res.status(200).json({ name: \"John Doe\" });\n}\n`;\n}\n\nexport function getSentryExampleAppDirApiRoute() {\n return `import { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\n// A faulty API route to test Sentry's error monitoring\nexport function GET() {\n throw new Error(\"Sentry Example API Route Error\");\n return NextResponse.json({ data: \"Testing Sentry Error...\" });\n}\n`;\n}\n\nexport function getSentryDefaultUnderscoreErrorPage() {\n return `import * as Sentry from \"@sentry/nextjs\";\nimport Error from \"next/error\";\n\nconst CustomErrorComponent = (props) => {\n return <Error statusCode={props.statusCode} />;\n};\n\nCustomErrorComponent.getInitialProps = async (contextData) => {\n // In case this is running in a serverless function, await this in order to give Sentry\n // time to send the error before the lambda exits\n await Sentry.captureUnderscoreErrorException(contextData);\n\n // This will contain the status code of the response\n return Error.getInitialProps(contextData);\n};\n\nexport default CustomErrorComponent;\n`;\n}\n\nexport function getSimpleUnderscoreErrorCopyPasteSnippet() {\n return `\n${chalk.green(`import * as Sentry from '@sentry/nextjs';`)}\n${chalk.green(`import Error from \"next/error\";`)}\n\n${chalk.dim(\n '// Replace \"YourCustomErrorComponent\" with your custom error component!',\n)}\nYourCustomErrorComponent.getInitialProps = async (${chalk.green(\n 'contextData',\n )}) => {\n ${chalk.green('await Sentry.captureUnderscoreErrorException(contextData);')}\n\n ${chalk.dim('// ...other getInitialProps code')}\n\n return Error.getInitialProps(contextData);\n};\n`;\n}\n\nexport function getFullUnderscoreErrorCopyPasteSnippet(isTs: boolean) {\n return `\nimport * as Sentry from '@sentry/nextjs';${\n isTs ? '\\nimport type { NextPageContext } from \"next\";' : ''\n }\nimport Error from \"next/error\";\n\n${chalk.dim(\n '// Replace \"YourCustomErrorComponent\" with your custom error component!',\n)}\nYourCustomErrorComponent.getInitialProps = async (contextData${\n isTs ? ': NextPageContext' : ''\n }) => {\n await Sentry.captureUnderscoreErrorException(contextData);\n\n return Error.getInitialProps(contextData);\n};\n`;\n}\n\nexport function getInstrumentationHookContent(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return `import * as Sentry from '@sentry/nextjs';\n\nexport async function register() {\n if (process.env.NEXT_RUNTIME === 'nodejs') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.server.config');\n }\n\n if (process.env.NEXT_RUNTIME === 'edge') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.edge.config');\n }\n}\n\nexport const onRequestError = Sentry.captureRequestError;\n`;\n}\n\nexport function getInstrumentationHookCopyPasteSnippet(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return makeCodeSnippet(true, (unchanged, plus) => {\n return unchanged(`${plus(\"import * as Sentry from '@sentry/nextjs';\")}\n\nexport ${plus('async')} function register() {\n ${plus(`if (process.env.NEXT_RUNTIME === 'nodejs') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.server.config');\n }\n\n if (process.env.NEXT_RUNTIME === 'edge') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.edge.config');\n }`)}\n}\n\n${plus('export const onRequestError = Sentry.captureRequestError;')}\n`);\n });\n}\n\nexport function getSentryDefaultGlobalErrorPage(isTs: boolean) {\n return isTs\n ? `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport NextError from \"next/error\";\nimport { useEffect } from \"react\";\n\nexport default function GlobalError({ error }: { error: Error & { digest?: string } }) {\n useEffect(() => {\n Sentry.captureException(error);\n }, [error]);\n\n return (\n <html>\n <body>\n {/* \\`NextError\\` is the default Next.js error page component. Its type\n definition requires a \\`statusCode\\` prop. However, since the App Router\n does not expose status codes for errors, we simply pass 0 to render a\n generic error message. */}\n <NextError statusCode={0} />\n </body>\n </html>\n );\n}`\n : `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport NextError from \"next/error\";\nimport { useEffect } from \"react\";\n\nexport default function GlobalError({ error }) {\n useEffect(() => {\n Sentry.captureException(error);\n }, [error]);\n\n return (\n <html>\n <body>\n {/* \\`NextError\\` is the default Next.js error page component. Its type\n definition requires a \\`statusCode\\` prop. However, since the App Router\n does not expose status codes for errors, we simply pass 0 to render a\n generic error message. */}\n <NextError statusCode={0} />\n </body>\n </html>\n );\n}\n`;\n}\n\nexport function getGlobalErrorCopyPasteSnippet(isTs: boolean) {\n if (isTs) {\n return `\"use client\";\n\n${chalk.green('import * as Sentry from \"@sentry/nextjs\";')}\n${chalk.green('import Error from \"next/error\";')}\n${chalk.green('import { useEffect } from \"react\";')}\n\nexport default function GlobalError(${chalk.green(\n '{ error }: { error: Error }',\n )}) {\n ${chalk.green(`useEffect(() => {\n Sentry.captureException(error);\n }, [error]);`)}\n\n return (\n <html>\n <body>\n {/* Your Error component here... */}\n </body>\n </html>\n );\n}\n`;\n } else {\n return `\"use client\";\n\n${chalk.green('import * as Sentry from \"@sentry/nextjs\";')}\n${chalk.green('import Error from \"next/error\";')}\n${chalk.green('import { useEffect } from \"react\";')}\n\nexport default function GlobalError(${chalk.green('{ error }')}) {\n ${chalk.green(`useEffect(() => {\n Sentry.captureException(error);\n }, [error]);`)}\n\n return (\n <html>\n <body>\n {/* Your Error component here... */}\n </body>\n </html>\n );\n}\n`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nextjs/templates.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAC1B,oDAAuD;AAWvD,SAAgB,kCAAkC,CAAC,EAOzB;QANxB,OAAO,aAAA,EACP,WAAW,iBAAA,EACX,UAAU,gBAAA,EACV,WAAW,iBAAA,EACX,wBAAwB,8BAAA,EACxB,SAAS,eAAA;IAET,OAAO,qIAIG,OAAO,iCACH,WAAW,gBACvB,UAAU,CAAC,CAAC,CAAC,6BAAqB,SAAS,QAAI,CAAC,CAAC,CAAC,EAAE,+VAWlD,wBAAwB;QACtB,CAAC,CAAC,6KAIH;QACC,CAAC,CAAC,EAAE,wBAIN,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,qUAK5C,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,6gBAa1B,CAAC;AACL,CAAC;AAtDD,gFAsDC;AAED,SAAgB,0BAA0B,CACxC,+BAAuC;IAEvC,OAAO,gMAOL,+BAA+B,WAElC,CAAC;AACF,CAAC;AAbD,gEAaC;AAED,SAAgB,0BAA0B,CACxC,+BAAuC;IAEvC,OAAO,yLAOL,+BAA+B,WAElC,CAAC;AACF,CAAC;AAbD,gEAaC;AAED,SAAgB,0BAA0B,CACxC,+BAAuC;IAEvC,OAAO,mLAQL,+BAA+B,WAElC,CAAC;AACF,CAAC;AAdD,gEAcC;AAED,SAAgB,kCAAkC,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AAC;KACC;AACH,CAAC;AA9CD,wEA8CC","sourcesContent":["import chalk from 'chalk';\nimport { makeCodeSnippet } from '../utils/clack-utils';\n\ntype WithSentryConfigOptions = {\n orgSlug: string;\n projectSlug: string;\n selfHosted: boolean;\n sentryUrl: string;\n tunnelRoute: boolean;\n reactComponentAnnotation: boolean;\n};\n\nexport function getWithSentryConfigOptionsTemplate({\n orgSlug,\n projectSlug,\n selfHosted,\n tunnelRoute,\n reactComponentAnnotation,\n sentryUrl,\n}: WithSentryConfigOptions): string {\n return `{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",${\n selfHosted ? `\\n sentryUrl: \"${sentryUrl}\",` : ''\n }\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,${\n reactComponentAnnotation\n ? `\\n\n // Automatically annotate React components to show their full name in breadcrumbs and session replay\n reactComponentAnnotation: {\n enabled: true,\n },`\n : ''\n }\n\n // ${\n tunnelRoute ? 'Route' : 'Uncomment to route'\n } browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n ${tunnelRoute ? '' : '// '}tunnelRoute: \"/monitoring\",\n\n // Hides source maps from generated client bundles\n hideSourceMaps: true,\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }`;\n}\n\nexport function getNextjsConfigCjsTemplate(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `const { withSentryConfig } = require(\"@sentry/nextjs\");\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nmodule.exports = withSentryConfig(\n nextConfig,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigMjsTemplate(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `import { withSentryConfig } from \"@sentry/nextjs\";\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {};\n\nexport default withSentryConfig(\n nextConfig,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigCjsAppendix(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `\n\n// Injected content via Sentry wizard below\n\nconst { withSentryConfig } = require(\"@sentry/nextjs\");\n\nmodule.exports = withSentryConfig(\n module.exports,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigEsmCopyPasteSnippet(\n withSentryConfigOptionsTemplate: string,\n): string {\n return `\n\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs\";\n\nexport default withSentryConfig(\n yourNextConfig,\n ${withSentryConfigOptionsTemplate}\n);\n`;\n}\n\nfunction getClientIntegrationsSnippet(features: { replay: boolean }) {\n if (features.replay) {\n return `\n\n // Add optional integrations for additional features\n integrations: [\n Sentry.replayIntegration(),\n ],`;\n }\n\n return '';\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'server' | 'client' | 'edge',\n selectedFeaturesMap: {\n replay: boolean;\n performance: boolean;\n },\n): string {\n let primer;\n if (config === 'server') {\n primer = `// This file configures the initialization of Sentry on the server.\n// The config you add here will be used whenever the server handles a request.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'client') {\n primer = `// This file configures the initialization of Sentry on the client.\n// The config you add here will be used whenever a users loads a page in their browser.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n } else if (config === 'edge') {\n primer = `// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n// The config you add here will be used whenever one of the edge features is loaded.\n// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.\n// https://docs.sentry.io/platforms/javascript/guides/nextjs/`;\n }\n\n const integrationsOptions = getClientIntegrationsSnippet({\n replay: config === 'client' && selectedFeaturesMap.replay,\n });\n\n let replayOptions = '';\n if (config === 'client') {\n if (selectedFeaturesMap.replay) {\n replayOptions += `\n\n // Define how likely Replay events are sampled.\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // Define how likely Replay events are sampled when an error occurs.\n replaysOnErrorSampleRate: 1.0,`;\n }\n }\n\n let performanceOptions = '';\n if (selectedFeaturesMap.performance) {\n performanceOptions += `\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,`;\n }\n\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n return `${primer}\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"${dsn}\",${integrationsOptions}${performanceOptions}${replayOptions}\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n sentryUrl: string;\n orgSlug: string;\n projectId: string;\n useClient: boolean;\n}): string {\n const issuesPageLink = options.selfHosted\n ? `${options.sentryUrl}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `${\n options.useClient ? '\"use client\";\\n\\n' : ''\n }import Head from \"next/head\";\nimport * as Sentry from \"@sentry/nextjs\";\n\nexport default function Page() {\n return (\n <div>\n <Head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your Next.js app!\" />\n </Head>\n\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n <svg\n style={{\n height: \"1em\",\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 200 44\"\n >\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n ></path>\n </svg>\n </h1>\n\n <p>Get started by sending us a sample error:</p>\n <button\n type=\"button\"\n style={{\n padding: \"12px\",\n cursor: \"pointer\",\n backgroundColor: \"#AD6CAA\",\n borderRadius: \"4px\",\n border: \"none\",\n color: \"white\",\n fontSize: \"14px\",\n margin: \"18px\",\n }}\n onClick={async () => {\n await Sentry.startSpan({\n name: 'Example Frontend Span',\n op: 'test'\n }, async () => {\n const res = await fetch(\"/api/sentry-example-api\");\n if (!res.ok) {\n throw new Error(\"Sentry Example Frontend Error\");\n }\n });\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style={{ marginTop: \"24px\" }}>\n For more information, see{\" \"}\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nextjs/\">\n https://docs.sentry.io/platforms/javascript/guides/nextjs/\n </a>\n </p>\n </main>\n </div>\n );\n}\n`;\n}\n\nexport function getSentryExamplePagesDirApiRoute() {\n return `// A faulty API route to test Sentry's error monitoring\nexport default function handler(_req, res) {\n throw new Error(\"Sentry Example API Route Error\");\n res.status(200).json({ name: \"John Doe\" });\n}\n`;\n}\n\nexport function getSentryExampleAppDirApiRoute() {\n return `import { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\n// A faulty API route to test Sentry's error monitoring\nexport function GET() {\n throw new Error(\"Sentry Example API Route Error\");\n return NextResponse.json({ data: \"Testing Sentry Error...\" });\n}\n`;\n}\n\nexport function getSentryDefaultUnderscoreErrorPage() {\n return `import * as Sentry from \"@sentry/nextjs\";\nimport Error from \"next/error\";\n\nconst CustomErrorComponent = (props) => {\n return <Error statusCode={props.statusCode} />;\n};\n\nCustomErrorComponent.getInitialProps = async (contextData) => {\n // In case this is running in a serverless function, await this in order to give Sentry\n // time to send the error before the lambda exits\n await Sentry.captureUnderscoreErrorException(contextData);\n\n // This will contain the status code of the response\n return Error.getInitialProps(contextData);\n};\n\nexport default CustomErrorComponent;\n`;\n}\n\nexport function getSimpleUnderscoreErrorCopyPasteSnippet() {\n return `\n${chalk.green(`import * as Sentry from '@sentry/nextjs';`)}\n${chalk.green(`import Error from \"next/error\";`)}\n\n${chalk.dim(\n '// Replace \"YourCustomErrorComponent\" with your custom error component!',\n)}\nYourCustomErrorComponent.getInitialProps = async (${chalk.green(\n 'contextData',\n )}) => {\n ${chalk.green('await Sentry.captureUnderscoreErrorException(contextData);')}\n\n ${chalk.dim('// ...other getInitialProps code')}\n\n return Error.getInitialProps(contextData);\n};\n`;\n}\n\nexport function getFullUnderscoreErrorCopyPasteSnippet(isTs: boolean) {\n return `\nimport * as Sentry from '@sentry/nextjs';${\n isTs ? '\\nimport type { NextPageContext } from \"next\";' : ''\n }\nimport Error from \"next/error\";\n\n${chalk.dim(\n '// Replace \"YourCustomErrorComponent\" with your custom error component!',\n)}\nYourCustomErrorComponent.getInitialProps = async (contextData${\n isTs ? ': NextPageContext' : ''\n }) => {\n await Sentry.captureUnderscoreErrorException(contextData);\n\n return Error.getInitialProps(contextData);\n};\n`;\n}\n\nexport function getInstrumentationHookContent(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return `import * as Sentry from '@sentry/nextjs';\n\nexport async function register() {\n if (process.env.NEXT_RUNTIME === 'nodejs') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.server.config');\n }\n\n if (process.env.NEXT_RUNTIME === 'edge') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.edge.config');\n }\n}\n\nexport const onRequestError = Sentry.captureRequestError;\n`;\n}\n\nexport function getInstrumentationHookCopyPasteSnippet(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return makeCodeSnippet(true, (unchanged, plus) => {\n return unchanged(`${plus(\"import * as Sentry from '@sentry/nextjs';\")}\n\nexport ${plus('async')} function register() {\n ${plus(`if (process.env.NEXT_RUNTIME === 'nodejs') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.server.config');\n }\n\n if (process.env.NEXT_RUNTIME === 'edge') {\n await import('${\n instrumentationHookLocation === 'root' ? '.' : '..'\n }/sentry.edge.config');\n }`)}\n}\n\n${plus('export const onRequestError = Sentry.captureRequestError;')}\n`);\n });\n}\n\nexport function getSentryDefaultGlobalErrorPage(isTs: boolean) {\n return isTs\n ? `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport NextError from \"next/error\";\nimport { useEffect } from \"react\";\n\nexport default function GlobalError({ error }: { error: Error & { digest?: string } }) {\n useEffect(() => {\n Sentry.captureException(error);\n }, [error]);\n\n return (\n <html>\n <body>\n {/* \\`NextError\\` is the default Next.js error page component. Its type\n definition requires a \\`statusCode\\` prop. However, since the App Router\n does not expose status codes for errors, we simply pass 0 to render a\n generic error message. */}\n <NextError statusCode={0} />\n </body>\n </html>\n );\n}`\n : `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport NextError from \"next/error\";\nimport { useEffect } from \"react\";\n\nexport default function GlobalError({ error }) {\n useEffect(() => {\n Sentry.captureException(error);\n }, [error]);\n\n return (\n <html>\n <body>\n {/* \\`NextError\\` is the default Next.js error page component. Its type\n definition requires a \\`statusCode\\` prop. However, since the App Router\n does not expose status codes for errors, we simply pass 0 to render a\n generic error message. */}\n <NextError statusCode={0} />\n </body>\n </html>\n );\n}\n`;\n}\n\nexport function getGlobalErrorCopyPasteSnippet(isTs: boolean) {\n if (isTs) {\n return `\"use client\";\n\n${chalk.green('import * as Sentry from \"@sentry/nextjs\";')}\n${chalk.green('import Error from \"next/error\";')}\n${chalk.green('import { useEffect } from \"react\";')}\n\nexport default function GlobalError(${chalk.green(\n '{ error }: { error: Error }',\n )}) {\n ${chalk.green(`useEffect(() => {\n Sentry.captureException(error);\n }, [error]);`)}\n\n return (\n <html>\n <body>\n {/* Your Error component here... */}\n </body>\n </html>\n );\n}\n`;\n } else {\n return `\"use client\";\n\n${chalk.green('import * as Sentry from \"@sentry/nextjs\";')}\n${chalk.green('import Error from \"next/error\";')}\n${chalk.green('import { useEffect } from \"react\";')}\n\nexport default function GlobalError(${chalk.green('{ error }')}) {\n ${chalk.green(`useEffect(() => {\n Sentry.captureException(error);\n }, [error]);`)}\n\n return (\n <html>\n <body>\n {/* Your Error component here... */}\n </body>\n </html>\n );\n}\n`;\n }\n}\n"]}
|
package/e2e-tests/jest.config.ts
CHANGED
package/e2e-tests/run.sh
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Check if volta is installed in the environment
|
|
2
|
+
VOLTA=$(which volta)
|
|
3
|
+
|
|
4
|
+
# Set cwd to the directory of this script
|
|
5
|
+
cd "$(dirname "$0")"
|
|
6
|
+
|
|
7
|
+
# Run the tests with volta if it is installed
|
|
8
|
+
if [ -x "$VOLTA" ]; then
|
|
9
|
+
echo "Running tests with volta"
|
|
10
|
+
volta run yarn test $@
|
|
11
|
+
# Otherwise, run the tests without volta
|
|
12
|
+
else
|
|
13
|
+
echo "Running tests without volta"
|
|
14
|
+
yarn test $@
|
|
15
|
+
fi
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nextjs-test-app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev",
|
|
7
|
+
"build": "next build",
|
|
8
|
+
"start": "next start -p 8082",
|
|
9
|
+
"lint": "next lint"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"react": "^18",
|
|
13
|
+
"react-dom": "^18",
|
|
14
|
+
"next": "14.2.14"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"typescript": "^5",
|
|
18
|
+
"@types/node": "^20",
|
|
19
|
+
"@types/react": "^18",
|
|
20
|
+
"@types/react-dom": "^18"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
|
|
3
|
+
export const metadata: Metadata = {
|
|
4
|
+
title: "Create Next App",
|
|
5
|
+
description: "Generated by create next app",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default function RootLayout({
|
|
9
|
+
children,
|
|
10
|
+
}: Readonly<{
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}>) {
|
|
13
|
+
return (
|
|
14
|
+
<html lang="en">
|
|
15
|
+
<body>
|
|
16
|
+
{children}
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import Image from "next/image";
|
|
2
|
+
|
|
3
|
+
export default function Home() {
|
|
4
|
+
return (
|
|
5
|
+
<div>
|
|
6
|
+
<main>
|
|
7
|
+
<Image
|
|
8
|
+
src="https://nextjs.org/icons/next.svg"
|
|
9
|
+
alt="Next.js logo"
|
|
10
|
+
width={180}
|
|
11
|
+
height={38}
|
|
12
|
+
priority
|
|
13
|
+
/>
|
|
14
|
+
<ol>
|
|
15
|
+
<li>
|
|
16
|
+
Get started by editing <code>src/app/page.tsx</code>.
|
|
17
|
+
</li>
|
|
18
|
+
<li>Save and see your changes instantly.</li>
|
|
19
|
+
</ol>
|
|
20
|
+
|
|
21
|
+
<div>
|
|
22
|
+
<a
|
|
23
|
+
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
|
24
|
+
target="_blank"
|
|
25
|
+
rel="noopener noreferrer"
|
|
26
|
+
>
|
|
27
|
+
<Image
|
|
28
|
+
src="https://nextjs.org/icons/vercel.svg"
|
|
29
|
+
alt="Vercel logomark"
|
|
30
|
+
width={20}
|
|
31
|
+
height={20}
|
|
32
|
+
/>
|
|
33
|
+
Deploy now
|
|
34
|
+
</a>
|
|
35
|
+
<a
|
|
36
|
+
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
|
37
|
+
target="_blank"
|
|
38
|
+
rel="noopener noreferrer"
|
|
39
|
+
>
|
|
40
|
+
Read our docs
|
|
41
|
+
</a>
|
|
42
|
+
</div>
|
|
43
|
+
</main>
|
|
44
|
+
<footer>
|
|
45
|
+
<a
|
|
46
|
+
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
|
47
|
+
target="_blank"
|
|
48
|
+
rel="noopener noreferrer"
|
|
49
|
+
>
|
|
50
|
+
<Image
|
|
51
|
+
aria-hidden
|
|
52
|
+
src="https://nextjs.org/icons/file.svg"
|
|
53
|
+
alt="File icon"
|
|
54
|
+
width={16}
|
|
55
|
+
height={16}
|
|
56
|
+
/>
|
|
57
|
+
Learn
|
|
58
|
+
</a>
|
|
59
|
+
<a
|
|
60
|
+
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
|
61
|
+
target="_blank"
|
|
62
|
+
rel="noopener noreferrer"
|
|
63
|
+
>
|
|
64
|
+
<Image
|
|
65
|
+
aria-hidden
|
|
66
|
+
src="https://nextjs.org/icons/window.svg"
|
|
67
|
+
alt="Window icon"
|
|
68
|
+
width={16}
|
|
69
|
+
height={16}
|
|
70
|
+
/>
|
|
71
|
+
Examples
|
|
72
|
+
</a>
|
|
73
|
+
<a
|
|
74
|
+
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
|
75
|
+
target="_blank"
|
|
76
|
+
rel="noopener noreferrer"
|
|
77
|
+
>
|
|
78
|
+
<Image
|
|
79
|
+
aria-hidden
|
|
80
|
+
src="https://nextjs.org/icons/globe.svg"
|
|
81
|
+
alt="Globe icon"
|
|
82
|
+
width={16}
|
|
83
|
+
height={16}
|
|
84
|
+
/>
|
|
85
|
+
Go to nextjs.org →
|
|
86
|
+
</a>
|
|
87
|
+
</footer>
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sveltekit-test-app",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite dev",
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"preview": "vite preview",
|
|
9
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
10
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@sveltejs/adapter-auto": "^3.0.0",
|
|
14
|
+
"@sveltejs/kit": "^2.0.0",
|
|
15
|
+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
|
|
16
|
+
"svelte": "^5.0.0",
|
|
17
|
+
"svelte-check": "^4.0.0",
|
|
18
|
+
"typescript": "^5.0.0",
|
|
19
|
+
"vite": "^5.0.3"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// See https://svelte.dev/docs/kit/types#app
|
|
2
|
+
// for information about these interfaces
|
|
3
|
+
declare global {
|
|
4
|
+
namespace App {
|
|
5
|
+
// interface Error {}
|
|
6
|
+
// interface Locals {}
|
|
7
|
+
// interface PageData {}
|
|
8
|
+
// interface PageState {}
|
|
9
|
+
// interface Platform {}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
%sveltekit.head%
|
|
7
|
+
</head>
|
|
8
|
+
<body data-sveltekit-preload-data="hover">
|
|
9
|
+
<div style="display: contents">%sveltekit.body%</div>
|
|
10
|
+
</body>
|
|
11
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// place files you want to import through the `$lib` alias in this folder.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import adapter from '@sveltejs/adapter-auto';
|
|
2
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
3
|
+
|
|
4
|
+
/** @type {import('@sveltejs/kit').Config} */
|
|
5
|
+
const config = {
|
|
6
|
+
// Consult https://svelte.dev/docs/kit/integrations#preprocessors
|
|
7
|
+
// for more information about preprocessors
|
|
8
|
+
preprocess: vitePreprocess(),
|
|
9
|
+
|
|
10
|
+
kit: {
|
|
11
|
+
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
|
12
|
+
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
|
13
|
+
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
|
14
|
+
adapter: adapter()
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default config;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/* eslint-disable jest/expect-expect */
|
|
2
|
+
import { Integration } from '../../lib/Constants';
|
|
3
|
+
import {
|
|
4
|
+
checkEnvBuildPlugin,
|
|
5
|
+
cleanupGit,
|
|
6
|
+
KEYS,
|
|
7
|
+
revertLocalChanges,
|
|
8
|
+
} from '../utils';
|
|
9
|
+
import { startWizardInstance } from '../utils';
|
|
10
|
+
import {
|
|
11
|
+
checkFileContents,
|
|
12
|
+
checkFileExists,
|
|
13
|
+
checkIfBuilds,
|
|
14
|
+
checkIfRunsOnDevMode,
|
|
15
|
+
checkIfRunsOnProdMode,
|
|
16
|
+
checkPackageJson,
|
|
17
|
+
} from '../utils';
|
|
18
|
+
import * as path from 'path';
|
|
19
|
+
|
|
20
|
+
describe('NextJS', () => {
|
|
21
|
+
const integration = Integration.nextjs;
|
|
22
|
+
const projectDir = path.resolve(
|
|
23
|
+
__dirname,
|
|
24
|
+
'../test-applications/nextjs-test-app',
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
beforeAll(async () => {
|
|
28
|
+
const wizardInstance = startWizardInstance(integration, projectDir);
|
|
29
|
+
const packageManagerPrompted = await wizardInstance.waitForOutput(
|
|
30
|
+
'Please select your package manager.',
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const routeThroughNextJsPrompted =
|
|
34
|
+
packageManagerPrompted &&
|
|
35
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
36
|
+
// Selecting `yarn` as the package manager
|
|
37
|
+
[KEYS.DOWN, KEYS.ENTER],
|
|
38
|
+
'Do you want to route Sentry requests in the browser through your Next.js server',
|
|
39
|
+
{
|
|
40
|
+
timeout: 240_000,
|
|
41
|
+
},
|
|
42
|
+
));
|
|
43
|
+
|
|
44
|
+
const reactComponentAnnotationsPrompted =
|
|
45
|
+
routeThroughNextJsPrompted &&
|
|
46
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
47
|
+
[KEYS.ENTER],
|
|
48
|
+
'Do you want to enable React component annotations',
|
|
49
|
+
));
|
|
50
|
+
|
|
51
|
+
const tracingOptionPrompted =
|
|
52
|
+
reactComponentAnnotationsPrompted &&
|
|
53
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
54
|
+
[KEYS.ENTER],
|
|
55
|
+
// "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
|
|
56
|
+
'to track the performance of your application?',
|
|
57
|
+
));
|
|
58
|
+
|
|
59
|
+
const replayOptionPrompted =
|
|
60
|
+
tracingOptionPrompted &&
|
|
61
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
62
|
+
[KEYS.ENTER],
|
|
63
|
+
// "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
|
|
64
|
+
'to get a video-like reproduction of errors during a user session?',
|
|
65
|
+
));
|
|
66
|
+
|
|
67
|
+
const examplePagePrompted =
|
|
68
|
+
replayOptionPrompted &&
|
|
69
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
70
|
+
[KEYS.ENTER],
|
|
71
|
+
'Do you want to create an example page',
|
|
72
|
+
{
|
|
73
|
+
optional: true,
|
|
74
|
+
},
|
|
75
|
+
));
|
|
76
|
+
|
|
77
|
+
const ciCdPrompted =
|
|
78
|
+
examplePagePrompted &&
|
|
79
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
80
|
+
[KEYS.ENTER],
|
|
81
|
+
'Are you using a CI/CD tool',
|
|
82
|
+
));
|
|
83
|
+
|
|
84
|
+
ciCdPrompted &&
|
|
85
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
86
|
+
// Selecting `No` for CI/CD tool
|
|
87
|
+
[KEYS.DOWN, KEYS.ENTER],
|
|
88
|
+
'Successfully installed the Sentry Next.js SDK!',
|
|
89
|
+
));
|
|
90
|
+
|
|
91
|
+
wizardInstance.kill();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
afterAll(() => {
|
|
95
|
+
revertLocalChanges(projectDir);
|
|
96
|
+
cleanupGit(projectDir);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('package.json is updated correctly', () => {
|
|
100
|
+
checkPackageJson(projectDir, integration);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('.env-sentry-build-plugin is created and contains the auth token', () => {
|
|
104
|
+
checkEnvBuildPlugin(projectDir);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('example page exists', () => {
|
|
108
|
+
checkFileExists(`${projectDir}/src/app/sentry-example-page/page.tsx`);
|
|
109
|
+
checkFileExists(`${projectDir}/src/app/api/sentry-example-api/route.ts`);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('config files created', () => {
|
|
113
|
+
checkFileExists(`${projectDir}/sentry.server.config.ts`);
|
|
114
|
+
checkFileExists(`${projectDir}/sentry.client.config.ts`);
|
|
115
|
+
checkFileExists(`${projectDir}/sentry.edge.config.ts`);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('global error file exists', () => {
|
|
119
|
+
checkFileExists(`${projectDir}/src/app/global-error.tsx`);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('instrumentation file exists', () => {
|
|
123
|
+
checkFileExists(`${projectDir}/src/instrumentation.ts`);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('instrumentation file contains Sentry initialization', () => {
|
|
127
|
+
checkFileContents(`${projectDir}/src/instrumentation.ts`, [
|
|
128
|
+
"import * as Sentry from '@sentry/nextjs';",
|
|
129
|
+
`export async function register() {
|
|
130
|
+
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
131
|
+
await import('../sentry.server.config');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (process.env.NEXT_RUNTIME === 'edge') {
|
|
135
|
+
await import('../sentry.edge.config');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const onRequestError = Sentry.captureRequestError;`,
|
|
140
|
+
]);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('next.config file contains Sentry wrapper', () => {
|
|
144
|
+
checkFileContents(`${projectDir}/next.config.mjs`, [
|
|
145
|
+
"import {withSentryConfig} from '@sentry/nextjs'",
|
|
146
|
+
'export default withSentryConfig(nextConfig, {',
|
|
147
|
+
]);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('runs on dev mode correctly', async () => {
|
|
151
|
+
await checkIfRunsOnDevMode(projectDir, 'Ready in');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('builds correctly', async () => {
|
|
155
|
+
await checkIfBuilds(projectDir, 'server-rendered on demand');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test('runs on prod mode correctly', async () => {
|
|
159
|
+
await checkIfRunsOnProdMode(projectDir, 'Ready in');
|
|
160
|
+
});
|
|
161
|
+
});
|
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
import { Integration } from '../../lib/Constants';
|
|
3
3
|
import {
|
|
4
4
|
checkEnvBuildPlugin,
|
|
5
|
-
cleanupGit,
|
|
6
|
-
KEYS,
|
|
7
|
-
revertLocalChanges,
|
|
8
|
-
} from '../utils';
|
|
9
|
-
import { startWizardInstance } from '../utils';
|
|
10
|
-
import {
|
|
11
5
|
checkFileContents,
|
|
12
6
|
checkFileExists,
|
|
13
7
|
checkIfBuilds,
|
|
14
8
|
checkIfRunsOnDevMode,
|
|
15
9
|
checkIfRunsOnProdMode,
|
|
16
10
|
checkPackageJson,
|
|
11
|
+
cleanupGit,
|
|
12
|
+
KEYS,
|
|
13
|
+
revertLocalChanges,
|
|
14
|
+
startWizardInstance,
|
|
17
15
|
TEST_ARGS,
|
|
18
16
|
} from '../utils';
|
|
19
17
|
import * as path from 'path';
|
|
@@ -31,44 +29,37 @@ describe('Remix', () => {
|
|
|
31
29
|
'Please select your package manager.',
|
|
32
30
|
);
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
wizardInstance.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
wizardInstance.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (examplePagePrompted) {
|
|
67
|
-
wizardInstance.sendStdin(KEYS.ENTER);
|
|
68
|
-
wizardInstance.sendStdin(KEYS.ENTER);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
await wizardInstance.waitForOutput(
|
|
32
|
+
const tracingOptionPrompted =
|
|
33
|
+
packageManagerPrompted &&
|
|
34
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
35
|
+
// Selecting `yarn` as the package manager
|
|
36
|
+
[KEYS.DOWN, KEYS.ENTER],
|
|
37
|
+
// "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
|
|
38
|
+
'to track the performance of your application?',
|
|
39
|
+
{
|
|
40
|
+
timeout: 240_000,
|
|
41
|
+
},
|
|
42
|
+
));
|
|
43
|
+
|
|
44
|
+
const replayOptionPrompted =
|
|
45
|
+
tracingOptionPrompted &&
|
|
46
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
47
|
+
[KEYS.ENTER],
|
|
48
|
+
// "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
|
|
49
|
+
'to get a video-like reproduction of errors during a user session?',
|
|
50
|
+
));
|
|
51
|
+
|
|
52
|
+
replayOptionPrompted &&
|
|
53
|
+
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
54
|
+
[KEYS.ENTER],
|
|
55
|
+
'Do you want to create an example page',
|
|
56
|
+
{
|
|
57
|
+
optional: true,
|
|
58
|
+
},
|
|
59
|
+
));
|
|
60
|
+
|
|
61
|
+
await wizardInstance.sendStdinAndWaitForOutput(
|
|
62
|
+
[KEYS.ENTER, KEYS.ENTER],
|
|
72
63
|
'Sentry has been successfully configured for your Remix project',
|
|
73
64
|
);
|
|
74
65
|
|