@sentry/wizard 4.4.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -1
- package/README.md +23 -19
- package/dist/bin.js +13 -0
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-14.test.js +4 -5
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +3 -5
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +1 -1
- package/dist/e2e-tests/utils/index.js +20 -2
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +2 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/File.d.ts +1 -1
- package/dist/lib/Helper/File.js +1 -3
- package/dist/lib/Helper/File.js.map +1 -1
- package/dist/lib/Helper/Logging.d.ts +3 -0
- package/dist/lib/Helper/Logging.js +3 -0
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Helper/Package.d.ts +5 -3
- package/dist/lib/Helper/Package.js +2 -2
- package/dist/lib/Helper/Package.js.map +1 -1
- package/dist/lib/Helper/SentryCli.d.ts +20 -7
- package/dist/lib/Helper/SentryCli.js +21 -13
- package/dist/lib/Helper/SentryCli.js.map +1 -1
- package/dist/lib/Helper/Wizard.js +9 -5
- package/dist/lib/Helper/Wizard.js.map +1 -1
- package/dist/lib/Helper/__tests__/SentryCli.js +21 -4
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.d.ts +3 -1
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/Integrations/BaseIntegration.js +1 -2
- package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js +14 -10
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.d.ts +4 -1
- package/dist/lib/Steps/Integrations/Electron.js +1 -1
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.d.ts +3 -1
- package/dist/lib/Steps/Integrations/MobileProject.js +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
- package/dist/lib/Steps/PromptForParameters.d.ts +4 -1
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/lib/Steps/SentryProjectSelector.d.ts +42 -1
- package/dist/lib/Steps/SentryProjectSelector.js +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
- package/dist/lib/Steps/WaitForSentry.d.ts +3 -1
- package/dist/lib/Steps/WaitForSentry.js +4 -4
- package/dist/lib/Steps/WaitForSentry.js.map +1 -1
- package/dist/lib/Types.d.ts +14 -0
- package/dist/lib/Types.js +3 -0
- package/dist/lib/Types.js.map +1 -0
- package/dist/lib/__tests__/Env.js +6 -13
- package/dist/lib/__tests__/Env.js.map +1 -1
- package/dist/src/android/android-wizard.js +15 -12
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/android/code-tools.js +1 -1
- package/dist/src/android/code-tools.js.map +1 -1
- package/dist/src/android/gradle.js +4 -4
- package/dist/src/android/gradle.js.map +1 -1
- package/dist/src/android/manifest.js +1 -1
- package/dist/src/android/manifest.js.map +1 -1
- package/dist/src/apple/apple-wizard.d.ts +2 -2
- package/dist/src/apple/apple-wizard.js +37 -118
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/check-installed-cli.d.ts +1 -0
- package/dist/src/apple/check-installed-cli.js +60 -0
- package/dist/src/apple/check-installed-cli.js.map +1 -0
- package/dist/src/apple/cocoapod.js +1 -1
- package/dist/src/apple/cocoapod.js.map +1 -1
- package/dist/src/apple/code-tools.js +1 -1
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/configure-fastlane.d.ts +5 -0
- package/dist/src/apple/configure-fastlane.js +66 -0
- package/dist/src/apple/configure-fastlane.js.map +1 -0
- package/dist/src/apple/fastlane.d.ts +1 -1
- package/dist/src/apple/fastlane.js +5 -5
- package/dist/src/apple/fastlane.js.map +1 -1
- package/dist/src/apple/lookup-xcode-project.d.ts +7 -0
- package/dist/src/apple/lookup-xcode-project.js +98 -0
- package/dist/src/apple/lookup-xcode-project.js.map +1 -0
- package/dist/src/apple/options.d.ts +4 -0
- package/dist/src/apple/options.js +3 -0
- package/dist/src/apple/options.js.map +1 -0
- package/dist/src/apple/search-xcode-project-at-path.d.ts +1 -0
- package/dist/src/apple/search-xcode-project-at-path.js +70 -0
- package/dist/src/apple/search-xcode-project-at-path.js.map +1 -0
- package/dist/src/apple/xcode-manager.js +1 -1
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/flutter/code-tools.js +3 -3
- package/dist/src/flutter/code-tools.js.map +1 -1
- package/dist/src/flutter/flutter-wizard.js +21 -15
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/flutter/templates.js +4 -4
- package/dist/src/flutter/templates.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +118 -67
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +11 -3
- package/dist/src/nextjs/templates.js +193 -71
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +21 -16
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/nuxt/sdk-example.js +3 -3
- package/dist/src/nuxt/sdk-example.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.js +9 -9
- package/dist/src/nuxt/sdk-setup.js.map +1 -1
- package/dist/src/nuxt/templates.js +173 -58
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/nuxt/utils.js +6 -3
- package/dist/src/nuxt/utils.js.map +1 -1
- package/dist/src/react-native/expo-env-file.js +1 -1
- package/dist/src/react-native/expo-env-file.js.map +1 -1
- package/dist/src/react-native/expo-metro.js +4 -4
- package/dist/src/react-native/expo-metro.js.map +1 -1
- package/dist/src/react-native/expo.js +4 -4
- package/dist/src/react-native/expo.js.map +1 -1
- package/dist/src/react-native/javascript.js +7 -7
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.js +8 -8
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.d.ts +1 -1
- package/dist/src/react-native/react-native-wizard.js +36 -31
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/uninstall.js +8 -5
- package/dist/src/react-native/uninstall.js.map +1 -1
- package/dist/src/react-native/xcode.d.ts +2 -1
- package/dist/src/react-native/xcode.js +1 -2
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/remix/codemods/handle-error.js +4 -1
- package/dist/src/remix/codemods/handle-error.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +23 -18
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/remix/sdk-example.js +163 -64
- package/dist/src/remix/sdk-example.js.map +1 -1
- package/dist/src/remix/sdk-setup.js +11 -7
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/run.d.ts +3 -1
- package/dist/src/run.js +29 -9
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +30 -28
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/angular.js +3 -3
- package/dist/src/sourcemaps/tools/angular.js.map +1 -1
- package/dist/src/sourcemaps/tools/create-react-app.js +3 -3
- package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -1
- package/dist/src/sourcemaps/tools/esbuild.js +6 -6
- package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
- package/dist/src/sourcemaps/tools/nextjs.js +5 -5
- package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
- package/dist/src/sourcemaps/tools/remix.js +4 -4
- package/dist/src/sourcemaps/tools/remix.js.map +1 -1
- package/dist/src/sourcemaps/tools/rollup.js +6 -6
- package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +23 -16
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/tsc.js +6 -6
- package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +12 -12
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.js +10 -10
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.js +2 -2
- package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
- package/dist/src/sourcemaps/utils/other-wizards.js +5 -5
- package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
- package/dist/src/sourcemaps/utils/sdk-version.js +7 -7
- package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.js +1 -1
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +15 -14
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +25 -20
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.js +126 -37
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/telemetry.js +11 -0
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/{clack-utils.d.ts → clack/index.d.ts} +54 -15
- package/dist/src/utils/{clack-utils.js → clack/index.js} +107 -24
- package/dist/src/utils/clack/index.js.map +1 -0
- package/dist/src/utils/debug.js +1 -1
- package/dist/src/utils/debug.js.map +1 -1
- package/dist/src/utils/find-files-with-extension.d.ts +1 -0
- package/dist/src/utils/find-files-with-extension.js +39 -0
- package/dist/src/utils/find-files-with-extension.js.map +1 -0
- package/dist/src/utils/package-manager.d.ts +6 -1
- package/dist/src/utils/package-manager.js +32 -27
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/utils/sentrycli-utils.js +0 -1
- package/dist/src/utils/sentrycli-utils.js.map +1 -1
- package/dist/src/utils/types.d.ts +4 -0
- package/dist/src/utils/types.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/android/code-tools.test.js +0 -1
- package/dist/test/android/code-tools.test.js.map +1 -1
- package/dist/test/apple/cocoapod.test.js +1 -1
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +1 -1
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +1 -1
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/xcode-manager.test.js +26 -2
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +0 -2
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +23 -23
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +127 -133
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/react-native/expo-metro.test.js +1 -1
- package/dist/test/react-native/expo-metro.test.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +1 -1
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +1 -1
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +14 -3
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
- package/dist/test/utils/{clack-utils.test.js → clack/index.test.js} +131 -41
- package/dist/test/utils/clack/index.test.js.map +1 -0
- package/dist/test/utils/package-manager.test.d.ts +1 -0
- package/dist/test/utils/package-manager.test.js +29 -0
- package/dist/test/utils/package-manager.test.js.map +1 -0
- package/package.json +1 -1
- package/dist/src/utils/clack-utils.js.map +0 -1
- package/dist/test/utils/clack-utils.test.js.map +0 -1
- /package/dist/test/utils/{clack-utils.test.d.ts → clack/index.test.d.ts} +0 -0
|
@@ -28,16 +28,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.runFlutterWizard = void 0;
|
|
30
30
|
const Sentry = __importStar(require("@sentry/node"));
|
|
31
|
-
const codetools = __importStar(require("./code-tools"));
|
|
32
31
|
const fs = __importStar(require("fs"));
|
|
33
32
|
const path = __importStar(require("path"));
|
|
34
|
-
const clack_utils_1 = require("../utils/clack-utils");
|
|
35
|
-
const templates_1 = require("./templates");
|
|
36
33
|
const release_registry_1 = require("../utils/release-registry");
|
|
37
|
-
|
|
34
|
+
const codetools = __importStar(require("./code-tools"));
|
|
35
|
+
const templates_1 = require("./templates");
|
|
36
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
38
37
|
const clack = __importStar(require("@clack/prompts"));
|
|
39
38
|
const chalk_1 = __importDefault(require("chalk"));
|
|
40
|
-
const
|
|
39
|
+
const clack_1 = require("../utils/clack");
|
|
41
40
|
const telemetry_1 = require("../telemetry");
|
|
42
41
|
const code_tools_1 = require("./code-tools");
|
|
43
42
|
async function runFlutterWizard(options) {
|
|
@@ -49,12 +48,15 @@ async function runFlutterWizard(options) {
|
|
|
49
48
|
}
|
|
50
49
|
exports.runFlutterWizard = runFlutterWizard;
|
|
51
50
|
async function runFlutterWizardWithTelemetry(options) {
|
|
52
|
-
(0,
|
|
51
|
+
(0, clack_1.printWelcome)({
|
|
53
52
|
wizardName: 'Sentry Flutter Wizard',
|
|
54
53
|
promoCode: options.promoCode,
|
|
55
54
|
});
|
|
56
|
-
await (0,
|
|
57
|
-
|
|
55
|
+
await (0, clack_1.confirmContinueIfNoOrDirtyGitRepo)({
|
|
56
|
+
ignoreGitChanges: options.ignoreGitChanges,
|
|
57
|
+
cwd: undefined,
|
|
58
|
+
});
|
|
59
|
+
const { selectedProject, selfHosted, sentryUrl, authToken } = await (0, clack_1.getOrAskForProjectData)(options, 'flutter');
|
|
58
60
|
const projectDir = process.cwd();
|
|
59
61
|
const pubspecFile = path.join(projectDir, 'pubspec.yaml');
|
|
60
62
|
if (!fs.existsSync(pubspecFile)) {
|
|
@@ -70,7 +72,7 @@ async function runFlutterWizardWithTelemetry(options) {
|
|
|
70
72
|
const pubspecPatched = (0, telemetry_1.traceStep)('Patch pubspec.yaml', () => codetools.patchPubspec(pubspecFile, flutterVersionOrAny, pluginVersionOrAny, selectedProject.slug, selectedProject.organization.slug));
|
|
71
73
|
if (!pubspecPatched) {
|
|
72
74
|
clack.log.warn(`Could not patch ${chalk_1.default.cyan('pubspec.yaml')}. Add the dependencies to it.`);
|
|
73
|
-
await (0,
|
|
75
|
+
await (0, clack_1.showCopyPasteInstructions)('pubspec.yaml', (0, templates_1.pubspecSnippetColored)(flutterVersionOrAny, pluginVersionOrAny, selectedProject.slug, selectedProject.organization.slug), 'This ensures the Sentry SDK and plugin can be imported.');
|
|
74
76
|
}
|
|
75
77
|
Sentry.setTag('pubspec-patched', pubspecPatched);
|
|
76
78
|
// ======== STEP 2. Add sentry.properties with auth token ============
|
|
@@ -85,14 +87,14 @@ Set the ${chalk_1.default.cyan('SENTRY_AUTH_TOKEN')} environment variable in you
|
|
|
85
87
|
}
|
|
86
88
|
Sentry.setTag('sentry-properties-added', pubspecPatched);
|
|
87
89
|
// ======== STEP 3. Patch main.dart with setup and a test error snippet ============
|
|
88
|
-
clack.log.step(`
|
|
90
|
+
clack.log.step(`Next, the wizard will patch your ${chalk_1.default.cyan('main.dart')} file with the SDK init and a test error snippet.`);
|
|
89
91
|
const mainFile = (0, code_tools_1.findFile)(`${projectDir}/lib`, 'main.dart');
|
|
90
92
|
const dsn = selectedProject.keys[0].dsn.public;
|
|
91
93
|
const canEnableProfiling = fs.existsSync(`${projectDir}/ios`) || fs.existsSync(`${projectDir}/macos`);
|
|
92
94
|
const mainPatched = await (0, telemetry_1.traceStep)('Patch main.dart', () => codetools.patchMain(mainFile, dsn, canEnableProfiling));
|
|
93
95
|
if (!mainPatched) {
|
|
94
96
|
clack.log.warn(`Could not patch ${chalk_1.default.cyan('main.dart')} file. Place the following code snippet within the apps main function.`);
|
|
95
|
-
await (0,
|
|
97
|
+
await (0, clack_1.showCopyPasteInstructions)('main.dart', (0, templates_1.initSnippetColored)(dsn), 'This ensures the Sentry SDK is ready to capture errors.');
|
|
96
98
|
}
|
|
97
99
|
Sentry.setTag('main-patched', mainPatched);
|
|
98
100
|
// ======== OUTRO ========
|
|
@@ -102,11 +104,15 @@ Set the ${chalk_1.default.cyan('SENTRY_AUTH_TOKEN')} environment variable in you
|
|
|
102
104
|
clack.outro(`
|
|
103
105
|
${chalk_1.default.greenBright('Successfully installed the Sentry Flutter SDK!')}
|
|
104
106
|
|
|
105
|
-
${chalk_1.default.cyan(
|
|
106
|
-
${
|
|
107
|
+
${chalk_1.default.cyan('Next steps:')}
|
|
108
|
+
1. Run ${chalk_1.default.bold('flutter run')} to test the setup - we've added a test error that will trigger on app start
|
|
109
|
+
2. For production builds, run ${chalk_1.default.bold('flutter build apk --obfuscate --split-debug-info=build/debug-info')} (or ios/macos) then ${chalk_1.default.bold('flutter pub run sentry_dart_plugin')} to upload debug symbols
|
|
110
|
+
3. View your test error and transaction data at ${issuesPageLink}
|
|
107
111
|
|
|
108
|
-
|
|
109
|
-
https://docs.sentry.io/platforms/flutter/
|
|
112
|
+
${chalk_1.default.cyan('Learn more:')}
|
|
113
|
+
- Debug Symbols: https://docs.sentry.io/platforms/dart/guides/flutter/debug-symbols/
|
|
114
|
+
- Performance Monitoring: https://docs.sentry.io/platforms/dart/guides/flutter/performance/
|
|
115
|
+
- Integrations: https://docs.sentry.io/platforms/dart/guides/flutter/integrations/
|
|
110
116
|
`);
|
|
111
117
|
}
|
|
112
118
|
//# sourceMappingURL=flutter-wizard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-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IACD,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAE3C,0BAA0B;IAE1B,MAAM,cAAc,GAAG,UAAU;QAC/B,CAAC,CAAC,GAAG,SAAS,iBAAiB,eAAe,CAAC,YAAY,CAAC,IAAI,oBAAoB,eAAe,CAAC,EAAE,EAAE;QACxG,CAAC,CAAC,WAAW,eAAe,CAAC,YAAY,CAAC,IAAI,8BAA8B,eAAe,CAAC,EAAE,EAAE,CAAC;IAEnG,KAAK,CAAC,KAAK,CAAC;MACR,eAAK,CAAC,WAAW,CAAC,gDAAgD,CAAC;;MAEnE,eAAK,CAAC,IAAI,CACV;MACA,cAAc,EAAE,CACjB;;;;GAIF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { WizardOptions } from '../utils/types';\nimport * as Sentry from '@sentry/node';\nimport * as codetools from './code-tools';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { showCopyPasteInstructions } from '../utils/clack-utils';\nimport { pubspecSnippetColored, initSnippetColored } from './templates';\nimport { fetchSdkVersion } from '../utils/release-registry';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n confirmContinueIfNoOrDirtyGitRepo,\n getOrAskForProjectData,\n printWelcome,\n} from '../utils/clack-utils';\n\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { findFile } from './code-tools';\n\nexport async function runFlutterWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'flutter',\n wizardOptions: options,\n },\n () => runFlutterWizardWithTelemetry(options),\n );\n}\n\nasync function runFlutterWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Flutter Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const { selectedProject, selfHosted, sentryUrl, authToken } =\n await getOrAskForProjectData(options, 'flutter');\n\n const projectDir = process.cwd();\n const pubspecFile = path.join(projectDir, 'pubspec.yaml');\n if (!fs.existsSync(pubspecFile)) {\n clack.log.error(\n `Could not find ${chalk.cyan(\n 'pubspec.yaml',\n )}. Make sure you run the wizard in the projects root folder.`,\n );\n return;\n }\n\n // ======== STEP 1. Add sentry_flutter and sentry_dart_plugin to pubspec.yaml ============\n\n clack.log.step(\n `Adding ${chalk.bold('Sentry')} to your apps ${chalk.cyan(\n 'pubspec.yaml',\n )} file.`,\n );\n\n const flutterVersion = await fetchSdkVersion('sentry.dart.flutter');\n const flutterVersionOrAny = flutterVersion ? `^${flutterVersion}` : 'any';\n\n const pluginVersion = await fetchSdkVersion('sentry.dart.plugin');\n const pluginVersionOrAny = pluginVersion ? `^${pluginVersion}` : 'any';\n\n const pubspecPatched = traceStep('Patch pubspec.yaml', () =>\n codetools.patchPubspec(\n pubspecFile,\n flutterVersionOrAny,\n pluginVersionOrAny,\n selectedProject.slug,\n selectedProject.organization.slug,\n ),\n );\n if (!pubspecPatched) {\n clack.log.warn(\n `Could not patch ${chalk.cyan(\n 'pubspec.yaml',\n )}. Add the dependencies to it.`,\n );\n await showCopyPasteInstructions(\n 'pubspec.yaml',\n pubspecSnippetColored(\n flutterVersionOrAny,\n pluginVersionOrAny,\n selectedProject.slug,\n selectedProject.organization.slug,\n ),\n 'This ensures the Sentry SDK and plugin can be imported.',\n );\n }\n Sentry.setTag('pubspec-patched', pubspecPatched);\n\n // ======== STEP 2. Add sentry.properties with auth token ============\n\n const propertiesAdded = traceStep('Add sentry.properties', () =>\n codetools.addProperties(pubspecFile, authToken),\n );\n if (!propertiesAdded) {\n clack.log.warn(\n `We could not add ${chalk.cyan(\n 'sentry.properties',\n )} file in your project directory in order to provide an auth token for Sentry CLI. You'll have to add it manually, or you can set the SENTRY_AUTH_TOKEN environment variable instead. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`,\n );\n } else {\n clack.log.info(\n `Created a ${chalk.cyan(\n 'sentry.properties',\n )} file in your project directory to provide an auth token for Sentry CLI.\nIt was also added to your ${chalk.cyan('.gitignore')} file.\nSet the ${chalk.cyan(\n 'SENTRY_AUTH_TOKEN',\n )} environment variable in your CI environment. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`,\n );\n }\n Sentry.setTag('sentry-properties-added', pubspecPatched);\n\n // ======== STEP 3. Patch main.dart with setup and a test error snippet ============\n\n clack.log.step(\n `Patching ${chalk.cyan('main.dart')} with setup and test error snippet.`,\n );\n\n const mainFile = findFile(`${projectDir}/lib`, 'main.dart');\n const dsn = selectedProject.keys[0].dsn.public;\n const canEnableProfiling =\n fs.existsSync(`${projectDir}/ios`) || fs.existsSync(`${projectDir}/macos`);\n\n const mainPatched = await traceStep('Patch main.dart', () =>\n codetools.patchMain(mainFile, dsn, canEnableProfiling),\n );\n if (!mainPatched) {\n clack.log.warn(\n `Could not patch ${chalk.cyan(\n 'main.dart',\n )} file. Place the following code snippet within the apps main function.`,\n );\n await showCopyPasteInstructions(\n 'main.dart',\n initSnippetColored(dsn),\n 'This ensures the Sentry SDK is ready to capture errors.',\n );\n }\n Sentry.setTag('main-patched', mainPatched);\n\n // ======== OUTRO ========\n\n const issuesPageLink = selfHosted\n ? `${sentryUrl}organizations/${selectedProject.organization.slug}/issues/?project=${selectedProject.id}`\n : `https://${selectedProject.organization.slug}.sentry.io/issues/?project=${selectedProject.id}`;\n\n clack.outro(`\n ${chalk.greenBright('Successfully installed the Sentry Flutter SDK!')}\n \n ${chalk.cyan(\n `You can validate your setup by launching your application and checking Sentry issues page afterwards\n ${issuesPageLink}`,\n )}\n \n Check out the SDK documentation for further configuration:\n https://docs.sentry.io/platforms/flutter/\n `);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flutter-wizard.js","sourceRoot":"","sources":["../../../src/flutter/flutter-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,uCAAyB;AACzB,2CAA6B;AAC7B,gEAA4D;AAE5D,wDAA0C;AAC1C,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G,SAAS,iBAAiB,eAAe,CAAC,YAAY,CAAC,IAAI,oBAAoB,eAAe,CAAC,EAAE,EAAE;QACxG,CAAC,CAAC,WAAW,eAAe,CAAC,YAAY,CAAC,IAAI,8BAA8B,eAAe,CAAC,EAAE,EAAE,CAAC;IAEnG,KAAK,CAAC,KAAK,CAAC;MACR,eAAK,CAAC,WAAW,CAAC,gDAAgD,CAAC;;MAEnE,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC;aAClB,eAAK,CAAC,IAAI,CACjB,aAAa,CACd;oCAC+B,eAAK,CAAC,IAAI,CACxC,mEAAmE,CACpE,wBAAwB,eAAK,CAAC,IAAI,CACnC,oCAAoC,CACrC;sDACmD,cAAc;;MAE9D,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC;;;;GAI5B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as Sentry from '@sentry/node';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { fetchSdkVersion } from '../utils/release-registry';\nimport { WizardOptions } from '../utils/types';\nimport * as codetools from './code-tools';\nimport { initSnippetColored, pubspecSnippetColored } from './templates';\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';\n\nimport {\n confirmContinueIfNoOrDirtyGitRepo,\n getOrAskForProjectData,\n printWelcome,\n showCopyPasteInstructions,\n} from '../utils/clack';\n\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { findFile } from './code-tools';\n\nexport async function runFlutterWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'flutter',\n wizardOptions: options,\n },\n () => runFlutterWizardWithTelemetry(options),\n );\n}\n\nasync function runFlutterWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Flutter Wizard',\n promoCode: options.promoCode,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const { selectedProject, selfHosted, sentryUrl, authToken } =\n await getOrAskForProjectData(options, 'flutter');\n\n const projectDir = process.cwd();\n const pubspecFile = path.join(projectDir, 'pubspec.yaml');\n if (!fs.existsSync(pubspecFile)) {\n clack.log.error(\n `Could not find ${chalk.cyan(\n 'pubspec.yaml',\n )}. Make sure you run the wizard in the projects root folder.`,\n );\n return;\n }\n\n // ======== STEP 1. Add sentry_flutter and sentry_dart_plugin to pubspec.yaml ============\n\n clack.log.step(\n `Adding ${chalk.bold('Sentry')} to your apps ${chalk.cyan(\n 'pubspec.yaml',\n )} file.`,\n );\n\n const flutterVersion = await fetchSdkVersion('sentry.dart.flutter');\n const flutterVersionOrAny = flutterVersion ? `^${flutterVersion}` : 'any';\n\n const pluginVersion = await fetchSdkVersion('sentry.dart.plugin');\n const pluginVersionOrAny = pluginVersion ? `^${pluginVersion}` : 'any';\n\n const pubspecPatched = traceStep('Patch pubspec.yaml', () =>\n codetools.patchPubspec(\n pubspecFile,\n flutterVersionOrAny,\n pluginVersionOrAny,\n selectedProject.slug,\n selectedProject.organization.slug,\n ),\n );\n if (!pubspecPatched) {\n clack.log.warn(\n `Could not patch ${chalk.cyan(\n 'pubspec.yaml',\n )}. Add the dependencies to it.`,\n );\n await showCopyPasteInstructions(\n 'pubspec.yaml',\n pubspecSnippetColored(\n flutterVersionOrAny,\n pluginVersionOrAny,\n selectedProject.slug,\n selectedProject.organization.slug,\n ),\n 'This ensures the Sentry SDK and plugin can be imported.',\n );\n }\n Sentry.setTag('pubspec-patched', pubspecPatched);\n\n // ======== STEP 2. Add sentry.properties with auth token ============\n\n const propertiesAdded = traceStep('Add sentry.properties', () =>\n codetools.addProperties(pubspecFile, authToken),\n );\n if (!propertiesAdded) {\n clack.log.warn(\n `We could not add ${chalk.cyan(\n 'sentry.properties',\n )} file in your project directory in order to provide an auth token for Sentry CLI. You'll have to add it manually, or you can set the SENTRY_AUTH_TOKEN environment variable instead. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`,\n );\n } else {\n clack.log.info(\n `Created a ${chalk.cyan(\n 'sentry.properties',\n )} file in your project directory to provide an auth token for Sentry CLI.\nIt was also added to your ${chalk.cyan('.gitignore')} file.\nSet the ${chalk.cyan(\n 'SENTRY_AUTH_TOKEN',\n )} environment variable in your CI environment. See https://docs.sentry.io/cli/configuration/#auth-token for more information.`,\n );\n }\n Sentry.setTag('sentry-properties-added', pubspecPatched);\n\n // ======== STEP 3. Patch main.dart with setup and a test error snippet ============\n\n clack.log.step(\n `Next, the wizard will patch your ${chalk.cyan(\n 'main.dart',\n )} file with the SDK init and a test error snippet.`,\n );\n\n const mainFile = findFile(`${projectDir}/lib`, 'main.dart');\n const dsn = selectedProject.keys[0].dsn.public;\n const canEnableProfiling =\n fs.existsSync(`${projectDir}/ios`) || fs.existsSync(`${projectDir}/macos`);\n\n const mainPatched = await traceStep('Patch main.dart', () =>\n codetools.patchMain(mainFile, dsn, canEnableProfiling),\n );\n if (!mainPatched) {\n clack.log.warn(\n `Could not patch ${chalk.cyan(\n 'main.dart',\n )} file. Place the following code snippet within the apps main function.`,\n );\n await showCopyPasteInstructions(\n 'main.dart',\n initSnippetColored(dsn),\n 'This ensures the Sentry SDK is ready to capture errors.',\n );\n }\n Sentry.setTag('main-patched', mainPatched);\n\n // ======== OUTRO ========\n\n const issuesPageLink = selfHosted\n ? `${sentryUrl}organizations/${selectedProject.organization.slug}/issues/?project=${selectedProject.id}`\n : `https://${selectedProject.organization.slug}.sentry.io/issues/?project=${selectedProject.id}`;\n\n clack.outro(`\n ${chalk.greenBright('Successfully installed the Sentry Flutter SDK!')}\n \n ${chalk.cyan('Next steps:')}\n 1. Run ${chalk.bold(\n 'flutter run',\n )} to test the setup - we've added a test error that will trigger on app start\n 2. For production builds, run ${chalk.bold(\n 'flutter build apk --obfuscate --split-debug-info=build/debug-info',\n )} (or ios/macos) then ${chalk.bold(\n 'flutter pub run sentry_dart_plugin',\n )} to upload debug symbols\n 3. View your test error and transaction data at ${issuesPageLink}\n \n ${chalk.cyan('Learn more:')}\n - Debug Symbols: https://docs.sentry.io/platforms/dart/guides/flutter/debug-symbols/\n - Performance Monitoring: https://docs.sentry.io/platforms/dart/guides/flutter/performance/\n - Integrations: https://docs.sentry.io/platforms/dart/guides/flutter/integrations/\n `);\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initSnippetColored = exports.pubspecSnippetColored = exports.initSnippet = exports.sentryProperties = exports.pubspecOptions = exports.sentryImport = void 0;
|
|
4
|
-
const
|
|
4
|
+
const clack_1 = require("../utils/clack");
|
|
5
5
|
exports.sentryImport = `import 'package:sentry_flutter/sentry_flutter.dart';\n`;
|
|
6
6
|
function pubspecOptions(project, org) {
|
|
7
7
|
return `sentry:
|
|
@@ -37,7 +37,7 @@ function initSnippet(dsn, selectedFeaturesMap, runApp) {
|
|
|
37
37
|
appRunner: () => runApp(SentryWidget(child: ${runApp})),
|
|
38
38
|
);
|
|
39
39
|
// TODO: Remove this line after sending the first sample event to sentry.
|
|
40
|
-
await Sentry.captureException(
|
|
40
|
+
await Sentry.captureException(StateError('This is a sample exception.'));`;
|
|
41
41
|
return snippet;
|
|
42
42
|
}
|
|
43
43
|
exports.initSnippet = initSnippet;
|
|
@@ -49,7 +49,7 @@ dev_dependencies:
|
|
|
49
49
|
sentry_dart_plugin: ${pluginVersion}
|
|
50
50
|
|
|
51
51
|
${pubspecOptions(project, org)}`;
|
|
52
|
-
return (0,
|
|
52
|
+
return (0, clack_1.makeCodeSnippet)(true, (_unchanged, plus, _minus) => {
|
|
53
53
|
return plus(snippet);
|
|
54
54
|
});
|
|
55
55
|
}
|
|
@@ -68,7 +68,7 @@ Future<void>main() async {
|
|
|
68
68
|
appRunner: () => runApp(SentryWidget(child: YourApp())),
|
|
69
69
|
)
|
|
70
70
|
}`;
|
|
71
|
-
return (0,
|
|
71
|
+
return (0, clack_1.makeCodeSnippet)(true, (_unchanged, plus, _minus) => {
|
|
72
72
|
return plus(snippet);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/flutter/templates.ts"],"names":[],"mappings":";;;AAAA,
|
|
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,IAAI,CAAC;IAE7B,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;AAlCD,kCAkCC;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;;;;;;;EAOxB,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;AAjBD,gDAiBC","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\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 // 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"]}
|
|
@@ -28,20 +28,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.runNextjsWizardWithTelemetry = exports.runNextjsWizard = void 0;
|
|
30
30
|
/* eslint-disable max-lines */
|
|
31
|
-
// @ts-
|
|
31
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
32
32
|
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
33
33
|
const chalk_1 = __importDefault(require("chalk"));
|
|
34
34
|
const fs = __importStar(require("fs"));
|
|
35
|
-
// @ts-
|
|
35
|
+
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
36
36
|
const magicast_1 = require("magicast");
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
38
|
const Sentry = __importStar(require("@sentry/node"));
|
|
39
|
-
const
|
|
40
|
-
const templates_1 = require("./templates");
|
|
39
|
+
const sourcemaps_wizard_1 = require("../sourcemaps/sourcemaps-wizard");
|
|
41
40
|
const telemetry_1 = require("../telemetry");
|
|
41
|
+
const clack_1 = require("../utils/clack");
|
|
42
42
|
const package_json_1 = require("../utils/package-json");
|
|
43
|
+
const templates_1 = require("./templates");
|
|
43
44
|
const utils_1 = require("./utils");
|
|
44
|
-
const sourcemaps_wizard_1 = require("../sourcemaps/sourcemaps-wizard");
|
|
45
45
|
function runNextjsWizard(options) {
|
|
46
46
|
return (0, telemetry_1.withTelemetry)({
|
|
47
47
|
enabled: options.telemetryEnabled,
|
|
@@ -52,32 +52,33 @@ function runNextjsWizard(options) {
|
|
|
52
52
|
exports.runNextjsWizard = runNextjsWizard;
|
|
53
53
|
async function runNextjsWizardWithTelemetry(options) {
|
|
54
54
|
const { promoCode, telemetryEnabled, forceInstall } = options;
|
|
55
|
-
(0,
|
|
55
|
+
(0, clack_1.printWelcome)({
|
|
56
56
|
wizardName: 'Sentry Next.js Wizard',
|
|
57
57
|
promoCode,
|
|
58
58
|
telemetryEnabled,
|
|
59
59
|
});
|
|
60
|
-
const typeScriptDetected = (0,
|
|
61
|
-
await (0,
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
const typeScriptDetected = (0, clack_1.isUsingTypeScript)();
|
|
61
|
+
await (0, clack_1.confirmContinueIfNoOrDirtyGitRepo)({
|
|
62
|
+
ignoreGitChanges: options.ignoreGitChanges,
|
|
63
|
+
cwd: undefined,
|
|
64
|
+
});
|
|
65
|
+
const packageJson = await (0, clack_1.getPackageDotJson)();
|
|
66
|
+
await (0, clack_1.ensurePackageIsInstalled)(packageJson, 'next', 'Next.js');
|
|
64
67
|
const nextVersion = (0, package_json_1.getPackageVersion)('next', packageJson);
|
|
65
68
|
Sentry.setTag('nextjs-version', (0, utils_1.getNextJsVersionBucket)(nextVersion));
|
|
66
|
-
const { selectedProject, authToken, selfHosted, sentryUrl } = await (0,
|
|
69
|
+
const { selectedProject, authToken, selfHosted, sentryUrl } = await (0, clack_1.getOrAskForProjectData)(options, 'javascript-nextjs');
|
|
67
70
|
const sdkAlreadyInstalled = (0, package_json_1.hasPackageInstalled)('@sentry/nextjs', packageJson);
|
|
68
71
|
Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);
|
|
69
|
-
const { packageManager: packageManagerFromInstallStep } = await (0,
|
|
70
|
-
packageName: '@sentry/nextjs
|
|
72
|
+
const { packageManager: packageManagerFromInstallStep } = await (0, clack_1.installPackage)({
|
|
73
|
+
packageName: '@sentry/nextjs@latest',
|
|
71
74
|
packageNameDisplayLabel: '@sentry/nextjs',
|
|
72
75
|
alreadyInstalled: !!packageJson?.dependencies?.['@sentry/nextjs'],
|
|
73
76
|
forceInstall,
|
|
74
77
|
});
|
|
75
78
|
await (0, telemetry_1.traceStep)('configure-sdk', async () => {
|
|
76
79
|
const tunnelRoute = await askShouldSetTunnelRoute();
|
|
77
|
-
const reactComponentAnnotation = await askShouldEnableReactComponentAnnotation();
|
|
78
80
|
await createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, {
|
|
79
81
|
tunnelRoute,
|
|
80
|
-
reactComponentAnnotation,
|
|
81
82
|
});
|
|
82
83
|
});
|
|
83
84
|
await (0, telemetry_1.traceStep)('create-underscoreerror-page', async () => {
|
|
@@ -113,13 +114,13 @@ async function runNextjsWizardWithTelemetry(options) {
|
|
|
113
114
|
prompts_1.default.log.info(`It seems like you already have a custom error page.\n\nPlease put the following function call in the ${chalk_1.default.bold('getInitialProps')}\nmethod of your custom error page at ${chalk_1.default.bold(path.join(...pagesLocation, underscoreErrorPageFile))}:`);
|
|
114
115
|
// eslint-disable-next-line no-console
|
|
115
116
|
console.log((0, templates_1.getSimpleUnderscoreErrorCopyPasteSnippet)());
|
|
116
|
-
const shouldContinue = await (0,
|
|
117
|
+
const shouldContinue = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
117
118
|
message: `Did you modify your ${chalk_1.default.cyan(path.join(...pagesLocation, underscoreErrorPageFile))} file as described above?`,
|
|
118
119
|
active: 'Yes',
|
|
119
120
|
inactive: 'No, get me out of here',
|
|
120
121
|
}));
|
|
121
122
|
if (!shouldContinue) {
|
|
122
|
-
await (0,
|
|
123
|
+
await (0, clack_1.abort)();
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
else {
|
|
@@ -127,13 +128,13 @@ async function runNextjsWizardWithTelemetry(options) {
|
|
|
127
128
|
// eslint-disable-next-line no-console
|
|
128
129
|
console.log((0, templates_1.getFullUnderscoreErrorCopyPasteSnippet)(underscoreErrorPageFile === '_error.ts' ||
|
|
129
130
|
underscoreErrorPageFile === '_error.tsx'));
|
|
130
|
-
const shouldContinue = await (0,
|
|
131
|
+
const shouldContinue = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
131
132
|
message: `Did you add the code to your ${chalk_1.default.cyan(path.join(...pagesLocation, underscoreErrorPageFile))} file as described above?`,
|
|
132
133
|
active: 'Yes',
|
|
133
134
|
inactive: 'No, get me out of here',
|
|
134
135
|
}));
|
|
135
136
|
if (!shouldContinue) {
|
|
136
|
-
await (0,
|
|
137
|
+
await (0, clack_1.abort)();
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
});
|
|
@@ -169,25 +170,25 @@ async function runNextjsWizardWithTelemetry(options) {
|
|
|
169
170
|
// eslint-disable-next-line no-console
|
|
170
171
|
console.log((0, templates_1.getGlobalErrorCopyPasteSnippet)(globalErrorPageFile === 'global-error.ts' ||
|
|
171
172
|
globalErrorPageFile === 'global-error.tsx'));
|
|
172
|
-
const shouldContinue = await (0,
|
|
173
|
+
const shouldContinue = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
173
174
|
message: `Did you add the code to your ${chalk_1.default.cyan(path.join(...appDirLocation, globalErrorPageFile))} file as described above?`,
|
|
174
175
|
active: 'Yes',
|
|
175
176
|
inactive: 'No, get me out of here',
|
|
176
177
|
}));
|
|
177
178
|
if (!shouldContinue) {
|
|
178
|
-
await (0,
|
|
179
|
+
await (0, clack_1.abort)();
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
182
|
});
|
|
182
|
-
const shouldCreateExamplePage = await (0,
|
|
183
|
+
const shouldCreateExamplePage = await (0, clack_1.askShouldCreateExamplePage)();
|
|
183
184
|
if (shouldCreateExamplePage) {
|
|
184
185
|
await (0, telemetry_1.traceStep)('create-example-page', async () => createExamplePage(selfHosted, selectedProject, sentryUrl));
|
|
185
186
|
}
|
|
186
|
-
await (0,
|
|
187
|
+
await (0, clack_1.addDotEnvSentryBuildPluginFile)(authToken);
|
|
187
188
|
const isLikelyUsingTurbopack = await checkIfLikelyIsUsingTurbopack();
|
|
188
189
|
if (isLikelyUsingTurbopack || isLikelyUsingTurbopack === null) {
|
|
189
|
-
await (0,
|
|
190
|
-
message: `Warning: The Sentry SDK
|
|
190
|
+
await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
191
|
+
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_1.default.bold(`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.`)}`,
|
|
191
192
|
options: [
|
|
192
193
|
{
|
|
193
194
|
label: 'I understand.',
|
|
@@ -206,8 +207,10 @@ async function runNextjsWizardWithTelemetry(options) {
|
|
|
206
207
|
else {
|
|
207
208
|
await (0, sourcemaps_wizard_1.setupCI)('nextjs', authToken, options.comingFrom);
|
|
208
209
|
}
|
|
209
|
-
const packageManagerForOutro = packageManagerFromInstallStep ?? (await (0,
|
|
210
|
-
await (0,
|
|
210
|
+
const packageManagerForOutro = packageManagerFromInstallStep ?? (await (0, clack_1.getPackageManager)());
|
|
211
|
+
await (0, clack_1.runPrettierIfInstalled)({
|
|
212
|
+
cwd: undefined,
|
|
213
|
+
});
|
|
211
214
|
prompts_1.default.outro(`
|
|
212
215
|
${chalk_1.default.green('Successfully installed the Sentry Next.js SDK!')} ${shouldCreateExamplePage
|
|
213
216
|
? `\n\nYou can validate your setup by (re)starting your dev environment (e.g. ${chalk_1.default.cyan(`${packageManagerForOutro.runScriptCommand} dev`)}) and visiting ${chalk_1.default.cyan('"/sentry-example-page"')}`
|
|
@@ -219,7 +222,7 @@ ${chalk_1.default.dim('If you encounter any issues, let us know here: https://gi
|
|
|
219
222
|
}
|
|
220
223
|
exports.runNextjsWizardWithTelemetry = runNextjsWizardWithTelemetry;
|
|
221
224
|
async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, sdkConfigOptions) {
|
|
222
|
-
const selectedFeatures = await (0,
|
|
225
|
+
const selectedFeatures = await (0, clack_1.featureSelectionPrompt)([
|
|
223
226
|
{
|
|
224
227
|
id: 'performance',
|
|
225
228
|
prompt: `Do you want to enable ${chalk_1.default.bold('Tracing')} to track the performance of your application?`,
|
|
@@ -231,8 +234,8 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
231
234
|
enabledHint: 'recommended, but increases bundle size',
|
|
232
235
|
},
|
|
233
236
|
]);
|
|
234
|
-
const typeScriptDetected = (0,
|
|
235
|
-
const configVariants = ['server', '
|
|
237
|
+
const typeScriptDetected = (0, clack_1.isUsingTypeScript)();
|
|
238
|
+
const configVariants = ['server', 'edge'];
|
|
236
239
|
for (const configVariant of configVariants) {
|
|
237
240
|
await (0, telemetry_1.traceStep)(`create-sentry-${configVariant}-config`, async () => {
|
|
238
241
|
const jsConfig = `sentry.${configVariant}.config.js`;
|
|
@@ -248,7 +251,7 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
248
251
|
if (tsConfigExists) {
|
|
249
252
|
existingConfigs.push(tsConfig);
|
|
250
253
|
}
|
|
251
|
-
const overwriteExistingConfigs = await (0,
|
|
254
|
+
const overwriteExistingConfigs = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
252
255
|
message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(', ')}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,
|
|
253
256
|
}));
|
|
254
257
|
Sentry.setTag(`overwrite-${configVariant}-config`, overwriteExistingConfigs);
|
|
@@ -265,7 +268,7 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
265
268
|
}
|
|
266
269
|
}
|
|
267
270
|
if (shouldWriteFile) {
|
|
268
|
-
await fs.promises.writeFile(path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig), (0, templates_1.
|
|
271
|
+
await fs.promises.writeFile(path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig), (0, templates_1.getSentryServersideConfigContents)(selectedProject.keys[0].dsn.public, configVariant, selectedFeatures), { encoding: 'utf8', flag: 'w' });
|
|
269
272
|
prompts_1.default.log.success(`Created fresh ${chalk_1.default.cyan(typeScriptDetected ? tsConfig : jsConfig)}.`);
|
|
270
273
|
Sentry.setTag(`created-${configVariant}-config`, true);
|
|
271
274
|
}
|
|
@@ -318,19 +321,80 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
318
321
|
const newInstrumentationHookPath = newInstrumentationHookLocation === 'root'
|
|
319
322
|
? path.join(process.cwd(), newInstrumentationFileName)
|
|
320
323
|
: path.join(process.cwd(), 'src', newInstrumentationFileName);
|
|
321
|
-
const successfullyCreated = await (0,
|
|
324
|
+
const successfullyCreated = await (0, clack_1.createNewConfigFile)(newInstrumentationHookPath, (0, templates_1.getInstrumentationHookContent)(newInstrumentationHookLocation));
|
|
322
325
|
if (!successfullyCreated) {
|
|
323
|
-
await (0,
|
|
326
|
+
await (0, clack_1.showCopyPasteInstructions)(newInstrumentationFileName, (0, templates_1.getInstrumentationHookCopyPasteSnippet)(newInstrumentationHookLocation), "create the file if it doesn't already exist");
|
|
324
327
|
}
|
|
325
328
|
}
|
|
326
329
|
else {
|
|
327
|
-
await (0,
|
|
330
|
+
await (0, clack_1.showCopyPasteInstructions)(srcInstrumentationTsExists || instrumentationTsExists
|
|
328
331
|
? 'instrumentation.ts'
|
|
329
332
|
: srcInstrumentationJsExists || instrumentationJsExists
|
|
330
333
|
? 'instrumentation.js'
|
|
331
334
|
: newInstrumentationFileName, (0, templates_1.getInstrumentationHookCopyPasteSnippet)(instrumentationHookLocation));
|
|
332
335
|
}
|
|
333
336
|
});
|
|
337
|
+
await (0, telemetry_1.traceStep)('setup-instrumentation-client-hook', async () => {
|
|
338
|
+
const hasRootAppDirectory = hasDirectoryPathFromRoot('app');
|
|
339
|
+
const hasRootPagesDirectory = hasDirectoryPathFromRoot('pages');
|
|
340
|
+
const hasSrcDirectory = hasDirectoryPathFromRoot('src');
|
|
341
|
+
let instrumentationClientHookLocation;
|
|
342
|
+
const instrumentationClientTsExists = fs.existsSync(path.join(process.cwd(), 'instrumentation-client.ts'));
|
|
343
|
+
const instrumentationClientJsExists = fs.existsSync(path.join(process.cwd(), 'instrumentation-client.js'));
|
|
344
|
+
const srcInstrumentationClientTsExists = fs.existsSync(path.join(process.cwd(), 'src', 'instrumentation-client.ts'));
|
|
345
|
+
const srcInstrumentationClientJsExists = fs.existsSync(path.join(process.cwd(), 'src', 'instrumentation-client.js'));
|
|
346
|
+
// https://nextjs.org/docs/app/building-your-application/configuring/src-directory
|
|
347
|
+
// https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation
|
|
348
|
+
// The logic for where Next.js picks up the instrumentation file is as follows:
|
|
349
|
+
// - If there is either an `app` folder or a `pages` folder in the root directory of your Next.js app, Next.js looks
|
|
350
|
+
// for an `instrumentation.ts` file in the root of the Next.js app.
|
|
351
|
+
// - Otherwise, if there is neither an `app` folder or a `pages` folder in the rood directory of your Next.js app,
|
|
352
|
+
// AND if there is an `src` folder, Next.js will look for the `instrumentation.ts` file in the `src` folder.
|
|
353
|
+
if (hasRootPagesDirectory || hasRootAppDirectory) {
|
|
354
|
+
if (instrumentationClientJsExists || instrumentationClientTsExists) {
|
|
355
|
+
instrumentationClientHookLocation = 'root';
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
instrumentationClientHookLocation = 'does-not-exist';
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
if (srcInstrumentationClientTsExists ||
|
|
363
|
+
srcInstrumentationClientJsExists) {
|
|
364
|
+
instrumentationClientHookLocation = 'src';
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
instrumentationClientHookLocation = 'does-not-exist';
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const newInstrumentationClientFileName = `instrumentation-client.${typeScriptDetected ? 'ts' : 'js'}`;
|
|
371
|
+
if (instrumentationClientHookLocation === 'does-not-exist') {
|
|
372
|
+
let newInstrumentationClientHookLocation;
|
|
373
|
+
if (hasRootPagesDirectory || hasRootAppDirectory) {
|
|
374
|
+
newInstrumentationClientHookLocation = 'root';
|
|
375
|
+
}
|
|
376
|
+
else if (hasSrcDirectory) {
|
|
377
|
+
newInstrumentationClientHookLocation = 'src';
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
newInstrumentationClientHookLocation = 'root';
|
|
381
|
+
}
|
|
382
|
+
const newInstrumentationClientHookPath = newInstrumentationClientHookLocation === 'root'
|
|
383
|
+
? path.join(process.cwd(), newInstrumentationClientFileName)
|
|
384
|
+
: path.join(process.cwd(), 'src', newInstrumentationClientFileName);
|
|
385
|
+
const successfullyCreated = await (0, clack_1.createNewConfigFile)(newInstrumentationClientHookPath, (0, templates_1.getInstrumentationClientFileContents)(selectedProject.keys[0].dsn.public, selectedFeatures));
|
|
386
|
+
if (!successfullyCreated) {
|
|
387
|
+
await (0, clack_1.showCopyPasteInstructions)(newInstrumentationClientFileName, (0, templates_1.getInstrumentationClientHookCopyPasteSnippet)(selectedProject.keys[0].dsn.public, selectedFeatures), "create the file if it doesn't already exist");
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
await (0, clack_1.showCopyPasteInstructions)(srcInstrumentationClientTsExists || instrumentationClientTsExists
|
|
392
|
+
? 'instrumentation-client.ts'
|
|
393
|
+
: srcInstrumentationClientJsExists || instrumentationClientJsExists
|
|
394
|
+
? 'instrumentation-client.js'
|
|
395
|
+
: newInstrumentationClientFileName, (0, templates_1.getInstrumentationClientHookCopyPasteSnippet)(selectedProject.keys[0].dsn.public, selectedFeatures));
|
|
396
|
+
}
|
|
397
|
+
});
|
|
334
398
|
await (0, telemetry_1.traceStep)('setup-next-config', async () => {
|
|
335
399
|
const withSentryConfigOptionsTemplate = (0, templates_1.getWithSentryConfigOptionsTemplate)({
|
|
336
400
|
orgSlug: selectedProject.organization.slug,
|
|
@@ -338,7 +402,6 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
338
402
|
selfHosted,
|
|
339
403
|
sentryUrl,
|
|
340
404
|
tunnelRoute: sdkConfigOptions.tunnelRoute,
|
|
341
|
-
reactComponentAnnotation: sdkConfigOptions.reactComponentAnnotation,
|
|
342
405
|
});
|
|
343
406
|
const nextConfigPossibleFilesMap = {
|
|
344
407
|
js: 'next.config.js',
|
|
@@ -384,7 +447,7 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
384
447
|
nextConfigCjsContent.includes('withSentryConfig');
|
|
385
448
|
let shouldInject = true;
|
|
386
449
|
if (probablyIncludesSdk) {
|
|
387
|
-
const injectAnyhow = await (0,
|
|
450
|
+
const injectAnyhow = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
388
451
|
message: `${chalk_1.default.cyan(foundNextConfigFileFilename)} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,
|
|
389
452
|
}));
|
|
390
453
|
shouldInject = injectAnyhow;
|
|
@@ -404,7 +467,7 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
404
467
|
nextConfigMjsContent.includes('withSentryConfig');
|
|
405
468
|
let shouldInject = true;
|
|
406
469
|
if (probablyIncludesSdk) {
|
|
407
|
-
const injectAnyhow = await (0,
|
|
470
|
+
const injectAnyhow = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
408
471
|
message: `${chalk_1.default.cyan(foundNextConfigFileFilename)} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,
|
|
409
472
|
}));
|
|
410
473
|
shouldInject = injectAnyhow;
|
|
@@ -439,13 +502,13 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
439
502
|
prompts_1.default.log.info(`Please put the following code snippet into ${chalk_1.default.cyan(foundNextConfigFileFilename)}: ${chalk_1.default.dim('You probably have to clean it up a bit.')}\n`);
|
|
440
503
|
// eslint-disable-next-line no-console
|
|
441
504
|
console.log((0, templates_1.getNextjsConfigEsmCopyPasteSnippet)(withSentryConfigOptionsTemplate));
|
|
442
|
-
const shouldContinue = await (0,
|
|
505
|
+
const shouldContinue = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
443
506
|
message: `Are you done putting the snippet above into ${chalk_1.default.cyan(foundNextConfigFileFilename)}?`,
|
|
444
507
|
active: 'Yes',
|
|
445
508
|
inactive: 'No, get me out of here',
|
|
446
509
|
}));
|
|
447
510
|
if (!shouldContinue) {
|
|
448
|
-
await (0,
|
|
511
|
+
await (0, clack_1.abort)();
|
|
449
512
|
}
|
|
450
513
|
}
|
|
451
514
|
}
|
|
@@ -464,7 +527,7 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
|
464
527
|
const hasSrcAppDirectory = hasDirectoryPathFromRoot(['src', 'app']);
|
|
465
528
|
const hasSrcPagesDirectory = hasDirectoryPathFromRoot(['src', 'pages']);
|
|
466
529
|
Sentry.setTag('nextjs-app-dir', hasRootAppDirectory || hasSrcAppDirectory);
|
|
467
|
-
const typeScriptDetected = (0,
|
|
530
|
+
const typeScriptDetected = (0, clack_1.isUsingTypeScript)();
|
|
468
531
|
// If `pages` or an `app` directory exists in the root, we'll put the example page there.
|
|
469
532
|
// `app` directory takes priority over `pages` directory when they coexist, so we prioritize that.
|
|
470
533
|
// https://nextjs.org/docs/app/building-your-application/routing#the-app-router
|
|
@@ -489,6 +552,15 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
|
489
552
|
pagesFolderLocation = newPagesFolderLocation;
|
|
490
553
|
}
|
|
491
554
|
if (appFolderLocation) {
|
|
555
|
+
const appFolderPath = path.join(process.cwd(), ...appFolderLocation);
|
|
556
|
+
const hasRootLayout = ['jsx', 'tsx', 'js'].some((ext) => fs.existsSync(path.join(appFolderPath, `layout.${ext}`)));
|
|
557
|
+
if (!hasRootLayout) {
|
|
558
|
+
// In case no root layout file exists, we create a simple one so that
|
|
559
|
+
// the example page can be rendered correctly.
|
|
560
|
+
const newRootLayoutFilename = `layout.${typeScriptDetected ? 'tsx' : 'jsx'}`;
|
|
561
|
+
await fs.promises.writeFile(path.join(appFolderPath, newRootLayoutFilename), (0, templates_1.getRootLayout)(typeScriptDetected), { encoding: 'utf8', flag: 'w' });
|
|
562
|
+
prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...appFolderLocation, newRootLayoutFilename))}.`);
|
|
563
|
+
}
|
|
492
564
|
const examplePageContents = (0, templates_1.getSentryExamplePageContents)({
|
|
493
565
|
selfHosted,
|
|
494
566
|
orgSlug: selectedProject.organization.slug,
|
|
@@ -496,17 +568,17 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
|
496
568
|
sentryUrl,
|
|
497
569
|
useClient: true,
|
|
498
570
|
});
|
|
499
|
-
fs.mkdirSync(path.join(
|
|
571
|
+
fs.mkdirSync(path.join(appFolderPath, 'sentry-example-page'), {
|
|
500
572
|
recursive: true,
|
|
501
573
|
});
|
|
502
574
|
const newPageFileName = `page.${typeScriptDetected ? 'tsx' : 'jsx'}`;
|
|
503
|
-
await fs.promises.writeFile(path.join(
|
|
575
|
+
await fs.promises.writeFile(path.join(appFolderPath, 'sentry-example-page', newPageFileName), examplePageContents, { encoding: 'utf8', flag: 'w' });
|
|
504
576
|
prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...appFolderLocation, 'sentry-example-page', newPageFileName))}.`);
|
|
505
|
-
fs.mkdirSync(path.join(
|
|
577
|
+
fs.mkdirSync(path.join(appFolderPath, 'api', 'sentry-example-api'), {
|
|
506
578
|
recursive: true,
|
|
507
579
|
});
|
|
508
580
|
const newRouteFileName = `route.${typeScriptDetected ? 'ts' : 'js'}`;
|
|
509
|
-
await fs.promises.writeFile(path.join(
|
|
581
|
+
await fs.promises.writeFile(path.join(appFolderPath, 'api', 'sentry-example-api', newRouteFileName), (0, templates_1.getSentryExampleAppDirApiRoute)(), { encoding: 'utf8', flag: 'w' });
|
|
510
582
|
prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...appFolderLocation, 'api', 'sentry-example-api', newRouteFileName))}.`);
|
|
511
583
|
}
|
|
512
584
|
else if (pagesFolderLocation) {
|
|
@@ -533,7 +605,7 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
|
533
605
|
*/
|
|
534
606
|
async function askShouldSetTunnelRoute() {
|
|
535
607
|
return await (0, telemetry_1.traceStep)('ask-tunnelRoute-option', async (span) => {
|
|
536
|
-
const shouldSetTunnelRoute = await (0,
|
|
608
|
+
const shouldSetTunnelRoute = await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
537
609
|
message: 'Do you want to route Sentry requests in the browser through your Next.js server to avoid ad blockers?',
|
|
538
610
|
options: [
|
|
539
611
|
{
|
|
@@ -557,27 +629,6 @@ async function askShouldSetTunnelRoute() {
|
|
|
557
629
|
return shouldSetTunnelRoute;
|
|
558
630
|
});
|
|
559
631
|
}
|
|
560
|
-
async function askShouldEnableReactComponentAnnotation() {
|
|
561
|
-
return await (0, telemetry_1.traceStep)('ask-react-component-annotation-option', async () => {
|
|
562
|
-
const shouldEnableReactComponentAnnotation = await (0, clack_utils_1.abortIfCancelled)(prompts_1.default.select({
|
|
563
|
-
message: 'Do you want to enable React component annotations to make breadcrumbs and session replays more readable?',
|
|
564
|
-
options: [
|
|
565
|
-
{
|
|
566
|
-
label: 'Yes',
|
|
567
|
-
value: true,
|
|
568
|
-
hint: 'Annotates React component names - increases bundle size',
|
|
569
|
-
},
|
|
570
|
-
{
|
|
571
|
-
label: 'No',
|
|
572
|
-
value: false,
|
|
573
|
-
hint: 'Continue without React component annotations',
|
|
574
|
-
},
|
|
575
|
-
],
|
|
576
|
-
initialValue: true,
|
|
577
|
-
}));
|
|
578
|
-
return shouldEnableReactComponentAnnotation;
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
632
|
/**
|
|
582
633
|
* Returns true or false depending on whether we think the user is using Turbopack. May return null in case we aren't sure.
|
|
583
634
|
*/
|