@sentry/wizard 5.1.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/e2e-tests/tests/expo.test.js +19 -9
  3. package/dist/e2e-tests/tests/expo.test.js.map +1 -1
  4. package/dist/e2e-tests/tests/flutter.test.js +10 -2
  5. package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
  6. package/dist/e2e-tests/tests/react-native.test.js +19 -13
  7. package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
  8. package/dist/e2e-tests/utils/index.d.ts +16 -0
  9. package/dist/e2e-tests/utils/index.js +72 -1
  10. package/dist/e2e-tests/utils/index.js.map +1 -1
  11. package/dist/src/flutter/code-tools.d.ts +1 -0
  12. package/dist/src/flutter/code-tools.js +10 -0
  13. package/dist/src/flutter/code-tools.js.map +1 -1
  14. package/dist/src/flutter/templates.d.ts +3 -0
  15. package/dist/src/flutter/templates.js +13 -1
  16. package/dist/src/flutter/templates.js.map +1 -1
  17. package/dist/src/nextjs/nextjs-wizard.js +14 -10
  18. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  19. package/dist/src/nextjs/templates.d.ts +7 -2
  20. package/dist/src/nextjs/templates.js +23 -14
  21. package/dist/src/nextjs/templates.js.map +1 -1
  22. package/dist/src/nuxt/templates.js +29 -12
  23. package/dist/src/nuxt/templates.js.map +1 -1
  24. package/dist/src/react-native/expo.js +8 -2
  25. package/dist/src/react-native/expo.js.map +1 -1
  26. package/dist/src/remix/sdk-example.js +20 -5
  27. package/dist/src/remix/sdk-example.js.map +1 -1
  28. package/dist/src/sveltekit/templates.js +13 -6
  29. package/dist/src/sveltekit/templates.js.map +1 -1
  30. package/dist/src/version.d.ts +1 -1
  31. package/dist/src/version.js +1 -1
  32. package/dist/src/version.js.map +1 -1
  33. package/dist/test/flutter/code-tools.test.js +1 -0
  34. package/dist/test/flutter/code-tools.test.js.map +1 -1
  35. package/dist/test/flutter/templates.test.js +8 -2
  36. package/dist/test/flutter/templates.test.js.map +1 -1
  37. package/dist/test/nextjs/templates.test.js +78 -0
  38. package/dist/test/nextjs/templates.test.js.map +1 -1
  39. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/flutter/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,qDAAuC;AACvC,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,2CAKqB;AACrB,0CAAwD;AAExD;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,IAAY;IAChD,MAAM,KAAK,GAAa,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,QAAQ,GAAW,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAa,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;YACvB,MAAM,MAAM,GAAkB,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACvD,IAAI,MAAM,EAAE;gBACV,OAAO,MAAM,CAAC;aACf;SACF;aAAM,IAAI,IAAI,KAAK,IAAI,EAAE;YACxB,OAAO,QAAQ,CAAC;SACjB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAlBD,4BAkBC;AAED,SAAgB,YAAY,CAC1B,WAA0B,EAC1B,wBAAgC,EAChC,uBAA+B,EAC/B,OAAe,EACf,GAAW;IAEX,IAAI;QACF,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;SAC7D;QAED,IAAI,cAAc,GAAG,EAAE,CAAC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AAC,EAAE,UAAU,EAAE,EAAE,CAAC,IAAA,uBAAW,EAAC,GAAG,EAAE,gBAAgB,EAAE,UAAoB,CAAC,CAC5E,CAAC;IAEF,qDAAqD;IACrD,WAAW,GAAG,WAAW,CAAC,OAAO,CAC/B,uBAAuB,EACvB,6BAA6B,CAC9B,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC;AA3BD,4CA2BC;AAED,SAAgB,yBAAyB,CAAC,UAAkB;IAC1D,MAAM,WAAW,GAAG,2BAA2B,CAAC;IAChD,OAAO,qBAAqB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AACxD,CAAC;AAHD,8DAGC;AAED,SAAgB,uBAAuB,CAAC,UAAkB;IACxD,MAAM,eAAe,GAAG,uBAAuB,CAAC;IAChD,OAAO,qBAAqB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAC5D,CAAC;AAHD,0DAGC;AAED,SAAgB,0BAA0B,CAAC,UAAkB;IAC3D,MAAM,eAAe,GAAG,2BAA2B,CAAC;IACpD,OAAO,qBAAqB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAC5D,CAAC;AAHD,gEAGC;AAED,SAAS;AAET,SAAS,qBAAqB,CAAC,UAAkB,EAAE,MAAc;IAC/D,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,EAAE;QACZ,WAAW,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAChD,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KACjC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as Sentry from '@sentry/node';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport {\n sentryImport,\n pubspecOptions,\n sentryProperties,\n initSnippet,\n} from './templates';\nimport { featureSelectionPrompt } from '../utils/clack';\n\n/**\n * Recursively finds a file per name in subfolders.\n * @param dir - The directory to start searching.\n * @param name - The name of the file including path extension.\n * @returns The path to the main.dart file or null if not found.\n */\nexport function findFile(dir: string, name: string): string | null {\n const files: string[] = fs.readdirSync(dir);\n\n for (const file of files) {\n const fullPath: string = path.join(dir, file);\n const stats: fs.Stats = fs.statSync(fullPath);\n\n if (stats.isDirectory()) {\n const result: string | null = findFile(fullPath, name);\n if (result) {\n return result;\n }\n } else if (file === name) {\n return fullPath;\n }\n }\n\n return null;\n}\n\nexport function patchPubspec(\n pubspecFile: string | null,\n sentryDartFlutterVersion: string,\n sentryDartPluginVersion: string,\n project: string,\n org: string,\n): boolean {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let pubspecContent = fs.readFileSync(pubspecFile, 'utf8');\n\n if (!pubspecContent.includes('sentry_flutter:')) {\n const dependenciesIndex = getDependenciesLocation(pubspecContent);\n\n pubspecContent =\n pubspecContent.slice(0, dependenciesIndex) +\n ` sentry_flutter: ${sentryDartFlutterVersion}\\n` +\n pubspecContent.slice(dependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry_dart_plugin:')) {\n const devDependenciesIndex = getDevDependenciesLocation(pubspecContent);\n pubspecContent =\n pubspecContent.slice(0, devDependenciesIndex) +\n ` sentry_dart_plugin: ${sentryDartPluginVersion}\\n` +\n pubspecContent.slice(devDependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_dart_plugin')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry_dart_plugin',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry:')) {\n pubspecContent += '\\n';\n pubspecContent += pubspecOptions(project, org);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry plugin configuration')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry plugin configuration',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n fs.writeFileSync(pubspecFile, pubspecContent, 'utf8');\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function addProperties(pubspecFile: string | null, authToken: string) {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n const pubspecDir = path.dirname(pubspecFile);\n const sentryPropertiesFileName = 'sentry.properties';\n const sentryPropertiesFile = path.join(\n pubspecDir,\n sentryPropertiesFileName,\n );\n const sentryPropertiesContent = sentryProperties(authToken);\n\n fs.writeFileSync(sentryPropertiesFile, sentryPropertiesContent, 'utf8');\n\n const gitignoreFile = path.join(pubspecDir, '.gitignore');\n if (fs.existsSync(gitignoreFile)) {\n fs.appendFileSync(gitignoreFile, `\\n${sentryPropertiesFileName}\\n`);\n } else {\n fs.writeFileSync(gitignoreFile, `${sentryPropertiesFileName}\\n`, 'utf8');\n }\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport async function patchMain(\n mainFile: string | null,\n dsn: string,\n canEnableProfiling: boolean,\n): Promise<boolean> {\n try {\n if (!mainFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let mainContent = fs.readFileSync(mainFile, 'utf8');\n if (\n /import\\s+['\"]package[:]sentry_flutter\\/sentry_flutter\\.dart['\"];?/i.test(\n mainContent,\n )\n ) {\n // sentry is already configured\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('main.dart')} already has Sentry configured.`,\n ),\n );\n return true;\n }\n\n const features = [\n {\n id: 'tracing',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n ];\n if (canEnableProfiling) {\n features.push({\n id: 'profiling',\n prompt: `Do you want to enable ${chalk.bold(\n 'Profiling',\n )} to analyze CPU usage and optimize performance-critical code on iOS & macOS?`,\n enabledHint: 'recommended, tracing must be enabled',\n });\n }\n\n const selectedFeatures = await featureSelectionPrompt(features);\n const normalizedSelectedFeatures = {\n tracing: selectedFeatures.tracing ?? false,\n profiling: selectedFeatures.profiling ?? false,\n };\n mainContent = patchMainContent(\n dsn,\n mainContent,\n normalizedSelectedFeatures,\n );\n\n fs.writeFileSync(mainFile, mainContent, 'utf8');\n\n clack.log.success(\n chalk.greenBright(\n `Patched ${chalk.bold(\n 'main.dart',\n )} with the Sentry setup and test error snippet.`,\n ),\n );\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('main.dart')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function patchMainContent(\n dsn: string,\n mainContent: string,\n selectedFeatures: {\n tracing: boolean;\n profiling: boolean;\n },\n): string {\n const importIndex = getLastImportLineLocation(mainContent);\n mainContent =\n mainContent.slice(0, importIndex) +\n sentryImport +\n mainContent.slice(importIndex);\n\n // Find and replace `runApp(...)`\n mainContent = mainContent.replace(\n /runApp\\(([\\s\\S]*?)\\);/g, // Match the `runApp(...)` invocation\n (_, runAppArgs) => initSnippet(dsn, selectedFeatures, runAppArgs as string),\n );\n\n // Make the `main` function async if it's not already\n mainContent = mainContent.replace(\n /void\\s+main\\(\\)\\s*\\{/g,\n 'Future<void> main() async {',\n );\n\n return mainContent;\n}\n\nexport function getLastImportLineLocation(sourceCode: string): number {\n const importRegex = /import\\s+['\"].*['\"].*;/gim;\n return getLastReqExpLocation(sourceCode, importRegex);\n}\n\nexport function getDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\nexport function getDevDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dev_dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\n// Helper\n\nfunction getLastReqExpLocation(sourceCode: string, regExp: RegExp): number {\n let match = regExp.exec(sourceCode);\n let importIndex = 0;\n while (match) {\n importIndex = match.index + match[0].length + 1;\n match = regExp.exec(sourceCode);\n }\n return importIndex;\n}\n"]}
1
+ {"version":3,"file":"code-tools.js","sourceRoot":"","sources":["../../../src/flutter/code-tools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,qDAAuC;AACvC,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,2CAOqB;AACrB,0CAAwD;AAExD;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,IAAY;IAChD,MAAM,KAAK,GAAa,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,QAAQ,GAAW,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAa,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;YACvB,MAAM,MAAM,GAAkB,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACvD,IAAI,MAAM,EAAE;gBACV,OAAO,MAAM,CAAC;aACf;SACF;aAAM,IAAI,IAAI,KAAK,IAAI,EAAE;YACxB,OAAO,QAAQ,CAAC;SACjB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAlBD,4BA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AAC,UAAkB;IAC3D,MAAM,eAAe,GAAG,2BAA2B,CAAC;IACpD,OAAO,qBAAqB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAC5D,CAAC;AAHD,gEAGC;AAED,SAAS;AAET,SAAS,qBAAqB,CAAC,UAAkB,EAAE,MAAc;IAC/D,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,EAAE;QACZ,WAAW,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAChD,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KACjC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as Sentry from '@sentry/node';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport {\n sentryImport,\n pubspecOptions,\n sentryProperties,\n initSnippet,\n sessionReplaySampleRate,\n sessionReplayOnErrorSampleRate,\n} from './templates';\nimport { featureSelectionPrompt } from '../utils/clack';\n\n/**\n * Recursively finds a file per name in subfolders.\n * @param dir - The directory to start searching.\n * @param name - The name of the file including path extension.\n * @returns The path to the main.dart file or null if not found.\n */\nexport function findFile(dir: string, name: string): string | null {\n const files: string[] = fs.readdirSync(dir);\n\n for (const file of files) {\n const fullPath: string = path.join(dir, file);\n const stats: fs.Stats = fs.statSync(fullPath);\n\n if (stats.isDirectory()) {\n const result: string | null = findFile(fullPath, name);\n if (result) {\n return result;\n }\n } else if (file === name) {\n return fullPath;\n }\n }\n\n return null;\n}\n\nexport function patchPubspec(\n pubspecFile: string | null,\n sentryDartFlutterVersion: string,\n sentryDartPluginVersion: string,\n project: string,\n org: string,\n): boolean {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let pubspecContent = fs.readFileSync(pubspecFile, 'utf8');\n\n if (!pubspecContent.includes('sentry_flutter:')) {\n const dependenciesIndex = getDependenciesLocation(pubspecContent);\n\n pubspecContent =\n pubspecContent.slice(0, dependenciesIndex) +\n ` sentry_flutter: ${sentryDartFlutterVersion}\\n` +\n pubspecContent.slice(dependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_flutter')} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry_dart_plugin:')) {\n const devDependenciesIndex = getDevDependenciesLocation(pubspecContent);\n pubspecContent =\n pubspecContent.slice(0, devDependenciesIndex) +\n ` sentry_dart_plugin: ${sentryDartPluginVersion}\\n` +\n pubspecContent.slice(devDependenciesIndex);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry_dart_plugin')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry_dart_plugin',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n if (!pubspecContent.includes('sentry:')) {\n pubspecContent += '\\n';\n pubspecContent += pubspecOptions(project, org);\n\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('sentry plugin configuration')} added to pubspec.yaml`,\n ),\n );\n } else {\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold(\n 'sentry plugin configuration',\n )} is already included in pubspec.yaml`,\n ),\n );\n }\n\n fs.writeFileSync(pubspecFile, pubspecContent, 'utf8');\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function addProperties(pubspecFile: string | null, authToken: string) {\n try {\n if (!pubspecFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n const pubspecDir = path.dirname(pubspecFile);\n const sentryPropertiesFileName = 'sentry.properties';\n const sentryPropertiesFile = path.join(\n pubspecDir,\n sentryPropertiesFileName,\n );\n const sentryPropertiesContent = sentryProperties(authToken);\n\n fs.writeFileSync(sentryPropertiesFile, sentryPropertiesContent, 'utf8');\n\n const gitignoreFile = path.join(pubspecDir, '.gitignore');\n if (fs.existsSync(gitignoreFile)) {\n fs.appendFileSync(gitignoreFile, `\\n${sentryPropertiesFileName}\\n`);\n } else {\n fs.writeFileSync(gitignoreFile, `${sentryPropertiesFileName}\\n`, 'utf8');\n }\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('pubspec.yaml')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport async function patchMain(\n mainFile: string | null,\n dsn: string,\n canEnableProfiling: boolean,\n): Promise<boolean> {\n try {\n if (!mainFile) {\n throw new Error('pubspec.yaml is not provided or invalid.');\n }\n\n let mainContent = fs.readFileSync(mainFile, 'utf8');\n if (\n /import\\s+['\"]package[:]sentry_flutter\\/sentry_flutter\\.dart['\"];?/i.test(\n mainContent,\n )\n ) {\n // sentry is already configured\n clack.log.success(\n chalk.greenBright(\n `${chalk.bold('main.dart')} already has Sentry configured.`,\n ),\n );\n return true;\n }\n\n const features = [\n {\n id: 'tracing',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n ];\n if (canEnableProfiling) {\n features.push({\n id: 'profiling',\n prompt: `Do you want to enable ${chalk.bold(\n 'Profiling',\n )} to analyze CPU usage and optimize performance-critical code on iOS & macOS?`,\n enabledHint: 'recommended, tracing must be enabled',\n });\n }\n features.push({\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Session Replay',\n )} to record user interactions and debug issues?`,\n enabledHint: 'recommended',\n });\n\n const selectedFeatures = await featureSelectionPrompt(features);\n const normalizedSelectedFeatures = {\n tracing: selectedFeatures.tracing ?? false,\n profiling: selectedFeatures.profiling ?? false,\n replay: selectedFeatures.replay ?? false,\n };\n mainContent = patchMainContent(\n dsn,\n mainContent,\n normalizedSelectedFeatures,\n );\n\n if (normalizedSelectedFeatures.replay) {\n clack.log.info(\n `Session Replay will be enabled with default settings (replaysSessionSampleRate: ${sessionReplaySampleRate}, replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate}).`,\n );\n clack.log.message(\n 'By default, all text content, images, and webviews will be masked for privacy. You can customize this in your code later.',\n );\n }\n\n fs.writeFileSync(mainFile, mainContent, 'utf8');\n\n clack.log.success(\n chalk.greenBright(\n `Patched ${chalk.bold(\n 'main.dart',\n )} with the Sentry setup and test error snippet.`,\n ),\n );\n\n return true;\n } catch (error) {\n clack.log.warn(`Failed to read/write ${chalk.cyan('main.dart')} file.`);\n Sentry.captureException(error);\n return false;\n }\n}\n\nexport function patchMainContent(\n dsn: string,\n mainContent: string,\n selectedFeatures: {\n tracing: boolean;\n profiling: boolean;\n replay: boolean;\n },\n): string {\n const importIndex = getLastImportLineLocation(mainContent);\n mainContent =\n mainContent.slice(0, importIndex) +\n sentryImport +\n mainContent.slice(importIndex);\n\n // Find and replace `runApp(...)`\n mainContent = mainContent.replace(\n /runApp\\(([\\s\\S]*?)\\);/g, // Match the `runApp(...)` invocation\n (_, runAppArgs) => initSnippet(dsn, selectedFeatures, runAppArgs as string),\n );\n\n // Make the `main` function async if it's not already\n mainContent = mainContent.replace(\n /void\\s+main\\(\\)\\s*\\{/g,\n 'Future<void> main() async {',\n );\n\n return mainContent;\n}\n\nexport function getLastImportLineLocation(sourceCode: string): number {\n const importRegex = /import\\s+['\"].*['\"].*;/gim;\n return getLastReqExpLocation(sourceCode, importRegex);\n}\n\nexport function getDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\nexport function getDevDependenciesLocation(sourceCode: string): number {\n const dependencyRegex = /^dev_dependencies:\\s*$/gim;\n return getLastReqExpLocation(sourceCode, dependencyRegex);\n}\n\n// Helper\n\nfunction getLastReqExpLocation(sourceCode: string, regExp: RegExp): number {\n let match = regExp.exec(sourceCode);\n let importIndex = 0;\n while (match) {\n importIndex = match.index + match[0].length + 1;\n match = regExp.exec(sourceCode);\n }\n return importIndex;\n}\n"]}
@@ -1,9 +1,12 @@
1
1
  export declare const sentryImport = "import 'package:sentry_flutter/sentry_flutter.dart';\n";
2
+ export declare const sessionReplaySampleRate = 0.1;
3
+ export declare const sessionReplayOnErrorSampleRate = 1;
2
4
  export declare function pubspecOptions(project: string, org: string): string;
3
5
  export declare function sentryProperties(authToken: string): string;
4
6
  export declare function initSnippet(dsn: string, selectedFeaturesMap: {
5
7
  tracing: boolean;
6
8
  profiling: boolean;
9
+ replay: boolean;
7
10
  }, runApp: string): string;
8
11
  export declare function pubspecSnippetColored(sentryVersion: string, pluginVersion: string, project: string, org: string): string;
9
12
  export declare function initSnippetColored(dsn: string): string;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initSnippetColored = exports.pubspecSnippetColored = exports.initSnippet = exports.sentryProperties = exports.pubspecOptions = exports.sentryImport = void 0;
3
+ exports.initSnippetColored = exports.pubspecSnippetColored = exports.initSnippet = exports.sentryProperties = exports.pubspecOptions = exports.sessionReplayOnErrorSampleRate = exports.sessionReplaySampleRate = exports.sentryImport = void 0;
4
4
  const clack_1 = require("../utils/clack");
5
5
  exports.sentryImport = `import 'package:sentry_flutter/sentry_flutter.dart';\n`;
6
+ exports.sessionReplaySampleRate = 0.1;
7
+ exports.sessionReplayOnErrorSampleRate = 1.0;
6
8
  function pubspecOptions(project, org) {
7
9
  return `sentry:
8
10
  upload_debug_symbols: true
@@ -35,6 +37,16 @@ function initSnippet(dsn, selectedFeaturesMap, runApp) {
35
37
  // Setting to 1.0 will profile 100% of sampled transactions:
36
38
  options.profilesSampleRate = 1.0;`;
37
39
  }
40
+ if (selectedFeaturesMap.replay) {
41
+ snippet += `
42
+ // Configure Session Replay
43
+ options.replay.sessionSampleRate = ${exports.sessionReplaySampleRate % 1 === 0
44
+ ? `${exports.sessionReplaySampleRate}.0`
45
+ : exports.sessionReplaySampleRate};
46
+ options.replay.onErrorSampleRate = ${exports.sessionReplayOnErrorSampleRate % 1 === 0
47
+ ? `${exports.sessionReplayOnErrorSampleRate}.0`
48
+ : exports.sessionReplayOnErrorSampleRate};`;
49
+ }
38
50
  snippet += `
39
51
  },
40
52
  appRunner: () => runApp(SentryWidget(child: ${runApp})),
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/flutter/templates.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AAEpC,QAAA,YAAY,GAAG,wDAAwD,CAAC;AAErF,SAAgB,cAAc,CAAC,OAAe,EAAE,GAAW;IACzD,OAAO;;;aAGI,OAAO;SACX,GAAG;CACX,CAAC;AACF,CAAC;AAPD,wCAOC;AAED,SAAgB,gBAAgB,CAAC,SAAiB;IAChD,OAAO,cAAc,SAAS,EAAE,CAAC;AACnC,CAAC;AAFD,4CAEC;AAED,SAAgB,WAAW,CACzB,GAAW,EACX,mBAGC,EACD,MAAc;IAEd,IAAI,OAAO,GAAG;;uBAEO,GAAG;;;qCAGW,CAAC;IAEpC,IAAI,mBAAmB,CAAC,OAAO,EAAE;QAC/B,OAAO,IAAI;;;sCAGuB,CAAC;KACpC;IAED,IAAI,mBAAmB,CAAC,SAAS,IAAI,mBAAmB,CAAC,OAAO,EAAE;QAChE,OAAO,IAAI;;;wCAGyB,CAAC;KACtC;IAED,OAAO,IAAI;;kDAEqC,MAAM;;;4EAGoB,CAAC;IAE3E,OAAO,OAAO,CAAC;AACjB,CAAC;AArCD,kCAqCC;AAED,SAAgB,qBAAqB,CACnC,aAAqB,EACrB,aAAqB,EACrB,OAAe,EACf,GAAW;IAEX,MAAM,OAAO,GAAG;oBACE,aAAa;;;wBAGT,aAAa;;EAEnC,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;IAE/B,OAAO,IAAA,uBAAe,EAAC,IAAI,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,sDAiBC;AAED,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,MAAM,OAAO,GAAG;;;;;uBAKK,GAAG;;;;;;;;;;EAUxB,CAAC;IACD,OAAO,IAAA,uBAAe,EAAC,IAAI,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC;AApBD,gDAoBC","sourcesContent":["import { makeCodeSnippet } from '../utils/clack';\n\nexport const sentryImport = `import 'package:sentry_flutter/sentry_flutter.dart';\\n`;\n\nexport function pubspecOptions(project: string, org: string): string {\n return `sentry:\n upload_debug_symbols: true\n upload_source_maps: true\n project: ${project}\n org: ${org}\n`;\n}\n\nexport function sentryProperties(authToken: string): string {\n return `auth_token=${authToken}`;\n}\n\nexport function initSnippet(\n dsn: string,\n selectedFeaturesMap: {\n tracing: boolean;\n profiling: boolean;\n },\n runApp: string,\n): string {\n let snippet = `await SentryFlutter.init(\n (options) {\n options.dsn = '${dsn}';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;`;\n\n if (selectedFeaturesMap.tracing) {\n snippet += `\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0;`;\n }\n\n if (selectedFeaturesMap.profiling && selectedFeaturesMap.tracing) {\n snippet += `\n // The sampling rate for profiling is relative to tracesSampleRate\n // Setting to 1.0 will profile 100% of sampled transactions:\n options.profilesSampleRate = 1.0;`;\n }\n\n snippet += `\n },\n appRunner: () => runApp(SentryWidget(child: ${runApp})),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));`;\n\n return snippet;\n}\n\nexport function pubspecSnippetColored(\n sentryVersion: string,\n pluginVersion: string,\n project: string,\n org: string,\n): string {\n const snippet = `dependencies:\n sentry_flutter: ${sentryVersion}\n\ndev_dependencies:\n sentry_dart_plugin: ${pluginVersion}\n \n${pubspecOptions(project, org)}`;\n\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(snippet);\n });\n}\n\nexport function initSnippetColored(dsn: string): string {\n const snippet = `import 'package:sentry_flutter/sentry_flutter.dart';\n\nFuture<void>main() async {\n await SentryFlutter.init(\n (options) {\n options.dsn = '${dsn}';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0;\n },\n appRunner: () => runApp(SentryWidget(child: YourApp())),\n )\n}`;\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(snippet);\n });\n}\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/flutter/templates.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AAEpC,QAAA,YAAY,GAAG,wDAAwD,CAAC;AACxE,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAC9B,QAAA,8BAA8B,GAAG,GAAG,CAAC;AAElD,SAAgB,cAAc,CAAC,OAAe,EAAE,GAAW;IACzD,OAAO;;;aAGI,OAAO;SACX,GAAG;CACX,CAAC;AACF,CAAC;AAPD,wCAOC;AAED,SAAgB,gBAAgB,CAAC,SAAiB;IAChD,OAAO,cAAc,SAAS,EAAE,CAAC;AACnC,CAAC;AAFD,4CAEC;AAED,SAAgB,WAAW,CACzB,GAAW,EACX,mBAIC,EACD,MAAc;IAEd,IAAI,OA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CAAC;AApBD,gDAoBC","sourcesContent":["import { makeCodeSnippet } from '../utils/clack';\n\nexport const sentryImport = `import 'package:sentry_flutter/sentry_flutter.dart';\\n`;\nexport const sessionReplaySampleRate = 0.1;\nexport const sessionReplayOnErrorSampleRate = 1.0;\n\nexport function pubspecOptions(project: string, org: string): string {\n return `sentry:\n upload_debug_symbols: true\n upload_source_maps: true\n project: ${project}\n org: ${org}\n`;\n}\n\nexport function sentryProperties(authToken: string): string {\n return `auth_token=${authToken}`;\n}\n\nexport function initSnippet(\n dsn: string,\n selectedFeaturesMap: {\n tracing: boolean;\n profiling: boolean;\n replay: boolean;\n },\n runApp: string,\n): string {\n let snippet = `await SentryFlutter.init(\n (options) {\n options.dsn = '${dsn}';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;`;\n\n if (selectedFeaturesMap.tracing) {\n snippet += `\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0;`;\n }\n\n if (selectedFeaturesMap.profiling && selectedFeaturesMap.tracing) {\n snippet += `\n // The sampling rate for profiling is relative to tracesSampleRate\n // Setting to 1.0 will profile 100% of sampled transactions:\n options.profilesSampleRate = 1.0;`;\n }\n\n if (selectedFeaturesMap.replay) {\n snippet += `\n // Configure Session Replay\n options.replay.sessionSampleRate = ${\n sessionReplaySampleRate % 1 === 0\n ? `${sessionReplaySampleRate}.0`\n : sessionReplaySampleRate\n };\n options.replay.onErrorSampleRate = ${\n sessionReplayOnErrorSampleRate % 1 === 0\n ? `${sessionReplayOnErrorSampleRate}.0`\n : sessionReplayOnErrorSampleRate\n };`;\n }\n\n snippet += `\n },\n appRunner: () => runApp(SentryWidget(child: ${runApp})),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));`;\n\n return snippet;\n}\n\nexport function pubspecSnippetColored(\n sentryVersion: string,\n pluginVersion: string,\n project: string,\n org: string,\n): string {\n const snippet = `dependencies:\n sentry_flutter: ${sentryVersion}\n\ndev_dependencies:\n sentry_dart_plugin: ${pluginVersion}\n \n${pubspecOptions(project, org)}`;\n\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(snippet);\n });\n}\n\nexport function initSnippetColored(dsn: string): string {\n const snippet = `import 'package:sentry_flutter/sentry_flutter.dart';\n\nFuture<void>main() async {\n await SentryFlutter.init(\n (options) {\n options.dsn = '${dsn}';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0;\n },\n appRunner: () => runApp(SentryWidget(child: YourApp())),\n )\n}`;\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(snippet);\n });\n}\n"]}
@@ -105,8 +105,9 @@ async function runNextjsWizardWithTelemetry(options) {
105
105
  ? '_error.js'
106
106
  : undefined;
107
107
  if (!underscoreErrorPageFile) {
108
- await fs.promises.writeFile(path.join(process.cwd(), ...pagesLocation, '_error.jsx'), (0, templates_1.getSentryDefaultUnderscoreErrorPage)(), { encoding: 'utf8', flag: 'w' });
109
- prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...pagesLocation, '_error.jsx'))}.`);
108
+ const underscoreErrorFileName = `_error.${typeScriptDetected ? 'tsx' : 'jsx'}`;
109
+ await fs.promises.writeFile(path.join(process.cwd(), ...pagesLocation, underscoreErrorFileName), (0, templates_1.getSentryDefaultUnderscoreErrorPage)(), { encoding: 'utf8', flag: 'w' });
110
+ prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...pagesLocation, underscoreErrorFileName))}.`);
110
111
  }
111
112
  else if (fs
112
113
  .readFileSync(path.join(process.cwd(), ...pagesLocation, underscoreErrorPageFile), 'utf8')
@@ -196,7 +197,7 @@ async function runNextjsWizardWithTelemetry(options) {
196
197
  });
197
198
  const shouldCreateExamplePage = await (0, clack_1.askShouldCreateExamplePage)();
198
199
  if (shouldCreateExamplePage) {
199
- await (0, telemetry_1.traceStep)('create-example-page', async () => createExamplePage(selfHosted, selectedProject, sentryUrl));
200
+ await (0, telemetry_1.traceStep)('create-example-page', async () => createExamplePage(selfHosted, selectedProject, sentryUrl, typeScriptDetected));
200
201
  }
201
202
  await (0, clack_1.addDotEnvSentryBuildPluginFile)(authToken);
202
203
  const isLikelyUsingTurbopack = await checkIfLikelyIsUsingTurbopack();
@@ -546,14 +547,13 @@ function hasDirectoryPathFromRoot(dirnameOrDirs) {
546
547
  : path.join(process.cwd(), dirnameOrDirs);
547
548
  return fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory();
548
549
  }
549
- async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
550
+ async function createExamplePage(selfHosted, selectedProject, sentryUrl, typeScriptDetected) {
550
551
  const hasSrcDirectory = hasDirectoryPathFromRoot('src');
551
552
  const hasRootAppDirectory = hasDirectoryPathFromRoot('app');
552
553
  const hasRootPagesDirectory = hasDirectoryPathFromRoot('pages');
553
554
  const hasSrcAppDirectory = hasDirectoryPathFromRoot(['src', 'app']);
554
555
  const hasSrcPagesDirectory = hasDirectoryPathFromRoot(['src', 'pages']);
555
556
  Sentry.setTag('nextjs-app-dir', hasRootAppDirectory || hasSrcAppDirectory);
556
- const typeScriptDetected = (0, clack_1.isUsingTypeScript)();
557
557
  // If `pages` or an `app` directory exists in the root, we'll put the example page there.
558
558
  // `app` directory takes priority over `pages` directory when they coexist, so we prioritize that.
559
559
  // https://nextjs.org/docs/app/building-your-application/routing#the-app-router
@@ -593,6 +593,7 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
593
593
  projectId: selectedProject.id,
594
594
  sentryUrl,
595
595
  useClient: true,
596
+ isTypeScript: typeScriptDetected,
596
597
  });
597
598
  fs.mkdirSync(path.join(appFolderPath, 'sentry-example-page'), {
598
599
  recursive: true,
@@ -604,7 +605,7 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
604
605
  recursive: true,
605
606
  });
606
607
  const newRouteFileName = `route.${typeScriptDetected ? 'ts' : 'js'}`;
607
- await fs.promises.writeFile(path.join(appFolderPath, 'api', 'sentry-example-api', newRouteFileName), (0, templates_1.getSentryExampleAppDirApiRoute)(), { encoding: 'utf8', flag: 'w' });
608
+ await fs.promises.writeFile(path.join(appFolderPath, 'api', 'sentry-example-api', newRouteFileName), (0, templates_1.getSentryExampleAppDirApiRoute)({ isTypeScript: typeScriptDetected }), { encoding: 'utf8', flag: 'w' });
608
609
  prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...appFolderLocation, 'api', 'sentry-example-api', newRouteFileName))}.`);
609
610
  }
610
611
  else if (pagesFolderLocation) {
@@ -614,14 +615,17 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
614
615
  projectId: selectedProject.id,
615
616
  sentryUrl,
616
617
  useClient: false,
618
+ isTypeScript: typeScriptDetected,
617
619
  });
618
- await fs.promises.writeFile(path.join(process.cwd(), ...pagesFolderLocation, 'sentry-example-page.jsx'), examplePageContents, { encoding: 'utf8', flag: 'w' });
619
- prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...pagesFolderLocation, 'sentry-example-page.js'))}.`);
620
+ const examplePageFileName = `sentry-example-page.${typeScriptDetected ? 'tsx' : 'jsx'}`;
621
+ await fs.promises.writeFile(path.join(process.cwd(), ...pagesFolderLocation, examplePageFileName), examplePageContents, { encoding: 'utf8', flag: 'w' });
622
+ prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...pagesFolderLocation, examplePageFileName))}.`);
620
623
  fs.mkdirSync(path.join(process.cwd(), ...pagesFolderLocation, 'api'), {
621
624
  recursive: true,
622
625
  });
623
- await fs.promises.writeFile(path.join(process.cwd(), ...pagesFolderLocation, 'api', 'sentry-example-api.js'), (0, templates_1.getSentryExamplePagesDirApiRoute)(), { encoding: 'utf8', flag: 'w' });
624
- prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...pagesFolderLocation, 'api', 'sentry-example-api.js'))}.`);
626
+ const apiRouteFileName = `sentry-example-api.${typeScriptDetected ? 'ts' : 'js'}`;
627
+ await fs.promises.writeFile(path.join(process.cwd(), ...pagesFolderLocation, 'api', apiRouteFileName), (0, templates_1.getSentryExamplePagesDirApiRoute)({ isTypeScript: typeScriptDetected }), { encoding: 'utf8', flag: 'w' });
628
+ prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...pagesFolderLocation, 'api', apiRouteFileName))}.`);
625
629
  }
626
630
  }
627
631
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"nextjs-wizard.js","sourceRoot":"","sources":["../../../src/nextjs/nextjs-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,uCAAyB;AACzB,kFAAkF;AAClF,uCAA+D;AAC/D,2CAA6B;AAE7B,qDAAuC;AAEvC,uEAA0D;AAC1D,4CAAwD;AACxD,0CAiBwB;AACxB,wDAA+E;AAE/E,2CAsBqB;AACrB,mCAIiB;AAEjB,SAAgB,eAAe,CAAC,OAAsB;IACpD,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,QAAQ;QACrB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAC5C,CAAC;AACJ,CAAC;AATD,0CASC;AAEM,KAAK,UAAU,4BAA4B,CAChD,OAAsB;IAEtB,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE9D,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,uBAAuB;QACnC,SAAS;QACT,gBAAgB;KACjB,CAAC,C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EAAE,IAAI;oBACX,IAAI,EAAE,gDAAgD;iBACvD;gBACD;oBACE,KAAK,EAAE,IAAI;oBACX,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,uFAAuF;iBAC9F;aACF;YACD,YAAY,EAAE,IAAI;SACnB,CAAC,CACH,CAAC;QAEF,IAAI,CAAC,oBAAoB,EAAE;YACzB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,0EAA0E,CAC3E,CAAC;SACH;QAED,IAAI,EAAE,YAAY,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;QACxD,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;QAEnD,OAAO,oBAAoB,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,6BAA6B;IAC1C,IAAI,kBAA0B,CAAC;IAC/B,IAAI;QACF,kBAAkB,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAC7C,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,EACxC,MAAM,CACP,CAAC;KACH;IAAC,MAAM;QACN,OAAO,IAAI,CAAC;KACb;IAED,OAAO,kBAAkB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAChD,CAAC","sourcesContent":["/* eslint-disable max-lines */\n// @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 fs from 'fs';\n// @ts-expect-error - 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 { setupCI } from '../sourcemaps/sourcemaps-wizard';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abort,\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n createNewConfigFile,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n getPackageManager,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n runPrettierIfInstalled,\n showCopyPasteInstructions,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport type { SentryProjectData, WizardOptions } from '../utils/types';\nimport {\n getFullUnderscoreErrorCopyPasteSnippet,\n getGlobalErrorCopyPasteSnippet,\n getInstrumentationHookContent,\n getInstrumentationHookCopyPasteSnippet,\n getNextjsConfigCjsAppendix,\n getNextjsConfigCjsTemplate,\n getNextjsConfigEsmCopyPasteSnippet,\n getNextjsConfigMjsTemplate,\n getRootLayout,\n getSentryServersideConfigContents,\n getInstrumentationClientFileContents,\n getSentryDefaultGlobalErrorPage,\n getSentryDefaultUnderscoreErrorPage,\n getSentryExampleAppDirApiRoute,\n getSentryExamplePageContents,\n getSentryExamplePagesDirApiRoute,\n getSimpleUnderscoreErrorCopyPasteSnippet,\n getWithSentryConfigOptionsTemplate,\n getInstrumentationClientHookCopyPasteSnippet,\n getRootLayoutWithGenerateMetadata,\n getGenerateMetadataSnippet,\n} from './templates';\nimport {\n getMaybeAppDirLocation,\n getNextJsVersionBucket,\n hasRootLayoutFile,\n} from './utils';\n\nexport function runNextjsWizard(options: WizardOptions) {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'nextjs',\n wizardOptions: options,\n },\n () => runNextjsWizardWithTelemetry(options),\n );\n}\n\nexport async function runNextjsWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Next.js Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n const typeScriptDetected = isUsingTypeScript();\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\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 const { packageManager: packageManagerFromInstallStep } =\n await installPackage({\n packageName: '@sentry/nextjs@latest',\n packageNameDisplayLabel: '@sentry/nextjs',\n alreadyInstalled: !!packageJson?.dependencies?.['@sentry/nextjs'],\n forceInstall,\n });\n\n await traceStep('configure-sdk', async () => {\n const tunnelRoute = await askShouldSetTunnelRoute();\n\n await createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, {\n tunnelRoute,\n });\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 you 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 appDirLocation = getMaybeAppDirLocation();\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 const newGlobalErrorFileName = `global-error.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), ...appDirLocation, newGlobalErrorFileName),\n getSentryDefaultGlobalErrorPage(typeScriptDetected),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appDirLocation, newGlobalErrorFileName),\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\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 you 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 await traceStep('add-generate-metadata-function', async () => {\n const isNext14 = getNextJsVersionBucket(nextVersion) === '14.x';\n const appDirLocation = getMaybeAppDirLocation();\n\n // We only need this specific change for app router on next@14\n if (!appDirLocation || !isNext14) {\n return;\n }\n\n const appDirPath = path.join(process.cwd(), ...appDirLocation);\n const hasRootLayout = hasRootLayoutFile(appDirPath);\n\n if (!hasRootLayout) {\n const newRootLayoutFilename = `layout.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n\n await fs.promises.writeFile(\n path.join(appDirPath, newRootLayoutFilename),\n getRootLayoutWithGenerateMetadata(typeScriptDetected),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appDirLocation, newRootLayoutFilename),\n )}.`,\n );\n } else {\n clack.log.info(\n `It seems like you already have a root layout component. Please add or modify your generateMetadata function.`,\n );\n\n await showCopyPasteInstructions({\n filename: `layout.${typeScriptDetected ? 'tsx' : 'jsx'}`,\n codeSnippet: getGenerateMetadataSnippet(typeScriptDetected),\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 addDotEnvSentryBuildPluginFile(authToken);\n\n const isLikelyUsingTurbopack = await checkIfLikelyIsUsingTurbopack();\n if (isLikelyUsingTurbopack || isLikelyUsingTurbopack === null) {\n await abortIfCancelled(\n clack.select({\n message: `Warning: The Sentry SDK is only compatible with Turbopack on Next.js version 15.3.0 (or 15.3.0-canary.8) or later. ${chalk.bold(\n `If you are using Turbopack with an older Next.js version, temporarily remove \\`--turbo\\` or \\`--turbopack\\` from your dev command until you have verified the SDK is working as expected. Note that the SDK will continue to work for non-Turbopack production builds.`,\n )}`,\n options: [\n {\n label: 'I understand.',\n hint: 'press enter',\n value: true,\n },\n ],\n initialValue: true,\n }),\n );\n }\n\n const mightBeUsingVercel = fs.existsSync(\n path.join(process.cwd(), 'vercel.json'),\n );\n\n if (mightBeUsingVercel && !options.comingFrom) {\n clack.log.info(\n \"▲ It seems like you're using Vercel. We recommend using the Sentry Vercel \\\n integration to set up an auth token for Vercel deployments: https://vercel.com/integrations/sentry\",\n );\n } else {\n await setupCI('nextjs', authToken, options.comingFrom);\n }\n\n const packageManagerForOutro =\n packageManagerFromInstallStep ?? (await getPackageManager());\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n clack.outro(`\n${chalk.green('Successfully installed the Sentry Next.js SDK!')} ${\n shouldCreateExamplePage\n ? `\\n\\nYou can validate your setup by (re)starting your dev environment (e.g. ${chalk.cyan(\n `${packageManagerForOutro.runScriptCommand} dev`,\n )}) and visiting ${chalk.cyan('\"/sentry-example-page\"')}`\n : ''\n }${\n shouldCreateExamplePage && isLikelyUsingTurbopack\n ? `\\nDon't forget to remove \\`--turbo\\` or \\`--turbopack\\` from your dev command until you have verified the SDK is working. You can safely add it back afterwards.`\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\ntype SDKConfigOptions = {\n tunnelRoute: boolean;\n};\n\nasync function createOrMergeNextJsFiles(\n selectedProject: SentryProjectData,\n selfHosted: boolean,\n sentryUrl: string,\n sdkConfigOptions: SDKConfigOptions,\n) {\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', '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 getSentryServersideConfigContents(\n selectedProject.keys[0].dsn.public,\n configVariant,\n selectedFeatures,\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 await traceStep('setup-instrumentation-hook', async () => {\n const hasRootAppDirectory = hasDirectoryPathFromRoot('app');\n const hasRootPagesDirectory = hasDirectoryPathFromRoot('pages');\n const hasSrcDirectory = hasDirectoryPathFromRoot('src');\n\n let instrumentationHookLocation: 'src' | 'root' | 'does-not-exist';\n\n const instrumentationTsExists = fs.existsSync(\n path.join(process.cwd(), 'instrumentation.ts'),\n );\n const instrumentationJsExists = fs.existsSync(\n path.join(process.cwd(), 'instrumentation.js'),\n );\n const srcInstrumentationTsExists = fs.existsSync(\n path.join(process.cwd(), 'src', 'instrumentation.ts'),\n );\n const srcInstrumentationJsExists = fs.existsSync(\n path.join(process.cwd(), 'src', 'instrumentation.js'),\n );\n\n // https://nextjs.org/docs/app/building-your-application/configuring/src-directory\n // https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation\n // The logic for where Next.js picks up the instrumentation file is as follows:\n // - If there is either an `app` folder or a `pages` folder in the root directory of your Next.js app, Next.js looks\n // for an `instrumentation.ts` file in the root of the Next.js app.\n // - Otherwise, if there is neither an `app` folder or a `pages` folder in the rood directory of your Next.js app,\n // AND if there is an `src` folder, Next.js will look for the `instrumentation.ts` file in the `src` folder.\n if (hasRootPagesDirectory || hasRootAppDirectory) {\n if (instrumentationJsExists || instrumentationTsExists) {\n instrumentationHookLocation = 'root';\n } else {\n instrumentationHookLocation = 'does-not-exist';\n }\n } else {\n if (srcInstrumentationTsExists || srcInstrumentationJsExists) {\n instrumentationHookLocation = 'src';\n } else {\n instrumentationHookLocation = 'does-not-exist';\n }\n }\n\n const newInstrumentationFileName = `instrumentation.${\n typeScriptDetected ? 'ts' : 'js'\n }`;\n\n if (instrumentationHookLocation === 'does-not-exist') {\n let newInstrumentationHookLocation: 'root' | 'src';\n if (hasRootPagesDirectory || hasRootAppDirectory) {\n newInstrumentationHookLocation = 'root';\n } else if (hasSrcDirectory) {\n newInstrumentationHookLocation = 'src';\n } else {\n newInstrumentationHookLocation = 'root';\n }\n\n const newInstrumentationHookPath =\n newInstrumentationHookLocation === 'root'\n ? path.join(process.cwd(), newInstrumentationFileName)\n : path.join(process.cwd(), 'src', newInstrumentationFileName);\n\n const successfullyCreated = await createNewConfigFile(\n newInstrumentationHookPath,\n getInstrumentationHookContent(newInstrumentationHookLocation),\n );\n\n if (!successfullyCreated) {\n await showCopyPasteInstructions({\n filename: newInstrumentationFileName,\n codeSnippet: getInstrumentationHookCopyPasteSnippet(\n newInstrumentationHookLocation,\n ),\n hint: \"create the file if it doesn't already exist\",\n });\n }\n } else {\n await showCopyPasteInstructions({\n filename:\n srcInstrumentationTsExists || instrumentationTsExists\n ? 'instrumentation.ts'\n : srcInstrumentationJsExists || instrumentationJsExists\n ? 'instrumentation.js'\n : newInstrumentationFileName,\n codeSnippet: getInstrumentationHookCopyPasteSnippet(\n instrumentationHookLocation,\n ),\n });\n }\n });\n\n await traceStep('setup-instrumentation-client-hook', async () => {\n const hasRootAppDirectory = hasDirectoryPathFromRoot('app');\n const hasRootPagesDirectory = hasDirectoryPathFromRoot('pages');\n const hasSrcDirectory = hasDirectoryPathFromRoot('src');\n\n let instrumentationClientHookLocation: 'src' | 'root' | 'does-not-exist';\n\n const instrumentationClientTsExists = fs.existsSync(\n path.join(process.cwd(), 'instrumentation-client.ts'),\n );\n const instrumentationClientJsExists = fs.existsSync(\n path.join(process.cwd(), 'instrumentation-client.js'),\n );\n const srcInstrumentationClientTsExists = fs.existsSync(\n path.join(process.cwd(), 'src', 'instrumentation-client.ts'),\n );\n const srcInstrumentationClientJsExists = fs.existsSync(\n path.join(process.cwd(), 'src', 'instrumentation-client.js'),\n );\n\n // https://nextjs.org/docs/app/building-your-application/configuring/src-directory\n // https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation\n // The logic for where Next.js picks up the instrumentation file is as follows:\n // - If there is either an `app` folder or a `pages` folder in the root directory of your Next.js app, Next.js looks\n // for an `instrumentation.ts` file in the root of the Next.js app.\n // - Otherwise, if there is neither an `app` folder or a `pages` folder in the rood directory of your Next.js app,\n // AND if there is an `src` folder, Next.js will look for the `instrumentation.ts` file in the `src` folder.\n if (hasRootPagesDirectory || hasRootAppDirectory) {\n if (instrumentationClientJsExists || instrumentationClientTsExists) {\n instrumentationClientHookLocation = 'root';\n } else {\n instrumentationClientHookLocation = 'does-not-exist';\n }\n } else {\n if (\n srcInstrumentationClientTsExists ||\n srcInstrumentationClientJsExists\n ) {\n instrumentationClientHookLocation = 'src';\n } else {\n instrumentationClientHookLocation = 'does-not-exist';\n }\n }\n\n const newInstrumentationClientFileName = `instrumentation-client.${\n typeScriptDetected ? 'ts' : 'js'\n }`;\n\n if (instrumentationClientHookLocation === 'does-not-exist') {\n let newInstrumentationClientHookLocation: 'root' | 'src';\n if (hasRootPagesDirectory || hasRootAppDirectory) {\n newInstrumentationClientHookLocation = 'root';\n } else if (hasSrcDirectory) {\n newInstrumentationClientHookLocation = 'src';\n } else {\n newInstrumentationClientHookLocation = 'root';\n }\n\n const newInstrumentationClientHookPath =\n newInstrumentationClientHookLocation === 'root'\n ? path.join(process.cwd(), newInstrumentationClientFileName)\n : path.join(process.cwd(), 'src', newInstrumentationClientFileName);\n\n const successfullyCreated = await createNewConfigFile(\n newInstrumentationClientHookPath,\n getInstrumentationClientFileContents(\n selectedProject.keys[0].dsn.public,\n selectedFeatures,\n ),\n );\n\n if (!successfullyCreated) {\n await showCopyPasteInstructions({\n filename: newInstrumentationClientFileName,\n codeSnippet: getInstrumentationClientHookCopyPasteSnippet(\n selectedProject.keys[0].dsn.public,\n selectedFeatures,\n ),\n hint: \"create the file if it doesn't already exist\",\n });\n }\n } else {\n await showCopyPasteInstructions({\n filename:\n srcInstrumentationClientTsExists || instrumentationClientTsExists\n ? 'instrumentation-client.ts'\n : srcInstrumentationClientJsExists || instrumentationClientJsExists\n ? 'instrumentation-client.js'\n : newInstrumentationClientFileName,\n codeSnippet: getInstrumentationClientHookCopyPasteSnippet(\n selectedProject.keys[0].dsn.public,\n selectedFeatures,\n ),\n });\n }\n });\n\n await traceStep('setup-next-config', async () => {\n const withSentryConfigOptionsTemplate = getWithSentryConfigOptionsTemplate({\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n selfHosted,\n sentryUrl,\n tunnelRoute: sdkConfigOptions.tunnelRoute,\n });\n\n const nextConfigPossibleFilesMap = {\n js: 'next.config.js',\n mjs: 'next.config.mjs',\n cjs: 'next.config.cjs',\n ts: 'next.config.ts',\n mts: 'next.config.mts',\n cts: 'next.config.cts',\n };\n\n const foundNextConfigFile = Object.entries(nextConfigPossibleFilesMap).find(\n ([, fileName]) => fs.existsSync(path.join(process.cwd(), fileName)),\n );\n\n if (!foundNextConfigFile) {\n Sentry.setTag('next-config-strategy', 'create');\n\n // Try to figure out whether the user prefers ESM\n let isTypeModule = false;\n try {\n const packageJsonText = await fs.promises.readFile(\n path.join(process.cwd(), 'package.json'),\n 'utf8',\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const packageJson = JSON.parse(packageJsonText);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (packageJson.type === 'module') {\n isTypeModule = true;\n }\n } catch {\n // noop\n }\n\n // We are creating `next.config.(m)js` files by default as they are supported by the most Next.js versions\n const configFilename = isTypeModule\n ? nextConfigPossibleFilesMap.mjs\n : nextConfigPossibleFilesMap.js;\n const configContent = isTypeModule\n ? getNextjsConfigMjsTemplate(withSentryConfigOptionsTemplate)\n : getNextjsConfigCjsTemplate(withSentryConfigOptionsTemplate);\n\n await fs.promises.writeFile(\n path.join(process.cwd(), configFilename),\n configContent,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(configFilename)} with Sentry configuration.`,\n );\n\n return;\n }\n\n const [foundNextConfigFileType, foundNextConfigFileFilename] =\n foundNextConfigFile;\n\n if (foundNextConfigFileType === 'js' || foundNextConfigFileType === 'cjs') {\n Sentry.setTag('next-config-strategy', 'modify');\n\n const nextConfigCjsContent = fs.readFileSync(\n path.join(process.cwd(), foundNextConfigFileFilename),\n 'utf8',\n );\n\n const probablyIncludesSdk =\n nextConfigCjsContent.includes('@sentry/nextjs') &&\n nextConfigCjsContent.includes('withSentryConfig');\n\n let shouldInject = true;\n\n if (probablyIncludesSdk) {\n const injectAnyhow = await abortIfCancelled(\n clack.confirm({\n message: `${chalk.cyan(\n foundNextConfigFileFilename,\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(), foundNextConfigFileFilename),\n getNextjsConfigCjsAppendix(withSentryConfigOptionsTemplate),\n 'utf8',\n );\n\n clack.log.success(\n `Added Sentry configuration to ${chalk.cyan(\n foundNextConfigFileFilename,\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 (\n foundNextConfigFileType === 'mjs' ||\n foundNextConfigFileType === 'mts' ||\n foundNextConfigFileType === 'cts' ||\n foundNextConfigFileType === 'ts'\n ) {\n const nextConfigMjsContent = fs.readFileSync(\n path.join(process.cwd(), foundNextConfigFileFilename),\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 foundNextConfigFileFilename,\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 ${withSentryConfigOptionsTemplate}\n)`);\n const newCode = mod.generate().code;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), foundNextConfigFileFilename),\n newCode,\n {\n encoding: 'utf8',\n flag: 'w',\n },\n );\n clack.log.success(\n `Added Sentry configuration to ${chalk.cyan(\n foundNextConfigFileFilename,\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(\n foundNextConfigFileFilename,\n )}.`,\n ),\n );\n clack.log.info(\n `Please put the following code snippet into ${chalk.cyan(\n foundNextConfigFileFilename,\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(withSentryConfigOptionsTemplate),\n );\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Are you done putting the snippet above into ${chalk.cyan(\n foundNextConfigFileFilename,\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\nfunction hasDirectoryPathFromRoot(dirnameOrDirs: string | string[]): boolean {\n const dirPath = Array.isArray(dirnameOrDirs)\n ? path.join(process.cwd(), ...dirnameOrDirs)\n : path.join(process.cwd(), dirnameOrDirs);\n\n return fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory();\n}\n\nasync function createExamplePage(\n selfHosted: boolean,\n selectedProject: SentryProjectData,\n sentryUrl: string,\n): Promise<void> {\n const hasSrcDirectory = hasDirectoryPathFromRoot('src');\n const hasRootAppDirectory = hasDirectoryPathFromRoot('app');\n const hasRootPagesDirectory = hasDirectoryPathFromRoot('pages');\n const hasSrcAppDirectory = hasDirectoryPathFromRoot(['src', 'app']);\n const hasSrcPagesDirectory = hasDirectoryPathFromRoot(['src', 'pages']);\n\n Sentry.setTag('nextjs-app-dir', hasRootAppDirectory || hasSrcAppDirectory);\n\n const typeScriptDetected = isUsingTypeScript();\n\n // If `pages` or an `app` directory exists in the root, we'll put the example page there.\n // `app` directory takes priority over `pages` directory when they coexist, so we prioritize that.\n // https://nextjs.org/docs/app/building-your-application/routing#the-app-router\n\n const appFolderLocation = hasRootAppDirectory\n ? ['app']\n : hasSrcAppDirectory\n ? ['src', 'app']\n : undefined;\n\n let pagesFolderLocation = hasRootPagesDirectory\n ? ['pages']\n : hasSrcPagesDirectory\n ? ['src', 'pages']\n : undefined;\n\n // If the user has neither pages nor app directory we create a pages folder for them\n if (!appFolderLocation && !pagesFolderLocation) {\n const newPagesFolderLocation = hasSrcDirectory\n ? ['src', 'pages']\n : ['pages'];\n fs.mkdirSync(path.join(process.cwd(), ...newPagesFolderLocation), {\n recursive: true,\n });\n\n pagesFolderLocation = newPagesFolderLocation;\n }\n\n if (appFolderLocation) {\n const appFolderPath = path.join(process.cwd(), ...appFolderLocation);\n\n const hasRootLayout = hasRootLayoutFile(appFolderPath);\n\n if (!hasRootLayout) {\n // In case no root layout file exists, we create a simple one so that\n // the example page can be rendered correctly.\n const newRootLayoutFilename = `layout.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n\n await fs.promises.writeFile(\n path.join(appFolderPath, newRootLayoutFilename),\n getRootLayout(typeScriptDetected),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appFolderLocation, newRootLayoutFilename),\n )}.`,\n );\n }\n\n const examplePageContents = getSentryExamplePageContents({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n sentryUrl,\n useClient: true,\n });\n\n fs.mkdirSync(path.join(appFolderPath, 'sentry-example-page'), {\n recursive: true,\n });\n\n const newPageFileName = `page.${typeScriptDetected ? 'tsx' : 'jsx'}`;\n\n await fs.promises.writeFile(\n path.join(appFolderPath, 'sentry-example-page', newPageFileName),\n examplePageContents,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appFolderLocation, 'sentry-example-page', newPageFileName),\n )}.`,\n );\n\n fs.mkdirSync(path.join(appFolderPath, 'api', 'sentry-example-api'), {\n recursive: true,\n });\n\n const newRouteFileName = `route.${typeScriptDetected ? 'ts' : 'js'}`;\n\n await fs.promises.writeFile(\n path.join(appFolderPath, 'api', 'sentry-example-api', newRouteFileName),\n getSentryExampleAppDirApiRoute(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(\n ...appFolderLocation,\n 'api',\n 'sentry-example-api',\n newRouteFileName,\n ),\n )}.`,\n );\n } else if (pagesFolderLocation) {\n const examplePageContents = getSentryExamplePageContents({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n sentryUrl,\n useClient: false,\n });\n\n await fs.promises.writeFile(\n path.join(\n process.cwd(),\n ...pagesFolderLocation,\n 'sentry-example-page.jsx',\n ),\n examplePageContents,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...pagesFolderLocation, 'sentry-example-page.js'),\n )}.`,\n );\n\n fs.mkdirSync(path.join(process.cwd(), ...pagesFolderLocation, 'api'), {\n recursive: true,\n });\n\n await fs.promises.writeFile(\n path.join(\n process.cwd(),\n ...pagesFolderLocation,\n 'api',\n 'sentry-example-api.js',\n ),\n getSentryExamplePagesDirApiRoute(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...pagesFolderLocation, 'api', 'sentry-example-api.js'),\n )}.`,\n );\n }\n}\n\n/**\n * Ask users if they want to set the tunnelRoute option.\n * We can't set this by default because it potentially increases hosting bills.\n * It's valuable enough to for users to justify asking the additional question.\n */\nasync function askShouldSetTunnelRoute() {\n return await traceStep('ask-tunnelRoute-option', async (span) => {\n const shouldSetTunnelRoute = await abortIfCancelled(\n clack.select({\n message:\n 'Do you want to route Sentry requests in the browser through your Next.js server to avoid ad blockers?',\n options: [\n {\n label: 'Yes',\n value: true,\n hint: 'Can increase your server load and hosting bill',\n },\n {\n label: 'No',\n value: false,\n hint: 'Browser errors and events might be blocked by ad blockers before being sent to Sentry',\n },\n ],\n initialValue: true,\n }),\n );\n\n if (!shouldSetTunnelRoute) {\n clack.log.info(\n \"Sounds good! We'll leave the option commented for later, just in case :)\",\n );\n }\n\n span?.setAttribute('tunnelRoute', shouldSetTunnelRoute);\n Sentry.setTag('tunnelRoute', shouldSetTunnelRoute);\n\n return shouldSetTunnelRoute;\n });\n}\n\n/**\n * Returns true or false depending on whether we think the user is using Turbopack. May return null in case we aren't sure.\n */\nasync function checkIfLikelyIsUsingTurbopack(): Promise<boolean | null> {\n let packageJsonContent: string;\n try {\n packageJsonContent = await fs.promises.readFile(\n path.join(process.cwd(), 'package.json'),\n 'utf8',\n );\n } catch {\n return null;\n }\n\n return packageJsonContent.includes('--turbo');\n}\n"]}
1
+ {"version":3,"file":"nextjs-wizard.js","sourceRoot":"","sources":["../../../src/nextjs/nextjs-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,uCAAyB;AACzB,kFAAkF;AAClF,uCAA+D;AAC/D,2CAA6B;AAE7B,qDAAuC;AAEvC,uEAA0D;AAC1D,4CAAwD;AACxD,0CAiBwB;AACxB,wDAA+E;AAE/E,2CAsBqB;AACrB,mCAIiB;AAEjB,SAAgB,eAAe,CAAC,OAAsB;IACpD,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,QAAQ;QACrB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAC5C,CAAC;AACJ,CAAC;AATD,0CASC;AAEM,KAAK,UAAU,4BAA4B,CAChD,OAAsB;IAEtB,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE9D,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,uBAAuB;QACnC,SAAS;QACT,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,IAAA,yBAAiB,GAAE,CAAC;IAE/C,MAAM,IAAA,yCAAiC,EAAC;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAE9C,MAAM,IAAA,gCAAwB,EAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAE/D,MAAM,WAAW,GAAG,IAAA,gC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AO,EACL,uGAAuG;YACzG,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,IAAI;oBACX,IAAI,EAAE,gDAAgD;iBACvD;gBACD;oBACE,KAAK,EAAE,IAAI;oBACX,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,uFAAuF;iBAC9F;aACF;YACD,YAAY,EAAE,IAAI;SACnB,CAAC,CACH,CAAC;QAEF,IAAI,CAAC,oBAAoB,EAAE;YACzB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,0EAA0E,CAC3E,CAAC;SACH;QAED,IAAI,EAAE,YAAY,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;QACxD,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;QAEnD,OAAO,oBAAoB,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,6BAA6B;IAC1C,IAAI,kBAA0B,CAAC;IAC/B,IAAI;QACF,kBAAkB,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAC7C,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,EACxC,MAAM,CACP,CAAC;KACH;IAAC,MAAM;QACN,OAAO,IAAI,CAAC;KACb;IAED,OAAO,kBAAkB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAChD,CAAC","sourcesContent":["/* eslint-disable max-lines */\n// @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 fs from 'fs';\n// @ts-expect-error - 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 { setupCI } from '../sourcemaps/sourcemaps-wizard';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abort,\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n createNewConfigFile,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n getPackageManager,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n runPrettierIfInstalled,\n showCopyPasteInstructions,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport type { SentryProjectData, WizardOptions } from '../utils/types';\nimport {\n getFullUnderscoreErrorCopyPasteSnippet,\n getGlobalErrorCopyPasteSnippet,\n getInstrumentationHookContent,\n getInstrumentationHookCopyPasteSnippet,\n getNextjsConfigCjsAppendix,\n getNextjsConfigCjsTemplate,\n getNextjsConfigEsmCopyPasteSnippet,\n getNextjsConfigMjsTemplate,\n getRootLayout,\n getSentryServersideConfigContents,\n getInstrumentationClientFileContents,\n getSentryDefaultGlobalErrorPage,\n getSentryDefaultUnderscoreErrorPage,\n getSentryExampleAppDirApiRoute,\n getSentryExamplePageContents,\n getSentryExamplePagesDirApiRoute,\n getSimpleUnderscoreErrorCopyPasteSnippet,\n getWithSentryConfigOptionsTemplate,\n getInstrumentationClientHookCopyPasteSnippet,\n getRootLayoutWithGenerateMetadata,\n getGenerateMetadataSnippet,\n} from './templates';\nimport {\n getMaybeAppDirLocation,\n getNextJsVersionBucket,\n hasRootLayoutFile,\n} from './utils';\n\nexport function runNextjsWizard(options: WizardOptions) {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'nextjs',\n wizardOptions: options,\n },\n () => runNextjsWizardWithTelemetry(options),\n );\n}\n\nexport async function runNextjsWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Next.js Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n const typeScriptDetected = isUsingTypeScript();\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\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 const { packageManager: packageManagerFromInstallStep } =\n await installPackage({\n packageName: '@sentry/nextjs@latest',\n packageNameDisplayLabel: '@sentry/nextjs',\n alreadyInstalled: !!packageJson?.dependencies?.['@sentry/nextjs'],\n forceInstall,\n });\n\n await traceStep('configure-sdk', async () => {\n const tunnelRoute = await askShouldSetTunnelRoute();\n\n await createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, {\n tunnelRoute,\n });\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 const underscoreErrorFileName = `_error.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), ...pagesLocation, underscoreErrorFileName),\n getSentryDefaultUnderscoreErrorPage(),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...pagesLocation, underscoreErrorFileName),\n )}.`,\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 you 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 appDirLocation = getMaybeAppDirLocation();\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 const newGlobalErrorFileName = `global-error.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), ...appDirLocation, newGlobalErrorFileName),\n getSentryDefaultGlobalErrorPage(typeScriptDetected),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appDirLocation, newGlobalErrorFileName),\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\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 you 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 await traceStep('add-generate-metadata-function', async () => {\n const isNext14 = getNextJsVersionBucket(nextVersion) === '14.x';\n const appDirLocation = getMaybeAppDirLocation();\n\n // We only need this specific change for app router on next@14\n if (!appDirLocation || !isNext14) {\n return;\n }\n\n const appDirPath = path.join(process.cwd(), ...appDirLocation);\n const hasRootLayout = hasRootLayoutFile(appDirPath);\n\n if (!hasRootLayout) {\n const newRootLayoutFilename = `layout.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n\n await fs.promises.writeFile(\n path.join(appDirPath, newRootLayoutFilename),\n getRootLayoutWithGenerateMetadata(typeScriptDetected),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appDirLocation, newRootLayoutFilename),\n )}.`,\n );\n } else {\n clack.log.info(\n `It seems like you already have a root layout component. Please add or modify your generateMetadata function.`,\n );\n\n await showCopyPasteInstructions({\n filename: `layout.${typeScriptDetected ? 'tsx' : 'jsx'}`,\n codeSnippet: getGenerateMetadataSnippet(typeScriptDetected),\n });\n }\n });\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage();\n if (shouldCreateExamplePage) {\n await traceStep('create-example-page', async () =>\n createExamplePage(\n selfHosted,\n selectedProject,\n sentryUrl,\n typeScriptDetected,\n ),\n );\n }\n\n await addDotEnvSentryBuildPluginFile(authToken);\n\n const isLikelyUsingTurbopack = await checkIfLikelyIsUsingTurbopack();\n if (isLikelyUsingTurbopack || isLikelyUsingTurbopack === null) {\n await abortIfCancelled(\n clack.select({\n message: `Warning: The Sentry SDK is only compatible with Turbopack on Next.js version 15.3.0 (or 15.3.0-canary.8) or later. ${chalk.bold(\n `If you are using Turbopack with an older Next.js version, temporarily remove \\`--turbo\\` or \\`--turbopack\\` from your dev command until you have verified the SDK is working as expected. Note that the SDK will continue to work for non-Turbopack production builds.`,\n )}`,\n options: [\n {\n label: 'I understand.',\n hint: 'press enter',\n value: true,\n },\n ],\n initialValue: true,\n }),\n );\n }\n\n const mightBeUsingVercel = fs.existsSync(\n path.join(process.cwd(), 'vercel.json'),\n );\n\n if (mightBeUsingVercel && !options.comingFrom) {\n clack.log.info(\n \"▲ It seems like you're using Vercel. We recommend using the Sentry Vercel \\\n integration to set up an auth token for Vercel deployments: https://vercel.com/integrations/sentry\",\n );\n } else {\n await setupCI('nextjs', authToken, options.comingFrom);\n }\n\n const packageManagerForOutro =\n packageManagerFromInstallStep ?? (await getPackageManager());\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n clack.outro(`\n${chalk.green('Successfully installed the Sentry Next.js SDK!')} ${\n shouldCreateExamplePage\n ? `\\n\\nYou can validate your setup by (re)starting your dev environment (e.g. ${chalk.cyan(\n `${packageManagerForOutro.runScriptCommand} dev`,\n )}) and visiting ${chalk.cyan('\"/sentry-example-page\"')}`\n : ''\n }${\n shouldCreateExamplePage && isLikelyUsingTurbopack\n ? `\\nDon't forget to remove \\`--turbo\\` or \\`--turbopack\\` from your dev command until you have verified the SDK is working. You can safely add it back afterwards.`\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\ntype SDKConfigOptions = {\n tunnelRoute: boolean;\n};\n\nasync function createOrMergeNextJsFiles(\n selectedProject: SentryProjectData,\n selfHosted: boolean,\n sentryUrl: string,\n sdkConfigOptions: SDKConfigOptions,\n) {\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', '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 getSentryServersideConfigContents(\n selectedProject.keys[0].dsn.public,\n configVariant,\n selectedFeatures,\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 await traceStep('setup-instrumentation-hook', async () => {\n const hasRootAppDirectory = hasDirectoryPathFromRoot('app');\n const hasRootPagesDirectory = hasDirectoryPathFromRoot('pages');\n const hasSrcDirectory = hasDirectoryPathFromRoot('src');\n\n let instrumentationHookLocation: 'src' | 'root' | 'does-not-exist';\n\n const instrumentationTsExists = fs.existsSync(\n path.join(process.cwd(), 'instrumentation.ts'),\n );\n const instrumentationJsExists = fs.existsSync(\n path.join(process.cwd(), 'instrumentation.js'),\n );\n const srcInstrumentationTsExists = fs.existsSync(\n path.join(process.cwd(), 'src', 'instrumentation.ts'),\n );\n const srcInstrumentationJsExists = fs.existsSync(\n path.join(process.cwd(), 'src', 'instrumentation.js'),\n );\n\n // https://nextjs.org/docs/app/building-your-application/configuring/src-directory\n // https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation\n // The logic for where Next.js picks up the instrumentation file is as follows:\n // - If there is either an `app` folder or a `pages` folder in the root directory of your Next.js app, Next.js looks\n // for an `instrumentation.ts` file in the root of the Next.js app.\n // - Otherwise, if there is neither an `app` folder or a `pages` folder in the rood directory of your Next.js app,\n // AND if there is an `src` folder, Next.js will look for the `instrumentation.ts` file in the `src` folder.\n if (hasRootPagesDirectory || hasRootAppDirectory) {\n if (instrumentationJsExists || instrumentationTsExists) {\n instrumentationHookLocation = 'root';\n } else {\n instrumentationHookLocation = 'does-not-exist';\n }\n } else {\n if (srcInstrumentationTsExists || srcInstrumentationJsExists) {\n instrumentationHookLocation = 'src';\n } else {\n instrumentationHookLocation = 'does-not-exist';\n }\n }\n\n const newInstrumentationFileName = `instrumentation.${\n typeScriptDetected ? 'ts' : 'js'\n }`;\n\n if (instrumentationHookLocation === 'does-not-exist') {\n let newInstrumentationHookLocation: 'root' | 'src';\n if (hasRootPagesDirectory || hasRootAppDirectory) {\n newInstrumentationHookLocation = 'root';\n } else if (hasSrcDirectory) {\n newInstrumentationHookLocation = 'src';\n } else {\n newInstrumentationHookLocation = 'root';\n }\n\n const newInstrumentationHookPath =\n newInstrumentationHookLocation === 'root'\n ? path.join(process.cwd(), newInstrumentationFileName)\n : path.join(process.cwd(), 'src', newInstrumentationFileName);\n\n const successfullyCreated = await createNewConfigFile(\n newInstrumentationHookPath,\n getInstrumentationHookContent(newInstrumentationHookLocation),\n );\n\n if (!successfullyCreated) {\n await showCopyPasteInstructions({\n filename: newInstrumentationFileName,\n codeSnippet: getInstrumentationHookCopyPasteSnippet(\n newInstrumentationHookLocation,\n ),\n hint: \"create the file if it doesn't already exist\",\n });\n }\n } else {\n await showCopyPasteInstructions({\n filename:\n srcInstrumentationTsExists || instrumentationTsExists\n ? 'instrumentation.ts'\n : srcInstrumentationJsExists || instrumentationJsExists\n ? 'instrumentation.js'\n : newInstrumentationFileName,\n codeSnippet: getInstrumentationHookCopyPasteSnippet(\n instrumentationHookLocation,\n ),\n });\n }\n });\n\n await traceStep('setup-instrumentation-client-hook', async () => {\n const hasRootAppDirectory = hasDirectoryPathFromRoot('app');\n const hasRootPagesDirectory = hasDirectoryPathFromRoot('pages');\n const hasSrcDirectory = hasDirectoryPathFromRoot('src');\n\n let instrumentationClientHookLocation: 'src' | 'root' | 'does-not-exist';\n\n const instrumentationClientTsExists = fs.existsSync(\n path.join(process.cwd(), 'instrumentation-client.ts'),\n );\n const instrumentationClientJsExists = fs.existsSync(\n path.join(process.cwd(), 'instrumentation-client.js'),\n );\n const srcInstrumentationClientTsExists = fs.existsSync(\n path.join(process.cwd(), 'src', 'instrumentation-client.ts'),\n );\n const srcInstrumentationClientJsExists = fs.existsSync(\n path.join(process.cwd(), 'src', 'instrumentation-client.js'),\n );\n\n // https://nextjs.org/docs/app/building-your-application/configuring/src-directory\n // https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation\n // The logic for where Next.js picks up the instrumentation file is as follows:\n // - If there is either an `app` folder or a `pages` folder in the root directory of your Next.js app, Next.js looks\n // for an `instrumentation.ts` file in the root of the Next.js app.\n // - Otherwise, if there is neither an `app` folder or a `pages` folder in the rood directory of your Next.js app,\n // AND if there is an `src` folder, Next.js will look for the `instrumentation.ts` file in the `src` folder.\n if (hasRootPagesDirectory || hasRootAppDirectory) {\n if (instrumentationClientJsExists || instrumentationClientTsExists) {\n instrumentationClientHookLocation = 'root';\n } else {\n instrumentationClientHookLocation = 'does-not-exist';\n }\n } else {\n if (\n srcInstrumentationClientTsExists ||\n srcInstrumentationClientJsExists\n ) {\n instrumentationClientHookLocation = 'src';\n } else {\n instrumentationClientHookLocation = 'does-not-exist';\n }\n }\n\n const newInstrumentationClientFileName = `instrumentation-client.${\n typeScriptDetected ? 'ts' : 'js'\n }`;\n\n if (instrumentationClientHookLocation === 'does-not-exist') {\n let newInstrumentationClientHookLocation: 'root' | 'src';\n if (hasRootPagesDirectory || hasRootAppDirectory) {\n newInstrumentationClientHookLocation = 'root';\n } else if (hasSrcDirectory) {\n newInstrumentationClientHookLocation = 'src';\n } else {\n newInstrumentationClientHookLocation = 'root';\n }\n\n const newInstrumentationClientHookPath =\n newInstrumentationClientHookLocation === 'root'\n ? path.join(process.cwd(), newInstrumentationClientFileName)\n : path.join(process.cwd(), 'src', newInstrumentationClientFileName);\n\n const successfullyCreated = await createNewConfigFile(\n newInstrumentationClientHookPath,\n getInstrumentationClientFileContents(\n selectedProject.keys[0].dsn.public,\n selectedFeatures,\n ),\n );\n\n if (!successfullyCreated) {\n await showCopyPasteInstructions({\n filename: newInstrumentationClientFileName,\n codeSnippet: getInstrumentationClientHookCopyPasteSnippet(\n selectedProject.keys[0].dsn.public,\n selectedFeatures,\n ),\n hint: \"create the file if it doesn't already exist\",\n });\n }\n } else {\n await showCopyPasteInstructions({\n filename:\n srcInstrumentationClientTsExists || instrumentationClientTsExists\n ? 'instrumentation-client.ts'\n : srcInstrumentationClientJsExists || instrumentationClientJsExists\n ? 'instrumentation-client.js'\n : newInstrumentationClientFileName,\n codeSnippet: getInstrumentationClientHookCopyPasteSnippet(\n selectedProject.keys[0].dsn.public,\n selectedFeatures,\n ),\n });\n }\n });\n\n await traceStep('setup-next-config', async () => {\n const withSentryConfigOptionsTemplate = getWithSentryConfigOptionsTemplate({\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n selfHosted,\n sentryUrl,\n tunnelRoute: sdkConfigOptions.tunnelRoute,\n });\n\n const nextConfigPossibleFilesMap = {\n js: 'next.config.js',\n mjs: 'next.config.mjs',\n cjs: 'next.config.cjs',\n ts: 'next.config.ts',\n mts: 'next.config.mts',\n cts: 'next.config.cts',\n };\n\n const foundNextConfigFile = Object.entries(nextConfigPossibleFilesMap).find(\n ([, fileName]) => fs.existsSync(path.join(process.cwd(), fileName)),\n );\n\n if (!foundNextConfigFile) {\n Sentry.setTag('next-config-strategy', 'create');\n\n // Try to figure out whether the user prefers ESM\n let isTypeModule = false;\n try {\n const packageJsonText = await fs.promises.readFile(\n path.join(process.cwd(), 'package.json'),\n 'utf8',\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const packageJson = JSON.parse(packageJsonText);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (packageJson.type === 'module') {\n isTypeModule = true;\n }\n } catch {\n // noop\n }\n\n // We are creating `next.config.(m)js` files by default as they are supported by the most Next.js versions\n const configFilename = isTypeModule\n ? nextConfigPossibleFilesMap.mjs\n : nextConfigPossibleFilesMap.js;\n const configContent = isTypeModule\n ? getNextjsConfigMjsTemplate(withSentryConfigOptionsTemplate)\n : getNextjsConfigCjsTemplate(withSentryConfigOptionsTemplate);\n\n await fs.promises.writeFile(\n path.join(process.cwd(), configFilename),\n configContent,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(configFilename)} with Sentry configuration.`,\n );\n\n return;\n }\n\n const [foundNextConfigFileType, foundNextConfigFileFilename] =\n foundNextConfigFile;\n\n if (foundNextConfigFileType === 'js' || foundNextConfigFileType === 'cjs') {\n Sentry.setTag('next-config-strategy', 'modify');\n\n const nextConfigCjsContent = fs.readFileSync(\n path.join(process.cwd(), foundNextConfigFileFilename),\n 'utf8',\n );\n\n const probablyIncludesSdk =\n nextConfigCjsContent.includes('@sentry/nextjs') &&\n nextConfigCjsContent.includes('withSentryConfig');\n\n let shouldInject = true;\n\n if (probablyIncludesSdk) {\n const injectAnyhow = await abortIfCancelled(\n clack.confirm({\n message: `${chalk.cyan(\n foundNextConfigFileFilename,\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(), foundNextConfigFileFilename),\n getNextjsConfigCjsAppendix(withSentryConfigOptionsTemplate),\n 'utf8',\n );\n\n clack.log.success(\n `Added Sentry configuration to ${chalk.cyan(\n foundNextConfigFileFilename,\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 (\n foundNextConfigFileType === 'mjs' ||\n foundNextConfigFileType === 'mts' ||\n foundNextConfigFileType === 'cts' ||\n foundNextConfigFileType === 'ts'\n ) {\n const nextConfigMjsContent = fs.readFileSync(\n path.join(process.cwd(), foundNextConfigFileFilename),\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 foundNextConfigFileFilename,\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 ${withSentryConfigOptionsTemplate}\n)`);\n const newCode = mod.generate().code;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), foundNextConfigFileFilename),\n newCode,\n {\n encoding: 'utf8',\n flag: 'w',\n },\n );\n clack.log.success(\n `Added Sentry configuration to ${chalk.cyan(\n foundNextConfigFileFilename,\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(\n foundNextConfigFileFilename,\n )}.`,\n ),\n );\n clack.log.info(\n `Please put the following code snippet into ${chalk.cyan(\n foundNextConfigFileFilename,\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(withSentryConfigOptionsTemplate),\n );\n\n const shouldContinue = await abortIfCancelled(\n clack.confirm({\n message: `Are you done putting the snippet above into ${chalk.cyan(\n foundNextConfigFileFilename,\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\nfunction hasDirectoryPathFromRoot(dirnameOrDirs: string | string[]): boolean {\n const dirPath = Array.isArray(dirnameOrDirs)\n ? path.join(process.cwd(), ...dirnameOrDirs)\n : path.join(process.cwd(), dirnameOrDirs);\n\n return fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory();\n}\n\nasync function createExamplePage(\n selfHosted: boolean,\n selectedProject: SentryProjectData,\n sentryUrl: string,\n typeScriptDetected: boolean,\n): Promise<void> {\n const hasSrcDirectory = hasDirectoryPathFromRoot('src');\n const hasRootAppDirectory = hasDirectoryPathFromRoot('app');\n const hasRootPagesDirectory = hasDirectoryPathFromRoot('pages');\n const hasSrcAppDirectory = hasDirectoryPathFromRoot(['src', 'app']);\n const hasSrcPagesDirectory = hasDirectoryPathFromRoot(['src', 'pages']);\n\n Sentry.setTag('nextjs-app-dir', hasRootAppDirectory || hasSrcAppDirectory);\n\n // If `pages` or an `app` directory exists in the root, we'll put the example page there.\n // `app` directory takes priority over `pages` directory when they coexist, so we prioritize that.\n // https://nextjs.org/docs/app/building-your-application/routing#the-app-router\n\n const appFolderLocation = hasRootAppDirectory\n ? ['app']\n : hasSrcAppDirectory\n ? ['src', 'app']\n : undefined;\n\n let pagesFolderLocation = hasRootPagesDirectory\n ? ['pages']\n : hasSrcPagesDirectory\n ? ['src', 'pages']\n : undefined;\n\n // If the user has neither pages nor app directory we create a pages folder for them\n if (!appFolderLocation && !pagesFolderLocation) {\n const newPagesFolderLocation = hasSrcDirectory\n ? ['src', 'pages']\n : ['pages'];\n fs.mkdirSync(path.join(process.cwd(), ...newPagesFolderLocation), {\n recursive: true,\n });\n\n pagesFolderLocation = newPagesFolderLocation;\n }\n\n if (appFolderLocation) {\n const appFolderPath = path.join(process.cwd(), ...appFolderLocation);\n\n const hasRootLayout = hasRootLayoutFile(appFolderPath);\n\n if (!hasRootLayout) {\n // In case no root layout file exists, we create a simple one so that\n // the example page can be rendered correctly.\n const newRootLayoutFilename = `layout.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n\n await fs.promises.writeFile(\n path.join(appFolderPath, newRootLayoutFilename),\n getRootLayout(typeScriptDetected),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appFolderLocation, newRootLayoutFilename),\n )}.`,\n );\n }\n\n const examplePageContents = getSentryExamplePageContents({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n sentryUrl,\n useClient: true,\n isTypeScript: typeScriptDetected,\n });\n\n fs.mkdirSync(path.join(appFolderPath, 'sentry-example-page'), {\n recursive: true,\n });\n\n const newPageFileName = `page.${typeScriptDetected ? 'tsx' : 'jsx'}`;\n\n await fs.promises.writeFile(\n path.join(appFolderPath, 'sentry-example-page', newPageFileName),\n examplePageContents,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...appFolderLocation, 'sentry-example-page', newPageFileName),\n )}.`,\n );\n\n fs.mkdirSync(path.join(appFolderPath, 'api', 'sentry-example-api'), {\n recursive: true,\n });\n\n const newRouteFileName = `route.${typeScriptDetected ? 'ts' : 'js'}`;\n\n await fs.promises.writeFile(\n path.join(appFolderPath, 'api', 'sentry-example-api', newRouteFileName),\n getSentryExampleAppDirApiRoute({ isTypeScript: typeScriptDetected }),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(\n ...appFolderLocation,\n 'api',\n 'sentry-example-api',\n newRouteFileName,\n ),\n )}.`,\n );\n } else if (pagesFolderLocation) {\n const examplePageContents = getSentryExamplePageContents({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n sentryUrl,\n useClient: false,\n isTypeScript: typeScriptDetected,\n });\n\n const examplePageFileName = `sentry-example-page.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), ...pagesFolderLocation, examplePageFileName),\n examplePageContents,\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...pagesFolderLocation, examplePageFileName),\n )}.`,\n );\n\n fs.mkdirSync(path.join(process.cwd(), ...pagesFolderLocation, 'api'), {\n recursive: true,\n });\n\n const apiRouteFileName = `sentry-example-api.${\n typeScriptDetected ? 'ts' : 'js'\n }`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), ...pagesFolderLocation, 'api', apiRouteFileName),\n getSentryExamplePagesDirApiRoute({ isTypeScript: typeScriptDetected }),\n { encoding: 'utf8', flag: 'w' },\n );\n\n clack.log.success(\n `Created ${chalk.cyan(\n path.join(...pagesFolderLocation, 'api', apiRouteFileName),\n )}.`,\n );\n }\n}\n\n/**\n * Ask users if they want to set the tunnelRoute option.\n * We can't set this by default because it potentially increases hosting bills.\n * It's valuable enough to for users to justify asking the additional question.\n */\nasync function askShouldSetTunnelRoute() {\n return await traceStep('ask-tunnelRoute-option', async (span) => {\n const shouldSetTunnelRoute = await abortIfCancelled(\n clack.select({\n message:\n 'Do you want to route Sentry requests in the browser through your Next.js server to avoid ad blockers?',\n options: [\n {\n label: 'Yes',\n value: true,\n hint: 'Can increase your server load and hosting bill',\n },\n {\n label: 'No',\n value: false,\n hint: 'Browser errors and events might be blocked by ad blockers before being sent to Sentry',\n },\n ],\n initialValue: true,\n }),\n );\n\n if (!shouldSetTunnelRoute) {\n clack.log.info(\n \"Sounds good! We'll leave the option commented for later, just in case :)\",\n );\n }\n\n span?.setAttribute('tunnelRoute', shouldSetTunnelRoute);\n Sentry.setTag('tunnelRoute', shouldSetTunnelRoute);\n\n return shouldSetTunnelRoute;\n });\n}\n\n/**\n * Returns true or false depending on whether we think the user is using Turbopack. May return null in case we aren't sure.\n */\nasync function checkIfLikelyIsUsingTurbopack(): Promise<boolean | null> {\n let packageJsonContent: string;\n try {\n packageJsonContent = await fs.promises.readFile(\n path.join(process.cwd(), 'package.json'),\n 'utf8',\n );\n } catch {\n return null;\n }\n\n return packageJsonContent.includes('--turbo');\n}\n"]}
@@ -24,9 +24,14 @@ export declare function getSentryExamplePageContents(options: {
24
24
  orgSlug: string;
25
25
  projectId: string;
26
26
  useClient: boolean;
27
+ isTypeScript?: boolean;
28
+ }): string;
29
+ export declare function getSentryExamplePagesDirApiRoute({ isTypeScript, }: {
30
+ isTypeScript: boolean;
31
+ }): string;
32
+ export declare function getSentryExampleAppDirApiRoute({ isTypeScript, }: {
33
+ isTypeScript: boolean;
27
34
  }): string;
28
- export declare function getSentryExamplePagesDirApiRoute(): string;
29
- export declare function getSentryExampleAppDirApiRoute(): string;
30
35
  export declare function getSentryDefaultUnderscoreErrorPage(): string;
31
36
  export declare function getSimpleUnderscoreErrorCopyPasteSnippet(): string;
32
37
  export declare function getGenerateMetadataSnippet(isTs: boolean): string;