@sentry/wizard 3.34.3 → 3.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/dist/e2e-tests/tests/nuxt-3.test.d.ts +1 -0
  3. package/dist/e2e-tests/tests/nuxt-3.test.js +231 -0
  4. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -0
  5. package/dist/e2e-tests/tests/nuxt-4.test.d.ts +1 -0
  6. package/dist/e2e-tests/tests/nuxt-4.test.js +232 -0
  7. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -0
  8. package/dist/e2e-tests/tests/remix.test.js +92 -27
  9. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  10. package/dist/e2e-tests/tests/sveltekit.test.js +102 -42
  11. package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
  12. package/dist/e2e-tests/utils/index.d.ts +18 -1
  13. package/dist/e2e-tests/utils/index.js +31 -2
  14. package/dist/e2e-tests/utils/index.js.map +1 -1
  15. package/dist/lib/Constants.d.ts +1 -0
  16. package/dist/lib/Constants.js +1 -0
  17. package/dist/lib/Constants.js.map +1 -1
  18. package/dist/package.json +3 -3
  19. package/dist/src/apple/templates.js +2 -2
  20. package/dist/src/apple/templates.js.map +1 -1
  21. package/dist/src/nextjs/nextjs-wizard.js +1 -0
  22. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  23. package/dist/src/nuxt/nuxt-wizard.d.ts +3 -0
  24. package/dist/src/nuxt/nuxt-wizard.js +220 -0
  25. package/dist/src/nuxt/nuxt-wizard.js.map +1 -0
  26. package/dist/src/nuxt/sdk-example.d.ts +8 -0
  27. package/dist/src/nuxt/sdk-example.js +179 -0
  28. package/dist/src/nuxt/sdk-example.js.map +1 -0
  29. package/dist/src/nuxt/sdk-setup.d.ts +8 -0
  30. package/dist/src/nuxt/sdk-setup.js +275 -0
  31. package/dist/src/nuxt/sdk-setup.js.map +1 -0
  32. package/dist/src/nuxt/templates.d.ts +22 -0
  33. package/dist/src/nuxt/templates.js +84 -0
  34. package/dist/src/nuxt/templates.js.map +1 -0
  35. package/dist/src/nuxt/utils.d.ts +1 -0
  36. package/dist/src/nuxt/utils.js +71 -0
  37. package/dist/src/nuxt/utils.js.map +1 -0
  38. package/dist/src/remix/remix-wizard.js +2 -1
  39. package/dist/src/remix/remix-wizard.js.map +1 -1
  40. package/dist/src/run.d.ts +1 -1
  41. package/dist/src/run.js +30 -23
  42. package/dist/src/run.js.map +1 -1
  43. package/dist/src/sourcemaps/tools/rollup.js +1 -1
  44. package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
  45. package/dist/src/sveltekit/sveltekit-wizard.js +2 -1
  46. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  47. package/dist/src/utils/clack-utils.d.ts +6 -2
  48. package/dist/src/utils/clack-utils.js +30 -10
  49. package/dist/src/utils/clack-utils.js.map +1 -1
  50. package/dist/test/nuxt/templates.test.d.ts +1 -0
  51. package/dist/test/nuxt/templates.test.js +70 -0
  52. package/dist/test/nuxt/templates.test.js.map +1 -0
  53. package/e2e-tests/README.md +59 -0
  54. package/e2e-tests/test-applications/nuxt-3-test-app/README.md +75 -0
  55. package/e2e-tests/test-applications/nuxt-3-test-app/nuxt.config.ts +5 -0
  56. package/e2e-tests/test-applications/nuxt-3-test-app/package.json +18 -0
  57. package/e2e-tests/test-applications/nuxt-3-test-app/public/favicon.ico +0 -0
  58. package/e2e-tests/test-applications/nuxt-3-test-app/public/robots.txt +1 -0
  59. package/e2e-tests/tests/nuxt-3.test.ts +169 -0
  60. package/e2e-tests/tests/nuxt-4.test.ts +168 -0
  61. package/e2e-tests/tests/remix.test.ts +163 -50
  62. package/e2e-tests/tests/sveltekit.test.ts +180 -79
  63. package/e2e-tests/utils/index.ts +31 -1
  64. package/lib/Constants.ts +1 -0
  65. package/package.json +3 -3
  66. package/src/apple/templates.ts +14 -2
  67. package/src/nextjs/nextjs-wizard.ts +1 -0
  68. package/src/nuxt/nuxt-wizard.ts +166 -0
  69. package/src/nuxt/sdk-example.ts +135 -0
  70. package/src/nuxt/sdk-setup.ts +209 -0
  71. package/src/nuxt/templates.ts +296 -0
  72. package/src/nuxt/utils.ts +32 -0
  73. package/src/remix/remix-wizard.ts +2 -1
  74. package/src/run.ts +7 -0
  75. package/src/sourcemaps/tools/rollup.ts +1 -1
  76. package/src/sveltekit/sveltekit-wizard.ts +2 -1
  77. package/src/utils/clack-utils.ts +32 -8
  78. package/test/nuxt/templates.test.ts +228 -0
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
46
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
72
+ var __importDefault = (this && this.__importDefault) || function (mod) {
73
+ return (mod && mod.__esModule) ? mod : { "default": mod };
74
+ };
75
+ Object.defineProperty(exports, "__esModule", { value: true });
76
+ exports.createConfigFiles = exports.addSDKModule = exports.getNuxtConfig = void 0;
77
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
78
+ var prompts_1 = __importDefault(require("@clack/prompts"));
79
+ var Sentry = __importStar(require("@sentry/node"));
80
+ var chalk_1 = __importDefault(require("chalk"));
81
+ var fs_1 = __importDefault(require("fs"));
82
+ // @ts-expect-error - magicast is ESM and TS complains about that. It works though
83
+ var magicast_1 = require("magicast");
84
+ // @ts-expect-error - magicast is ESM and TS complains about that. It works though
85
+ var helpers_1 = require("magicast/helpers");
86
+ var path_1 = __importDefault(require("path"));
87
+ var templates_1 = require("./templates");
88
+ var clack_utils_1 = require("../utils/clack-utils");
89
+ var telemetry_1 = require("../telemetry");
90
+ var possibleNuxtConfig = [
91
+ 'nuxt.config.js',
92
+ 'nuxt.config.mjs',
93
+ 'nuxt.config.cjs',
94
+ 'nuxt.config.ts',
95
+ 'nuxt.config.mts',
96
+ 'nuxt.config.cts',
97
+ ];
98
+ function getNuxtConfig() {
99
+ return __awaiter(this, void 0, void 0, function () {
100
+ var configFile;
101
+ return __generator(this, function (_a) {
102
+ switch (_a.label) {
103
+ case 0:
104
+ configFile = possibleNuxtConfig.find(function (fileName) {
105
+ return fs_1.default.existsSync(path_1.default.join(process.cwd(), fileName));
106
+ });
107
+ if (!!configFile) return [3 /*break*/, 2];
108
+ prompts_1.default.log.info('No Nuxt config file found, creating a new one.');
109
+ Sentry.setTag('nuxt-config-strategy', 'create');
110
+ // nuxt recommends its config to be .ts by default
111
+ configFile = 'nuxt.config.ts';
112
+ return [4 /*yield*/, fs_1.default.promises.writeFile(path_1.default.join(process.cwd(), configFile), (0, templates_1.getDefaultNuxtConfig)(), { encoding: 'utf-8', flag: 'w' })];
113
+ case 1:
114
+ _a.sent();
115
+ prompts_1.default.log.success("Created ".concat(chalk_1.default.cyan('nuxt.config.ts'), "."));
116
+ _a.label = 2;
117
+ case 2: return [2 /*return*/, path_1.default.join(process.cwd(), configFile)];
118
+ }
119
+ });
120
+ });
121
+ }
122
+ exports.getNuxtConfig = getNuxtConfig;
123
+ function addSDKModule(config, options) {
124
+ return __awaiter(this, void 0, void 0, function () {
125
+ var mod, code, e_1;
126
+ return __generator(this, function (_a) {
127
+ switch (_a.label) {
128
+ case 0:
129
+ _a.trys.push([0, 3, , 7]);
130
+ return [4 /*yield*/, (0, magicast_1.loadFile)(config)];
131
+ case 1:
132
+ mod = _a.sent();
133
+ (0, helpers_1.addNuxtModule)(mod, '@sentry/nuxt/module', 'sentry', {
134
+ sourceMapsUploadOptions: __assign({ org: options.org, project: options.project }, (options.selfHosted && { url: options.url })),
135
+ });
136
+ (0, helpers_1.addNuxtModule)(mod, '@sentry/nuxt/module', 'sourcemap', {
137
+ client: 'hidden',
138
+ });
139
+ code = (0, magicast_1.generateCode)(mod).code;
140
+ return [4 /*yield*/, fs_1.default.promises.writeFile(config, code, { encoding: 'utf-8', flag: 'w' })];
141
+ case 2:
142
+ _a.sent();
143
+ prompts_1.default.log.success("Added Sentry Nuxt Module to ".concat(chalk_1.default.cyan(path_1.default.basename(config)), "."));
144
+ return [3 /*break*/, 7];
145
+ case 3:
146
+ e_1 = _a.sent();
147
+ if (!(e_1 instanceof magicast_1.MagicastError)) return [3 /*break*/, 4];
148
+ prompts_1.default.log.warn("Automatic configuration of ".concat(chalk_1.default.cyan(path_1.default.basename(config)), " failed, please add the following settings:"));
149
+ // eslint-disable-next-line no-console
150
+ console.log("\n\n".concat((0, templates_1.getNuxtModuleFallbackTemplate)(options), "\n\n"));
151
+ return [3 /*break*/, 6];
152
+ case 4:
153
+ prompts_1.default.log.error('Error while adding the Sentry Nuxt Module to the Nuxt config.');
154
+ prompts_1.default.log.info(chalk_1.default.dim(typeof e_1 === 'object' && e_1 != null && 'toString' in e_1
155
+ ? e_1.toString()
156
+ : typeof e_1 === 'string'
157
+ ? e_1
158
+ : 'Unknown error'));
159
+ Sentry.captureException('Error while setting up the Nuxt SDK');
160
+ return [4 /*yield*/, (0, clack_utils_1.abort)('Exiting Wizard')];
161
+ case 5:
162
+ _a.sent();
163
+ _a.label = 6;
164
+ case 6: return [3 /*break*/, 7];
165
+ case 7: return [2 /*return*/];
166
+ }
167
+ });
168
+ });
169
+ }
170
+ exports.addSDKModule = addSDKModule;
171
+ function createConfigFiles(dsn) {
172
+ return __awaiter(this, void 0, void 0, function () {
173
+ var selectedFeatures, typeScriptDetected, configVariants, _loop_1, _i, configVariants_1, configVariant;
174
+ var _this = this;
175
+ return __generator(this, function (_a) {
176
+ switch (_a.label) {
177
+ case 0: return [4 /*yield*/, (0, clack_utils_1.featureSelectionPrompt)([
178
+ {
179
+ id: 'performance',
180
+ prompt: "Do you want to enable ".concat(chalk_1.default.bold('Tracing'), " to track the performance of your application?"),
181
+ enabledHint: 'recommended',
182
+ },
183
+ {
184
+ id: 'replay',
185
+ prompt: "Do you want to enable ".concat(chalk_1.default.bold('Sentry Session Replay'), " to get a video-like reproduction of errors during a user session?"),
186
+ enabledHint: 'recommended, but increases bundle size',
187
+ },
188
+ ])];
189
+ case 1:
190
+ selectedFeatures = _a.sent();
191
+ typeScriptDetected = (0, clack_utils_1.isUsingTypeScript)();
192
+ configVariants = ['server', 'client'];
193
+ _loop_1 = function (configVariant) {
194
+ return __generator(this, function (_b) {
195
+ switch (_b.label) {
196
+ case 0: return [4 /*yield*/, (0, telemetry_1.traceStep)("create-sentry-".concat(configVariant, "-config"), function () { return __awaiter(_this, void 0, void 0, function () {
197
+ var jsConfig, tsConfig, jsConfigExists, tsConfigExists, shouldWriteFile, existingConfigs, overwriteExistingConfigs;
198
+ return __generator(this, function (_a) {
199
+ switch (_a.label) {
200
+ case 0:
201
+ jsConfig = "sentry.".concat(configVariant, ".config.js");
202
+ tsConfig = "sentry.".concat(configVariant, ".config.ts");
203
+ jsConfigExists = fs_1.default.existsSync(path_1.default.join(process.cwd(), jsConfig));
204
+ tsConfigExists = fs_1.default.existsSync(path_1.default.join(process.cwd(), tsConfig));
205
+ shouldWriteFile = true;
206
+ if (!(jsConfigExists || tsConfigExists)) return [3 /*break*/, 2];
207
+ existingConfigs = [];
208
+ if (jsConfigExists) {
209
+ existingConfigs.push(jsConfig);
210
+ }
211
+ if (tsConfigExists) {
212
+ existingConfigs.push(tsConfig);
213
+ }
214
+ return [4 /*yield*/, (0, clack_utils_1.abortIfCancelled)(prompts_1.default.confirm({
215
+ message: "Found existing Sentry ".concat(configVariant, " config (").concat(existingConfigs.join(', '), "). Overwrite ").concat(existingConfigs.length > 1 ? 'them' : 'it', "?"),
216
+ }))];
217
+ case 1:
218
+ overwriteExistingConfigs = _a.sent();
219
+ Sentry.setTag("overwrite-".concat(configVariant, "-config"), overwriteExistingConfigs);
220
+ shouldWriteFile = overwriteExistingConfigs;
221
+ if (overwriteExistingConfigs) {
222
+ if (jsConfigExists) {
223
+ fs_1.default.unlinkSync(path_1.default.join(process.cwd(), jsConfig));
224
+ prompts_1.default.log.warn("Removed existing ".concat(chalk_1.default.cyan(jsConfig), "."));
225
+ }
226
+ if (tsConfigExists) {
227
+ fs_1.default.unlinkSync(path_1.default.join(process.cwd(), tsConfig));
228
+ prompts_1.default.log.warn("Removed existing ".concat(chalk_1.default.cyan(tsConfig), "."));
229
+ }
230
+ }
231
+ _a.label = 2;
232
+ case 2:
233
+ if (!shouldWriteFile) return [3 /*break*/, 4];
234
+ return [4 /*yield*/, fs_1.default.promises.writeFile(path_1.default.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig), (0, templates_1.getSentryConfigContents)(dsn, configVariant, selectedFeatures), { encoding: 'utf8', flag: 'w' })];
235
+ case 3:
236
+ _a.sent();
237
+ prompts_1.default.log.success("Created new ".concat(chalk_1.default.cyan(typeScriptDetected ? tsConfig : jsConfig), "."));
238
+ Sentry.setTag("created-".concat(configVariant, "-config"), true);
239
+ return [3 /*break*/, 5];
240
+ case 4:
241
+ prompts_1.default.log.info("Okay, here are the changes your ".concat(chalk_1.default.cyan(typeScriptDetected ? tsConfig : jsConfig), " should contain:"));
242
+ // eslint-disable-next-line no-console
243
+ console.log('\n\n ' +
244
+ (0, templates_1.getConfigBody)(dsn, configVariant, selectedFeatures) +
245
+ '\n\n');
246
+ _a.label = 5;
247
+ case 5: return [2 /*return*/];
248
+ }
249
+ });
250
+ }); })];
251
+ case 1:
252
+ _b.sent();
253
+ return [2 /*return*/];
254
+ }
255
+ });
256
+ };
257
+ _i = 0, configVariants_1 = configVariants;
258
+ _a.label = 2;
259
+ case 2:
260
+ if (!(_i < configVariants_1.length)) return [3 /*break*/, 5];
261
+ configVariant = configVariants_1[_i];
262
+ return [5 /*yield**/, _loop_1(configVariant)];
263
+ case 3:
264
+ _a.sent();
265
+ _a.label = 4;
266
+ case 4:
267
+ _i++;
268
+ return [3 /*break*/, 2];
269
+ case 5: return [2 /*return*/];
270
+ }
271
+ });
272
+ });
273
+ }
274
+ exports.createConfigFiles = createConfigFiles;
275
+ //# sourceMappingURL=sdk-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/nuxt/sdk-setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,2DAAmC;AACnC,mDAAuC;AACvC,gDAA0B;AAC1B,0CAAoB;AACpB,kFAAkF;AAClF,qCAAiE;AACjE,kFAAkF;AAClF,4CAAiD;AACjD,8CAAwB;AACxB,yCAKqB;AACrB,oDAK8B;AAC9B,0CAAyC;AAEz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SAAS,CACzB,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAClE,IAAA,mCAAuB,EAAC,GAAG,EAAE,aAAa,EAAE,gBAAgB,CAAC,EAC7D,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAChC,EAAA;;oDAJD,SAIC,CAAC;oDACF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,sBAAe,eAAK,CAAC,IAAI,CACvB,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CACzC,MAAG,CACL,CAAC;oDACF,MAAM,CAAC,MAAM,CAAC,kBAAW,aAAa,YAAS,EAAE,IAAI,CAAC,CAAC;;;oDAEvD,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,0CAAmC,eAAK,CAAC,IAAI,CAC3C,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CACzC,qBAAkB,CACpB,CAAC;oDACF,sCAAsC;oDACtC,OAAO,CAAC,GAAG,CACT,QAAQ;wDACN,IAAA,yBAAa,EAAC,GAAG,EAAE,aAAa,EAAE,gBAAgB,CAAC;wDACnD,MAAM,CACT,CAAC;;;;;yCAEL,CAAC,EAAA;;oCAvEF,SAuEE,CAAC;;;;;0BAxEqC,EAAd,iCAAc;;;yBAAd,CAAA,4BAAc,CAAA;oBAA/B,aAAa;kDAAb,aAAa;;;;;oBAAI,IAAc,CAAA;;;;;;CA0E3C;AAhGD,8CAgGC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport fs from 'fs';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { loadFile, generateCode, MagicastError } from 'magicast';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { addNuxtModule } from 'magicast/helpers';\nimport path from 'path';\nimport {\n getConfigBody,\n getDefaultNuxtConfig,\n getNuxtModuleFallbackTemplate,\n getSentryConfigContents,\n} from './templates';\nimport {\n abort,\n abortIfCancelled,\n featureSelectionPrompt,\n isUsingTypeScript,\n} from '../utils/clack-utils';\nimport { traceStep } from '../telemetry';\n\nconst possibleNuxtConfig = [\n 'nuxt.config.js',\n 'nuxt.config.mjs',\n 'nuxt.config.cjs',\n 'nuxt.config.ts',\n 'nuxt.config.mts',\n 'nuxt.config.cts',\n];\n\nexport async function getNuxtConfig(): Promise<string> {\n let configFile = possibleNuxtConfig.find((fileName) =>\n fs.existsSync(path.join(process.cwd(), fileName)),\n );\n\n if (!configFile) {\n clack.log.info('No Nuxt config file found, creating a new one.');\n Sentry.setTag('nuxt-config-strategy', 'create');\n // nuxt recommends its config to be .ts by default\n configFile = 'nuxt.config.ts';\n\n await fs.promises.writeFile(\n path.join(process.cwd(), configFile),\n getDefaultNuxtConfig(),\n { encoding: 'utf-8', flag: 'w' },\n );\n\n clack.log.success(`Created ${chalk.cyan('nuxt.config.ts')}.`);\n }\n\n return path.join(process.cwd(), configFile);\n}\n\nexport async function addSDKModule(\n config: string,\n options: { org: string; project: string; url: string; selfHosted: boolean },\n): Promise<void> {\n try {\n const mod = await loadFile(config);\n\n addNuxtModule(mod, '@sentry/nuxt/module', 'sentry', {\n sourceMapsUploadOptions: {\n org: options.org,\n project: options.project,\n ...(options.selfHosted && { url: options.url }),\n },\n });\n addNuxtModule(mod, '@sentry/nuxt/module', 'sourcemap', {\n client: 'hidden',\n });\n\n const { code } = generateCode(mod);\n\n await fs.promises.writeFile(config, code, { encoding: 'utf-8', flag: 'w' });\n\n clack.log.success(\n `Added Sentry Nuxt Module to ${chalk.cyan(path.basename(config))}.`,\n );\n } catch (e: unknown) {\n // Cases where users spread options are not covered by magicast,\n // so we fall back to showing how to configure the nuxt config\n // manually.\n if (e instanceof MagicastError) {\n clack.log.warn(\n `Automatic configuration of ${chalk.cyan(\n path.basename(config),\n )} failed, please add the following settings:`,\n );\n // eslint-disable-next-line no-console\n console.log(`\\n\\n${getNuxtModuleFallbackTemplate(options)}\\n\\n`);\n } else {\n clack.log.error(\n 'Error while adding the Sentry Nuxt Module to the Nuxt config.',\n );\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n Sentry.captureException('Error while setting up the Nuxt SDK');\n await abort('Exiting Wizard');\n }\n }\n}\n\nexport async function createConfigFiles(dsn: string) {\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Sentry Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', 'client'] as const;\n\n for (const configVariant of configVariants) {\n await traceStep(`create-sentry-${configVariant}-config`, async () => {\n const jsConfig = `sentry.${configVariant}.config.js`;\n const tsConfig = `sentry.${configVariant}.config.ts`;\n\n const jsConfigExists = fs.existsSync(path.join(process.cwd(), jsConfig));\n const tsConfigExists = fs.existsSync(path.join(process.cwd(), tsConfig));\n\n let shouldWriteFile = true;\n\n if (jsConfigExists || tsConfigExists) {\n const existingConfigs = [];\n\n if (jsConfigExists) {\n existingConfigs.push(jsConfig);\n }\n\n if (tsConfigExists) {\n existingConfigs.push(tsConfig);\n }\n\n const overwriteExistingConfigs = await abortIfCancelled(\n clack.confirm({\n message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(\n ', ',\n )}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,\n }),\n );\n Sentry.setTag(\n `overwrite-${configVariant}-config`,\n overwriteExistingConfigs,\n );\n\n shouldWriteFile = overwriteExistingConfigs;\n\n if (overwriteExistingConfigs) {\n if (jsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), jsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(jsConfig)}.`);\n }\n if (tsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), tsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(tsConfig)}.`);\n }\n }\n }\n\n if (shouldWriteFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig),\n getSentryConfigContents(dsn, configVariant, selectedFeatures),\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created new ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )}.`,\n );\n Sentry.setTag(`created-${configVariant}-config`, true);\n } else {\n clack.log.info(\n `Okay, here are the changes your ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )} should contain:`,\n );\n // eslint-disable-next-line no-console\n console.log(\n '\\n\\n ' +\n getConfigBody(dsn, configVariant, selectedFeatures) +\n '\\n\\n',\n );\n }\n });\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ type SelectedSentryFeatures = {
2
+ performance: boolean;
3
+ replay: boolean;
4
+ };
5
+ export declare function getDefaultNuxtConfig(): string;
6
+ export declare function getNuxtModuleFallbackTemplate(options: {
7
+ org: string;
8
+ project: string;
9
+ url: string;
10
+ selfHosted: boolean;
11
+ }): string;
12
+ export declare function getSentryConfigContents(dsn: string, config: 'client' | 'server', selectedFeatures: SelectedSentryFeatures): string;
13
+ export declare function getConfigBody(dsn: string, variant: 'client' | 'server', selectedFeatures: SelectedSentryFeatures): string;
14
+ export declare function getIndexRouteTemplate(): string;
15
+ export declare function getSentryExamplePageTemplate(options: {
16
+ url: string;
17
+ org: string;
18
+ projectId: string;
19
+ }): string;
20
+ export declare function getSentryExampleApiTemplate(): string;
21
+ export declare function getSentryErrorButtonTemplate(): string;
22
+ export {};
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSentryErrorButtonTemplate = exports.getSentryExampleApiTemplate = exports.getSentryExamplePageTemplate = exports.getIndexRouteTemplate = exports.getConfigBody = exports.getSentryConfigContents = exports.getNuxtModuleFallbackTemplate = exports.getDefaultNuxtConfig = void 0;
4
+ var url_1 = require("../utils/url");
5
+ function getDefaultNuxtConfig() {
6
+ return "// https://nuxt.com/docs/api/configuration/nuxt-config\nexport default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n})\n";
7
+ }
8
+ exports.getDefaultNuxtConfig = getDefaultNuxtConfig;
9
+ function getNuxtModuleFallbackTemplate(options) {
10
+ return " modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"".concat(options.org, "\",\n project: \"").concat(options.project, "\",").concat(options.selfHosted ? "\n url: \"".concat(options.url, "\",") : '', "\n },\n },\n sourcemap: { client: \"hidden\" },");
11
+ }
12
+ exports.getNuxtModuleFallbackTemplate = getNuxtModuleFallbackTemplate;
13
+ function getSentryConfigContents(dsn, config, selectedFeatures) {
14
+ if (config === 'client') {
15
+ return getSentryClientConfigContents(dsn, selectedFeatures);
16
+ }
17
+ return getSentryServerConfigContents(dsn, selectedFeatures);
18
+ }
19
+ exports.getSentryConfigContents = getSentryConfigContents;
20
+ var featuresConfigMap = {
21
+ performance: [
22
+ ' // We recommend adjusting this value in production, or using tracesSampler',
23
+ ' // for finer control',
24
+ ' tracesSampleRate: 1.0,',
25
+ ].join('\n'),
26
+ replay: [
27
+ ' // This sets the sample rate to be 10%. You may want this to be 100% while',
28
+ ' // in development and sample at a lower rate in production',
29
+ ' replaysSessionSampleRate: 0.1,',
30
+ ' ',
31
+ ' // If the entire session is not sampled, use the below sample rate to sample',
32
+ ' // sessions when an error occurs.',
33
+ ' replaysOnErrorSampleRate: 1.0,',
34
+ ' ',
35
+ " // If you don't want to use Session Replay, just remove the line below:",
36
+ ' integrations: [Sentry.replayIntegration()],',
37
+ ].join('\n'),
38
+ };
39
+ var featuresMap = {
40
+ client: ['performance', 'replay'],
41
+ server: ['performance'],
42
+ };
43
+ function getConfigBody(dsn, variant, selectedFeatures) {
44
+ return [
45
+ "dsn: \"".concat(dsn, "\","),
46
+ Object.entries(selectedFeatures)
47
+ .map(function (_a) {
48
+ var feature = _a[0], activated = _a[1];
49
+ return featuresMap[variant].includes(feature) && activated
50
+ ? featuresConfigMap[feature]
51
+ : null;
52
+ })
53
+ .filter(Boolean)
54
+ .join('\n\n'),
55
+ ]
56
+ .filter(Boolean)
57
+ .join('\n\n');
58
+ }
59
+ exports.getConfigBody = getConfigBody;
60
+ function getSentryClientConfigContents(dsn, selectedFeatures) {
61
+ return "import * as Sentry from \"@sentry/nuxt\";\n\nSentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n ".concat(getConfigBody(dsn, 'client', selectedFeatures), "\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n");
62
+ }
63
+ function getSentryServerConfigContents(dsn, selectedFeatures) {
64
+ return "import * as Sentry from \"@sentry/nuxt\";\n \nSentry.init({\n ".concat(getConfigBody(dsn, 'server', selectedFeatures), "\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n");
65
+ }
66
+ function getIndexRouteTemplate() {
67
+ return "<!--\nThis is just to verify the sentry-example-page.\nFeel free to delete this file.\n-->\n\n<template></template>";
68
+ }
69
+ exports.getIndexRouteTemplate = getIndexRouteTemplate;
70
+ function getSentryExamplePageTemplate(options) {
71
+ var url = options.url, org = options.org, projectId = options.projectId;
72
+ var issuesPageLink = (0, url_1.getIssueStreamUrl)({ url: url, orgSlug: org, projectId: projectId });
73
+ return "<!--\nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n import { useFetch} from '#imports'\n \n function getSentryData() {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const { error } = await useFetch('/api/sentry-example-api');\n if (error.value) {\n throw new Error('Sentry Example Frontend Error');\n }\n }\n )\n }\n</script>\n\n<template>\n <title>Sentry Onboarding</title>\n <div>\n <main>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n />\n </svg>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button type=\"button\" @click=\"getSentryData\"> Throw error! </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"".concat(issuesPageLink, "\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nuxt/\">\n Sentry Nuxt Documentation\n </a>\n </p>\n </main>\n</div>\n</template>\n\n<style scoped>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n svg {\n font-size: 4rem;\n margin: 14px 0;\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n");
74
+ }
75
+ exports.getSentryExamplePageTemplate = getSentryExamplePageTemplate;
76
+ function getSentryExampleApiTemplate() {
77
+ return "// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(event => {\n throw new Error(\"Sentry Example API Route Error\");\n});\n";
78
+ }
79
+ exports.getSentryExampleApiTemplate = getSentryExampleApiTemplate;
80
+ function getSentryErrorButtonTemplate() {
81
+ return "<!--\nThis is just a very simple component that throws an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n \n const throwError = () => {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n () => {\n throw new Error('Sentry Example Error');\n }\n )\n };\n</script>\n\n<template>\n <button id=\"errorBtn\" @click=\"throwError\"> Throw Error! </button>\n</template>\n\n<style scoped>\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n";
82
+ }
83
+ exports.getSentryErrorButtonTemplate = getSentryErrorButtonTemplate;
84
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nuxt/templates.ts"],"names":[],"mappings":";;;AAAA,oCAAiD;AAOjD,SAAgB,oBAAoB;IAClC,OAAO,oKAKR,CAAC;AACF,CAAC;AAPD,oDAOC;AAED,SAAgB,6BAA6B,CAAC,OAK7C;IACC,OAAO,2GAGK,OAAO,CAAC,GAAG,mCACP,OAAO,CAAC,OAAO,gBAC7B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,yBAAiB,OAAO,CAAC,GAAG,QAAI,CAAC,CAAC,CAAC,EAAE,yDAI3B,CAAC;AACpC,CAAC;AAhBD,sEAgBC;AAED,SAAgB,uBAAuB,CACrC,GAAW,EACX,MAA2B,EAC3B,gBAAwC;IAExC,IAAI,MAAM,KAAK,QAAQ,EAAE;QACvB,OAAO,6BAA6B,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;KAC7D;IAED,OAAO,6BAA6B,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;AAC9D,CAAC;AAVD,0DAUC;AAED,IAAM,iBAAiB,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JAKjD,CAAC;AACF,CAAC;AAED,SAAgB,qBAAqB;IACnC,OAAO,qHAKa,CAAC;AACvB,CAAC;AAPD,sDAOC;AAED,SAAgB,4BAA4B,CAAC,OAI5C;IACS,IAAA,GAAG,GAAqB,OAAO,IAA5B,EAAE,GAAG,GAAgB,OAAO,IAAvB,EAAE,SAAS,GAAK,OAAO,UAAZ,CAAa;IACxC,IAAM,cAAc,GAAG,IAAA,uBAAiB,EAAC,EAAE,GAAG,KAAA,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,WAAA,EAAE,CAAC,CAAC;IAE3E,OAAO,k1EA4CQ,cAAc,m7BA8C9B,CAAC;AACF,CAAC;AAnGD,oEAmGC;AAED,SAAgB,2BAA2B;IACzC,OAAO,yQAOR,CAAC;AACF,CAAC;AATD,kEASC;AAED,SAAgB,4BAA4B;IAC1C,OAAO,y8BA8CR,CAAC;AACF,CAAC;AAhDD,oEAgDC","sourcesContent":["import { getIssueStreamUrl } from '../utils/url';\n\ntype SelectedSentryFeatures = {\n performance: boolean;\n replay: boolean;\n};\n\nexport function getDefaultNuxtConfig(): string {\n return `// https://nuxt.com/docs/api/configuration/nuxt-config\nexport default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n})\n`;\n}\n\nexport function getNuxtModuleFallbackTemplate(options: {\n org: string;\n project: string;\n url: string;\n selfHosted: boolean;\n}): string {\n return ` modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"${options.org}\",\n project: \"${options.project}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n },\n },\n sourcemap: { client: \"hidden\" },`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n): string {\n if (config === 'client') {\n return getSentryClientConfigContents(dsn, selectedFeatures);\n }\n\n return getSentryServerConfigContents(dsn, selectedFeatures);\n}\n\nconst featuresConfigMap: Record<keyof SelectedSentryFeatures, string> = {\n performance: [\n ' // We recommend adjusting this value in production, or using tracesSampler',\n ' // for finer control',\n ' tracesSampleRate: 1.0,',\n ].join('\\n'),\n replay: [\n ' // This sets the sample rate to be 10%. You may want this to be 100% while',\n ' // in development and sample at a lower rate in production',\n ' replaysSessionSampleRate: 0.1,',\n ' ',\n ' // If the entire session is not sampled, use the below sample rate to sample',\n ' // sessions when an error occurs.',\n ' replaysOnErrorSampleRate: 1.0,',\n ' ',\n \" // If you don't want to use Session Replay, just remove the line below:\",\n ' integrations: [Sentry.replayIntegration()],',\n ].join('\\n'),\n};\n\nconst featuresMap: Record<\n 'client' | 'server',\n Array<keyof SelectedSentryFeatures>\n> = {\n client: ['performance', 'replay'],\n server: ['performance'],\n};\n\nexport function getConfigBody(\n dsn: string,\n variant: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n) {\n return [\n `dsn: \"${dsn}\",`,\n Object.entries(selectedFeatures)\n .map(([feature, activated]: [keyof SelectedSentryFeatures, boolean]) => {\n return featuresMap[variant].includes(feature) && activated\n ? featuresConfigMap[feature]\n : null;\n })\n .filter(Boolean)\n .join('\\n\\n'),\n ]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\nfunction getSentryClientConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n\nSentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n ${getConfigBody(dsn, 'client', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nfunction getSentryServerConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n \nSentry.init({\n ${getConfigBody(dsn, 'server', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getIndexRouteTemplate(): string {\n return `<!--\nThis is just to verify the sentry-example-page.\nFeel free to delete this file.\n-->\n\n<template></template>`;\n}\n\nexport function getSentryExamplePageTemplate(options: {\n url: string;\n org: string;\n projectId: string;\n}): string {\n const { url, org, projectId } = options;\n const issuesPageLink = getIssueStreamUrl({ url, orgSlug: org, projectId });\n\n return `<!--\nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n import { useFetch} from '#imports'\n \n function getSentryData() {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const { error } = await useFetch('/api/sentry-example-api');\n if (error.value) {\n throw new Error('Sentry Example Frontend Error');\n }\n }\n )\n }\n</script>\n\n<template>\n <title>Sentry Onboarding</title>\n <div>\n <main>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n />\n </svg>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button type=\"button\" @click=\"getSentryData\"> Throw error! </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/nuxt/\">\n Sentry Nuxt Documentation\n </a>\n </p>\n </main>\n</div>\n</template>\n\n<style scoped>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n svg {\n font-size: 4rem;\n margin: 14px 0;\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n\nexport function getSentryExampleApiTemplate() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(event => {\n throw new Error(\"Sentry Example API Route Error\");\n});\n`;\n}\n\nexport function getSentryErrorButtonTemplate() {\n return `<!--\nThis is just a very simple component that throws an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n \n const throwError = () => {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n () => {\n throw new Error('Sentry Example Error');\n }\n )\n };\n</script>\n\n<template>\n <button id=\"errorBtn\" @click=\"throwError\"> Throw Error! </button>\n</template>\n\n<style scoped>\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function isNuxtV4(nuxtConfig: string, packageVersion: string | undefined): Promise<boolean>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.isNuxtV4 = void 0;
40
+ var semver_1 = require("semver");
41
+ // @ts-expect-error - magicast is ESM and TS complains about that. It works though
42
+ var magicast_1 = require("magicast");
43
+ function isNuxtV4(nuxtConfig, packageVersion) {
44
+ return __awaiter(this, void 0, void 0, function () {
45
+ var minVer, mod, config;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0:
49
+ if (!packageVersion) {
50
+ return [2 /*return*/, false];
51
+ }
52
+ minVer = (0, semver_1.minVersion)(packageVersion);
53
+ if (minVer && (0, semver_1.gte)(minVer, '4.0.0')) {
54
+ return [2 /*return*/, true];
55
+ }
56
+ return [4 /*yield*/, (0, magicast_1.loadFile)(nuxtConfig)];
57
+ case 1:
58
+ mod = _a.sent();
59
+ config = mod.exports.default.$type === 'function-call'
60
+ ? mod.exports.default.$args[0]
61
+ : mod.exports.default;
62
+ if (config && config.future && config.future.compatibilityVersion === 4) {
63
+ return [2 /*return*/, true];
64
+ }
65
+ return [2 /*return*/, false];
66
+ }
67
+ });
68
+ });
69
+ }
70
+ exports.isNuxtV4 = isNuxtV4;
71
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/nuxt/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAyC;AACzC,kFAAkF;AAClF,qCAAoC;AAEpC,SAAsB,QAAQ,CAC5B,UAAkB,EAClB,cAAkC;;;;;;oBAElC,IAAI,CAAC,cAAc,EAAE;wBACnB,sBAAO,KAAK,EAAC;qBACd;oBAEK,MAAM,GAAG,IAAA,mBAAU,EAAC,cAAc,CAAC,CAAC;oBAC1C,IAAI,MAAM,IAAI,IAAA,YAAG,EAAC,MAAM,EAAE,OAAO,CAAC,EAAE;wBAClC,sBAAO,IAAI,EAAC;qBACb;oBAKW,qBAAM,IAAA,mBAAQ,EAAC,UAAU,CAAC,EAAA;;oBAAhC,GAAG,GAAG,SAA0B;oBAChC,MAAM,GACV,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,KAAK,eAAe;wBAC3C,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;wBAC9B,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;oBAE1B,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,oBAAoB,KAAK,CAAC,EAAE;wBACvE,sBAAO,IAAI,EAAC;qBACb;oBAED,sBAAO,KAAK,EAAC;;;;CACd;AA3BD,4BA2BC","sourcesContent":["import { gte, minVersion } from 'semver';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { loadFile } from 'magicast';\n\nexport async function isNuxtV4(\n nuxtConfig: string,\n packageVersion: string | undefined,\n) {\n if (!packageVersion) {\n return false;\n }\n\n const minVer = minVersion(packageVersion);\n if (minVer && gte(minVer, '4.0.0')) {\n return true;\n }\n\n // At the time of writing, nuxt 4 is not on its own\n // major yet. We must read the `compatibilityVersion`\n // from the nuxt config.\n const mod = await loadFile(nuxtConfig);\n const config =\n mod.exports.default.$type === 'function-call'\n ? mod.exports.default.$args[0]\n : mod.exports.default;\n\n if (config && config.future && config.future.compatibilityVersion === 4) {\n return true;\n }\n\n return false;\n}\n"]}
@@ -95,7 +95,8 @@ function runRemixWizardWithTelemetry(options) {
95
95
  case 5:
96
96
  _a = _b.sent(), selectedProject = _a.selectedProject, authToken = _a.authToken, sentryUrl = _a.sentryUrl, selfHosted = _a.selfHosted;
97
97
  return [4 /*yield*/, (0, clack_utils_1.installPackage)({
98
- packageName: '@sentry/remix',
98
+ packageName: '@sentry/remix@^8',
99
+ packageNameDisplayLabel: '@sentry/remix',
99
100
  alreadyInstalled: (0, package_json_1.hasPackageInstalled)('@sentry/remix', packageJson),
100
101
  })];
101
102
  case 6:
@@ -1 +1 @@
1
- {"version":3,"file":"remix-wizard.js","sourceRoot":"","sources":["../../../src/remix/remix-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAE1B,oDAa8B;AAC9B,sDAA4D;AAE5D,yCAWqB;AACrB,wCAAuC;AACvC,0CAAwD;AACxD,iCAAwC;AACx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,SAA+C,CAAC;;;;oCAEhD,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,sKACkG,CAAC,CAAC;oCACnH,IAAA,aAAK,EAAC,GAAC,CAAC,CAAC;;;;;yBAEZ,CAAC,EAAA;;oBARF,SAQE,CAAC;oBAE6B,qBAAM,IAAA,wCAA0B,GAAE,EAAA;;oBAA5D,uBAAuB,GAAG,SAAkC;yBAE9D,uBAAuB,EAAvB,yBAAuB;oBACzB,qBAAM,IAAA,qBAAS,EAAC,qBAAqB,EAAE;;;4CACrC,qBAAM,IAAA,+BAAiB,EAAC;4CACtB,IAAI,MAAA;4CACJ,UAAU,YAAA;4CACV,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;4CAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;4CAC7B,GAAG,EAAE,SAAS;yCACf,CAAC,EAAA;;wCANF,SAME,CAAC;;;;6BACJ,CAAC,EAAA;;oBARF,SAQE,CAAC;;yBAGL,qBAAM,IAAA,oCAAsB,GAAE,EAAA;;oBAA9B,SAA8B,CAAC;oBAE/B,iBAAK,CAAC,KAAK,CAAC,YACZ,eAAK,CAAC,KAAK,CACX,iEAAiE,CAClE,iBAEC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC,iBAEtE,eAAK,CAAC,IAAI,CACV,uIACwD,CACzD,CAAE,CAAC,CAAC;;;;;CACJ","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n rcCliSetupConfig,\n runPrettierIfInstalled,\n} from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport {\n initializeSentryOnEntryClient,\n instrumentSentryOnEntryServer,\n updateBuildScript,\n instrumentRootRoute,\n isRemixV2,\n loadRemixConfig,\n runRemixReveal,\n insertServerInstrumentationFile,\n createServerInstrumentationFile,\n updateStartScript,\n} from './sdk-setup';\nimport { debug } from '../utils/debug';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { isHydrogenApp } from './utils';\nimport { DEFAULT_URL } from '../../lib/Constants';\nimport { findFile } from '../utils/ast-utils';\nimport { configureVitePlugin } from '../sourcemaps/tools/vite';\nimport { createExamplePage } from './sdk-example';\n\nexport async function runRemixWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'remix',\n wizardOptions: options,\n },\n () => runRemixWizardWithTelemetry(options),\n );\n}\n\nasync function runRemixWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Remix Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const remixConfig = await loadRemixConfig();\n const packageJson = await getPackageDotJson();\n\n // We expect `@remix-run/dev` to be installed for every Remix project\n await ensurePackageIsInstalled(packageJson, '@remix-run/dev', 'Remix');\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-remix');\n\n await installPackage({\n packageName: '@sentry/remix',\n alreadyInstalled: hasPackageInstalled('@sentry/remix', packageJson),\n });\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const isTS = isUsingTypeScript();\n const isV2 = isRemixV2(remixConfig, packageJson);\n const viteConfig = findFile('vite.config');\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Sentry Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n if (viteConfig) {\n await traceStep(\n 'Update vite configuration for sourcemap uploads',\n async () => {\n try {\n await configureVitePlugin({\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n url: sentryUrl,\n selfHosted,\n authToken,\n });\n } catch (e) {\n clack.log\n .warn(`Could not update vite configuration to generate and upload sourcemaps.\n Please update your vite configuration manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n },\n );\n } else {\n await traceStep('Update build script for sourcemap uploads', async () => {\n try {\n await updateBuildScript({\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n url: sentryUrl === DEFAULT_URL ? undefined : sentryUrl,\n isHydrogen: isHydrogenApp(packageJson),\n });\n\n await addSentryCliConfig({ authToken }, rcCliSetupConfig);\n } catch (e) {\n clack.log\n .warn(`Could not update build script to generate and upload sourcemaps.\n Please update your build script manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n });\n }\n\n await traceStep('Instrument root route', async () => {\n try {\n await instrumentRootRoute(isV2, isTS);\n } catch (e) {\n clack.log.warn(`Could not instrument root route.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n traceStep('Reveal missing entry files', () => {\n try {\n runRemixReveal(isTS);\n } catch (e) {\n clack.log.warn(`Could not run 'npx remix reveal'.\n Please create your entry files manually`);\n debug(e);\n }\n });\n\n await traceStep('Initialize Sentry on client entry', async () => {\n try {\n await initializeSentryOnEntryClient(dsn, isTS, selectedFeatures);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on client entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n let instrumentationFile = '';\n\n await traceStep('Create server instrumentation file', async () => {\n try {\n instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n });\n\n let serverFileInstrumented = false;\n\n await traceStep(\n 'Create server instrumentation file and import it',\n async () => {\n try {\n serverFileInstrumented = await insertServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n },\n );\n\n if (!serverFileInstrumented && instrumentationFile) {\n await traceStep(\n 'Update `start` script to import instrumentation file.',\n async () => {\n try {\n await updateStartScript(instrumentationFile);\n } catch (e) {\n clack.log\n .warn(`Could not automatically add Sentry initialization to server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n },\n );\n }\n\n await traceStep('Instrument server `handleError`', async () => {\n try {\n await instrumentSentryOnEntryServer(isV2, isTS);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage();\n\n if (shouldCreateExamplePage) {\n await traceStep('Create example page', async () => {\n await createExamplePage({\n isTS,\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n });\n });\n }\n\n await runPrettierIfInstalled();\n\n clack.outro(`\n${chalk.green(\n 'Sentry has been successfully configured for your Remix project.',\n)}\n\n${chalk.cyan('You can now deploy your project to see Sentry in action.')}\n\n${chalk.cyan(\n `To learn more about how to use Sentry with Remix, visit our documentation:\nhttps://docs.sentry.io/platforms/javascript/guides/remix/`,\n)}`);\n}\n"]}
1
+ {"version":3,"file":"remix-wizard.js","sourceRoot":"","sources":["../../../src/remix/remix-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;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AAC,CAAC,CAAC;;;;;6BAEZ,CACF,EAAA;;oBAZD,SAYC,CAAC;;yBAGJ,qBAAM,IAAA,qBAAS,EAAC,iCAAiC,EAAE;;;;;;oCAE/C,qBAAM,IAAA,yCAA6B,EAAC,IAAI,EAAE,IAAI,CAAC,EAAA;;oCAA/C,SAA+C,CAAC;;;;oCAEhD,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,sKACkG,CAAC,CAAC;oCACnH,IAAA,aAAK,EAAC,GAAC,CAAC,CAAC;;;;;yBAEZ,CAAC,EAAA;;oBARF,SAQE,CAAC;oBAE6B,qBAAM,IAAA,wCAA0B,GAAE,EAAA;;oBAA5D,uBAAuB,GAAG,SAAkC;yBAE9D,uBAAuB,EAAvB,yBAAuB;oBACzB,qBAAM,IAAA,qBAAS,EAAC,qBAAqB,EAAE;;;4CACrC,qBAAM,IAAA,+BAAiB,EAAC;4CACtB,IAAI,MAAA;4CACJ,UAAU,YAAA;4CACV,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;4CAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;4CAC7B,GAAG,EAAE,SAAS;yCACf,CAAC,EAAA;;wCANF,SAME,CAAC;;;;6BACJ,CAAC,EAAA;;oBARF,SAQE,CAAC;;yBAGL,qBAAM,IAAA,oCAAsB,GAAE,EAAA;;oBAA9B,SAA8B,CAAC;oBAE/B,iBAAK,CAAC,KAAK,CAAC,YACZ,eAAK,CAAC,KAAK,CACX,iEAAiE,CAClE,iBAEC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC,iBAEtE,eAAK,CAAC,IAAI,CACV,uIACwD,CACzD,CAAE,CAAC,CAAC;;;;;CACJ","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport {\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n rcCliSetupConfig,\n runPrettierIfInstalled,\n} from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport {\n initializeSentryOnEntryClient,\n instrumentSentryOnEntryServer,\n updateBuildScript,\n instrumentRootRoute,\n isRemixV2,\n loadRemixConfig,\n runRemixReveal,\n insertServerInstrumentationFile,\n createServerInstrumentationFile,\n updateStartScript,\n} from './sdk-setup';\nimport { debug } from '../utils/debug';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { isHydrogenApp } from './utils';\nimport { DEFAULT_URL } from '../../lib/Constants';\nimport { findFile } from '../utils/ast-utils';\nimport { configureVitePlugin } from '../sourcemaps/tools/vite';\nimport { createExamplePage } from './sdk-example';\n\nexport async function runRemixWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'remix',\n wizardOptions: options,\n },\n () => runRemixWizardWithTelemetry(options),\n );\n}\n\nasync function runRemixWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Remix Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const remixConfig = await loadRemixConfig();\n const packageJson = await getPackageDotJson();\n\n // We expect `@remix-run/dev` to be installed for every Remix project\n await ensurePackageIsInstalled(packageJson, '@remix-run/dev', 'Remix');\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-remix');\n\n await installPackage({\n packageName: '@sentry/remix@^8',\n packageNameDisplayLabel: '@sentry/remix',\n alreadyInstalled: hasPackageInstalled('@sentry/remix', packageJson),\n });\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const isTS = isUsingTypeScript();\n const isV2 = isRemixV2(remixConfig, packageJson);\n const viteConfig = findFile('vite.config');\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Sentry Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n if (viteConfig) {\n await traceStep(\n 'Update vite configuration for sourcemap uploads',\n async () => {\n try {\n await configureVitePlugin({\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n url: sentryUrl,\n selfHosted,\n authToken,\n });\n } catch (e) {\n clack.log\n .warn(`Could not update vite configuration to generate and upload sourcemaps.\n Please update your vite configuration manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n },\n );\n } else {\n await traceStep('Update build script for sourcemap uploads', async () => {\n try {\n await updateBuildScript({\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n url: sentryUrl === DEFAULT_URL ? undefined : sentryUrl,\n isHydrogen: isHydrogenApp(packageJson),\n });\n\n await addSentryCliConfig({ authToken }, rcCliSetupConfig);\n } catch (e) {\n clack.log\n .warn(`Could not update build script to generate and upload sourcemaps.\n Please update your build script manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n });\n }\n\n await traceStep('Instrument root route', async () => {\n try {\n await instrumentRootRoute(isV2, isTS);\n } catch (e) {\n clack.log.warn(`Could not instrument root route.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n traceStep('Reveal missing entry files', () => {\n try {\n runRemixReveal(isTS);\n } catch (e) {\n clack.log.warn(`Could not run 'npx remix reveal'.\n Please create your entry files manually`);\n debug(e);\n }\n });\n\n await traceStep('Initialize Sentry on client entry', async () => {\n try {\n await initializeSentryOnEntryClient(dsn, isTS, selectedFeatures);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on client entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n let instrumentationFile = '';\n\n await traceStep('Create server instrumentation file', async () => {\n try {\n instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n });\n\n let serverFileInstrumented = false;\n\n await traceStep(\n 'Create server instrumentation file and import it',\n async () => {\n try {\n serverFileInstrumented = await insertServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n },\n );\n\n if (!serverFileInstrumented && instrumentationFile) {\n await traceStep(\n 'Update `start` script to import instrumentation file.',\n async () => {\n try {\n await updateStartScript(instrumentationFile);\n } catch (e) {\n clack.log\n .warn(`Could not automatically add Sentry initialization to server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n },\n );\n }\n\n await traceStep('Instrument server `handleError`', async () => {\n try {\n await instrumentSentryOnEntryServer(isV2, isTS);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage();\n\n if (shouldCreateExamplePage) {\n await traceStep('Create example page', async () => {\n await createExamplePage({\n isTS,\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n });\n });\n }\n\n await runPrettierIfInstalled();\n\n clack.outro(`\n${chalk.green(\n 'Sentry has been successfully configured for your Remix project.',\n)}\n\n${chalk.cyan('You can now deploy your project to see Sentry in action.')}\n\n${chalk.cyan(\n `To learn more about how to use Sentry with Remix, visit our documentation:\nhttps://docs.sentry.io/platforms/javascript/guides/remix/`,\n)}`);\n}\n"]}
package/dist/src/run.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Platform } from '../lib/Constants';
2
- type WizardIntegration = 'reactNative' | 'ios' | 'android' | 'cordova' | 'electron' | 'nextjs' | 'remix' | 'sveltekit' | 'sourcemaps';
2
+ type WizardIntegration = 'reactNative' | 'ios' | 'android' | 'cordova' | 'electron' | 'nextjs' | 'nuxt' | 'remix' | 'sveltekit' | 'sourcemaps';
3
3
  type Args = {
4
4
  integration?: WizardIntegration;
5
5
  uninstall: boolean;