@sentry/wizard 3.20.5 → 3.21.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.21.0
4
+
5
+ - feat(nextjs): Add comment to add spotlight in Sentry.init for Next.js server config (#545)
6
+ - feat(nextjs): Pin installed Next.js SDK version to version 7 (#550)
7
+ - feat(remix): Add example page (#542)
8
+ - feat(sveltekit): Add comment for spotlight in Sentry.init for SvelteKit server hooks config (#546)
9
+ - ref(nextjs): Add note about `tunnelRoute` and Next.js middleware incompatibility (#544)
10
+ - ref(remix): Remove Vite dev-mode modification step (#543)
11
+
3
12
  ## 3.20.5
4
13
 
5
14
  - fix: Update `@clack/core` to fix selection error on Windows (#539)
@@ -20,8 +29,10 @@
20
29
 
21
30
  ## 3.20.1
22
31
 
23
- - fix(nextjs): Replace deprecated Sentry API calls in example page templates (#520)
24
- - fix(sveltekit): Replace deprecated Sentry API calls in example page templates (#520)
32
+ - fix(nextjs): Replace deprecated Sentry API calls in example page templates
33
+ (#520)
34
+ - fix(sveltekit): Replace deprecated Sentry API calls in example page templates
35
+ (#520)
25
36
 
26
37
  ## 3.20.0
27
38
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/wizard",
3
- "version": "3.20.5",
3
+ "version": "3.21.0",
4
4
  "homepage": "https://github.com/getsentry/sentry-wizard",
5
5
  "repository": "https://github.com/getsentry/sentry-wizard",
6
6
  "description": "Sentry wizard helping you to configure your project",
@@ -124,7 +124,7 @@ function runNextjsWizardWithTelemetry(options) {
124
124
  sdkAlreadyInstalled = (0, package_json_1.hasPackageInstalled)('@sentry/nextjs', packageJson);
125
125
  Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);
126
126
  return [4 /*yield*/, (0, clack_utils_1.installPackage)({
127
- packageName: '@sentry/nextjs',
127
+ packageName: '@sentry/nextjs@^7.105.0',
128
128
  alreadyInstalled: !!((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.dependencies) === null || _a === void 0 ? void 0 : _a['@sentry/nextjs']),
129
129
  })];
130
130
  case 5:
@@ -1 +1 @@
1
- {"version":3,"file":"nextjs-wizard.js","sourceRoot":"","sources":["../../../src/nextjs/nextjs-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAC1B,qCAAyB;AACzB,4EAA4E;AAC5E,qCAA+D;AAC/D,yCAA6B;AAE7B,mDAAuC;AAEvC,oDAY8B;AAE9B,yCAeqB;AACrB,0CAAwD;AACxD,sDAA+E;AAC/E,iCAAiD;AACjD,qEAA8D;AAE9D,SAAgB,eAAe,CAAC,OAAsB;IACpD,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,QAAQ;KACtB,EACD,cAAM,OAAA,4BAA4B,CAAC,OAAO,CAAC,EAArC,CAAqC,CAC5C,CAAC;AACJ,CAAC;AARD,0CAQC;AAED,SAAsB,4BAA4B,CAChD,OAAsB;;;;;;;;oBAEtB,IAAA,0BAAY,EAAC;wBACX,UAAU,EAAE,uBAAuB;wBACnC,SAAS,EAAE,OAAO,CAAC,SAAS;wBAC5B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;qBAC3C,CAAC,CAAC;oBAEH,qBAAM,IAAA,+CAAiC,GAAE,EAAA;;oBAAzC,SAAyC,CAAC;oBAEtB,qBAAM,IAAA,+BAAiB,GAAE,EAAA;;oBAAvC,WAAW,GAAG,SAAyB;oBAE7C,qBAAM,IAAA,sCAAwB,EAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,EAAA;;oBAA9D,SAA8D,CAAC;oBAEzD,WAAW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AAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,OAAT,IAAI,+BAAM,OAAO,CAAC,GAAG,EAAE,GAAK,aAAa,WAAE,yBAAyB,YACpE,mBAAmB,EACnB,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAChC,EAAA;;oBAJD,SAIC,CAAC;oBAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,kBAAW,eAAK,CAAC,IAAI,CACnB,IAAI,CAAC,IAAI,OAAT,IAAI,kCAAS,aAAa,WAAE,wBAAwB,WACrD,MAAG,CACL,CAAC;oBAEF,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,OAAT,IAAI,+BAAM,OAAO,CAAC,GAAG,EAAE,GAAK,aAAa,WAAE,KAAK,YAAG;wBAC9D,SAAS,EAAE,IAAI;qBAChB,CAAC,CAAC;oBAEH,qBAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,OAAT,IAAI,+BACF,OAAO,CAAC,GAAG,EAAE,GACV,aAAa,WAChB,KAAK;4BACL,uBAAuB,YAEzB,IAAA,oCAAwB,GAAE,EAC1B,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAChC,EAAA;;oBATD,SASC,CAAC;oBAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,kBAAW,eAAK,CAAC,IAAI,CACnB,IAAI,CAAC,IAAI,OAAT,IAAI,kCAAS,aAAa,WAAE,KAAK,EAAE,uBAAuB,WAC3D,MAAG,CACL,CAAC;;;;;;CAEL","sourcesContent":["/* eslint-disable max-lines */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { builders, generateCode, parseModule } from 'magicast';\nimport * as path from 'path';\n\nimport * as Sentry from '@sentry/node';\n\nimport {\n abort,\n abortIfCancelled,\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n} from '../utils/clack-utils';\nimport { SentryProjectData, WizardOptions } from '../utils/types';\nimport {\n getFullUnderscoreErrorCopyPasteSnippet,\n getGlobalErrorCopyPasteSnippet,\n getNextjsConfigCjsAppendix,\n getNextjsConfigCjsTemplate,\n getNextjsConfigEsmCopyPasteSnippet,\n getNextjsSentryBuildOptionsTemplate,\n getNextjsWebpackPluginOptionsTemplate,\n getSentryConfigContents,\n getSentryDefaultGlobalErrorPage,\n getSentryDefaultUnderscoreErrorPage,\n getSentryExampleApiRoute,\n getSentryExampleAppDirApiRoute,\n getSentryExamplePageContents,\n getSimpleUnderscoreErrorCopyPasteSnippet,\n} from './templates';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { getNextJsVersionBucket } from './utils';\nimport { configureCI } from '../sourcemaps/sourcemaps-wizard';\n\nexport function runNextjsWizard(options: WizardOptions) {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'nextjs',\n },\n () => runNextjsWizardWithTelemetry(options),\n );\n}\n\nexport async function runNextjsWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Next.js Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, 'next', 'Next.js');\n\n const nextVersion = getPackageVersion('next', packageJson);\n Sentry.setTag('nextjs-version', getNextJsVersionBucket(nextVersion));\n\n const { selectedProject, authToken, selfHosted, sentryUrl } =\n await getOrAskForProjectData(options, 'javascript-nextjs');\n\n const sdkAlreadyInstalled = hasPackageInstalled(\n '@sentry/nextjs',\n packageJson,\n );\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/nextjs',\n alreadyInstalled: !!packageJson?.dependencies?.['@sentry/nextjs'],\n });\n\n await traceStep('configure-sdk', async () =>\n createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl),\n );\n\n await traceStep('create-underscoreerror-page', async () => {\n const srcDir = path.join(process.cwd(), 'src');\n const maybePagesDirPath = path.join(process.cwd(), 'pages');\n const maybeSrcPagesDirPath = path.join(srcDir, 'pages');\n\n const pagesLocation =\n fs.existsSync(maybePagesDirPath) &&\n fs.lstatSync(maybePagesDirPath).isDirectory()\n ? ['pages']\n : fs.existsSync(maybeSrcPagesDirPath) &&\n fs.lstatSync(maybeSrcPagesDirPath).isDirectory()\n ? ['src', 'pages']\n : undefined;\n\n if (!pagesLocation) {\n return;\n }\n\n const underscoreErrorPageFile = fs.existsSync(\n path.join(process.cwd(), ...pagesLocation, '_error.tsx'),\n )\n ? '_error.tsx'\n : fs.existsSync(path.join(process.cwd(), ...pagesLocation, '_error.ts'))\n ? '_error.ts'\n : fs.existsSync(path.join(process.cwd(), ...pagesLocation, '_error.jsx'))\n ? '_error.jsx'\n : fs.existsSync(path.join(process.cwd(), ...pagesLocation, '_error.js'))\n ? '_error.js'\n : undefined;\n\n if (!underscoreErrorPageFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), ...pagesLocation, '_error.jsx'),\n getSentryDefaultUnderscoreErrorPage(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(path.join(...pagesLocation, '_error.jsx'))}.`,\n );\n } else if (\n fs\n .readFileSync(\n path.join(process.cwd(), ...pagesLocation, underscoreErrorPageFile),\n 'utf8',\n )\n .includes('getInitialProps')\n ) {\n clack.log.info(\n `It seems like you already have a custom error page.\\n\\nPlease put the following function call in the ${chalk.bold(\n 'getInitialProps',\n )}\\nmethod of your custom error page at ${chalk.bold(\n path.join(...pagesLocation, underscoreErrorPageFile),\n )}:`,\n );\n\n // eslint-disable-next-line no-console\n console.log(getSimpleUnderscoreErrorCopyPasteSnippet());\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Did you modify your ${chalk.cyan(\n path.join(...pagesLocation, underscoreErrorPageFile),\n )} file as described above?`,\n active: 'Yes',\n inactive: 'No, get me out of here',\n }),\n );\n\n if (!shouldContinue) {\n await abort();\n }\n } else {\n clack.log.info(\n `It seems like you already have a custom error page.\\n\\nPlease add the following code to your custom error page\\nat ${chalk.cyan(\n path.join(...pagesLocation, underscoreErrorPageFile),\n )}:`,\n );\n\n // eslint-disable-next-line no-console\n console.log(\n getFullUnderscoreErrorCopyPasteSnippet(\n underscoreErrorPageFile === '_error.ts' ||\n underscoreErrorPageFile === '_error.tsx',\n ),\n );\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Did add the code to your ${chalk.cyan(\n path.join(...pagesLocation, underscoreErrorPageFile),\n )} file as described above?`,\n active: 'Yes',\n inactive: 'No, get me out of here',\n }),\n );\n\n if (!shouldContinue) {\n await abort();\n }\n }\n });\n\n await traceStep('create-global-error-page', async () => {\n const maybeAppDirPath = path.join(process.cwd(), 'app');\n const maybeSrcAppDirPath = path.join(process.cwd(), 'src', 'app');\n\n const appDirLocation =\n fs.existsSync(maybeAppDirPath) &&\n fs.lstatSync(maybeAppDirPath).isDirectory()\n ? ['app']\n : fs.existsSync(maybeSrcAppDirPath) &&\n fs.lstatSync(maybeSrcAppDirPath).isDirectory()\n ? ['src', 'app']\n : undefined;\n\n if (!appDirLocation) {\n return;\n }\n\n const globalErrorPageFile = fs.existsSync(\n path.join(process.cwd(), ...appDirLocation, 'global-error.tsx'),\n )\n ? 'global-error.tsx'\n : fs.existsSync(\n path.join(process.cwd(), ...appDirLocation, 'global-error.ts'),\n )\n ? 'global-error.ts'\n : fs.existsSync(\n path.join(process.cwd(), ...appDirLocation, 'global-error.jsx'),\n )\n ? 'global-error.jsx'\n : fs.existsSync(\n path.join(process.cwd(), ...appDirLocation, 'global-error.js'),\n )\n ? 'global-error.js'\n : undefined;\n\n if (!globalErrorPageFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), ...appDirLocation, 'global-error.jsx'),\n getSentryDefaultGlobalErrorPage(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appDirLocation, 'global-error.jsx'),\n )}.`,\n );\n } else {\n clack.log.info(\n `It seems like you already have a custom error page for your app directory.\\n\\nPlease add the following code to your custom error page\\nat ${chalk.cyan(\n path.join(...appDirLocation, globalErrorPageFile),\n )}:`,\n );\n\n // eslint-disable-next-line no-console\n console.log(\n getGlobalErrorCopyPasteSnippet(\n globalErrorPageFile === 'global-error.ts' ||\n globalErrorPageFile === 'global-error.tsx',\n ),\n );\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Did add the code to your ${chalk.cyan(\n path.join(...appDirLocation, globalErrorPageFile),\n )} file as described above?`,\n active: 'Yes',\n inactive: 'No, get me out of here',\n }),\n );\n\n if (!shouldContinue) {\n await abort();\n }\n }\n });\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage();\n if (shouldCreateExamplePage) {\n await traceStep('create-example-page', async () =>\n createExamplePage(selfHosted, selectedProject, sentryUrl),\n );\n }\n\n await addSentryCliConfig({ authToken });\n\n const mightBeUsingVercel = fs.existsSync(\n path.join(process.cwd(), 'vercel.json'),\n );\n\n if (mightBeUsingVercel) {\n clack.log.info(\n \"▲ It seems like you're using Vercel. We recommend using the Sentry Vercel integration to set up an auth token for Vercel deployments: https://vercel.com/integrations/sentry\",\n );\n } else {\n await traceStep('configure-ci', () => configureCI('nextjs', authToken));\n }\n\n clack.outro(`\n${chalk.green('Successfully installed the Sentry Next.js SDK!')} ${\n shouldCreateExamplePage\n ? `\\n\\nYou can validate your setup by restarting your dev environment (${chalk.cyan(\n `next dev`,\n )}) and visiting ${chalk.cyan('\"/sentry-example-page\"')}`\n : ''\n }\n\n${chalk.dim(\n 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-javascript/issues',\n)}`);\n}\n\nasync function createOrMergeNextJsFiles(\n selectedProject: SentryProjectData,\n selfHosted: boolean,\n sentryUrl: string,\n) {\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', 'client', 'edge'] as const;\n\n for (const configVariant of configVariants) {\n await traceStep(`create-sentry-${configVariant}-config`, async () => {\n const jsConfig = `sentry.${configVariant}.config.js`;\n const tsConfig = `sentry.${configVariant}.config.ts`;\n\n const jsConfigExists = fs.existsSync(path.join(process.cwd(), jsConfig));\n const tsConfigExists = fs.existsSync(path.join(process.cwd(), tsConfig));\n\n let shouldWriteFile = true;\n\n if (jsConfigExists || tsConfigExists) {\n const existingConfigs = [];\n\n if (jsConfigExists) {\n existingConfigs.push(jsConfig);\n }\n\n if (tsConfigExists) {\n existingConfigs.push(tsConfig);\n }\n\n const overwriteExistingConfigs = await abortIfCancelled(\n clack.confirm({\n message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(\n ', ',\n )}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,\n }),\n );\n Sentry.setTag(\n `overwrite-${configVariant}-config`,\n overwriteExistingConfigs,\n );\n\n shouldWriteFile = overwriteExistingConfigs;\n\n if (overwriteExistingConfigs) {\n if (jsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), jsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(jsConfig)}.`);\n }\n if (tsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), tsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(tsConfig)}.`);\n }\n }\n }\n\n if (shouldWriteFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig),\n getSentryConfigContents(\n selectedProject.keys[0].dsn.public,\n configVariant,\n ),\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created fresh ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )}.`,\n );\n Sentry.setTag(`created-${configVariant}-config`, true);\n }\n });\n }\n\n const sentryWebpackOptionsTemplate = getNextjsWebpackPluginOptionsTemplate(\n selectedProject.organization.slug,\n selectedProject.slug,\n selfHosted,\n sentryUrl,\n );\n const sentryBuildOptionsTemplate = getNextjsSentryBuildOptionsTemplate();\n\n const nextConfigJs = 'next.config.js';\n const nextConfigMjs = 'next.config.mjs';\n\n await traceStep('setup-next-config', async () => {\n const nextConfigJsExists = fs.existsSync(\n path.join(process.cwd(), nextConfigJs),\n );\n const nextConfigMjsExists = fs.existsSync(\n path.join(process.cwd(), nextConfigMjs),\n );\n\n if (!nextConfigJsExists && !nextConfigMjsExists) {\n Sentry.setTag('next-config-strategy', 'create');\n\n await fs.promises.writeFile(\n path.join(process.cwd(), nextConfigJs),\n getNextjsConfigCjsTemplate(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan('next.config.js')} with Sentry configuration.`,\n );\n }\n\n if (nextConfigJsExists) {\n Sentry.setTag('next-config-strategy', 'modify');\n\n const nextConfigJsContent = fs.readFileSync(\n path.join(process.cwd(), nextConfigJs),\n 'utf8',\n );\n\n const probablyIncludesSdk =\n nextConfigJsContent.includes('@sentry/nextjs') &&\n nextConfigJsContent.includes('withSentryConfig');\n\n let shouldInject = true;\n\n if (probablyIncludesSdk) {\n const injectAnyhow = await abortIfCancelled(\n clack.confirm({\n message: `${chalk.cyan(\n nextConfigJs,\n )} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,\n }),\n );\n\n shouldInject = injectAnyhow;\n }\n\n if (shouldInject) {\n await fs.promises.appendFile(\n path.join(process.cwd(), nextConfigJs),\n getNextjsConfigCjsAppendix(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n 'utf8',\n );\n\n clack.log.success(\n `Added Sentry configuration to ${chalk.cyan(\n nextConfigJs,\n )}. ${chalk.dim('(you probably want to clean this up a bit!)')}`,\n );\n }\n\n Sentry.setTag('next-config-mod-result', 'success');\n }\n\n if (nextConfigMjsExists) {\n const nextConfigMjsContent = fs.readFileSync(\n path.join(process.cwd(), nextConfigMjs),\n 'utf8',\n );\n\n const probablyIncludesSdk =\n nextConfigMjsContent.includes('@sentry/nextjs') &&\n nextConfigMjsContent.includes('withSentryConfig');\n\n let shouldInject = true;\n\n if (probablyIncludesSdk) {\n const injectAnyhow = await abortIfCancelled(\n clack.confirm({\n message: `${chalk.cyan(\n nextConfigMjs,\n )} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,\n }),\n );\n\n shouldInject = injectAnyhow;\n }\n\n try {\n if (shouldInject) {\n const mod = parseModule(nextConfigMjsContent);\n mod.imports.$add({\n from: '@sentry/nextjs',\n imported: 'withSentryConfig',\n local: 'withSentryConfig',\n });\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access\n const expressionToWrap = generateCode(mod.exports.default.$ast).code;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.default = builders.raw(`withSentryConfig(\n ${expressionToWrap},\n ${sentryWebpackOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n)`);\n const newCode = mod.generate().code;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), nextConfigMjs),\n newCode,\n {\n encoding: 'utf8',\n flag: 'w',\n },\n );\n clack.log.success(\n `Added Sentry configuration to ${chalk.cyan(\n nextConfigMjs,\n )}. ${chalk.dim('(you probably want to clean this up a bit!)')}`,\n );\n\n Sentry.setTag('next-config-mod-result', 'success');\n }\n } catch {\n Sentry.setTag('next-config-mod-result', 'fail');\n clack.log.warn(\n chalk.yellow(\n `Something went wrong writing to ${chalk.cyan(nextConfigMjs)}`,\n ),\n );\n clack.log.info(\n `Please put the following code snippet into ${chalk.cyan(\n nextConfigMjs,\n )}: ${chalk.dim('You probably have to clean it up a bit.')}\\n`,\n );\n\n // eslint-disable-next-line no-console\n console.log(\n getNextjsConfigEsmCopyPasteSnippet(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n );\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Are you done putting the snippet above into ${chalk.cyan(\n nextConfigMjs,\n )}?`,\n active: 'Yes',\n inactive: 'No, get me out of here',\n }),\n );\n\n if (!shouldContinue) {\n await abort();\n }\n }\n }\n });\n}\n\nasync function createExamplePage(\n selfHosted: boolean,\n selectedProject: SentryProjectData,\n sentryUrl: string,\n): Promise<void> {\n const srcDir = path.join(process.cwd(), 'src');\n const maybePagesDirPath = path.join(process.cwd(), 'pages');\n const maybeSrcPagesDirPath = path.join(srcDir, 'pages');\n const maybeAppDirPath = path.join(process.cwd(), 'app');\n const maybeSrcAppDirPath = path.join(srcDir, 'app');\n\n let pagesLocation =\n fs.existsSync(maybePagesDirPath) &&\n fs.lstatSync(maybePagesDirPath).isDirectory()\n ? ['pages']\n : fs.existsSync(maybeSrcPagesDirPath) &&\n fs.lstatSync(maybeSrcPagesDirPath).isDirectory()\n ? ['src', 'pages']\n : undefined;\n\n const appLocation =\n fs.existsSync(maybeAppDirPath) &&\n fs.lstatSync(maybeAppDirPath).isDirectory()\n ? ['app']\n : fs.existsSync(maybeSrcAppDirPath) &&\n fs.lstatSync(maybeSrcAppDirPath).isDirectory()\n ? ['src', 'app']\n : undefined;\n\n if (!pagesLocation && !appLocation) {\n pagesLocation =\n fs.existsSync(srcDir) && fs.lstatSync(srcDir).isDirectory()\n ? ['src', 'pages']\n : ['pages'];\n fs.mkdirSync(path.join(process.cwd(), ...pagesLocation), {\n recursive: true,\n });\n }\n\n Sentry.setTag('nextjs-app-dir', !!appLocation);\n\n if (appLocation) {\n const examplePageContents = getSentryExamplePageContents({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n useClient: true,\n });\n\n fs.mkdirSync(\n path.join(process.cwd(), ...appLocation, 'sentry-example-page'),\n {\n recursive: true,\n },\n );\n\n await fs.promises.writeFile(\n path.join(\n process.cwd(),\n ...appLocation,\n 'sentry-example-page',\n 'page.jsx',\n ),\n examplePageContents,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appLocation, 'sentry-example-page', 'page.jsx'),\n )}.`,\n );\n\n fs.mkdirSync(\n path.join(process.cwd(), ...appLocation, 'api', 'sentry-example-api'),\n {\n recursive: true,\n },\n );\n\n await fs.promises.writeFile(\n path.join(\n process.cwd(),\n ...appLocation,\n 'api',\n 'sentry-example-api',\n 'route.js',\n ),\n getSentryExampleAppDirApiRoute(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appLocation, 'api', 'sentry-example-api', 'route.js'),\n )}.`,\n );\n } else if (pagesLocation) {\n const examplePageContents = getSentryExamplePageContents({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n useClient: false,\n });\n\n await fs.promises.writeFile(\n path.join(process.cwd(), ...pagesLocation, 'sentry-example-page.jsx'),\n examplePageContents,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...pagesLocation, 'sentry-example-page.js'),\n )}.`,\n );\n\n fs.mkdirSync(path.join(process.cwd(), ...pagesLocation, 'api'), {\n recursive: true,\n });\n\n await fs.promises.writeFile(\n path.join(\n process.cwd(),\n ...pagesLocation,\n 'api',\n 'sentry-example-api.js',\n ),\n getSentryExampleApiRoute(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...pagesLocation, 'api', 'sentry-example-api.js'),\n )}.`,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"nextjs-wizard.js","sourceRoot":"","sources":["../../../src/nextjs/nextjs-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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,kBAAW,eAAK,CAAC,IAAI,CACnB,IAAI,CAAC,IAAI,OAAT,IAAI,kCAAS,aAAa,WAAE,wBAAwB,WACrD,MAAG,CACL,CAAC;oBAEF,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,OAAT,IAAI,+BAAM,OAAO,CAAC,GAAG,EAAE,GAAK,aAAa,WAAE,KAAK,YAAG;wBAC9D,SAAS,EAAE,IAAI;qBAChB,CAAC,CAAC;oBAEH,qBAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,OAAT,IAAI,+BACF,OAAO,CAAC,GAAG,EAAE,GACV,aAAa,WAChB,KAAK;4BACL,uBAAuB,YAEzB,IAAA,oCAAwB,GAAE,EAC1B,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAChC,EAAA;;oBATD,SASC,CAAC;oBAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,kBAAW,eAAK,CAAC,IAAI,CACnB,IAAI,CAAC,IAAI,OAAT,IAAI,kCAAS,aAAa,WAAE,KAAK,EAAE,uBAAuB,WAC3D,MAAG,CACL,CAAC;;;;;;CAEL","sourcesContent":["/* eslint-disable max-lines */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { builders, generateCode, parseModule } from 'magicast';\nimport * as path from 'path';\n\nimport * as Sentry from '@sentry/node';\n\nimport {\n abort,\n abortIfCancelled,\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n} from '../utils/clack-utils';\nimport { SentryProjectData, WizardOptions } from '../utils/types';\nimport {\n getFullUnderscoreErrorCopyPasteSnippet,\n getGlobalErrorCopyPasteSnippet,\n getNextjsConfigCjsAppendix,\n getNextjsConfigCjsTemplate,\n getNextjsConfigEsmCopyPasteSnippet,\n getNextjsSentryBuildOptionsTemplate,\n getNextjsWebpackPluginOptionsTemplate,\n getSentryConfigContents,\n getSentryDefaultGlobalErrorPage,\n getSentryDefaultUnderscoreErrorPage,\n getSentryExampleApiRoute,\n getSentryExampleAppDirApiRoute,\n getSentryExamplePageContents,\n getSimpleUnderscoreErrorCopyPasteSnippet,\n} from './templates';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { getNextJsVersionBucket } from './utils';\nimport { configureCI } from '../sourcemaps/sourcemaps-wizard';\n\nexport function runNextjsWizard(options: WizardOptions) {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'nextjs',\n },\n () => runNextjsWizardWithTelemetry(options),\n );\n}\n\nexport async function runNextjsWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Next.js Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, 'next', 'Next.js');\n\n const nextVersion = getPackageVersion('next', packageJson);\n Sentry.setTag('nextjs-version', getNextJsVersionBucket(nextVersion));\n\n const { selectedProject, authToken, selfHosted, sentryUrl } =\n await getOrAskForProjectData(options, 'javascript-nextjs');\n\n const sdkAlreadyInstalled = hasPackageInstalled(\n '@sentry/nextjs',\n packageJson,\n );\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/nextjs@^7.105.0',\n alreadyInstalled: !!packageJson?.dependencies?.['@sentry/nextjs'],\n });\n\n await traceStep('configure-sdk', async () =>\n createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl),\n );\n\n await traceStep('create-underscoreerror-page', async () => {\n const srcDir = path.join(process.cwd(), 'src');\n const maybePagesDirPath = path.join(process.cwd(), 'pages');\n const maybeSrcPagesDirPath = path.join(srcDir, 'pages');\n\n const pagesLocation =\n fs.existsSync(maybePagesDirPath) &&\n fs.lstatSync(maybePagesDirPath).isDirectory()\n ? ['pages']\n : fs.existsSync(maybeSrcPagesDirPath) &&\n fs.lstatSync(maybeSrcPagesDirPath).isDirectory()\n ? ['src', 'pages']\n : undefined;\n\n if (!pagesLocation) {\n return;\n }\n\n const underscoreErrorPageFile = fs.existsSync(\n path.join(process.cwd(), ...pagesLocation, '_error.tsx'),\n )\n ? '_error.tsx'\n : fs.existsSync(path.join(process.cwd(), ...pagesLocation, '_error.ts'))\n ? '_error.ts'\n : fs.existsSync(path.join(process.cwd(), ...pagesLocation, '_error.jsx'))\n ? '_error.jsx'\n : fs.existsSync(path.join(process.cwd(), ...pagesLocation, '_error.js'))\n ? '_error.js'\n : undefined;\n\n if (!underscoreErrorPageFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), ...pagesLocation, '_error.jsx'),\n getSentryDefaultUnderscoreErrorPage(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(path.join(...pagesLocation, '_error.jsx'))}.`,\n );\n } else if (\n fs\n .readFileSync(\n path.join(process.cwd(), ...pagesLocation, underscoreErrorPageFile),\n 'utf8',\n )\n .includes('getInitialProps')\n ) {\n clack.log.info(\n `It seems like you already have a custom error page.\\n\\nPlease put the following function call in the ${chalk.bold(\n 'getInitialProps',\n )}\\nmethod of your custom error page at ${chalk.bold(\n path.join(...pagesLocation, underscoreErrorPageFile),\n )}:`,\n );\n\n // eslint-disable-next-line no-console\n console.log(getSimpleUnderscoreErrorCopyPasteSnippet());\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Did you modify your ${chalk.cyan(\n path.join(...pagesLocation, underscoreErrorPageFile),\n )} file as described above?`,\n active: 'Yes',\n inactive: 'No, get me out of here',\n }),\n );\n\n if (!shouldContinue) {\n await abort();\n }\n } else {\n clack.log.info(\n `It seems like you already have a custom error page.\\n\\nPlease add the following code to your custom error page\\nat ${chalk.cyan(\n path.join(...pagesLocation, underscoreErrorPageFile),\n )}:`,\n );\n\n // eslint-disable-next-line no-console\n console.log(\n getFullUnderscoreErrorCopyPasteSnippet(\n underscoreErrorPageFile === '_error.ts' ||\n underscoreErrorPageFile === '_error.tsx',\n ),\n );\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Did add the code to your ${chalk.cyan(\n path.join(...pagesLocation, underscoreErrorPageFile),\n )} file as described above?`,\n active: 'Yes',\n inactive: 'No, get me out of here',\n }),\n );\n\n if (!shouldContinue) {\n await abort();\n }\n }\n });\n\n await traceStep('create-global-error-page', async () => {\n const maybeAppDirPath = path.join(process.cwd(), 'app');\n const maybeSrcAppDirPath = path.join(process.cwd(), 'src', 'app');\n\n const appDirLocation =\n fs.existsSync(maybeAppDirPath) &&\n fs.lstatSync(maybeAppDirPath).isDirectory()\n ? ['app']\n : fs.existsSync(maybeSrcAppDirPath) &&\n fs.lstatSync(maybeSrcAppDirPath).isDirectory()\n ? ['src', 'app']\n : undefined;\n\n if (!appDirLocation) {\n return;\n }\n\n const globalErrorPageFile = fs.existsSync(\n path.join(process.cwd(), ...appDirLocation, 'global-error.tsx'),\n )\n ? 'global-error.tsx'\n : fs.existsSync(\n path.join(process.cwd(), ...appDirLocation, 'global-error.ts'),\n )\n ? 'global-error.ts'\n : fs.existsSync(\n path.join(process.cwd(), ...appDirLocation, 'global-error.jsx'),\n )\n ? 'global-error.jsx'\n : fs.existsSync(\n path.join(process.cwd(), ...appDirLocation, 'global-error.js'),\n )\n ? 'global-error.js'\n : undefined;\n\n if (!globalErrorPageFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), ...appDirLocation, 'global-error.jsx'),\n getSentryDefaultGlobalErrorPage(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appDirLocation, 'global-error.jsx'),\n )}.`,\n );\n } else {\n clack.log.info(\n `It seems like you already have a custom error page for your app directory.\\n\\nPlease add the following code to your custom error page\\nat ${chalk.cyan(\n path.join(...appDirLocation, globalErrorPageFile),\n )}:`,\n );\n\n // eslint-disable-next-line no-console\n console.log(\n getGlobalErrorCopyPasteSnippet(\n globalErrorPageFile === 'global-error.ts' ||\n globalErrorPageFile === 'global-error.tsx',\n ),\n );\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Did add the code to your ${chalk.cyan(\n path.join(...appDirLocation, globalErrorPageFile),\n )} file as described above?`,\n active: 'Yes',\n inactive: 'No, get me out of here',\n }),\n );\n\n if (!shouldContinue) {\n await abort();\n }\n }\n });\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage();\n if (shouldCreateExamplePage) {\n await traceStep('create-example-page', async () =>\n createExamplePage(selfHosted, selectedProject, sentryUrl),\n );\n }\n\n await addSentryCliConfig({ authToken });\n\n const mightBeUsingVercel = fs.existsSync(\n path.join(process.cwd(), 'vercel.json'),\n );\n\n if (mightBeUsingVercel) {\n clack.log.info(\n \"▲ It seems like you're using Vercel. We recommend using the Sentry Vercel integration to set up an auth token for Vercel deployments: https://vercel.com/integrations/sentry\",\n );\n } else {\n await traceStep('configure-ci', () => configureCI('nextjs', authToken));\n }\n\n clack.outro(`\n${chalk.green('Successfully installed the Sentry Next.js SDK!')} ${\n shouldCreateExamplePage\n ? `\\n\\nYou can validate your setup by restarting your dev environment (${chalk.cyan(\n `next dev`,\n )}) and visiting ${chalk.cyan('\"/sentry-example-page\"')}`\n : ''\n }\n\n${chalk.dim(\n 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-javascript/issues',\n)}`);\n}\n\nasync function createOrMergeNextJsFiles(\n selectedProject: SentryProjectData,\n selfHosted: boolean,\n sentryUrl: string,\n) {\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', 'client', 'edge'] as const;\n\n for (const configVariant of configVariants) {\n await traceStep(`create-sentry-${configVariant}-config`, async () => {\n const jsConfig = `sentry.${configVariant}.config.js`;\n const tsConfig = `sentry.${configVariant}.config.ts`;\n\n const jsConfigExists = fs.existsSync(path.join(process.cwd(), jsConfig));\n const tsConfigExists = fs.existsSync(path.join(process.cwd(), tsConfig));\n\n let shouldWriteFile = true;\n\n if (jsConfigExists || tsConfigExists) {\n const existingConfigs = [];\n\n if (jsConfigExists) {\n existingConfigs.push(jsConfig);\n }\n\n if (tsConfigExists) {\n existingConfigs.push(tsConfig);\n }\n\n const overwriteExistingConfigs = await abortIfCancelled(\n clack.confirm({\n message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(\n ', ',\n )}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,\n }),\n );\n Sentry.setTag(\n `overwrite-${configVariant}-config`,\n overwriteExistingConfigs,\n );\n\n shouldWriteFile = overwriteExistingConfigs;\n\n if (overwriteExistingConfigs) {\n if (jsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), jsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(jsConfig)}.`);\n }\n if (tsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), tsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(tsConfig)}.`);\n }\n }\n }\n\n if (shouldWriteFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig),\n getSentryConfigContents(\n selectedProject.keys[0].dsn.public,\n configVariant,\n ),\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created fresh ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )}.`,\n );\n Sentry.setTag(`created-${configVariant}-config`, true);\n }\n });\n }\n\n const sentryWebpackOptionsTemplate = getNextjsWebpackPluginOptionsTemplate(\n selectedProject.organization.slug,\n selectedProject.slug,\n selfHosted,\n sentryUrl,\n );\n const sentryBuildOptionsTemplate = getNextjsSentryBuildOptionsTemplate();\n\n const nextConfigJs = 'next.config.js';\n const nextConfigMjs = 'next.config.mjs';\n\n await traceStep('setup-next-config', async () => {\n const nextConfigJsExists = fs.existsSync(\n path.join(process.cwd(), nextConfigJs),\n );\n const nextConfigMjsExists = fs.existsSync(\n path.join(process.cwd(), nextConfigMjs),\n );\n\n if (!nextConfigJsExists && !nextConfigMjsExists) {\n Sentry.setTag('next-config-strategy', 'create');\n\n await fs.promises.writeFile(\n path.join(process.cwd(), nextConfigJs),\n getNextjsConfigCjsTemplate(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan('next.config.js')} with Sentry configuration.`,\n );\n }\n\n if (nextConfigJsExists) {\n Sentry.setTag('next-config-strategy', 'modify');\n\n const nextConfigJsContent = fs.readFileSync(\n path.join(process.cwd(), nextConfigJs),\n 'utf8',\n );\n\n const probablyIncludesSdk =\n nextConfigJsContent.includes('@sentry/nextjs') &&\n nextConfigJsContent.includes('withSentryConfig');\n\n let shouldInject = true;\n\n if (probablyIncludesSdk) {\n const injectAnyhow = await abortIfCancelled(\n clack.confirm({\n message: `${chalk.cyan(\n nextConfigJs,\n )} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,\n }),\n );\n\n shouldInject = injectAnyhow;\n }\n\n if (shouldInject) {\n await fs.promises.appendFile(\n path.join(process.cwd(), nextConfigJs),\n getNextjsConfigCjsAppendix(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n 'utf8',\n );\n\n clack.log.success(\n `Added Sentry configuration to ${chalk.cyan(\n nextConfigJs,\n )}. ${chalk.dim('(you probably want to clean this up a bit!)')}`,\n );\n }\n\n Sentry.setTag('next-config-mod-result', 'success');\n }\n\n if (nextConfigMjsExists) {\n const nextConfigMjsContent = fs.readFileSync(\n path.join(process.cwd(), nextConfigMjs),\n 'utf8',\n );\n\n const probablyIncludesSdk =\n nextConfigMjsContent.includes('@sentry/nextjs') &&\n nextConfigMjsContent.includes('withSentryConfig');\n\n let shouldInject = true;\n\n if (probablyIncludesSdk) {\n const injectAnyhow = await abortIfCancelled(\n clack.confirm({\n message: `${chalk.cyan(\n nextConfigMjs,\n )} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,\n }),\n );\n\n shouldInject = injectAnyhow;\n }\n\n try {\n if (shouldInject) {\n const mod = parseModule(nextConfigMjsContent);\n mod.imports.$add({\n from: '@sentry/nextjs',\n imported: 'withSentryConfig',\n local: 'withSentryConfig',\n });\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access\n const expressionToWrap = generateCode(mod.exports.default.$ast).code;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.default = builders.raw(`withSentryConfig(\n ${expressionToWrap},\n ${sentryWebpackOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n)`);\n const newCode = mod.generate().code;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), nextConfigMjs),\n newCode,\n {\n encoding: 'utf8',\n flag: 'w',\n },\n );\n clack.log.success(\n `Added Sentry configuration to ${chalk.cyan(\n nextConfigMjs,\n )}. ${chalk.dim('(you probably want to clean this up a bit!)')}`,\n );\n\n Sentry.setTag('next-config-mod-result', 'success');\n }\n } catch {\n Sentry.setTag('next-config-mod-result', 'fail');\n clack.log.warn(\n chalk.yellow(\n `Something went wrong writing to ${chalk.cyan(nextConfigMjs)}`,\n ),\n );\n clack.log.info(\n `Please put the following code snippet into ${chalk.cyan(\n nextConfigMjs,\n )}: ${chalk.dim('You probably have to clean it up a bit.')}\\n`,\n );\n\n // eslint-disable-next-line no-console\n console.log(\n getNextjsConfigEsmCopyPasteSnippet(\n sentryWebpackOptionsTemplate,\n sentryBuildOptionsTemplate,\n ),\n );\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Are you done putting the snippet above into ${chalk.cyan(\n nextConfigMjs,\n )}?`,\n active: 'Yes',\n inactive: 'No, get me out of here',\n }),\n );\n\n if (!shouldContinue) {\n await abort();\n }\n }\n }\n });\n}\n\nasync function createExamplePage(\n selfHosted: boolean,\n selectedProject: SentryProjectData,\n sentryUrl: string,\n): Promise<void> {\n const srcDir = path.join(process.cwd(), 'src');\n const maybePagesDirPath = path.join(process.cwd(), 'pages');\n const maybeSrcPagesDirPath = path.join(srcDir, 'pages');\n const maybeAppDirPath = path.join(process.cwd(), 'app');\n const maybeSrcAppDirPath = path.join(srcDir, 'app');\n\n let pagesLocation =\n fs.existsSync(maybePagesDirPath) &&\n fs.lstatSync(maybePagesDirPath).isDirectory()\n ? ['pages']\n : fs.existsSync(maybeSrcPagesDirPath) &&\n fs.lstatSync(maybeSrcPagesDirPath).isDirectory()\n ? ['src', 'pages']\n : undefined;\n\n const appLocation =\n fs.existsSync(maybeAppDirPath) &&\n fs.lstatSync(maybeAppDirPath).isDirectory()\n ? ['app']\n : fs.existsSync(maybeSrcAppDirPath) &&\n fs.lstatSync(maybeSrcAppDirPath).isDirectory()\n ? ['src', 'app']\n : undefined;\n\n if (!pagesLocation && !appLocation) {\n pagesLocation =\n fs.existsSync(srcDir) && fs.lstatSync(srcDir).isDirectory()\n ? ['src', 'pages']\n : ['pages'];\n fs.mkdirSync(path.join(process.cwd(), ...pagesLocation), {\n recursive: true,\n });\n }\n\n Sentry.setTag('nextjs-app-dir', !!appLocation);\n\n if (appLocation) {\n const examplePageContents = getSentryExamplePageContents({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n useClient: true,\n });\n\n fs.mkdirSync(\n path.join(process.cwd(), ...appLocation, 'sentry-example-page'),\n {\n recursive: true,\n },\n );\n\n await fs.promises.writeFile(\n path.join(\n process.cwd(),\n ...appLocation,\n 'sentry-example-page',\n 'page.jsx',\n ),\n examplePageContents,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appLocation, 'sentry-example-page', 'page.jsx'),\n )}.`,\n );\n\n fs.mkdirSync(\n path.join(process.cwd(), ...appLocation, 'api', 'sentry-example-api'),\n {\n recursive: true,\n },\n );\n\n await fs.promises.writeFile(\n path.join(\n process.cwd(),\n ...appLocation,\n 'api',\n 'sentry-example-api',\n 'route.js',\n ),\n getSentryExampleAppDirApiRoute(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appLocation, 'api', 'sentry-example-api', 'route.js'),\n )}.`,\n );\n } else if (pagesLocation) {\n const examplePageContents = getSentryExamplePageContents({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n useClient: false,\n });\n\n await fs.promises.writeFile(\n path.join(process.cwd(), ...pagesLocation, 'sentry-example-page.jsx'),\n examplePageContents,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...pagesLocation, 'sentry-example-page.js'),\n )}.`,\n );\n\n fs.mkdirSync(path.join(process.cwd(), ...pagesLocation, 'api'), {\n recursive: true,\n });\n\n await fs.promises.writeFile(\n path.join(\n process.cwd(),\n ...pagesLocation,\n 'api',\n 'sentry-example-api.js',\n ),\n getSentryExampleApiRoute(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...pagesLocation, 'api', 'sentry-example-api.js'),\n )}.`,\n );\n }\n}\n"]}
@@ -10,7 +10,7 @@ function getNextjsWebpackPluginOptionsTemplate(orgSlug, projectSlug, selfHosted,
10
10
  }
11
11
  exports.getNextjsWebpackPluginOptionsTemplate = getNextjsWebpackPluginOptionsTemplate;
12
12
  function getNextjsSentryBuildOptionsTemplate() {
13
- return "{\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\n // Transpiles SDK to be compatible with IE11 (increases bundle size)\n transpileClientSDK: true,\n\n // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)\n 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.\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 }";
13
+ return "{\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\n // Transpiles SDK to be compatible with IE11 (increases bundle size)\n transpileClientSDK: true,\n\n // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers. (increases server load)\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: \"/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.\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 }";
14
14
  }
15
15
  exports.getNextjsSentryBuildOptionsTemplate = getNextjsSentryBuildOptionsTemplate;
16
16
  function getNextjsConfigCjsTemplate(sentryWebpackPluginOptionsTemplate, sentryBuildOptionsTemplate) {
@@ -40,8 +40,12 @@ function getSentryConfigContents(dsn, config) {
40
40
  if (config === 'client') {
41
41
  additionalOptions = "\n\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 ],";
42
42
  }
43
+ var spotlightOption = '';
44
+ if (config === 'server') {
45
+ spotlightOption = "\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: process.env.NODE_ENV === 'development',\n ";
46
+ }
43
47
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
44
- return "".concat(primer, "\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"").concat(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,").concat(additionalOptions, "\n});\n");
48
+ return "".concat(primer, "\n\nimport * as Sentry from \"@sentry/nextjs\";\n\nSentry.init({\n dsn: \"").concat(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,").concat(additionalOptions).concat(spotlightOption, "\n});\n");
45
49
  }
46
50
  exports.getSentryConfigContents = getSentryConfigContents;
47
51
  function getSentryExamplePageContents(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nextjs/templates.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA0B;AAE1B,SAAgB,qCAAqC,CACnD,OAAe,EACf,WAAmB,EACnB,UAAmB,EACnB,GAAW;IAEX,OAAO,kNAMG,OAAO,iCACH,WAAW,gBAAK,UAAU,CAAC,CAAC,CAAC,uBAAe,GAAG,OAAG,CAAC,CAAC,CAAC,EAAE,UACnE,CAAC;AACL,CAAC;AAfD,sFAeC;AAED,SAAgB,mCAAmC;IACjD,OAAO,w7BAwBL,CAAC;AACL,CAAC;AA1BD,kFA0BC;AAED,SAAgB,0BAA0B,CACxC,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,gMAOL,kCAAkC,kBAClC,0BAA0B,WAE7B,CAAC;AACF,CAAC;AAfD,gEAeC;AAED,SAAgB,0BAA0B,CACxC,kCAA0C,EAC1C,0BAAkC;IAElC,OAAO,mLAQL,kCAAkC,kBAClC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CAAC,KAAK,CAAC,wEAED,CAAC,kIAUf,CAAC;KACC;AACH,CAAC;AA9CD,wEA8CC","sourcesContent":["import chalk from 'chalk';\n\nexport function getNextjsWebpackPluginOptionsTemplate(\n orgSlug: string,\n projectSlug: string,\n selfHosted: boolean,\n url: string,\n): string {\n return `{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n // Suppresses source map uploading logs during build\n silent: true,\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",${selfHosted ? `\\n url: \"${url}\"` : ''}\n }`;\n}\n\nexport function getNextjsSentryBuildOptionsTemplate(): string {\n return `{\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\n // Transpiles SDK to be compatible with IE11 (increases bundle size)\n transpileClientSDK: true,\n\n // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)\n 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.\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 sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: 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 ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigCjsAppendix(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: 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 ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigEsmCopyPasteSnippet(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: string,\n): string {\n return `\n\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs\";\n\nexport default withSentryConfig(\n yourNextConfig,\n ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\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\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 // 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}\n});\n`;\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n useClient: boolean;\n}): string {\n const issuesPageLink = options.selfHosted\n ? `${options.url}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={() => {\n 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 getSentryExampleApiRoute() {\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\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`;\n}\n\nexport function getFullUnderscoreErrorCopyPasteSnippet(isTs: boolean) {\n return `\nimport * as Sentry from '@sentry/nextjs';${\n isTs ? '\\nimport type { NextPageContext } from \"next\";' : ''\n }\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`;\n}\n\nexport function getSentryDefaultGlobalErrorPage() {\n return `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport Error 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 <Error />\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;AAE1B,SAAgB,qCAAqC,CACnD,OAAe,EACf,WAAmB,EACnB,UAAmB,EACnB,GAAW;IAEX,OAAO,kNAMG,OAAO,iCACH,WAAW,gBAAK,UAAU,CAAC,CAAC,CAAC,uBAAe,GAAG,OAAG,CAAC,CAAC,CAAC,EAAE,UACnE,CAAC;AACL,CAAC;AAfD,sFAeC;AAED,SAAgB,mCAAmC;IACjD,OAAO,klCA0BL,CAAC;AACL,CAAC;AA5B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,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';\n\nexport function getNextjsWebpackPluginOptionsTemplate(\n orgSlug: string,\n projectSlug: string,\n selfHosted: boolean,\n url: string,\n): string {\n return `{\n // For all available options, see:\n // https://github.com/getsentry/sentry-webpack-plugin#options\n\n // Suppresses source map uploading logs during build\n silent: true,\n org: \"${orgSlug}\",\n project: \"${projectSlug}\",${selfHosted ? `\\n url: \"${url}\"` : ''}\n }`;\n}\n\nexport function getNextjsSentryBuildOptionsTemplate(): string {\n return `{\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\n // Transpiles SDK to be compatible with IE11 (increases bundle size)\n transpileClientSDK: true,\n\n // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers. (increases server load)\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: \"/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.\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 sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: 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 ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigCjsAppendix(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: 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 ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\n);\n`;\n}\n\nexport function getNextjsConfigEsmCopyPasteSnippet(\n sentryWebpackPluginOptionsTemplate: string,\n sentryBuildOptionsTemplate: string,\n): string {\n return `\n\n// next.config.mjs\nimport { withSentryConfig } from \"@sentry/nextjs\";\n\nexport default withSentryConfig(\n yourNextConfig,\n ${sentryWebpackPluginOptionsTemplate},\n ${sentryBuildOptionsTemplate}\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\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 url: string;\n orgSlug: string;\n projectId: string;\n useClient: boolean;\n}): string {\n const issuesPageLink = options.selfHosted\n ? `${options.url}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={() => {\n 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 getSentryExampleApiRoute() {\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\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`;\n}\n\nexport function getFullUnderscoreErrorCopyPasteSnippet(isTs: boolean) {\n return `\nimport * as Sentry from '@sentry/nextjs';${\n isTs ? '\\nimport type { NextPageContext } from \"next\";' : ''\n }\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`;\n}\n\nexport function getSentryDefaultGlobalErrorPage() {\n return `\"use client\";\n\nimport * as Sentry from \"@sentry/nextjs\";\nimport Error 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 <Error />\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,6 +1,5 @@
1
1
  import * as recast from 'recast';
2
- import { ASTNode, ProxifiedImportItem } from 'magicast';
3
- export declare function updateViteBuildParameter(node: ASTNode): void;
2
+ import { ProxifiedImportItem } from 'magicast';
4
3
  export declare function findCustomExpressServerImplementation(): Promise<string | null>;
5
4
  export declare function instrumentExpressCreateRequestHandler(expressServerPath: string): Promise<boolean>;
6
5
  export declare function wrapCreateRequestHandlerWithSentry(createRequestHandlerImport: ProxifiedImportItem | undefined): recast.types.namedTypes.VariableDeclaration | undefined;
@@ -62,7 +62,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
62
62
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
63
  };
64
64
  Object.defineProperty(exports, "__esModule", { value: true });
65
- exports.wrapCreateRequestHandlerWithSentry = exports.instrumentExpressCreateRequestHandler = exports.findCustomExpressServerImplementation = exports.updateViteBuildParameter = void 0;
65
+ exports.wrapCreateRequestHandlerWithSentry = exports.instrumentExpressCreateRequestHandler = exports.findCustomExpressServerImplementation = void 0;
66
66
  // @ts-expect-error - clack is ESM and TS complains about that. It works though
67
67
  var prompts_1 = __importDefault(require("@clack/prompts"));
68
68
  var chalk_1 = __importDefault(require("chalk"));
@@ -72,28 +72,6 @@ var magicast_1 = require("magicast");
72
72
  var fs = __importStar(require("fs"));
73
73
  var utils_1 = require("../utils");
74
74
  var ast_utils_1 = require("../../utils/ast-utils");
75
- // Find `loadViteServerBuild` or `unstable_loadViteServerBuild` call inside an arrow function
76
- // and replace it with await loadViteServerBuild.
77
- // For context, see: https://github.com/getsentry/sentry-javascript/issues/9500
78
- function updateViteBuildParameter(node) {
79
- var hasViteConfig = (0, ast_utils_1.findFile)('vite.config');
80
- if (!hasViteConfig) {
81
- return;
82
- }
83
- (0, ast_types_1.visit)(node, {
84
- visitArrowFunctionExpression: function (path) {
85
- if (path.value.body.type === 'CallExpression' &&
86
- path.value.body.callee.type === 'Identifier' &&
87
- (path.value.body.callee.name === 'unstable_loadViteServerBuild' ||
88
- path.value.body.callee.name === 'loadViteServerBuild')) {
89
- // Replace the arrow function with a call to await loadViteServerBuild
90
- path.replace(recast.types.builders.awaitExpression(path.value.body));
91
- }
92
- this.traverse(path);
93
- },
94
- });
95
- }
96
- exports.updateViteBuildParameter = updateViteBuildParameter;
97
75
  // Try to find the Express server implementation that contains `createRequestHandler` from `@remix-run/express`
98
76
  function findCustomExpressServerImplementation() {
99
77
  return __awaiter(this, void 0, void 0, function () {
@@ -180,9 +158,6 @@ function instrumentExpressCreateRequestHandler(expressServerPath) {
180
158
  // @ts-expect-error - string works here because the AST is proxified by magicast
181
159
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
182
160
  createRequestHandlerConst);
183
- // Update the Vite build parameter to await loadViteServerBuild if everything goes well.
184
- // This should be the last thing we do.
185
- updateViteBuildParameter(originalExpressServerMod.$ast);
186
161
  _a.label = 2;
187
162
  case 2:
188
163
  _a.trys.push([2, 4, , 5]);
@@ -1 +1 @@
1
- {"version":3,"file":"express-server.js","sourceRoot":"","sources":["../../../../src/remix/codemods/express-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAC1B,6CAAiC;AACjC,uCAAkC;AAClC,qCAOkB;AAElB,qCAAyB;AAEzB,kCAAuE;AACvE,mDAAiD;AAEjD,6FAA6F;AAC7F,iDAAiD;AACjD,+EAA+E;AAC/E,SAAgB,wBAAwB,CAAC,IAAa;IACpD,IAAM,aAAa,GAAG,IAAA,oBAAQ,EAAC,aAAa,CAAC,CAAC;IAE9C,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO;KAC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AC,iCAAiC,CAAC,EACnE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CACzD,CAAC;IAEF,OAAO,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE;QACxD,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CACtC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,4BAA4B,CAAC,EAC9D,wBAAwB,CACzB;KACF,CAAC,CAAC;AACL,CAAC;AApBD,gFAoBC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as recast from 'recast';\nimport { visit } from 'ast-types';\nimport {\n ASTNode,\n ProxifiedImportItem,\n generateCode,\n loadFile,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\nimport type { Program } from '@babel/types';\nimport * as fs from 'fs';\n\nimport { getInitCallInsertionIndex, hasSentryContent } from '../utils';\nimport { findFile } from '../../utils/ast-utils';\n\n// Find `loadViteServerBuild` or `unstable_loadViteServerBuild` call inside an arrow function\n// and replace it with await loadViteServerBuild.\n// For context, see: https://github.com/getsentry/sentry-javascript/issues/9500\nexport function updateViteBuildParameter(node: ASTNode) {\n const hasViteConfig = findFile('vite.config');\n\n if (!hasViteConfig) {\n return;\n }\n\n visit(node, {\n visitArrowFunctionExpression(path) {\n if (\n path.value.body.type === 'CallExpression' &&\n path.value.body.callee.type === 'Identifier' &&\n (path.value.body.callee.name === 'unstable_loadViteServerBuild' ||\n path.value.body.callee.name === 'loadViteServerBuild')\n ) {\n // Replace the arrow function with a call to await loadViteServerBuild\n path.replace(recast.types.builders.awaitExpression(path.value.body));\n }\n\n this.traverse(path);\n },\n });\n}\n\n// Try to find the Express server implementation that contains `createRequestHandler` from `@remix-run/express`\nexport async function findCustomExpressServerImplementation() {\n const possiblePaths = [\n 'server',\n 'server/index',\n 'app/server',\n 'app/server/index',\n ];\n\n for (const filePath of possiblePaths) {\n const filename = findFile(filePath);\n\n if (!filename) {\n continue;\n }\n\n const fileStat = fs.statSync(filename);\n\n if (!fileStat.isFile()) {\n continue;\n }\n\n const fileMod = await loadFile(filename);\n const createRequestHandlerImport = fileMod.imports.$items.find(\n (imp) =>\n imp.from === '@remix-run/express' &&\n imp.imported === 'createRequestHandler',\n );\n\n if (createRequestHandlerImport) {\n return filename;\n }\n }\n\n return null;\n}\n\n// Wrap createRequestHandler with `wrapExpressCreateRequestHandler` from `@sentry/remix`\nexport async function instrumentExpressCreateRequestHandler(\n expressServerPath: string,\n): Promise<boolean> {\n const originalExpressServerMod = await loadFile(expressServerPath);\n\n if (\n hasSentryContent(\n generateCode(originalExpressServerMod.$ast).code,\n originalExpressServerMod.$code,\n )\n ) {\n clack.log.warn(\n `Express server in ${chalk.cyan(\n expressServerPath,\n )} already has Sentry instrumentation. Skipping.`,\n );\n\n return false;\n }\n\n originalExpressServerMod.imports.$add({\n from: '@sentry/remix',\n imported: 'wrapExpressCreateRequestHandler',\n local: 'wrapExpressCreateRequestHandler',\n });\n\n const createRequestHandlerImport =\n originalExpressServerMod.imports.$items.find(\n (imp) =>\n imp.from === '@remix-run/express' &&\n imp.imported === 'createRequestHandler',\n );\n\n visit(originalExpressServerMod.$ast, {\n visitIdentifier(path) {\n if (\n path.value.name === 'createRequestHandler' &&\n path.parentPath.value.type === 'CallExpression'\n ) {\n path.value.name = 'sentryCreateRequestHandler';\n }\n\n this.traverse(path);\n },\n });\n\n // Insert the const declaration right after the imports\n // Where we want to insert the const declaration is the same as where we would want to insert the init call.\n const insertionIndex = getInitCallInsertionIndex(\n originalExpressServerMod.$ast as Program,\n );\n\n const createRequestHandlerConst = wrapCreateRequestHandlerWithSentry(\n createRequestHandlerImport,\n );\n\n if (!createRequestHandlerConst) {\n // Todo: throw error\n }\n\n (originalExpressServerMod.$ast as Program).body.splice(\n insertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n createRequestHandlerConst,\n );\n\n // Update the Vite build parameter to await loadViteServerBuild if everything goes well.\n // This should be the last thing we do.\n updateViteBuildParameter(originalExpressServerMod.$ast);\n\n try {\n await writeFile(originalExpressServerMod.$ast, expressServerPath);\n\n clack.log.info(\n `Successfully instrumented Express server in ${chalk.cyan(\n expressServerPath,\n )}.`,\n );\n } catch (e) {\n clack.log.warn(\n `Could not write to Express server in ${chalk.cyan(expressServerPath)}.`,\n );\n\n throw e;\n }\n\n return true;\n}\n\n// Wrap `createRequestHandler` with `wrapExpressCreateRequestHandler` and set const name to `sentryCreateRequestHandler`\nexport function wrapCreateRequestHandlerWithSentry(\n createRequestHandlerImport: ProxifiedImportItem | undefined,\n) {\n if (!createRequestHandlerImport) {\n return;\n }\n\n const createRequestHandler = createRequestHandlerImport.local;\n\n const wrapCreateRequestHandler = recast.types.builders.callExpression(\n recast.types.builders.identifier('wrapExpressCreateRequestHandler'),\n [recast.types.builders.identifier(createRequestHandler)],\n );\n\n return recast.types.builders.variableDeclaration('const', [\n recast.types.builders.variableDeclarator(\n recast.types.builders.identifier('sentryCreateRequestHandler'),\n wrapCreateRequestHandler,\n ),\n ]);\n}\n"]}
1
+ {"version":3,"file":"express-server.js","sourceRoot":"","sources":["../../../../src/remix/codemods/express-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAC1B,6CAAiC;AACjC,uCAAkC;AAClC,qCAMkB;AAElB,qCAAyB;AAEzB,kCAAuE;AACvE,mDAAiD;AAEjD,+GAA+G;AAC/G,SAAsB,qCAAqC;;;;;;oBACnD,aAAa,GAAG;wBACpB,QAAQ;wBACR,cAAc;wBACd,YAAY;wBACZ,kBAAkB;qBACnB,CAAC;0BAEkC,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B,CAAC,MAAG,CACzE,CAAC;oBAEF,MAAM,GAAC,CAAC;wBAGV,sBAAO,IAAI,EAAC;;;;CACb;AArFD,sFAqFC;AAED,wHAAwH;AACxH,SAAgB,kCAAkC,CAChD,0BAA2D;IAE3D,IAAI,CAAC,0BAA0B,EAAE;QAC/B,OAAO;KACR;IAED,IAAM,oBAAoB,GAAG,0BAA0B,CAAC,KAAK,CAAC;IAE9D,IAAM,wBAAwB,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CACnE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,iCAAiC,CAAC,EACnE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CACzD,CAAC;IAEF,OAAO,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE;QACxD,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CACtC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,4BAA4B,CAAC,EAC9D,wBAAwB,CACzB;KACF,CAAC,CAAC;AACL,CAAC;AApBD,gFAoBC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as recast from 'recast';\nimport { visit } from 'ast-types';\nimport {\n ProxifiedImportItem,\n generateCode,\n loadFile,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\nimport type { Program } from '@babel/types';\nimport * as fs from 'fs';\n\nimport { getInitCallInsertionIndex, hasSentryContent } from '../utils';\nimport { findFile } from '../../utils/ast-utils';\n\n// Try to find the Express server implementation that contains `createRequestHandler` from `@remix-run/express`\nexport async function findCustomExpressServerImplementation() {\n const possiblePaths = [\n 'server',\n 'server/index',\n 'app/server',\n 'app/server/index',\n ];\n\n for (const filePath of possiblePaths) {\n const filename = findFile(filePath);\n\n if (!filename) {\n continue;\n }\n\n const fileStat = fs.statSync(filename);\n\n if (!fileStat.isFile()) {\n continue;\n }\n\n const fileMod = await loadFile(filename);\n const createRequestHandlerImport = fileMod.imports.$items.find(\n (imp) =>\n imp.from === '@remix-run/express' &&\n imp.imported === 'createRequestHandler',\n );\n\n if (createRequestHandlerImport) {\n return filename;\n }\n }\n\n return null;\n}\n\n// Wrap createRequestHandler with `wrapExpressCreateRequestHandler` from `@sentry/remix`\nexport async function instrumentExpressCreateRequestHandler(\n expressServerPath: string,\n): Promise<boolean> {\n const originalExpressServerMod = await loadFile(expressServerPath);\n\n if (\n hasSentryContent(\n generateCode(originalExpressServerMod.$ast).code,\n originalExpressServerMod.$code,\n )\n ) {\n clack.log.warn(\n `Express server in ${chalk.cyan(\n expressServerPath,\n )} already has Sentry instrumentation. Skipping.`,\n );\n\n return false;\n }\n\n originalExpressServerMod.imports.$add({\n from: '@sentry/remix',\n imported: 'wrapExpressCreateRequestHandler',\n local: 'wrapExpressCreateRequestHandler',\n });\n\n const createRequestHandlerImport =\n originalExpressServerMod.imports.$items.find(\n (imp) =>\n imp.from === '@remix-run/express' &&\n imp.imported === 'createRequestHandler',\n );\n\n visit(originalExpressServerMod.$ast, {\n visitIdentifier(path) {\n if (\n path.value.name === 'createRequestHandler' &&\n path.parentPath.value.type === 'CallExpression'\n ) {\n path.value.name = 'sentryCreateRequestHandler';\n }\n\n this.traverse(path);\n },\n });\n\n // Insert the const declaration right after the imports\n // Where we want to insert the const declaration is the same as where we would want to insert the init call.\n const insertionIndex = getInitCallInsertionIndex(\n originalExpressServerMod.$ast as Program,\n );\n\n const createRequestHandlerConst = wrapCreateRequestHandlerWithSentry(\n createRequestHandlerImport,\n );\n\n if (!createRequestHandlerConst) {\n // Todo: throw error\n }\n\n (originalExpressServerMod.$ast as Program).body.splice(\n insertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n createRequestHandlerConst,\n );\n\n try {\n await writeFile(originalExpressServerMod.$ast, expressServerPath);\n\n clack.log.info(\n `Successfully instrumented Express server in ${chalk.cyan(\n expressServerPath,\n )}.`,\n );\n } catch (e) {\n clack.log.warn(\n `Could not write to Express server in ${chalk.cyan(expressServerPath)}.`,\n );\n\n throw e;\n }\n\n return true;\n}\n\n// Wrap `createRequestHandler` with `wrapExpressCreateRequestHandler` and set const name to `sentryCreateRequestHandler`\nexport function wrapCreateRequestHandlerWithSentry(\n createRequestHandlerImport: ProxifiedImportItem | undefined,\n) {\n if (!createRequestHandlerImport) {\n return;\n }\n\n const createRequestHandler = createRequestHandlerImport.local;\n\n const wrapCreateRequestHandler = recast.types.builders.callExpression(\n recast.types.builders.identifier('wrapExpressCreateRequestHandler'),\n [recast.types.builders.identifier(createRequestHandler)],\n );\n\n return recast.types.builders.variableDeclaration('const', [\n recast.types.builders.variableDeclarator(\n recast.types.builders.identifier('sentryCreateRequestHandler'),\n wrapCreateRequestHandler,\n ),\n ]);\n}\n"]}
@@ -52,6 +52,7 @@ var utils_1 = require("./utils");
52
52
  var Constants_1 = require("../../lib/Constants");
53
53
  var ast_utils_1 = require("../utils/ast-utils");
54
54
  var vite_1 = require("../sourcemaps/tools/vite");
55
+ var sdk_example_1 = require("./sdk-example");
55
56
  function runRemixWizard(options) {
56
57
  return __awaiter(this, void 0, void 0, function () {
57
58
  return __generator(this, function (_a) {
@@ -65,7 +66,7 @@ function runRemixWizard(options) {
65
66
  exports.runRemixWizard = runRemixWizard;
66
67
  function runRemixWizardWithTelemetry(options) {
67
68
  return __awaiter(this, void 0, void 0, function () {
68
- var remixConfig, packageJson, _a, selectedProject, authToken, sentryUrl, selfHosted, dsn, isTS, isV2, viteConfig;
69
+ var remixConfig, packageJson, _a, selectedProject, authToken, sentryUrl, selfHosted, dsn, isTS, isV2, viteConfig, shouldCreateExamplePage;
69
70
  var _this = this;
70
71
  return __generator(this, function (_b) {
71
72
  switch (_b.label) {
@@ -260,6 +261,30 @@ function runRemixWizardWithTelemetry(options) {
260
261
  }); })];
261
262
  case 15:
262
263
  _b.sent();
264
+ return [4 /*yield*/, (0, clack_utils_1.askShouldCreateExamplePage)()];
265
+ case 16:
266
+ shouldCreateExamplePage = _b.sent();
267
+ if (!shouldCreateExamplePage) return [3 /*break*/, 18];
268
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('Create example page', function () { return __awaiter(_this, void 0, void 0, function () {
269
+ return __generator(this, function (_a) {
270
+ switch (_a.label) {
271
+ case 0: return [4 /*yield*/, (0, sdk_example_1.createExamplePage)({
272
+ isTS: isTS,
273
+ selfHosted: selfHosted,
274
+ orgSlug: selectedProject.organization.slug,
275
+ projectId: selectedProject.id,
276
+ url: sentryUrl,
277
+ })];
278
+ case 1:
279
+ _a.sent();
280
+ return [2 /*return*/];
281
+ }
282
+ });
283
+ }); })];
284
+ case 17:
285
+ _b.sent();
286
+ _b.label = 18;
287
+ case 18:
263
288
  prompts_1.default.outro("\n".concat(chalk_1.default.green('Sentry has been successfully configured for your Remix project.'), "\n\n").concat(chalk_1.default.cyan('You can now deploy your project to see Sentry in action.'), "\n\n").concat(chalk_1.default.cyan("To learn more about how to use Sentry with Remix, visit our documentation:\nhttps://docs.sentry.io/platforms/javascript/guides/remix/")));
264
289
  return [2 /*return*/];
265
290
  }
@@ -1 +1 @@
1
- {"version":3,"file":"remix-wizard.js","sourceRoot":"","sources":["../../../src/remix/remix-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAE1B,oDAU8B;AAC9B,sDAA4D;AAE5D,yCASqB;AACrB,wCAAuC;AACvC,0CAAwD;AACxD,iCAAwC;AACxC,iDAAkD;AAClD,gDAA8C;AAC9C,iDAA+D;AAE/D,SAAsB,cAAc,CAAC,OAAsB;;;YACzD,sBAAO,IAAA,yBAAa,EAClB;oBACE,OAAO,EAAE,OAAO,CAAC,gBA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BAAM,IAAA,mCAAuB,GAAE,EAAA;;wCAA/B,SAA+B,CAAC;;;;wCAEhC,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,2LACwH,CAAC,CAAC;wCACzI,IAAA,aAAK,EAAC,GAAC,CAAC,CAAC;;;;;6BAEZ,CAAC,EAAA;;oBAjBF,SAiBE,CAAC;oBAEH,iBAAK,CAAC,KAAK,CAAC,YACZ,eAAK,CAAC,KAAK,CACX,iEAAiE,CAClE,iBAEC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC,iBAEtE,eAAK,CAAC,IAAI,CACV,uIACwD,CACzD,CAAE,CAAC,CAAC;;;;;CACJ","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n rcCliSetupConfig,\n} from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport { WizardOptions } from '../utils/types';\nimport {\n initializeSentryOnEntryClient,\n initializeSentryOnEntryServer,\n updateBuildScript,\n instrumentRootRoute,\n isRemixV2,\n loadRemixConfig,\n runRemixReveal,\n instrumentExpressServer,\n} from './sdk-setup';\nimport { debug } from '../utils/debug';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { isHydrogenApp } from './utils';\nimport { DEFAULT_URL } from '../../lib/Constants';\nimport { findFile } from '../utils/ast-utils';\nimport { configureVitePlugin } from '../sourcemaps/tools/vite';\n\nexport async function runRemixWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'remix',\n },\n () => runRemixWizardWithTelemetry(options),\n );\n}\n\nasync function runRemixWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Remix Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const remixConfig = await loadRemixConfig();\n const packageJson = await getPackageDotJson();\n\n // We expect `@remix-run/dev` to be installed for every Remix project\n await ensurePackageIsInstalled(packageJson, '@remix-run/dev', 'Remix');\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-remix');\n\n await installPackage({\n packageName: '@sentry/remix',\n alreadyInstalled: hasPackageInstalled('@sentry/remix', packageJson),\n });\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const isTS = isUsingTypeScript();\n const isV2 = isRemixV2(remixConfig, packageJson);\n const viteConfig = findFile('vite.config');\n\n await addSentryCliConfig({ authToken }, rcCliSetupConfig);\n\n if (viteConfig) {\n await traceStep(\n 'Update vite configuration for sourcemap uploads',\n async () => {\n try {\n await configureVitePlugin({\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n url: sentryUrl,\n selfHosted,\n authToken,\n });\n } catch (e) {\n clack.log\n .warn(`Could not update vite configuration to generate and upload sourcemaps.\n Please update your vite configuration manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n },\n );\n } else {\n await traceStep('Update build script for sourcemap uploads', async () => {\n try {\n await updateBuildScript({\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n url: sentryUrl === DEFAULT_URL ? undefined : sentryUrl,\n isHydrogen: isHydrogenApp(packageJson),\n });\n } catch (e) {\n clack.log\n .warn(`Could not update build script to generate and upload sourcemaps.\n Please update your build script manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n });\n }\n\n await traceStep('Instrument root route', async () => {\n try {\n await instrumentRootRoute(isV2, isTS);\n } catch (e) {\n clack.log.warn(`Could not instrument root route.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n traceStep('Reveal missing entry files', () => {\n try {\n runRemixReveal(isTS);\n } catch (e) {\n clack.log.warn(`Could not run 'npx remix reveal'.\n Please create your entry files manually`);\n debug(e);\n }\n });\n\n await traceStep('Initialize Sentry on client entry', async () => {\n try {\n await initializeSentryOnEntryClient(dsn, isTS);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on client entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n await traceStep('Initialize Sentry on server entry', async () => {\n try {\n await initializeSentryOnEntryServer(dsn, isV2, isTS);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n await traceStep('Instrument custom Express server', async () => {\n try {\n const hasExpressAdapter = hasPackageInstalled(\n '@remix-run/express',\n packageJson,\n );\n\n if (!hasExpressAdapter) {\n return;\n }\n\n await instrumentExpressServer();\n } catch (e) {\n clack.log.warn(`Could not instrument custom Express server.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/#custom-express-server`);\n debug(e);\n }\n });\n\n clack.outro(`\n${chalk.green(\n 'Sentry has been successfully configured for your Remix project.',\n)}\n\n${chalk.cyan('You can now deploy your project to see Sentry in action.')}\n\n${chalk.cyan(\n `To learn more about how to use Sentry with Remix, visit our documentation:\nhttps://docs.sentry.io/platforms/javascript/guides/remix/`,\n)}`);\n}\n"]}
1
+ {"version":3,"file":"remix-wizard.js","sourceRoot":"","sources":["../../../src/remix/remix-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAE1B,oDAW8B;AAC9B,sDAA4D;AAE5D,yCASqB;AACrB,wCAAuC;AACvC,0CAAwD;AACxD,iCAAwC;AACxC,iDAAkD;AAClD,gDAA8C;AAC9C,iDAA+D;A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IAAA,kCAAmB,EAC3C,oBAAoB,EACpB,WAAW,CACZ,CAAC;wCAEF,IAAI,CAAC,iBAAiB,EAAE;4CACtB,sBAAO;yCACR;wCAED,qBAAM,IAAA,mCAAuB,GAAE,EAAA;;wCAA/B,SAA+B,CAAC;;;;wCAEhC,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,2LACwH,CAAC,CAAC;wCACzI,IAAA,aAAK,EAAC,GAAC,CAAC,CAAC;;;;;6BAEZ,CAAC,EAAA;;oBAjBF,SAiBE,CAAC;oBAE6B,qBAAM,IAAA,wCAA0B,GAAE,EAAA;;oBAA5D,uBAAuB,GAAG,SAAkC;yBAE9D,uBAAuB,EAAvB,yBAAuB;oBACzB,qBAAM,IAAA,qBAAS,EAAC,qBAAqB,EAAE;;;4CACrC,qBAAM,IAAA,+BAAiB,EAAC;4CACtB,IAAI,MAAA;4CACJ,UAAU,YAAA;4CACV,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;4CAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;4CAC7B,GAAG,EAAE,SAAS;yCACf,CAAC,EAAA;;wCANF,SAME,CAAC;;;;6BACJ,CAAC,EAAA;;oBARF,SAQE,CAAC;;;oBAGL,iBAAK,CAAC,KAAK,CAAC,YACZ,eAAK,CAAC,KAAK,CACX,iEAAiE,CAClE,iBAEC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC,iBAEtE,eAAK,CAAC,IAAI,CACV,uIACwD,CACzD,CAAE,CAAC,CAAC;;;;;CACJ","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n rcCliSetupConfig,\n} from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport { WizardOptions } from '../utils/types';\nimport {\n initializeSentryOnEntryClient,\n initializeSentryOnEntryServer,\n updateBuildScript,\n instrumentRootRoute,\n isRemixV2,\n loadRemixConfig,\n runRemixReveal,\n instrumentExpressServer,\n} from './sdk-setup';\nimport { debug } from '../utils/debug';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { isHydrogenApp } from './utils';\nimport { DEFAULT_URL } from '../../lib/Constants';\nimport { findFile } from '../utils/ast-utils';\nimport { configureVitePlugin } from '../sourcemaps/tools/vite';\nimport { createExamplePage } from './sdk-example';\n\nexport async function runRemixWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'remix',\n },\n () => runRemixWizardWithTelemetry(options),\n );\n}\n\nasync function runRemixWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Remix Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const remixConfig = await loadRemixConfig();\n const packageJson = await getPackageDotJson();\n\n // We expect `@remix-run/dev` to be installed for every Remix project\n await ensurePackageIsInstalled(packageJson, '@remix-run/dev', 'Remix');\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-remix');\n\n await installPackage({\n packageName: '@sentry/remix',\n alreadyInstalled: hasPackageInstalled('@sentry/remix', packageJson),\n });\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const isTS = isUsingTypeScript();\n const isV2 = isRemixV2(remixConfig, packageJson);\n const viteConfig = findFile('vite.config');\n\n await addSentryCliConfig({ authToken }, rcCliSetupConfig);\n\n if (viteConfig) {\n await traceStep(\n 'Update vite configuration for sourcemap uploads',\n async () => {\n try {\n await configureVitePlugin({\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n url: sentryUrl,\n selfHosted,\n authToken,\n });\n } catch (e) {\n clack.log\n .warn(`Could not update vite configuration to generate and upload sourcemaps.\n Please update your vite configuration manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n },\n );\n } else {\n await traceStep('Update build script for sourcemap uploads', async () => {\n try {\n await updateBuildScript({\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n url: sentryUrl === DEFAULT_URL ? undefined : sentryUrl,\n isHydrogen: isHydrogenApp(packageJson),\n });\n } catch (e) {\n clack.log\n .warn(`Could not update build script to generate and upload sourcemaps.\n Please update your build script manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n });\n }\n\n await traceStep('Instrument root route', async () => {\n try {\n await instrumentRootRoute(isV2, isTS);\n } catch (e) {\n clack.log.warn(`Could not instrument root route.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n traceStep('Reveal missing entry files', () => {\n try {\n runRemixReveal(isTS);\n } catch (e) {\n clack.log.warn(`Could not run 'npx remix reveal'.\n Please create your entry files manually`);\n debug(e);\n }\n });\n\n await traceStep('Initialize Sentry on client entry', async () => {\n try {\n await initializeSentryOnEntryClient(dsn, isTS);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on client entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n await traceStep('Initialize Sentry on server entry', async () => {\n try {\n await initializeSentryOnEntryServer(dsn, isV2, isTS);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n await traceStep('Instrument custom Express server', async () => {\n try {\n const hasExpressAdapter = hasPackageInstalled(\n '@remix-run/express',\n packageJson,\n );\n\n if (!hasExpressAdapter) {\n return;\n }\n\n await instrumentExpressServer();\n } catch (e) {\n clack.log.warn(`Could not instrument custom Express server.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/#custom-express-server`);\n debug(e);\n }\n });\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage();\n\n if (shouldCreateExamplePage) {\n await traceStep('Create example page', async () => {\n await createExamplePage({\n isTS,\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n });\n });\n }\n\n clack.outro(`\n${chalk.green(\n 'Sentry has been successfully configured for your Remix project.',\n)}\n\n${chalk.cyan('You can now deploy your project to see Sentry in action.')}\n\n${chalk.cyan(\n `To learn more about how to use Sentry with Remix, visit our documentation:\nhttps://docs.sentry.io/platforms/javascript/guides/remix/`,\n)}`);\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Creates an example Remix page to test Sentry
3
+ */
4
+ export declare function createExamplePage(options: {
5
+ selfHosted: boolean;
6
+ orgSlug: string;
7
+ projectId: string;
8
+ url: string;
9
+ isTS: boolean;
10
+ }): Promise<void>;
11
+ export declare function getSentryExamplePageContents(options: {
12
+ selfHosted: boolean;
13
+ orgSlug: string;
14
+ projectId: string;
15
+ url: string;
16
+ isTS?: boolean;
17
+ }): string;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ var __importDefault = (this && this.__importDefault) || function (mod) {
62
+ return (mod && mod.__esModule) ? mod : { "default": mod };
63
+ };
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ exports.getSentryExamplePageContents = exports.createExamplePage = void 0;
66
+ var fs = __importStar(require("fs"));
67
+ var path = __importStar(require("path"));
68
+ // @ts-ignore - clack is ESM and TS complains about that. It works though
69
+ var prompts_1 = __importDefault(require("@clack/prompts"));
70
+ /**
71
+ * Creates an example Remix page to test Sentry
72
+ */
73
+ function createExamplePage(options) {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var exampleRoutePath;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ exampleRoutePath = "app/routes/sentry-example-page.".concat(options.isTS ? 'ts' : 'js', "x");
80
+ if (fs.existsSync(exampleRoutePath)) {
81
+ prompts_1.default.log.warn("It seems like a sentry example page already exists (".concat(path.basename(exampleRoutePath), "). Skipping creation of example route."));
82
+ return [2 /*return*/];
83
+ }
84
+ return [4 /*yield*/, fs.promises.writeFile(exampleRoutePath, getSentryExamplePageContents(options))];
85
+ case 1:
86
+ _a.sent();
87
+ prompts_1.default.log.info("Created sentry example page at ".concat(exampleRoutePath, "."));
88
+ return [2 /*return*/];
89
+ }
90
+ });
91
+ });
92
+ }
93
+ exports.createExamplePage = createExamplePage;
94
+ function getSentryExamplePageContents(options) {
95
+ var issuesPageLink = options.selfHosted
96
+ ? "".concat(options.url, "organizations/").concat(options.orgSlug, "/issues/?project=").concat(options.projectId)
97
+ : "https://".concat(options.orgSlug, ".sentry.io/issues/?project=").concat(options.projectId);
98
+ return "\nimport * as Sentry from '@sentry/remix';\n\nexport default function SentryExamplePage() {\n return (\n <div>\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n {/* biome-ignore lint/a11y/noSvgWithoutTitle: <explanation> */}\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 />\n </svg>\n </h1>\n\n <p>Get started by sending us a sample error:</p>\n\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={() => {\n throw new Error(\"Sentry Example Frontend Error\");\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"".concat(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/remix/\">\n https://docs.sentry.io/platforms/javascript/guides/remix/\n </a>\n </p>\n </main>\n </div>\n );\n}\n");
99
+ }
100
+ exports.getSentryExamplePageContents = getSentryExamplePageContents;
101
+ //# sourceMappingURL=sdk-example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-example.js","sourceRoot":"","sources":["../../../src/remix/sdk-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAC7B,yEAAyE;AACzE,2DAAmC;AAEnC;;GAEG;AACH,SAAsB,iBAAiB,CAAC,OAMvC;;;;;;oBACO,gBAAgB,GAAG,yCACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MACzB,CAAC;oBAEJ,IAAI,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;wBACnC,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,8DAAuD,IAAI,CAAC,QAAQ,CAClE,gBAAgB,CACjB,2CAAwC,CAC1C,CAAC;wBACF,sBAAO;qBACR;oBAED,qBAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,gBAAgB,EAChB,4BAA4B,CAAC,OAAO,CAAC,CACtC,EAAA;;oBAHD,SAGC,CAAC;oBAEF,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,yCAAkC,gBAAgB,MAAG,CAAC,CAAC;;;;;CACvE;AA1BD,8CA0BC;AAED,SAAgB,4BAA4B,CAAC,OAM5C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,08FAuDkB,cAAc,0YAYxC,CAAC;AACF,CAAC;AA/ED,oEA+EC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n\n/**\n * Creates an example Remix page to test Sentry\n */\nexport async function createExamplePage(options: {\n selfHosted: boolean;\n orgSlug: string;\n projectId: string;\n url: string;\n isTS: boolean;\n}) {\n const exampleRoutePath = `app/routes/sentry-example-page.${\n options.isTS ? 'ts' : 'js'\n }x`;\n\n if (fs.existsSync(exampleRoutePath)) {\n clack.log.warn(\n `It seems like a sentry example page already exists (${path.basename(\n exampleRoutePath,\n )}). Skipping creation of example route.`,\n );\n return;\n }\n\n await fs.promises.writeFile(\n exampleRoutePath,\n getSentryExamplePageContents(options),\n );\n\n clack.log.info(`Created sentry example page at ${exampleRoutePath}.`);\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n orgSlug: string;\n projectId: string;\n url: string;\n isTS?: boolean;\n}) {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `\nimport * as Sentry from '@sentry/remix';\n\nexport default function SentryExamplePage() {\n return (\n <div>\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n {/* biome-ignore lint/a11y/noSvgWithoutTitle: <explanation> */}\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 />\n </svg>\n </h1>\n\n <p>Get started by sending us a sample error:</p>\n\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={() => {\n throw new Error(\"Sentry Example Frontend Error\");\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/remix/\">\n https://docs.sentry.io/platforms/javascript/guides/remix/\n </a>\n </p>\n </main>\n </div>\n );\n}\n`;\n}\n"]}
@@ -6,7 +6,7 @@ function getClientHooksTemplate(dsn) {
6
6
  }
7
7
  exports.getClientHooksTemplate = getClientHooksTemplate;
8
8
  function getServerHooksTemplate(dsn) {
9
- return "import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n tracesSampleRate: 1.0,\n});\n\n// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to `handleErrorWithSentry`\nexport const handleError = handleErrorWithSentry();\n");
9
+ return "import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n tracesSampleRate: 1.0,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV, \n});\n\n// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to `handleErrorWithSentry`\nexport const handleError = handleErrorWithSentry();\n");
10
10
  }
11
11
  exports.getServerHooksTemplate = getServerHooksTemplate;
12
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/sveltekit/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,sBAAsB,CAAC,GAAW;IAChD,OAAO,kKAIC,GAAG,0mBAiBZ,CAAC;AACF,CAAC;AAvBD,wDAuBC;AAED,SAAgB,sBAAsB,CAAC,GAAW;IAChD,OAAO,gNAKC,GAAG,yUASZ,CAAC;AACF,CAAC;AAhBD,wDAgBC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CAAC,OAK1C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,y6EAiDQ,cAAc,w7BAgD9B,CAAC;AACF,CAAC;AA5GD,gEA4GC;AAED,SAAgB,wBAAwB;IACtC,OAAO,wOAMR,CAAC;AACF,CAAC;AARD,4DAQC","sourcesContent":["export function getClientHooksTemplate(dsn: string) {\n return `import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n tracesSampleRate: 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 // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n \n // If you don't want to use Session Replay, just remove the line below:\n integrations: [replayIntegration()],\n});\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\nexport function getServerHooksTemplate(dsn: string) {\n return `import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n tracesSampleRate: 1.0,\n});\n\n// If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\n/**\n * +page.svelte with Sentry example\n */\nexport function getSentryExampleSveltePage(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n}) {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `<!-- \nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file and the entire sentry route. \n-->\n\n<script>\n import * as Sentry from '@sentry/sveltekit';\n\n function getSentryData() {\n Sentry.startSpan({\n name: 'Example Frontend Span',\n op: 'test',\n }, async () => {\n const res = await fetch('/sentry-example');\n if (!res.ok) {\n throw new Error('Sentry Example Frontend Error');\n }\n });\n }\n</script>\n\n<div>\n <head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your SvelteKit app!\" />\n </head>\n\n <main>\n <h1>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\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 />\n </svg>\n </h1>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button\n type=\"button\"\n on:click={getSentryData}>\n Throw error!\n </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/sveltekit/\">\n Sentry SvelteKit Documentation\n </a>\n </p>\n </main>\n</div>\n\n<style>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n h1 {\n font-size: 4rem;\n margin: 14px 0;\n }\n\n svg {\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n\nexport function getSentryExampleApiRoute() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file and the entire sentry route.\n\nexport const GET = async () => {\n throw new Error(\"Sentry Example API Route Error\");\n};\n`;\n}\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/sveltekit/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,sBAAsB,CAAC,GAAW;IAChD,OAAO,kKAIC,GAAG,0mBAiBZ,CAAC;AACF,CAAC;AAvBD,wDAuBC;AAED,SAAgB,sBAAsB,CAAC,GAAW;IAChD,OAAO,gNAKC,GAAG,gcAYZ,CAAC;AACF,CAAC;AAnBD,wDAmBC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CAAC,OAK1C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,y6EAiDQ,cAAc,w7BAgD9B,CAAC;AACF,CAAC;AA5GD,gEA4GC;AAED,SAAgB,wBAAwB;IACtC,OAAO,wOAMR,CAAC;AACF,CAAC;AARD,4DAQC","sourcesContent":["export function getClientHooksTemplate(dsn: string) {\n return `import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n tracesSampleRate: 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 // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n \n // If you don't want to use Session Replay, just remove the line below:\n integrations: [replayIntegration()],\n});\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\nexport function getServerHooksTemplate(dsn: string) {\n return `import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n tracesSampleRate: 1.0,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV, \n});\n\n// If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\n/**\n * +page.svelte with Sentry example\n */\nexport function getSentryExampleSveltePage(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n}) {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `<!-- \nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file and the entire sentry route. \n-->\n\n<script>\n import * as Sentry from '@sentry/sveltekit';\n\n function getSentryData() {\n Sentry.startSpan({\n name: 'Example Frontend Span',\n op: 'test',\n }, async () => {\n const res = await fetch('/sentry-example');\n if (!res.ok) {\n throw new Error('Sentry Example Frontend Error');\n }\n });\n }\n</script>\n\n<div>\n <head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your SvelteKit app!\" />\n </head>\n\n <main>\n <h1>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\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 />\n </svg>\n </h1>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button\n type=\"button\"\n on:click={getSentryData}>\n Throw error!\n </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/sveltekit/\">\n Sentry SvelteKit Documentation\n </a>\n </p>\n </main>\n</div>\n\n<style>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n h1 {\n font-size: 4rem;\n margin: 14px 0;\n }\n\n svg {\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n\nexport function getSentryExampleApiRoute() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file and the entire sentry route.\n\nexport const GET = async () => {\n throw new Error(\"Sentry Example API Route Error\");\n};\n`;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/wizard",
3
- "version": "3.20.5",
3
+ "version": "3.21.0",
4
4
  "homepage": "https://github.com/getsentry/sentry-wizard",
5
5
  "repository": "https://github.com/getsentry/sentry-wizard",
6
6
  "description": "Sentry wizard helping you to configure your project",
@@ -82,7 +82,7 @@ export async function runNextjsWizardWithTelemetry(
82
82
  Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);
83
83
 
84
84
  await installPackage({
85
- packageName: '@sentry/nextjs',
85
+ packageName: '@sentry/nextjs@^7.105.0',
86
86
  alreadyInstalled: !!packageJson?.dependencies?.['@sentry/nextjs'],
87
87
  });
88
88
 
@@ -28,7 +28,9 @@ export function getNextjsSentryBuildOptionsTemplate(): string {
28
28
  // Transpiles SDK to be compatible with IE11 (increases bundle size)
29
29
  transpileClientSDK: true,
30
30
 
31
- // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
31
+ // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers. (increases server load)
32
+ // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
33
+ // side errors will fail.
32
34
  tunnelRoute: "/monitoring",
33
35
 
34
36
  // Hides source maps from generated client bundles
@@ -137,6 +139,15 @@ export function getSentryConfigContents(
137
139
  ],`;
138
140
  }
139
141
 
142
+ let spotlightOption = '';
143
+ if (config === 'server') {
144
+ spotlightOption = `
145
+
146
+ // uncomment the line below to enable Spotlight (https://spotlightjs.com)
147
+ // spotlight: process.env.NODE_ENV === 'development',
148
+ `;
149
+ }
150
+
140
151
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
141
152
  return `${primer}
142
153
 
@@ -149,7 +160,7 @@ Sentry.init({
149
160
  tracesSampleRate: 1,
150
161
 
151
162
  // Setting this option to true will print useful information to the console while you're setting up Sentry.
152
- debug: false,${additionalOptions}
163
+ debug: false,${additionalOptions}${spotlightOption}
153
164
  });
154
165
  `;
155
166
  }
@@ -4,7 +4,6 @@ import chalk from 'chalk';
4
4
  import * as recast from 'recast';
5
5
  import { visit } from 'ast-types';
6
6
  import {
7
- ASTNode,
8
7
  ProxifiedImportItem,
9
8
  generateCode,
10
9
  loadFile,
@@ -17,33 +16,6 @@ import * as fs from 'fs';
17
16
  import { getInitCallInsertionIndex, hasSentryContent } from '../utils';
18
17
  import { findFile } from '../../utils/ast-utils';
19
18
 
20
- // Find `loadViteServerBuild` or `unstable_loadViteServerBuild` call inside an arrow function
21
- // and replace it with await loadViteServerBuild.
22
- // For context, see: https://github.com/getsentry/sentry-javascript/issues/9500
23
- export function updateViteBuildParameter(node: ASTNode) {
24
- const hasViteConfig = findFile('vite.config');
25
-
26
- if (!hasViteConfig) {
27
- return;
28
- }
29
-
30
- visit(node, {
31
- visitArrowFunctionExpression(path) {
32
- if (
33
- path.value.body.type === 'CallExpression' &&
34
- path.value.body.callee.type === 'Identifier' &&
35
- (path.value.body.callee.name === 'unstable_loadViteServerBuild' ||
36
- path.value.body.callee.name === 'loadViteServerBuild')
37
- ) {
38
- // Replace the arrow function with a call to await loadViteServerBuild
39
- path.replace(recast.types.builders.awaitExpression(path.value.body));
40
- }
41
-
42
- this.traverse(path);
43
- },
44
- });
45
- }
46
-
47
19
  // Try to find the Express server implementation that contains `createRequestHandler` from `@remix-run/express`
48
20
  export async function findCustomExpressServerImplementation() {
49
21
  const possiblePaths = [
@@ -150,10 +122,6 @@ export async function instrumentExpressCreateRequestHandler(
150
122
  createRequestHandlerConst,
151
123
  );
152
124
 
153
- // Update the Vite build parameter to await loadViteServerBuild if everything goes well.
154
- // This should be the last thing we do.
155
- updateViteBuildParameter(originalExpressServerMod.$ast);
156
-
157
125
  try {
158
126
  await writeFile(originalExpressServerMod.$ast, expressServerPath);
159
127
 
@@ -4,6 +4,7 @@ import chalk from 'chalk';
4
4
 
5
5
  import {
6
6
  addSentryCliConfig,
7
+ askShouldCreateExamplePage,
7
8
  confirmContinueIfNoOrDirtyGitRepo,
8
9
  ensurePackageIsInstalled,
9
10
  getOrAskForProjectData,
@@ -31,6 +32,7 @@ import { isHydrogenApp } from './utils';
31
32
  import { DEFAULT_URL } from '../../lib/Constants';
32
33
  import { findFile } from '../utils/ast-utils';
33
34
  import { configureVitePlugin } from '../sourcemaps/tools/vite';
35
+ import { createExamplePage } from './sdk-example';
34
36
 
35
37
  export async function runRemixWizard(options: WizardOptions): Promise<void> {
36
38
  return withTelemetry(
@@ -172,6 +174,20 @@ async function runRemixWizardWithTelemetry(
172
174
  }
173
175
  });
174
176
 
177
+ const shouldCreateExamplePage = await askShouldCreateExamplePage();
178
+
179
+ if (shouldCreateExamplePage) {
180
+ await traceStep('Create example page', async () => {
181
+ await createExamplePage({
182
+ isTS,
183
+ selfHosted,
184
+ orgSlug: selectedProject.organization.slug,
185
+ projectId: selectedProject.id,
186
+ url: sentryUrl,
187
+ });
188
+ });
189
+ }
190
+
175
191
  clack.outro(`
176
192
  ${chalk.green(
177
193
  'Sentry has been successfully configured for your Remix project.',
@@ -0,0 +1,116 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ // @ts-ignore - clack is ESM and TS complains about that. It works though
4
+ import clack from '@clack/prompts';
5
+
6
+ /**
7
+ * Creates an example Remix page to test Sentry
8
+ */
9
+ export async function createExamplePage(options: {
10
+ selfHosted: boolean;
11
+ orgSlug: string;
12
+ projectId: string;
13
+ url: string;
14
+ isTS: boolean;
15
+ }) {
16
+ const exampleRoutePath = `app/routes/sentry-example-page.${
17
+ options.isTS ? 'ts' : 'js'
18
+ }x`;
19
+
20
+ if (fs.existsSync(exampleRoutePath)) {
21
+ clack.log.warn(
22
+ `It seems like a sentry example page already exists (${path.basename(
23
+ exampleRoutePath,
24
+ )}). Skipping creation of example route.`,
25
+ );
26
+ return;
27
+ }
28
+
29
+ await fs.promises.writeFile(
30
+ exampleRoutePath,
31
+ getSentryExamplePageContents(options),
32
+ );
33
+
34
+ clack.log.info(`Created sentry example page at ${exampleRoutePath}.`);
35
+ }
36
+
37
+ export function getSentryExamplePageContents(options: {
38
+ selfHosted: boolean;
39
+ orgSlug: string;
40
+ projectId: string;
41
+ url: string;
42
+ isTS?: boolean;
43
+ }) {
44
+ const issuesPageLink = options.selfHosted
45
+ ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`
46
+ : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;
47
+
48
+ return `
49
+ import * as Sentry from '@sentry/remix';
50
+
51
+ export default function SentryExamplePage() {
52
+ return (
53
+ <div>
54
+ <main
55
+ style={{
56
+ minHeight: "100vh",
57
+ display: "flex",
58
+ flexDirection: "column",
59
+ justifyContent: "center",
60
+ alignItems: "center",
61
+ }}
62
+ >
63
+
64
+ <h1 style={{ fontSize: "4rem", margin: "14px 0" }}>
65
+ {/* biome-ignore lint/a11y/noSvgWithoutTitle: <explanation> */}
66
+ <svg
67
+ style={{
68
+ height: "1em",
69
+ }}
70
+ xmlns="http://www.w3.org/2000/svg"
71
+ viewBox="0 0 200 44"
72
+ >
73
+ <path
74
+ fill="currentColor"
75
+ 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"
76
+ />
77
+ </svg>
78
+ </h1>
79
+
80
+ <p>Get started by sending us a sample error:</p>
81
+
82
+ <button
83
+ type="button"
84
+ style={{
85
+ padding: "12px",
86
+ cursor: "pointer",
87
+ backgroundColor: "#AD6CAA",
88
+ borderRadius: "4px",
89
+ border: "none",
90
+ color: "white",
91
+ fontSize: "14px",
92
+ margin: "18px",
93
+ }}
94
+ onClick={() => {
95
+ throw new Error("Sentry Example Frontend Error");
96
+ }}
97
+ >
98
+ Throw error!
99
+ </button>
100
+
101
+ <p>
102
+ Next, look for the error on the{" "}
103
+ <a href="${issuesPageLink}">Issues Page</a>.
104
+ </p>
105
+ <p style={{ marginTop: "24px" }}>
106
+ For more information, see{" "}
107
+ <a href="https://docs.sentry.io/platforms/javascript/guides/remix/">
108
+ https://docs.sentry.io/platforms/javascript/guides/remix/
109
+ </a>
110
+ </p>
111
+ </main>
112
+ </div>
113
+ );
114
+ }
115
+ `;
116
+ }
@@ -31,6 +31,9 @@ import * as Sentry from '@sentry/sveltekit';
31
31
  Sentry.init({
32
32
  dsn: '${dsn}',
33
33
  tracesSampleRate: 1.0,
34
+
35
+ // uncomment the line below to enable Spotlight (https://spotlightjs.com)
36
+ // spotlight: import.meta.env.DEV,
34
37
  });
35
38
 
36
39
  // If you have custom handlers, make sure to place them after \`sentryHandle()\` in the \`sequence\` function.