@sentry/wizard 3.26.0 → 3.28.0

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/package.json +2 -1
  3. package/dist/src/nextjs/nextjs-wizard.js +81 -25
  4. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  5. package/dist/src/nextjs/templates.d.ts +4 -1
  6. package/dist/src/nextjs/templates.js +18 -7
  7. package/dist/src/nextjs/templates.js.map +1 -1
  8. package/dist/src/run.js +1 -1
  9. package/dist/src/run.js.map +1 -1
  10. package/dist/src/sourcemaps/sourcemaps-wizard.js +1 -1
  11. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  12. package/dist/src/sveltekit/sdk-setup.js +64 -43
  13. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  14. package/dist/src/sveltekit/sveltekit-wizard.d.ts +1 -1
  15. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  16. package/dist/src/sveltekit/templates.d.ts +8 -2
  17. package/dist/src/sveltekit/templates.js +11 -5
  18. package/dist/src/sveltekit/templates.js.map +1 -1
  19. package/dist/src/utils/clack-utils.d.ts +4 -1
  20. package/dist/src/utils/clack-utils.js +47 -1
  21. package/dist/src/utils/clack-utils.js.map +1 -1
  22. package/dist/src/utils/package-manager.d.ts +4 -1
  23. package/dist/src/utils/package-manager.js +40 -5
  24. package/dist/src/utils/package-manager.js.map +1 -1
  25. package/dist/src/utils/types.d.ts +6 -0
  26. package/dist/src/utils/types.js.map +1 -1
  27. package/dist/src/utils/url.js +7 -2
  28. package/dist/src/utils/url.js.map +1 -1
  29. package/dist/test/nextjs/templates.test.js +65 -1
  30. package/dist/test/nextjs/templates.test.js.map +1 -1
  31. package/dist/test/sourcemaps/tools/sentry-cli.test.js +2 -1
  32. package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
  33. package/dist/test/sveltekit/templates.test.d.ts +1 -0
  34. package/dist/test/sveltekit/templates.test.js +43 -0
  35. package/dist/test/sveltekit/templates.test.js.map +1 -0
  36. package/package.json +2 -1
  37. package/src/nextjs/nextjs-wizard.ts +67 -7
  38. package/src/nextjs/templates.ts +35 -22
  39. package/src/run.ts +1 -1
  40. package/src/sourcemaps/sourcemaps-wizard.ts +1 -1
  41. package/src/sveltekit/sdk-setup.ts +100 -22
  42. package/src/sveltekit/sveltekit-wizard.ts +1 -1
  43. package/src/sveltekit/templates.ts +36 -10
  44. package/src/utils/clack-utils.ts +34 -1
  45. package/src/utils/package-manager.ts +38 -4
  46. package/src/utils/types.ts +7 -0
  47. package/src/utils/url.ts +6 -2
  48. package/test/nextjs/templates.test.ts +240 -2
  49. package/test/sourcemaps/tools/sentry-cli.test.ts +2 -1
  50. package/test/sveltekit/templates.test.ts +152 -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;IAEvC,OAAO,gMAOL,+BAA+B,WAElC,CAAC;AACF,CAAC;AAbD,g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O,CAAC,uCACxC,IAAI,CAAC,0EAEH,2BAA2B,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,8GAMnD,2BAA2B,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,gCAErD,CAAC,QACH,CAAC,CAAC;IACF,CAAC,CAAC,CAAC;AACL,CAAC;AAlBD,wFAkBC;AAED,SAAgB,+BAA+B,CAAC,IAAa;IAC3D,OAAO,IAAI;QACT,CAAC,CAAC,wrBAsBJ;QACE,CAAC,CAAC,kpBAuBL,CAAC;AACF,CAAC;AAjDD,0EAiDC;AAED,SAAgB,8BAA8B,CAAC,IAAa;IAC1D,IAAI,IAAI,EAAE;QACR,OAAO,6BAET,eAAK,CAAC,KAAK,CAAC,2CAA2C,CAAC,eACxD,eAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC,eAC9C,eAAK,CAAC,KAAK,CAAC,oCAAoC,CAAC,qDAEb,eAAK,CAAC,KAAK,CAC3C,6BAA6B,CAC9B,oBACD,eAAK,CAAC,KAAK,CAAC,wEAED,CAAC,kIAUf,CAAC;KACC;SAAM;QACL,OAAO,6BAET,eAAK,CAAC,KAAK,CAAC,2CAA2C,CAAC,eACxD,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\nexport function getSentryConfigContents(\n dsn: string,\n config: 'server' | 'client' | 'edge',\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 let additionalOptions = '';\n if (config === 'client') {\n additionalOptions = `\n replaysOnErrorSampleRate: 1.0,\n\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 // You can remove this option if you're not planning to use the Sentry Session Replay feature:\n integrations: [\n Sentry.replayIntegration({\n // Additional Replay configuration goes in here, for example:\n maskAllText: true,\n blockAllMedia: true,\n }),\n ],`;\n }\n\n let spotlightOption = '';\n if (config === 'server') {\n spotlightOption = `\n\n // Uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: process.env.NODE_ENV === 'development',\n `;\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}\",\n\n // Adjust this value in production, or use tracesSampler for greater control\n tracesSampleRate: 1,\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,${additionalOptions}${spotlightOption}\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 `export 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`;\n}\n\nexport function getInstrumentationHookCopyPasteSnippet(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return makeCodeSnippet(true, (unchanged, plus) => {\n return unchanged(`export ${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}\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,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AC9B,oBACD,eAAK,CAAC,KAAK,CAAC,wEAED,CAAC,kIAUf,CAAC;KACC;SAAM;QACL,OAAO,6BAET,eAAK,CAAC,KAAK,CAAC,2CAA2C,CAAC,eACxD,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 `export 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`;\n}\n\nexport function getInstrumentationHookCopyPasteSnippet(\n instrumentationHookLocation: 'src' | 'root',\n) {\n return makeCodeSnippet(true, (unchanged, plus) => {\n return unchanged(`export ${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}\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/dist/src/run.js CHANGED
@@ -101,7 +101,7 @@ function run(argv) {
101
101
  { value: 'android', label: 'Android' },
102
102
  { value: 'cordova', label: 'Cordova' },
103
103
  { value: 'electron', label: 'Electron' },
104
- { value: 'nextjs', label: 'NextJS' },
104
+ { value: 'nextjs', label: 'Next.js' },
105
105
  { value: 'remix', label: 'Remix' },
106
106
  { value: 'sveltekit', label: 'SvelteKit' },
107
107
  { value: 'sourcemaps', label: 'Configure Source Maps Upload' },
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,mDAAuD;AACvD,0EAA0E;AAE1E,sCAAgD;AAEhD,2DAA4D;AAC5D,qDAAsD;AACtD,wDAAyD;AACzD,qDAAsD;AACtD,iEAAkE;AAClE,oEAAqE;AACrE,yCAAoD;AA8BpD,SAAsB,GAAG,CAAC,IAAU;;;;;;oBAC5B,SAAS,yBACV,IAAI,GACJ,IAAA,qBAAe,GAAE,CACrB,CAAC;oBAEE,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;yBACpC,CAAC,WAAW,EAAZ,wBAAY;oBACd,KAAK,CAAC,KAAK,CAAC,wBAAiB,mBAAmB,EAAE,CAAE,CAAC,CAAC;oBAExC,qBAAM,IAAA,8BAAgB,EAClC,KAAK,CAAC,M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E,CAAC;KACpC;IAAC,WAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport { abortIfCancelled } from './utils/clack-utils';\nimport { runReactNativeWizard } from './react-native/react-native-wizard';\n\nimport { run as legacyRun } from '../lib/Setup';\nimport { WizardOptions } from './utils/types';\nimport { runAndroidWizard } from './android/android-wizard';\nimport { runAppleWizard } from './apple/apple-wizard';\nimport { runNextjsWizard } from './nextjs/nextjs-wizard';\nimport { runRemixWizard } from './remix/remix-wizard';\nimport { runSvelteKitWizard } from './sveltekit/sveltekit-wizard';\nimport { runSourcemapsWizard } from './sourcemaps/sourcemaps-wizard';\nimport { readEnvironment } from '../lib/Helper/Env';\nimport { Platform } from '../lib/Constants';\nimport { PackageDotJson } from './utils/package-json';\n\ntype WizardIntegration =\n | 'reactNative'\n | 'ios'\n | 'android'\n | 'cordova'\n | 'electron'\n | 'nextjs'\n | 'remix'\n | 'sveltekit'\n | 'sourcemaps';\n\ntype Args = {\n integration?: WizardIntegration;\n\n uninstall: boolean;\n signup: boolean;\n skipConnect: boolean;\n debug: boolean;\n quiet: boolean;\n disableTelemetry: boolean;\n promoCode?: string;\n\n url?: string;\n platform?: Platform[];\n};\n\nexport async function run(argv: Args) {\n const finalArgs = {\n ...argv,\n ...readEnvironment(),\n };\n\n let integration = finalArgs.integration;\n if (!integration) {\n clack.intro(`Sentry Wizard ${tryGetWizardVersion()}`);\n\n integration = await abortIfCancelled(\n clack.select({\n message: 'What do you want to set up?',\n options: [\n { value: 'reactNative', label: 'React Native' },\n { value: 'ios', label: 'iOS' },\n { value: 'android', label: 'Android' },\n { value: 'cordova', label: 'Cordova' },\n { value: 'electron', label: 'Electron' },\n { value: 'nextjs', label: 'NextJS' },\n { value: 'remix', label: 'Remix' },\n { value: 'sveltekit', label: 'SvelteKit' },\n { value: 'sourcemaps', label: 'Configure Source Maps Upload' },\n ],\n }),\n );\n\n if (!integration) {\n clack.log.error('No integration selected. Exiting.');\n return;\n }\n\n clack.outro(`Starting ${integration} setup`);\n }\n\n const wizardOptions: WizardOptions = {\n telemetryEnabled: !argv.disableTelemetry,\n promoCode: argv.promoCode,\n url: argv.url,\n };\n\n switch (integration) {\n case 'reactNative':\n await runReactNativeWizard({\n ...wizardOptions,\n uninstall: argv.uninstall,\n });\n break;\n\n case 'ios':\n await runAppleWizard(wizardOptions);\n break;\n\n case 'android':\n await runAndroidWizard(wizardOptions);\n break;\n\n case 'nextjs':\n await runNextjsWizard(wizardOptions);\n break;\n\n case 'remix':\n await runRemixWizard(wizardOptions);\n break;\n\n case 'sveltekit':\n await runSvelteKitWizard(wizardOptions);\n break;\n\n case 'sourcemaps':\n await runSourcemapsWizard(wizardOptions);\n break;\n\n case 'cordova':\n argv.integration = 'cordova';\n void legacyRun(argv);\n break;\n\n case 'electron':\n argv.integration = 'electron';\n void legacyRun(argv);\n break;\n\n default:\n clack.log.error(`No setup wizard selected!`);\n }\n}\n\n/**\n * TODO: replace with rollup replace whenever we switch to rollup\n */\nfunction tryGetWizardVersion(): string {\n try {\n const wizardPkgJson = require('../package.json') as PackageDotJson;\n return wizardPkgJson.version ?? '';\n } catch {\n return '';\n }\n}\n"]}
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,mDAAuD;AACvD,0EAA0E;AAE1E,sCAAgD;AAEhD,2DAA4D;AAC5D,qDAAsD;AACtD,wDAAyD;AACzD,qDAAsD;AACtD,iEAAkE;AAClE,oEAAqE;AACrE,yCAAoD;AA8BpD,SAAsB,GAAG,CAAC,IAAU;;;;;;oBAC5B,SAAS,yBACV,IAAI,GACJ,IAAA,qBAAe,GAAE,CACrB,CAAC;oBAEE,WAAW,GAAG,SAAS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CAElD;AAtFD,kBAsFC;AAED;;GAEG;AACH,SAAS,mBAAmB;;IAC1B,IAAI;QACF,IAAM,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAmB,CAAC;QACnE,OAAO,MAAA,aAAa,CAAC,OAAO,mCAAI,EAAE,CAAC;KACpC;IAAC,WAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport { abortIfCancelled } from './utils/clack-utils';\nimport { runReactNativeWizard } from './react-native/react-native-wizard';\n\nimport { run as legacyRun } from '../lib/Setup';\nimport { WizardOptions } from './utils/types';\nimport { runAndroidWizard } from './android/android-wizard';\nimport { runAppleWizard } from './apple/apple-wizard';\nimport { runNextjsWizard } from './nextjs/nextjs-wizard';\nimport { runRemixWizard } from './remix/remix-wizard';\nimport { runSvelteKitWizard } from './sveltekit/sveltekit-wizard';\nimport { runSourcemapsWizard } from './sourcemaps/sourcemaps-wizard';\nimport { readEnvironment } from '../lib/Helper/Env';\nimport { Platform } from '../lib/Constants';\nimport { PackageDotJson } from './utils/package-json';\n\ntype WizardIntegration =\n | 'reactNative'\n | 'ios'\n | 'android'\n | 'cordova'\n | 'electron'\n | 'nextjs'\n | 'remix'\n | 'sveltekit'\n | 'sourcemaps';\n\ntype Args = {\n integration?: WizardIntegration;\n\n uninstall: boolean;\n signup: boolean;\n skipConnect: boolean;\n debug: boolean;\n quiet: boolean;\n disableTelemetry: boolean;\n promoCode?: string;\n\n url?: string;\n platform?: Platform[];\n};\n\nexport async function run(argv: Args) {\n const finalArgs = {\n ...argv,\n ...readEnvironment(),\n };\n\n let integration = finalArgs.integration;\n if (!integration) {\n clack.intro(`Sentry Wizard ${tryGetWizardVersion()}`);\n\n integration = await abortIfCancelled(\n clack.select({\n message: 'What do you want to set up?',\n options: [\n { value: 'reactNative', label: 'React Native' },\n { value: 'ios', label: 'iOS' },\n { value: 'android', label: 'Android' },\n { value: 'cordova', label: 'Cordova' },\n { value: 'electron', label: 'Electron' },\n { value: 'nextjs', label: 'Next.js' },\n { value: 'remix', label: 'Remix' },\n { value: 'sveltekit', label: 'SvelteKit' },\n { value: 'sourcemaps', label: 'Configure Source Maps Upload' },\n ],\n }),\n );\n\n if (!integration) {\n clack.log.error('No integration selected. Exiting.');\n return;\n }\n\n clack.outro(`Starting ${integration} setup`);\n }\n\n const wizardOptions: WizardOptions = {\n telemetryEnabled: !argv.disableTelemetry,\n promoCode: argv.promoCode,\n url: argv.url,\n };\n\n switch (integration) {\n case 'reactNative':\n await runReactNativeWizard({\n ...wizardOptions,\n uninstall: argv.uninstall,\n });\n break;\n\n case 'ios':\n await runAppleWizard(wizardOptions);\n break;\n\n case 'android':\n await runAndroidWizard(wizardOptions);\n break;\n\n case 'nextjs':\n await runNextjsWizard(wizardOptions);\n break;\n\n case 'remix':\n await runRemixWizard(wizardOptions);\n break;\n\n case 'sveltekit':\n await runSvelteKitWizard(wizardOptions);\n break;\n\n case 'sourcemaps':\n await runSourcemapsWizard(wizardOptions);\n break;\n\n case 'cordova':\n argv.integration = 'cordova';\n void legacyRun(argv);\n break;\n\n case 'electron':\n argv.integration = 'electron';\n void legacyRun(argv);\n break;\n\n default:\n clack.log.error(`No setup wizard selected!`);\n }\n}\n\n/**\n * TODO: replace with rollup replace whenever we switch to rollup\n */\nfunction tryGetWizardVersion(): string {\n try {\n const wizardPkgJson = require('../package.json') as PackageDotJson;\n return wizardPkgJson.version ?? '';\n } catch {\n return '';\n }\n}\n"]}
@@ -199,7 +199,7 @@ function askForUsedBundlerTool() {
199
199
  {
200
200
  label: 'Next.js',
201
201
  value: 'nextjs',
202
- hint: 'Select this option if you want to set up source maps in a NextJS project.',
202
+ hint: 'Select this option if you want to set up source maps in a Next.js project.',
203
203
  },
204
204
  {
205
205
  label: 'Remix',
@@ -1 +1 @@
1
- {"version":3,"file":"sourcemaps-wizard.js","sourceRoot":"","sources":["../../../src/sourcemaps/sourcemaps-wizard.ts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BAAkB,CAAC,CAAC;qBACpC;;;;;CACF;AAED,SAAS,UAAU,CAAC,GAAW,EAAE,OAAe,EAAE,SAAiB;;IACjE,IAAM,cAAc,GAAG,IAAA,qCAAmB,GAAE,CAAC;IAC7C,IAAM,YAAY,GAAG,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,YAAY,mCAAI,eAAe,CAAC;IAErE,IAAM,cAAc,GAAG,IAAA,uBAAiB,EAAC,EAAE,GAAG,KAAA,EAAE,OAAO,SAAA,EAAE,SAAS,WAAA,EAAE,CAAC,CAAC;IAEtE,IAAM,KAAK,GAAG,IAAA,yCAAkB,GAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAEhD,iBAAK,CAAC,KAAK,CAAC,UAAG,eAAK,CAAC,KAAK,CAAC,mCAAmC,CAAC,oBAE5D,eAAK,CAAC,IAAI,CAAC,4GAEkB,eAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,sBACvD,eAAK,CAAC,IAAI,CAAC,UAAG,KAAK,+BAAqB,eAAK,CAAC,IAAI,CAAC,YAAY,CAAC,MAAG,CAAC,qBACpE,eAAK,CAAC,IAAI,CACV,UAAG,KAAK,4DAAyD,CAClE,yEAEC,eAAK,CAAC,IAAI,CAAC,UAAG,KAAK,wCAAqC,CAAC,qBACzD,eAAK,CAAC,IAAI,CAAC,UAAG,KAAK,cAAI,cAAc,CAAE,CAAC,yFAExC,eAAK,CAAC,IAAI,CACV,UAAG,KAAK,4DAAyD,CAClE,UACH,CAAC,kBACA,eAAK,CAAC,GAAG,CACT,6RAIoD,CACrD,OACH,CAAC,CAAC;AACH,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as Sentry from '@sentry/node';\n\nimport {\n abort,\n abortIfCancelled,\n confirmContinueIfNoOrDirtyGitRepo,\n SENTRY_DOT_ENV_FILE,\n printWelcome,\n SENTRY_CLI_RC_FILE,\n getOrAskForProjectData,\n} from '../utils/clack-utils';\nimport { isUnicodeSupported } from '../utils/vendor/is-unicorn-supported';\nimport { SourceMapUploadToolConfigurationOptions } from './tools/types';\nimport { configureVitePlugin } from './tools/vite';\nimport { setupNpmScriptInCI, configureSentryCLI } from './tools/sentry-cli';\nimport { configureWebPackPlugin } from './tools/webpack';\nimport { configureTscSourcemapGenerationFlow } from './tools/tsc';\nimport { configureRollupPlugin } from './tools/rollup';\nimport { configureEsbuildPlugin } from './tools/esbuild';\nimport { WizardOptions } from '../utils/types';\nimport { configureCRASourcemapGenerationFlow } from './tools/create-react-app';\nimport { ensureMinimumSdkVersionIsInstalled } from './utils/sdk-version';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { checkIfMoreSuitableWizardExistsAndAskForRedirect } from './utils/other-wizards';\nimport { configureAngularSourcemapGenerationFlow } from './tools/angular';\nimport { detectUsedTool, SupportedTools } from './utils/detect-tool';\nimport { configureNextJsSourceMapsUpload } from './tools/nextjs';\nimport { configureRemixSourceMapsUpload } from './tools/remix';\nimport { detectPackageManger } from '../utils/package-manager';\nimport { getIssueStreamUrl } from '../utils/url';\n\nexport async function runSourcemapsWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sourcemaps',\n },\n () => runSourcemapsWizardWithTelemetry(options),\n );\n}\n\nasync function runSourcemapsWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Source Maps Upload Configuration Wizard',\n message: `This wizard will help you upload source maps to Sentry as part of your build.\nThank you for using Sentry :)${\n options.telemetryEnabled\n ? `\n\n(This setup wizard sends telemetry data and crash reports to Sentry.\nYou can turn this off by running the wizard with the '--disable-telemetry' flag.)`\n : ''\n }`,\n promoCode: options.promoCode,\n });\n\n const moreSuitableWizard = await traceStep(\n 'check-framework-wizard',\n checkIfMoreSuitableWizardExistsAndAskForRedirect,\n );\n if (moreSuitableWizard) {\n await traceStep('run-framework-wizard', () => moreSuitableWizard(options));\n return;\n }\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n await traceStep('check-sdk-version', ensureMinimumSdkVersionIsInstalled);\n\n const { selfHosted, selectedProject, sentryUrl, authToken } =\n await getOrAskForProjectData(options);\n\n const wizardOptionsWithPreSelectedProject = {\n ...options,\n preSelectedProject: {\n project: selectedProject,\n authToken,\n selfHosted,\n },\n };\n\n const selectedTool = await traceStep('select-tool', askForUsedBundlerTool);\n\n Sentry.setTag('selected-tool', selectedTool);\n\n if (selectedTool === 'no-tool') {\n clack.log.info(\n \"No Problem! But in this case, there's nothing to configure :)\",\n );\n await abort('Exiting, have a great day!', 0);\n return;\n }\n\n await traceStep('tool-setup', () =>\n startToolSetupFlow(\n selectedTool,\n {\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n selfHosted,\n url: sentryUrl,\n authToken,\n },\n wizardOptionsWithPreSelectedProject,\n ),\n );\n\n await traceStep('ci-setup', () => configureCI(selectedTool, authToken));\n\n traceStep('outro', () =>\n printOutro(\n sentryUrl,\n selectedProject.organization.slug,\n selectedProject.id,\n ),\n );\n}\n\nasync function askForUsedBundlerTool(): Promise<SupportedTools> {\n const selectedTool = await abortIfCancelled(\n clack.select({\n message: 'Which framework, bundler or build tool are you using?',\n options: [\n {\n label: 'Angular',\n value: 'angular',\n hint: 'Select this option if you are using Angular.',\n },\n {\n label: 'Create React App',\n value: 'create-react-app',\n hint: 'Select this option if you set up your app with Create React App.',\n },\n {\n label: 'Next.js',\n value: 'nextjs',\n hint: 'Select this option if you want to set up source maps in a NextJS project.',\n },\n {\n label: 'Remix',\n value: 'remix',\n hint: 'Select this option if you want to set up source maps in a Remix project.',\n },\n {\n label: 'Webpack',\n value: 'webpack',\n hint: 'Select this if you are using Webpack and you have access to your Webpack config.',\n },\n {\n label: 'Vite',\n value: 'vite',\n hint: 'Select this if you are using Vite and you have access to your Vite config.',\n },\n {\n label: 'esbuild',\n value: 'esbuild',\n hint: 'Select this if you are using esbuild and you have access to your esbuild config.',\n },\n {\n label: 'Rollup',\n value: 'rollup',\n hint: 'Select this if you are using Rollup and you have access to your Rollup config.',\n },\n {\n label: 'tsc',\n value: 'tsc',\n hint: 'Configure source maps when using tsc as build tool',\n },\n {\n label: 'I use another tool',\n value: 'sentry-cli',\n hint: 'This will configure source maps upload for you using sentry-cli',\n },\n {\n label: \"I don't minify, transpile or bundle my code\",\n value: 'no-tool',\n hint: 'This will exit the wizard',\n },\n ],\n initialValue: await detectUsedTool(),\n }),\n );\n\n return selectedTool;\n}\n\nasync function startToolSetupFlow(\n selctedTool: SupportedTools,\n options: SourceMapUploadToolConfigurationOptions,\n wizardOptions: WizardOptions,\n): Promise<void> {\n switch (selctedTool) {\n case 'webpack':\n await configureWebPackPlugin(options);\n break;\n case 'vite':\n await configureVitePlugin(options);\n break;\n case 'esbuild':\n await configureEsbuildPlugin(options);\n break;\n case 'rollup':\n await configureRollupPlugin(options);\n break;\n case 'tsc':\n await configureSentryCLI(options, configureTscSourcemapGenerationFlow);\n break;\n case 'create-react-app':\n await configureSentryCLI(options, configureCRASourcemapGenerationFlow);\n break;\n case 'angular':\n await configureSentryCLI(\n options,\n configureAngularSourcemapGenerationFlow,\n );\n break;\n case 'nextjs':\n await configureNextJsSourceMapsUpload(options, wizardOptions);\n break;\n case 'remix':\n await configureRemixSourceMapsUpload(options, wizardOptions);\n break;\n default:\n await configureSentryCLI(options);\n break;\n }\n}\n\nexport async function configureCI(\n selectedTool: SupportedTools,\n authToken: string,\n): Promise<void> {\n const isUsingCI = await abortIfCancelled(\n clack.select({\n message: `Are you using a CI/CD tool to build and deploy your application?`,\n options: [\n {\n label: 'Yes',\n hint: 'I use a tool like GitHub Actions, GitLab, CircleCI, TravisCI, Jenkins, Vercel, ...',\n value: true,\n },\n {\n label: 'No',\n hint: 'I build and deploy my application manually',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('using-ci', isUsingCI);\n\n const isCliBasedFlowTool = [\n 'sentry-cli',\n 'tsc',\n 'angular',\n 'create-react-app',\n ].includes(selectedTool);\n\n // some non-cli-based flows also use the .sentryclirc file\n const usesSentryCliRc = selectedTool === 'nextjs';\n\n const authTokenFile =\n isCliBasedFlowTool || usesSentryCliRc\n ? SENTRY_CLI_RC_FILE\n : SENTRY_DOT_ENV_FILE;\n\n if (!isUsingCI) {\n clack.log.info(\n `No Problem! Just make sure that the Sentry auth token from ${chalk.cyan(\n authTokenFile,\n )} is available whenever you build and deploy your app.`,\n );\n return;\n }\n\n if (isCliBasedFlowTool) {\n await traceStep('ci-npm-script-setup', setupNpmScriptInCI);\n }\n\n await traceStep('ci-auth-token-setup', () => setupAuthTokenInCI(authToken));\n}\n\nasync function setupAuthTokenInCI(authToken: string) {\n clack.log.step(\n 'Add the Sentry authentication token as an environment variable to your CI setup:',\n );\n\n // Intentially logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\nSENTRY_AUTH_TOKEN=${authToken}\n`),\n );\n\n clack.log.warn(\n chalk.yellow('DO NOT commit this auth token to your repository!'),\n );\n\n const addedEnvVarToCI = await abortIfCancelled(\n clack.select({\n message: 'Did you configure CI as shown above?',\n options: [\n { label: 'Yes, continue!', value: true },\n {\n label: \"I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n 'You need to set the auth token to upload source maps in CI',\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('added-env-var-to-ci', addedEnvVarToCI);\n\n if (!addedEnvVarToCI) {\n clack.log.info(\"Don't forget! :)\");\n }\n}\n\nfunction printOutro(url: string, orgSlug: string, projectId: string) {\n const packageManager = detectPackageManger();\n const buildCommand = packageManager?.buildCommand ?? 'npm run build';\n\n const issueStreamUrl = getIssueStreamUrl({ url, orgSlug, projectId });\n\n const arrow = isUnicodeSupported() ? '→' : '->';\n\n clack.outro(`${chalk.green(\"That's it - everything is set up!\")}\n\n ${chalk.cyan(`Test and validate your setup locally with the following Steps:\n\n 1. Build your application in ${chalk.bold('production mode')}.\n ${chalk.gray(`${arrow} For example, run ${chalk.bold(buildCommand)}.`)}\n ${chalk.gray(\n `${arrow} You should see source map upload logs in your console.`,\n )}\n 2. Run your application and throw a test error.\n ${chalk.gray(`${arrow} The error should appear in Sentry:`)}\n ${chalk.gray(`${arrow} ${issueStreamUrl}`)}\n 3. Open the error in Sentry and verify that it's source-mapped.\n ${chalk.gray(\n `${arrow} The stack trace should show your original source code.`,\n )}\n `)}\n ${chalk.dim(\n `If you encounter any issues, please refer to the Troubleshooting Guide:\n https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting_js\n\n If the guide doesn't help or you encounter a bug, please let us know:\n https://github.com/getsentry/sentry-javascript/issues`,\n )}\n`);\n}\n"]}
1
+ {"version":3,"file":"sourcemaps-wizard.js","sourceRoot":"","sources":["../../../src/sourcemaps/sourcemaps-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAC1B,mDAAuC;AAEvC,oDAQ8B;AAC9B,6EAA0E;AAE1E,qCAAmD;AACnD,iDAA4E;AAC5E,2CAAyD;AACzD,mCAAkE;AAClE,yCAAuD;AACvD,2CAAyD;AAEzD,6DAA+E;AAC/E,mDAAyE;AACzE,0CAAwD;AACxD,uDAAyF;AACzF,2CAA0E;AAC1E,mDAAqE;AACrE,yCAAiE;AACjE,uCAA+D;AAC/D,4DAA+D;AAC/D,oCAAiD;AAEjD,SAAsB,mBAAmB,CACvC,OAAsB;;;YAEtB,sBAAO,IAAA,yBAAa,EAClB;oBACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;oBACjC,WAAW,EAAE,YAAY;iBAC1B,EACD,cAAM,OAAA,gCAAgC,CAAC,OAAO,CAAC,EAAzC,CAAyC,CAChD,EAAC;;;CACH;AAVD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AK,CAAC,IAAI,CAAC,YAAY,CAAC,MAAG,CAAC,qBACpE,eAAK,CAAC,IAAI,CACV,UAAG,KAAK,4DAAyD,CAClE,yEAEC,eAAK,CAAC,IAAI,CAAC,UAAG,KAAK,wCAAqC,CAAC,qBACzD,eAAK,CAAC,IAAI,CAAC,UAAG,KAAK,cAAI,cAAc,CAAE,CAAC,yFAExC,eAAK,CAAC,IAAI,CACV,UAAG,KAAK,4DAAyD,CAClE,UACH,CAAC,kBACA,eAAK,CAAC,GAAG,CACT,6RAIoD,CACrD,OACH,CAAC,CAAC;AACH,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as Sentry from '@sentry/node';\n\nimport {\n abort,\n abortIfCancelled,\n confirmContinueIfNoOrDirtyGitRepo,\n SENTRY_DOT_ENV_FILE,\n printWelcome,\n SENTRY_CLI_RC_FILE,\n getOrAskForProjectData,\n} from '../utils/clack-utils';\nimport { isUnicodeSupported } from '../utils/vendor/is-unicorn-supported';\nimport { SourceMapUploadToolConfigurationOptions } from './tools/types';\nimport { configureVitePlugin } from './tools/vite';\nimport { setupNpmScriptInCI, configureSentryCLI } from './tools/sentry-cli';\nimport { configureWebPackPlugin } from './tools/webpack';\nimport { configureTscSourcemapGenerationFlow } from './tools/tsc';\nimport { configureRollupPlugin } from './tools/rollup';\nimport { configureEsbuildPlugin } from './tools/esbuild';\nimport { WizardOptions } from '../utils/types';\nimport { configureCRASourcemapGenerationFlow } from './tools/create-react-app';\nimport { ensureMinimumSdkVersionIsInstalled } from './utils/sdk-version';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { checkIfMoreSuitableWizardExistsAndAskForRedirect } from './utils/other-wizards';\nimport { configureAngularSourcemapGenerationFlow } from './tools/angular';\nimport { detectUsedTool, SupportedTools } from './utils/detect-tool';\nimport { configureNextJsSourceMapsUpload } from './tools/nextjs';\nimport { configureRemixSourceMapsUpload } from './tools/remix';\nimport { detectPackageManger } from '../utils/package-manager';\nimport { getIssueStreamUrl } from '../utils/url';\n\nexport async function runSourcemapsWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sourcemaps',\n },\n () => runSourcemapsWizardWithTelemetry(options),\n );\n}\n\nasync function runSourcemapsWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Source Maps Upload Configuration Wizard',\n message: `This wizard will help you upload source maps to Sentry as part of your build.\nThank you for using Sentry :)${\n options.telemetryEnabled\n ? `\n\n(This setup wizard sends telemetry data and crash reports to Sentry.\nYou can turn this off by running the wizard with the '--disable-telemetry' flag.)`\n : ''\n }`,\n promoCode: options.promoCode,\n });\n\n const moreSuitableWizard = await traceStep(\n 'check-framework-wizard',\n checkIfMoreSuitableWizardExistsAndAskForRedirect,\n );\n if (moreSuitableWizard) {\n await traceStep('run-framework-wizard', () => moreSuitableWizard(options));\n return;\n }\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n await traceStep('check-sdk-version', ensureMinimumSdkVersionIsInstalled);\n\n const { selfHosted, selectedProject, sentryUrl, authToken } =\n await getOrAskForProjectData(options);\n\n const wizardOptionsWithPreSelectedProject = {\n ...options,\n preSelectedProject: {\n project: selectedProject,\n authToken,\n selfHosted,\n },\n };\n\n const selectedTool = await traceStep('select-tool', askForUsedBundlerTool);\n\n Sentry.setTag('selected-tool', selectedTool);\n\n if (selectedTool === 'no-tool') {\n clack.log.info(\n \"No Problem! But in this case, there's nothing to configure :)\",\n );\n await abort('Exiting, have a great day!', 0);\n return;\n }\n\n await traceStep('tool-setup', () =>\n startToolSetupFlow(\n selectedTool,\n {\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n selfHosted,\n url: sentryUrl,\n authToken,\n },\n wizardOptionsWithPreSelectedProject,\n ),\n );\n\n await traceStep('ci-setup', () => configureCI(selectedTool, authToken));\n\n traceStep('outro', () =>\n printOutro(\n sentryUrl,\n selectedProject.organization.slug,\n selectedProject.id,\n ),\n );\n}\n\nasync function askForUsedBundlerTool(): Promise<SupportedTools> {\n const selectedTool = await abortIfCancelled(\n clack.select({\n message: 'Which framework, bundler or build tool are you using?',\n options: [\n {\n label: 'Angular',\n value: 'angular',\n hint: 'Select this option if you are using Angular.',\n },\n {\n label: 'Create React App',\n value: 'create-react-app',\n hint: 'Select this option if you set up your app with Create React App.',\n },\n {\n label: 'Next.js',\n value: 'nextjs',\n hint: 'Select this option if you want to set up source maps in a Next.js project.',\n },\n {\n label: 'Remix',\n value: 'remix',\n hint: 'Select this option if you want to set up source maps in a Remix project.',\n },\n {\n label: 'Webpack',\n value: 'webpack',\n hint: 'Select this if you are using Webpack and you have access to your Webpack config.',\n },\n {\n label: 'Vite',\n value: 'vite',\n hint: 'Select this if you are using Vite and you have access to your Vite config.',\n },\n {\n label: 'esbuild',\n value: 'esbuild',\n hint: 'Select this if you are using esbuild and you have access to your esbuild config.',\n },\n {\n label: 'Rollup',\n value: 'rollup',\n hint: 'Select this if you are using Rollup and you have access to your Rollup config.',\n },\n {\n label: 'tsc',\n value: 'tsc',\n hint: 'Configure source maps when using tsc as build tool',\n },\n {\n label: 'I use another tool',\n value: 'sentry-cli',\n hint: 'This will configure source maps upload for you using sentry-cli',\n },\n {\n label: \"I don't minify, transpile or bundle my code\",\n value: 'no-tool',\n hint: 'This will exit the wizard',\n },\n ],\n initialValue: await detectUsedTool(),\n }),\n );\n\n return selectedTool;\n}\n\nasync function startToolSetupFlow(\n selctedTool: SupportedTools,\n options: SourceMapUploadToolConfigurationOptions,\n wizardOptions: WizardOptions,\n): Promise<void> {\n switch (selctedTool) {\n case 'webpack':\n await configureWebPackPlugin(options);\n break;\n case 'vite':\n await configureVitePlugin(options);\n break;\n case 'esbuild':\n await configureEsbuildPlugin(options);\n break;\n case 'rollup':\n await configureRollupPlugin(options);\n break;\n case 'tsc':\n await configureSentryCLI(options, configureTscSourcemapGenerationFlow);\n break;\n case 'create-react-app':\n await configureSentryCLI(options, configureCRASourcemapGenerationFlow);\n break;\n case 'angular':\n await configureSentryCLI(\n options,\n configureAngularSourcemapGenerationFlow,\n );\n break;\n case 'nextjs':\n await configureNextJsSourceMapsUpload(options, wizardOptions);\n break;\n case 'remix':\n await configureRemixSourceMapsUpload(options, wizardOptions);\n break;\n default:\n await configureSentryCLI(options);\n break;\n }\n}\n\nexport async function configureCI(\n selectedTool: SupportedTools,\n authToken: string,\n): Promise<void> {\n const isUsingCI = await abortIfCancelled(\n clack.select({\n message: `Are you using a CI/CD tool to build and deploy your application?`,\n options: [\n {\n label: 'Yes',\n hint: 'I use a tool like GitHub Actions, GitLab, CircleCI, TravisCI, Jenkins, Vercel, ...',\n value: true,\n },\n {\n label: 'No',\n hint: 'I build and deploy my application manually',\n value: false,\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('using-ci', isUsingCI);\n\n const isCliBasedFlowTool = [\n 'sentry-cli',\n 'tsc',\n 'angular',\n 'create-react-app',\n ].includes(selectedTool);\n\n // some non-cli-based flows also use the .sentryclirc file\n const usesSentryCliRc = selectedTool === 'nextjs';\n\n const authTokenFile =\n isCliBasedFlowTool || usesSentryCliRc\n ? SENTRY_CLI_RC_FILE\n : SENTRY_DOT_ENV_FILE;\n\n if (!isUsingCI) {\n clack.log.info(\n `No Problem! Just make sure that the Sentry auth token from ${chalk.cyan(\n authTokenFile,\n )} is available whenever you build and deploy your app.`,\n );\n return;\n }\n\n if (isCliBasedFlowTool) {\n await traceStep('ci-npm-script-setup', setupNpmScriptInCI);\n }\n\n await traceStep('ci-auth-token-setup', () => setupAuthTokenInCI(authToken));\n}\n\nasync function setupAuthTokenInCI(authToken: string) {\n clack.log.step(\n 'Add the Sentry authentication token as an environment variable to your CI setup:',\n );\n\n // Intentially logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\nSENTRY_AUTH_TOKEN=${authToken}\n`),\n );\n\n clack.log.warn(\n chalk.yellow('DO NOT commit this auth token to your repository!'),\n );\n\n const addedEnvVarToCI = await abortIfCancelled(\n clack.select({\n message: 'Did you configure CI as shown above?',\n options: [\n { label: 'Yes, continue!', value: true },\n {\n label: \"I'll do it later...\",\n value: false,\n hint: chalk.yellow(\n 'You need to set the auth token to upload source maps in CI',\n ),\n },\n ],\n initialValue: true,\n }),\n );\n\n Sentry.setTag('added-env-var-to-ci', addedEnvVarToCI);\n\n if (!addedEnvVarToCI) {\n clack.log.info(\"Don't forget! :)\");\n }\n}\n\nfunction printOutro(url: string, orgSlug: string, projectId: string) {\n const packageManager = detectPackageManger();\n const buildCommand = packageManager?.buildCommand ?? 'npm run build';\n\n const issueStreamUrl = getIssueStreamUrl({ url, orgSlug, projectId });\n\n const arrow = isUnicodeSupported() ? '→' : '->';\n\n clack.outro(`${chalk.green(\"That's it - everything is set up!\")}\n\n ${chalk.cyan(`Test and validate your setup locally with the following Steps:\n\n 1. Build your application in ${chalk.bold('production mode')}.\n ${chalk.gray(`${arrow} For example, run ${chalk.bold(buildCommand)}.`)}\n ${chalk.gray(\n `${arrow} You should see source map upload logs in your console.`,\n )}\n 2. Run your application and throw a test error.\n ${chalk.gray(`${arrow} The error should appear in Sentry:`)}\n ${chalk.gray(`${arrow} ${issueStreamUrl}`)}\n 3. Open the error in Sentry and verify that it's source-mapped.\n ${chalk.gray(\n `${arrow} The stack trace should show your original source code.`,\n )}\n `)}\n ${chalk.dim(\n `If you encounter any issues, please refer to the Troubleshooting Guide:\n https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting_js\n\n If the guide doesn't help or you encounter a bug, please let us know:\n https://github.com/getsentry/sentry-javascript/issues`,\n )}\n`);\n}\n"]}
@@ -102,10 +102,23 @@ var telemetry_1 = require("../telemetry");
102
102
  var SVELTE_CONFIG_FILE = 'svelte.config.js';
103
103
  function createOrMergeSvelteKitFiles(projectInfo, svelteConfig) {
104
104
  return __awaiter(this, void 0, void 0, function () {
105
- var _a, clientHooksPath, serverHooksPath, originalClientHooksFile, originalServerHooksFile, viteConfig, fileEnding, dsn;
105
+ var selectedFeatures, _a, clientHooksPath, serverHooksPath, originalClientHooksFile, originalServerHooksFile, viteConfig, fileEnding, dsn;
106
106
  return __generator(this, function (_b) {
107
107
  switch (_b.label) {
108
- case 0:
108
+ case 0: return [4 /*yield*/, (0, clack_utils_1.featureSelectionPrompt)([
109
+ {
110
+ id: 'performance',
111
+ prompt: "Do you want to enable ".concat(chalk_1.default.bold('Tracing'), " to track the performance of your application?"),
112
+ enabledHint: 'recommended',
113
+ },
114
+ {
115
+ id: 'replay',
116
+ prompt: "Do you want to enable ".concat(chalk_1.default.bold('Sentry Session Replay'), " to get a video-like reproduction of errors during a user session?"),
117
+ enabledHint: 'recommended, but increases bundle size',
118
+ },
119
+ ])];
120
+ case 1:
121
+ selectedFeatures = _b.sent();
109
122
  _a = getHooksConfigDirs(svelteConfig), clientHooksPath = _a.clientHooksPath, serverHooksPath = _a.serverHooksPath;
110
123
  originalClientHooksFile = (0, ast_utils_1.findFile)(clientHooksPath);
111
124
  originalServerHooksFile = (0, ast_utils_1.findFile)(serverHooksPath);
@@ -113,35 +126,35 @@ function createOrMergeSvelteKitFiles(projectInfo, svelteConfig) {
113
126
  fileEnding = (0, clack_utils_1.isUsingTypeScript)() ? 'ts' : 'js';
114
127
  dsn = projectInfo.dsn;
115
128
  Sentry.setTag('client-hooks-file-strategy', originalClientHooksFile ? 'merge' : 'create');
116
- if (!!originalClientHooksFile) return [3 /*break*/, 2];
129
+ if (!!originalClientHooksFile) return [3 /*break*/, 3];
117
130
  prompts_1.default.log.info('No client hooks file found, creating a new one.');
118
- return [4 /*yield*/, createNewHooksFile("".concat(clientHooksPath, ".").concat(fileEnding), 'client', dsn)];
119
- case 1:
120
- _b.sent();
121
- return [3 /*break*/, 4];
122
- case 2: return [4 /*yield*/, mergeHooksFile(originalClientHooksFile, 'client', dsn)];
123
- case 3:
131
+ return [4 /*yield*/, createNewHooksFile("".concat(clientHooksPath, ".").concat(fileEnding), 'client', dsn, selectedFeatures)];
132
+ case 2:
124
133
  _b.sent();
125
- _b.label = 4;
134
+ return [3 /*break*/, 5];
135
+ case 3: return [4 /*yield*/, mergeHooksFile(originalClientHooksFile, 'client', dsn, selectedFeatures)];
126
136
  case 4:
137
+ _b.sent();
138
+ _b.label = 5;
139
+ case 5:
127
140
  Sentry.setTag('server-hooks-file-strategy', originalServerHooksFile ? 'merge' : 'create');
128
- if (!!originalServerHooksFile) return [3 /*break*/, 6];
141
+ if (!!originalServerHooksFile) return [3 /*break*/, 7];
129
142
  prompts_1.default.log.info('No server hooks file found, creating a new one.');
130
- return [4 /*yield*/, createNewHooksFile("".concat(serverHooksPath, ".").concat(fileEnding), 'server', dsn)];
131
- case 5:
132
- _b.sent();
133
- return [3 /*break*/, 8];
134
- case 6: return [4 /*yield*/, mergeHooksFile(originalServerHooksFile, 'server', dsn)];
135
- case 7:
143
+ return [4 /*yield*/, createNewHooksFile("".concat(serverHooksPath, ".").concat(fileEnding), 'server', dsn, selectedFeatures)];
144
+ case 6:
136
145
  _b.sent();
137
- _b.label = 8;
146
+ return [3 /*break*/, 9];
147
+ case 7: return [4 /*yield*/, mergeHooksFile(originalServerHooksFile, 'server', dsn, selectedFeatures)];
138
148
  case 8:
139
- if (!viteConfig) return [3 /*break*/, 10];
140
- return [4 /*yield*/, modifyViteConfig(viteConfig, projectInfo)];
149
+ _b.sent();
150
+ _b.label = 9;
141
151
  case 9:
152
+ if (!viteConfig) return [3 /*break*/, 11];
153
+ return [4 /*yield*/, modifyViteConfig(viteConfig, projectInfo)];
154
+ case 10:
142
155
  _b.sent();
143
- _b.label = 10;
144
- case 10: return [2 /*return*/];
156
+ _b.label = 11;
157
+ case 11: return [2 /*return*/];
145
158
  }
146
159
  });
147
160
  });
@@ -170,15 +183,15 @@ function getHooksConfigDirs(svelteConfig) {
170
183
  /**
171
184
  * Reads the template, replaces the dsn placeholder with the actual dsn and writes the file to @param hooksFileDest
172
185
  */
173
- function createNewHooksFile(hooksFileDest, hooktype, dsn) {
186
+ function createNewHooksFile(hooksFileDest, hooktype, dsn, selectedFeatures) {
174
187
  return __awaiter(this, void 0, void 0, function () {
175
188
  var filledTemplate;
176
189
  return __generator(this, function (_a) {
177
190
  switch (_a.label) {
178
191
  case 0:
179
192
  filledTemplate = hooktype === 'client'
180
- ? (0, templates_1.getClientHooksTemplate)(dsn)
181
- : (0, templates_1.getServerHooksTemplate)(dsn);
193
+ ? (0, templates_1.getClientHooksTemplate)(dsn, selectedFeatures)
194
+ : (0, templates_1.getServerHooksTemplate)(dsn, selectedFeatures);
182
195
  return [4 /*yield*/, fs.promises.mkdir(path.dirname(hooksFileDest), { recursive: true })];
183
196
  case 1:
184
197
  _a.sent();
@@ -203,7 +216,7 @@ function createNewHooksFile(hooksFileDest, hooktype, dsn) {
203
216
  * Additionally in Server hook:
204
217
  * - add handle hook handler
205
218
  */
206
- function mergeHooksFile(hooksFile, hookType, dsn) {
219
+ function mergeHooksFile(hooksFile, hookType, dsn, selectedFeatures) {
207
220
  return __awaiter(this, void 0, void 0, function () {
208
221
  var originalHooksMod, file;
209
222
  var _this = this;
@@ -232,10 +245,10 @@ function mergeHooksFile(hooksFile, hookType, dsn) {
232
245
  _a.sent();
233
246
  return [4 /*yield*/, modifyAndRecordFail(function () {
234
247
  if (hookType === 'client') {
235
- insertClientInitCall(dsn, originalHooksMod);
248
+ insertClientInitCall(dsn, originalHooksMod, selectedFeatures);
236
249
  }
237
250
  else {
238
- insertServerInitCall(dsn, originalHooksMod);
251
+ insertServerInitCall(dsn, originalHooksMod, selectedFeatures);
239
252
  }
240
253
  }, 'init-call-injection', file)];
241
254
  case 3:
@@ -272,17 +285,22 @@ function mergeHooksFile(hooksFile, hookType, dsn) {
272
285
  }
273
286
  function insertClientInitCall(dsn,
274
287
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
275
- originalHooksMod) {
276
- var initCallComment = "\n // If you don't want to use Session Replay, remove the `Replay` integration, \n // `replaysSessionSampleRate` and `replaysOnErrorSampleRate` options.";
288
+ originalHooksMod, selectedFeatures) {
289
+ var initCallComment = "\n // If you don't want to use Session Replay, remove the `Replay` integration,\n // `replaysSessionSampleRate` and `replaysOnErrorSampleRate` options.";
290
+ var initArgs = {
291
+ dsn: dsn,
292
+ };
293
+ if (selectedFeatures.performance) {
294
+ initArgs.tracesSampleRate = 1.0;
295
+ }
296
+ if (selectedFeatures.replay) {
297
+ initArgs.replaysSessionSampleRate = 0.1;
298
+ initArgs.replaysOnErrorSampleRate = 1.0;
299
+ initArgs.integrations = [magicast_1.builders.functionCall('Sentry.replayIntegration')];
300
+ }
277
301
  // This assignment of any values is fine because we're just creating a function call in magicast
278
302
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
279
- var initCall = magicast_1.builders.functionCall('Sentry.init', {
280
- dsn: dsn,
281
- tracesSampleRate: 1.0,
282
- replaysSessionSampleRate: 0.1,
283
- replaysOnErrorSampleRate: 1.0,
284
- integrations: [magicast_1.builders.functionCall('Sentry.replayIntegration')],
285
- });
303
+ var initCall = magicast_1.builders.functionCall('Sentry.init', initArgs);
286
304
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
287
305
  var initCallWithComment = magicast_1.builders.raw(
288
306
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@@ -296,13 +314,16 @@ originalHooksMod) {
296
314
  }
297
315
  function insertServerInitCall(dsn,
298
316
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
299
- originalHooksMod) {
317
+ originalHooksMod, selectedFeatures) {
318
+ var initArgs = {
319
+ dsn: dsn,
320
+ };
321
+ if (selectedFeatures.performance) {
322
+ initArgs.tracesSampleRate = 1.0;
323
+ }
300
324
  // This assignment of any values is fine because we're just creating a function call in magicast
301
325
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
302
- var initCall = magicast_1.builders.functionCall('Sentry.init', {
303
- dsn: dsn,
304
- tracesSampleRate: 1.0,
305
- });
326
+ var initCall = magicast_1.builders.functionCall('Sentry.init', initArgs);
306
327
  var originalHooksModAST = originalHooksMod.$ast;
307
328
  var initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);
308
329
  originalHooksModAST.body.splice(initCallInsertionIndex, 0,
@@ -531,7 +552,7 @@ function showFallbackViteCopyPasteSnippet(viteConfigPath, codeSnippet) {
531
552
  });
532
553
  }
533
554
  var getViteConfigCodeSnippet = function (org, project, selfHosted, url) {
534
- return chalk_1.default.gray("\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { defineConfig } from 'vite';\n".concat(chalk_1.default.greenBright("import { sentrySvelteKit } from '@sentry/sveltekit'"), "\n\nexport default defineConfig({\n plugins: [\n // Make sure `sentrySvelteKit` is registered before `sveltekit`\n ").concat(chalk_1.default.greenBright("sentrySvelteKit({\n sourceMapsUploadOptions: {\n org: '".concat(org, "',\n project: '").concat(project, "',").concat(selfHosted ? "\n url: '".concat(url, "',") : '', "\n } \n }),")), "\n sveltekit(),\n ]\n});\n"));
555
+ return chalk_1.default.gray("\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { defineConfig } from 'vite';\n".concat(chalk_1.default.greenBright("import { sentrySvelteKit } from '@sentry/sveltekit'"), "\n\nexport default defineConfig({\n plugins: [\n // Make sure `sentrySvelteKit` is registered before `sveltekit`\n ").concat(chalk_1.default.greenBright("sentrySvelteKit({\n sourceMapsUploadOptions: {\n org: '".concat(org, "',\n project: '").concat(project, "',").concat(selfHosted ? "\n url: '".concat(url, "',") : '', "\n }\n }),")), "\n sveltekit(),\n ]\n});\n"));
535
556
  };
536
557
  /**
537
558
  * We want to insert the init call on top of the file but after all import statements