@sentry/wizard 4.5.0 → 4.7.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 +25 -1
- package/README.md +23 -19
- package/dist/bin.js +22 -0
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/tests/flutter.test.js +16 -16
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
- package/dist/e2e-tests/tests/help-message.test.js +56 -0
- package/dist/e2e-tests/tests/help-message.test.js.map +1 -0
- package/dist/e2e-tests/tests/nextjs-14.test.js +17 -16
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +16 -16
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +13 -12
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +13 -12
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +20 -20
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +20 -20
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +1 -1
- package/dist/e2e-tests/utils/index.js +35 -13
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +7 -1
- 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 +4 -1
- 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__/File.js +9 -9
- package/dist/lib/Helper/__tests__/File.js.map +1 -1
- package/dist/lib/Helper/__tests__/MergeConfig.js +17 -17
- package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
- package/dist/lib/Helper/__tests__/SentryCli.js +39 -21
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.d.ts +4 -1
- package/dist/lib/Setup.js +12 -2
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/BaseStep.d.ts +1 -1
- package/dist/lib/Steps/BaseStep.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/Steps/Welcome.js +5 -0
- package/dist/lib/Steps/Welcome.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 +10 -16
- 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 +54 -175
- 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/configure-package-manager.d.ts +5 -0
- package/dist/src/apple/configure-package-manager.js +68 -0
- package/dist/src/apple/configure-package-manager.js.map +1 -0
- package/dist/src/apple/configure-sentry-cli.d.ts +4 -0
- package/dist/src/apple/configure-sentry-cli.js +47 -0
- package/dist/src/apple/configure-sentry-cli.js.map +1 -0
- package/dist/src/apple/configure-xcode-project.d.ts +8 -0
- package/dist/src/apple/configure-xcode-project.js +11 -0
- package/dist/src/apple/configure-xcode-project.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/inject-code-snippet.d.ts +6 -0
- package/dist/src/apple/inject-code-snippet.js +54 -0
- package/dist/src/apple/inject-code-snippet.js.map +1 -0
- 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/templates.js +11 -7
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.js +4 -7
- 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 -43
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +10 -1
- package/dist/src/nextjs/templates.js +192 -62
- 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.d.ts +6 -4
- package/dist/src/react-native/javascript.js +31 -15
- 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 +5 -1
- package/dist/src/react-native/react-native-wizard.js +66 -36
- 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 +9 -4
- package/dist/src/react-native/xcode.js +65 -22
- 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 +15 -15
- 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} +45 -7
- package/dist/src/utils/{clack-utils.js → clack/index.js} +75 -20
- 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 +8 -1
- package/dist/src/utils/package-manager.js +79 -23
- 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 +13 -13
- package/dist/test/android/code-tools.test.js.map +1 -1
- package/dist/test/apple/cocoapod.test.js +78 -73
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +174 -167
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +87 -84
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/templates.test.js +32 -27
- package/dist/test/apple/templates.test.js.map +1 -1
- package/dist/test/apple/xcode-manager.test.js +208 -185
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +29 -30
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +38 -37
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +155 -103
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/nuxt/templates.test.js +25 -24
- package/dist/test/nuxt/templates.test.js.map +1 -1
- package/dist/test/react-native/expo-metro.test.js +12 -11
- package/dist/test/react-native/expo-metro.test.js.map +1 -1
- package/dist/test/react-native/expo.test.js +11 -10
- package/dist/test/react-native/expo.test.js.map +1 -1
- package/dist/test/react-native/gradle.test.js +27 -26
- package/dist/test/react-native/gradle.test.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +109 -59
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +66 -65
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/react-native/xcode.test.js +138 -37
- package/dist/test/react-native/xcode.test.js.map +1 -1
- package/dist/test/remix/client-entry.test.js +8 -7
- package/dist/test/remix/client-entry.test.js.map +1 -1
- package/dist/test/remix/server-instrumentation.test.js +6 -5
- package/dist/test/remix/server-instrumentation.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +21 -21
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/tsc.test.js +13 -14
- package/dist/test/sourcemaps/tools/tsc.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/vite.test.js +13 -14
- package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/webpack.test.js +19 -20
- package/dist/test/sourcemaps/tools/webpack.test.js.map +1 -1
- package/dist/test/sveltekit/templates.test.js +13 -12
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/dist/test/utils/ast-utils.test.js +45 -44
- package/dist/test/utils/ast-utils.test.js.map +1 -1
- package/dist/test/utils/clack/index.test.d.ts +1 -0
- package/dist/test/utils/clack/index.test.js +375 -0
- 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 +30 -0
- package/dist/test/utils/package-manager.test.js.map +1 -0
- package/package.json +10 -38
- package/dist/e2e-tests/jest.config.d.ts +0 -17
- package/dist/e2e-tests/jest.config.js +0 -23
- package/dist/e2e-tests/jest.config.js.map +0 -1
- package/dist/src/utils/clack-utils.js.map +0 -1
- package/dist/test/utils/clack-utils.test.js +0 -306
- package/dist/test/utils/clack-utils.test.js.map +0 -1
- /package/dist/{test/utils/clack-utils.test.d.ts → e2e-tests/tests/help-message.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
|
-
{"version":3,"file":"flutter-wizard.js","sourceRoot":"","sources":["../../../src/flutter/flutter-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qDAAuC;AACvC,wDAA0C;AAC1C,uCAAyB;AACzB,2CAA6B;AAC7B,sDAAiE;AACjE,2CAAwE;AACxE,gEAA4D;AAC5D,yEAAyE;AACzE,sDAAwC;AACxC,kDAA0B;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I,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,2CAAwE;AACxE,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAE1B,0CAKwB;AAExB,4CAAwD;AACxD,6CAAwC;AAEjC,KAAK,UAAU,gBAAgB,CAAC,OAAsB;IAC3D,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,SAAS;QACtB,aAAa,EAAE,OAAO;KACv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,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":[],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I,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,22 +52,25 @@ 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,
|
|
@@ -111,13 +114,13 @@ async function runNextjsWizardWithTelemetry(options) {
|
|
|
111
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))}:`);
|
|
112
115
|
// eslint-disable-next-line no-console
|
|
113
116
|
console.log((0, templates_1.getSimpleUnderscoreErrorCopyPasteSnippet)());
|
|
114
|
-
const shouldContinue = await (0,
|
|
117
|
+
const shouldContinue = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
115
118
|
message: `Did you modify your ${chalk_1.default.cyan(path.join(...pagesLocation, underscoreErrorPageFile))} file as described above?`,
|
|
116
119
|
active: 'Yes',
|
|
117
120
|
inactive: 'No, get me out of here',
|
|
118
121
|
}));
|
|
119
122
|
if (!shouldContinue) {
|
|
120
|
-
await (0,
|
|
123
|
+
await (0, clack_1.abort)();
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
else {
|
|
@@ -125,13 +128,13 @@ async function runNextjsWizardWithTelemetry(options) {
|
|
|
125
128
|
// eslint-disable-next-line no-console
|
|
126
129
|
console.log((0, templates_1.getFullUnderscoreErrorCopyPasteSnippet)(underscoreErrorPageFile === '_error.ts' ||
|
|
127
130
|
underscoreErrorPageFile === '_error.tsx'));
|
|
128
|
-
const shouldContinue = await (0,
|
|
131
|
+
const shouldContinue = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
129
132
|
message: `Did you add the code to your ${chalk_1.default.cyan(path.join(...pagesLocation, underscoreErrorPageFile))} file as described above?`,
|
|
130
133
|
active: 'Yes',
|
|
131
134
|
inactive: 'No, get me out of here',
|
|
132
135
|
}));
|
|
133
136
|
if (!shouldContinue) {
|
|
134
|
-
await (0,
|
|
137
|
+
await (0, clack_1.abort)();
|
|
135
138
|
}
|
|
136
139
|
}
|
|
137
140
|
});
|
|
@@ -167,25 +170,25 @@ async function runNextjsWizardWithTelemetry(options) {
|
|
|
167
170
|
// eslint-disable-next-line no-console
|
|
168
171
|
console.log((0, templates_1.getGlobalErrorCopyPasteSnippet)(globalErrorPageFile === 'global-error.ts' ||
|
|
169
172
|
globalErrorPageFile === 'global-error.tsx'));
|
|
170
|
-
const shouldContinue = await (0,
|
|
173
|
+
const shouldContinue = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
171
174
|
message: `Did you add the code to your ${chalk_1.default.cyan(path.join(...appDirLocation, globalErrorPageFile))} file as described above?`,
|
|
172
175
|
active: 'Yes',
|
|
173
176
|
inactive: 'No, get me out of here',
|
|
174
177
|
}));
|
|
175
178
|
if (!shouldContinue) {
|
|
176
|
-
await (0,
|
|
179
|
+
await (0, clack_1.abort)();
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
});
|
|
180
|
-
const shouldCreateExamplePage = await (0,
|
|
183
|
+
const shouldCreateExamplePage = await (0, clack_1.askShouldCreateExamplePage)();
|
|
181
184
|
if (shouldCreateExamplePage) {
|
|
182
185
|
await (0, telemetry_1.traceStep)('create-example-page', async () => createExamplePage(selfHosted, selectedProject, sentryUrl));
|
|
183
186
|
}
|
|
184
|
-
await (0,
|
|
187
|
+
await (0, clack_1.addDotEnvSentryBuildPluginFile)(authToken);
|
|
185
188
|
const isLikelyUsingTurbopack = await checkIfLikelyIsUsingTurbopack();
|
|
186
189
|
if (isLikelyUsingTurbopack || isLikelyUsingTurbopack === null) {
|
|
187
|
-
await (0,
|
|
188
|
-
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.`)}`,
|
|
189
192
|
options: [
|
|
190
193
|
{
|
|
191
194
|
label: 'I understand.',
|
|
@@ -204,8 +207,10 @@ async function runNextjsWizardWithTelemetry(options) {
|
|
|
204
207
|
else {
|
|
205
208
|
await (0, sourcemaps_wizard_1.setupCI)('nextjs', authToken, options.comingFrom);
|
|
206
209
|
}
|
|
207
|
-
const packageManagerForOutro = packageManagerFromInstallStep ?? (await (0,
|
|
208
|
-
await (0,
|
|
210
|
+
const packageManagerForOutro = packageManagerFromInstallStep ?? (await (0, clack_1.getPackageManager)());
|
|
211
|
+
await (0, clack_1.runPrettierIfInstalled)({
|
|
212
|
+
cwd: undefined,
|
|
213
|
+
});
|
|
209
214
|
prompts_1.default.outro(`
|
|
210
215
|
${chalk_1.default.green('Successfully installed the Sentry Next.js SDK!')} ${shouldCreateExamplePage
|
|
211
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"')}`
|
|
@@ -217,7 +222,7 @@ ${chalk_1.default.dim('If you encounter any issues, let us know here: https://gi
|
|
|
217
222
|
}
|
|
218
223
|
exports.runNextjsWizardWithTelemetry = runNextjsWizardWithTelemetry;
|
|
219
224
|
async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl, sdkConfigOptions) {
|
|
220
|
-
const selectedFeatures = await (0,
|
|
225
|
+
const selectedFeatures = await (0, clack_1.featureSelectionPrompt)([
|
|
221
226
|
{
|
|
222
227
|
id: 'performance',
|
|
223
228
|
prompt: `Do you want to enable ${chalk_1.default.bold('Tracing')} to track the performance of your application?`,
|
|
@@ -229,8 +234,8 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
229
234
|
enabledHint: 'recommended, but increases bundle size',
|
|
230
235
|
},
|
|
231
236
|
]);
|
|
232
|
-
const typeScriptDetected = (0,
|
|
233
|
-
const configVariants = ['server', '
|
|
237
|
+
const typeScriptDetected = (0, clack_1.isUsingTypeScript)();
|
|
238
|
+
const configVariants = ['server', 'edge'];
|
|
234
239
|
for (const configVariant of configVariants) {
|
|
235
240
|
await (0, telemetry_1.traceStep)(`create-sentry-${configVariant}-config`, async () => {
|
|
236
241
|
const jsConfig = `sentry.${configVariant}.config.js`;
|
|
@@ -246,7 +251,7 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
246
251
|
if (tsConfigExists) {
|
|
247
252
|
existingConfigs.push(tsConfig);
|
|
248
253
|
}
|
|
249
|
-
const overwriteExistingConfigs = await (0,
|
|
254
|
+
const overwriteExistingConfigs = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
250
255
|
message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(', ')}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,
|
|
251
256
|
}));
|
|
252
257
|
Sentry.setTag(`overwrite-${configVariant}-config`, overwriteExistingConfigs);
|
|
@@ -263,7 +268,7 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
263
268
|
}
|
|
264
269
|
}
|
|
265
270
|
if (shouldWriteFile) {
|
|
266
|
-
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' });
|
|
267
272
|
prompts_1.default.log.success(`Created fresh ${chalk_1.default.cyan(typeScriptDetected ? tsConfig : jsConfig)}.`);
|
|
268
273
|
Sentry.setTag(`created-${configVariant}-config`, true);
|
|
269
274
|
}
|
|
@@ -316,19 +321,80 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
316
321
|
const newInstrumentationHookPath = newInstrumentationHookLocation === 'root'
|
|
317
322
|
? path.join(process.cwd(), newInstrumentationFileName)
|
|
318
323
|
: path.join(process.cwd(), 'src', newInstrumentationFileName);
|
|
319
|
-
const successfullyCreated = await (0,
|
|
324
|
+
const successfullyCreated = await (0, clack_1.createNewConfigFile)(newInstrumentationHookPath, (0, templates_1.getInstrumentationHookContent)(newInstrumentationHookLocation));
|
|
320
325
|
if (!successfullyCreated) {
|
|
321
|
-
await (0,
|
|
326
|
+
await (0, clack_1.showCopyPasteInstructions)(newInstrumentationFileName, (0, templates_1.getInstrumentationHookCopyPasteSnippet)(newInstrumentationHookLocation), "create the file if it doesn't already exist");
|
|
322
327
|
}
|
|
323
328
|
}
|
|
324
329
|
else {
|
|
325
|
-
await (0,
|
|
330
|
+
await (0, clack_1.showCopyPasteInstructions)(srcInstrumentationTsExists || instrumentationTsExists
|
|
326
331
|
? 'instrumentation.ts'
|
|
327
332
|
: srcInstrumentationJsExists || instrumentationJsExists
|
|
328
333
|
? 'instrumentation.js'
|
|
329
334
|
: newInstrumentationFileName, (0, templates_1.getInstrumentationHookCopyPasteSnippet)(instrumentationHookLocation));
|
|
330
335
|
}
|
|
331
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
|
+
});
|
|
332
398
|
await (0, telemetry_1.traceStep)('setup-next-config', async () => {
|
|
333
399
|
const withSentryConfigOptionsTemplate = (0, templates_1.getWithSentryConfigOptionsTemplate)({
|
|
334
400
|
orgSlug: selectedProject.organization.slug,
|
|
@@ -381,7 +447,7 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
381
447
|
nextConfigCjsContent.includes('withSentryConfig');
|
|
382
448
|
let shouldInject = true;
|
|
383
449
|
if (probablyIncludesSdk) {
|
|
384
|
-
const injectAnyhow = await (0,
|
|
450
|
+
const injectAnyhow = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
385
451
|
message: `${chalk_1.default.cyan(foundNextConfigFileFilename)} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,
|
|
386
452
|
}));
|
|
387
453
|
shouldInject = injectAnyhow;
|
|
@@ -401,7 +467,7 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
401
467
|
nextConfigMjsContent.includes('withSentryConfig');
|
|
402
468
|
let shouldInject = true;
|
|
403
469
|
if (probablyIncludesSdk) {
|
|
404
|
-
const injectAnyhow = await (0,
|
|
470
|
+
const injectAnyhow = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
405
471
|
message: `${chalk_1.default.cyan(foundNextConfigFileFilename)} already contains Sentry SDK configuration. Should the wizard modify it anyways?`,
|
|
406
472
|
}));
|
|
407
473
|
shouldInject = injectAnyhow;
|
|
@@ -436,13 +502,13 @@ async function createOrMergeNextJsFiles(selectedProject, selfHosted, sentryUrl,
|
|
|
436
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`);
|
|
437
503
|
// eslint-disable-next-line no-console
|
|
438
504
|
console.log((0, templates_1.getNextjsConfigEsmCopyPasteSnippet)(withSentryConfigOptionsTemplate));
|
|
439
|
-
const shouldContinue = await (0,
|
|
505
|
+
const shouldContinue = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
|
|
440
506
|
message: `Are you done putting the snippet above into ${chalk_1.default.cyan(foundNextConfigFileFilename)}?`,
|
|
441
507
|
active: 'Yes',
|
|
442
508
|
inactive: 'No, get me out of here',
|
|
443
509
|
}));
|
|
444
510
|
if (!shouldContinue) {
|
|
445
|
-
await (0,
|
|
511
|
+
await (0, clack_1.abort)();
|
|
446
512
|
}
|
|
447
513
|
}
|
|
448
514
|
}
|
|
@@ -461,7 +527,7 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
|
461
527
|
const hasSrcAppDirectory = hasDirectoryPathFromRoot(['src', 'app']);
|
|
462
528
|
const hasSrcPagesDirectory = hasDirectoryPathFromRoot(['src', 'pages']);
|
|
463
529
|
Sentry.setTag('nextjs-app-dir', hasRootAppDirectory || hasSrcAppDirectory);
|
|
464
|
-
const typeScriptDetected = (0,
|
|
530
|
+
const typeScriptDetected = (0, clack_1.isUsingTypeScript)();
|
|
465
531
|
// If `pages` or an `app` directory exists in the root, we'll put the example page there.
|
|
466
532
|
// `app` directory takes priority over `pages` directory when they coexist, so we prioritize that.
|
|
467
533
|
// https://nextjs.org/docs/app/building-your-application/routing#the-app-router
|
|
@@ -486,6 +552,15 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
|
486
552
|
pagesFolderLocation = newPagesFolderLocation;
|
|
487
553
|
}
|
|
488
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
|
+
}
|
|
489
564
|
const examplePageContents = (0, templates_1.getSentryExamplePageContents)({
|
|
490
565
|
selfHosted,
|
|
491
566
|
orgSlug: selectedProject.organization.slug,
|
|
@@ -493,17 +568,17 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
|
493
568
|
sentryUrl,
|
|
494
569
|
useClient: true,
|
|
495
570
|
});
|
|
496
|
-
fs.mkdirSync(path.join(
|
|
571
|
+
fs.mkdirSync(path.join(appFolderPath, 'sentry-example-page'), {
|
|
497
572
|
recursive: true,
|
|
498
573
|
});
|
|
499
574
|
const newPageFileName = `page.${typeScriptDetected ? 'tsx' : 'jsx'}`;
|
|
500
|
-
await fs.promises.writeFile(path.join(
|
|
575
|
+
await fs.promises.writeFile(path.join(appFolderPath, 'sentry-example-page', newPageFileName), examplePageContents, { encoding: 'utf8', flag: 'w' });
|
|
501
576
|
prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...appFolderLocation, 'sentry-example-page', newPageFileName))}.`);
|
|
502
|
-
fs.mkdirSync(path.join(
|
|
577
|
+
fs.mkdirSync(path.join(appFolderPath, 'api', 'sentry-example-api'), {
|
|
503
578
|
recursive: true,
|
|
504
579
|
});
|
|
505
580
|
const newRouteFileName = `route.${typeScriptDetected ? 'ts' : 'js'}`;
|
|
506
|
-
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' });
|
|
507
582
|
prompts_1.default.log.success(`Created ${chalk_1.default.cyan(path.join(...appFolderLocation, 'api', 'sentry-example-api', newRouteFileName))}.`);
|
|
508
583
|
}
|
|
509
584
|
else if (pagesFolderLocation) {
|
|
@@ -530,7 +605,7 @@ async function createExamplePage(selfHosted, selectedProject, sentryUrl) {
|
|
|
530
605
|
*/
|
|
531
606
|
async function askShouldSetTunnelRoute() {
|
|
532
607
|
return await (0, telemetry_1.traceStep)('ask-tunnelRoute-option', async (span) => {
|
|
533
|
-
const shouldSetTunnelRoute = await (0,
|
|
608
|
+
const shouldSetTunnelRoute = await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
|
|
534
609
|
message: 'Do you want to route Sentry requests in the browser through your Next.js server to avoid ad blockers?',
|
|
535
610
|
options: [
|
|
536
611
|
{
|