@sentry/wizard
Version:
Sentry wizard helping you to configure your project
108 lines (101 loc) • 4.86 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.configureNextJsSourceMapsUpload = void 0;
// @ts-expect-error - clack is ESM and TS complains about that. It works though
const clack = __importStar(require("@clack/prompts"));
const chalk_1 = __importDefault(require("chalk"));
const nextjs_wizard_1 = require("../../nextjs/nextjs-wizard");
const telemetry_1 = require("../../telemetry");
const clack_1 = require("../../utils/clack");
const Sentry = __importStar(require("@sentry/node"));
const getCodeSnippet = (options) => chalk_1.default.grey(`
${chalk_1.default.greenBright('const { withSentryConfig } = require("@sentry/nextjs");')}
const nextConfig = {
// your existing next config
};
${chalk_1.default.greenBright(`const sentryWebpackPluginOptions = {
org: "${options.orgSlug}",
project: "${options.projectSlug}",${options.selfHosted ? `\n url: "${options.url}",` : ''}
};`)}
${chalk_1.default.greenBright(`const sentryOptions = {
// Upload additional client files (increases upload size)
widenClientFileUpload: true,
};`)}
${chalk_1.default.greenBright(`module.exports = withSentryConfig(
nextConfig,
sentryWebpackPluginOptions,
sentryOptions
);`)}
`);
const configureNextJsSourceMapsUpload = async (options, wizardOptions) => {
clack.log
.info(`Source Maps upload for Next.js is configured automatically by default if you run the Sentry Wizard for Next.JS.
But don't worry, we can redirect you to the wizard now!
In case you already tried the wizard, we can also show you how to configure your ${chalk_1.default.cyan('next.config.js')} file manually instead.`);
const shouldRedirect = await (0, clack_1.abortIfCancelled)(clack.select({
message: 'Do you want to run the Sentry Wizard for Next.JS now?',
options: [
{
label: 'Yes, run the wizard!',
value: true,
hint: 'The wizard can also configure your SDK setup',
},
{
label: 'No, show me how to configure it manually',
value: false,
},
],
}));
Sentry.setTag('redirect-nextjs-wizard', shouldRedirect);
if (shouldRedirect) {
await (0, telemetry_1.traceStep)('run-nextjs-wizard', () => (0, nextjs_wizard_1.runNextjsWizard)(wizardOptions));
clack.intro('Sentry Source Maps Upload Configuration Wizard');
clack.log.info("Welcome back to the Source Maps wizard - we're almost done ;)");
}
else {
clack.log.info(`Add the following code to your ${chalk_1.default.cyan('next.config.js')}:`);
// Intentionally logging directly to console here
// eslint-disable-next-line no-console
console.log(getCodeSnippet(options));
await (0, telemetry_1.traceStep)('nextjs-manual-nextconfigjs', () => (0, clack_1.abortIfCancelled)(clack.select({
message: 'Did you copy the code above?',
options: [{ label: 'Yes, continue!', value: true }],
initialValue: true,
})));
await (0, telemetry_1.traceStep)('nextjs-manual-sentryclirc', () => (0, clack_1.addDotEnvSentryBuildPluginFile)(options.authToken));
}
clack.log
.info(`In case you still run into problems, check out our docs to further debug your setup:
Uploading Source Maps:
https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#configure-source-maps
Troubleshooting Source Maps:
https://docs.sentry.io/platforms/javascript/guides/nextjs/troubleshooting/`);
};
exports.configureNextJsSourceMapsUpload = configureNextJsSourceMapsUpload;
//# sourceMappingURL=nextjs.js.map