@sentry/wizard 3.23.2 → 3.24.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 +14 -2
- package/dist/package.json +2 -2
- package/dist/src/nextjs/nextjs-wizard.js +1 -1
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +1 -1
- package/dist/src/nextjs/templates.js +4 -2
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/react-native/glob.js +24 -4
- package/dist/src/react-native/glob.js.map +1 -1
- package/dist/src/remix/codemods/express-server.d.ts +0 -4
- package/dist/src/remix/codemods/express-server.js +1 -80
- package/dist/src/remix/codemods/express-server.js.map +1 -1
- package/dist/src/remix/codemods/handle-error.js +2 -2
- package/dist/src/remix/codemods/handle-error.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +62 -19
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/remix/sdk-example.js +1 -1
- package/dist/src/remix/sdk-example.js.map +1 -1
- package/dist/src/remix/sdk-setup.d.ts +5 -3
- package/dist/src/remix/sdk-setup.js +98 -38
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/remix/templates.d.ts +1 -1
- package/dist/src/remix/templates.js +1 -1
- package/dist/src/remix/templates.js.map +1 -1
- package/dist/src/remix/utils.d.ts +9 -3
- package/dist/src/remix/utils.js +39 -10
- package/dist/src/remix/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/nextjs/nextjs-wizard.ts +1 -1
- package/src/nextjs/templates.ts +32 -4
- package/src/react-native/glob.ts +1 -1
- package/src/remix/codemods/express-server.ts +0 -121
- package/src/remix/codemods/handle-error.ts +3 -2
- package/src/remix/remix-wizard.ts +45 -17
- package/src/remix/sdk-example.ts +0 -2
- package/src/remix/sdk-setup.ts +125 -33
- package/src/remix/templates.ts +1 -1
- package/src/remix/utils.ts +57 -7
|
@@ -50,12 +50,12 @@ function instrumentHandleError(originalEntryServerMod, serverEntryFilename) {
|
|
|
50
50
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
51
51
|
var implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program
|
|
52
52
|
.body[0];
|
|
53
|
-
originalEntryServerModAST.body.splice((0, utils_1.
|
|
53
|
+
originalEntryServerModAST.body.splice((0, utils_1.getAfterImportsInsertionIndex)(originalEntryServerModAST), 0,
|
|
54
54
|
// @ts-expect-error - string works here because the AST is proxified by magicast
|
|
55
55
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
56
56
|
recast.types.builders.exportNamedDeclaration(implementation));
|
|
57
57
|
}
|
|
58
|
-
else if ((0, utils_1.hasSentryContent)((0, magicast_1.generateCode)(handleErrorFunction).code, originalEntryServerMod.$code)) {
|
|
58
|
+
else if ((0, utils_1.hasSentryContent)((0, magicast_1.generateCode)(handleErrorFunction).code, originalEntryServerMod.$code, 'captureRemixServerException')) {
|
|
59
59
|
return false;
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-error.js","sourceRoot":"","sources":["../../../../src/remix/codemods/handle-error.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM5D,6CAAiC;AAEjC,0CAAwD;AACxD,
|
|
1
|
+
{"version":3,"file":"handle-error.js","sourceRoot":"","sources":["../../../../src/remix/codemods/handle-error.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM5D,6CAAiC;AAEjC,0CAAwD;AACxD,kCAA2E;AAE3E,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAE1B,kFAAkF;AAClF,qCAAwC;AAExC,SAAgB,qBAAqB,CACnC,sBAA4C,EAC5C,mBAA2B;;IAE3B,IAAM,yBAAyB,GAAG,sBAAsB,CAAC,IAAe,CAAC;IAEzE,IAAM,mBAA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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CACpE,CAAC;QAEF,+BAA+B;QAC/B,EAAE;QACF,gFAAgF;QAChF,sEAAsE;QACtE,mBAAmB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAErE,mDAAmD;QACnD,iEAAiE;QACjE,EAAE;QACF,gFAAgF;QAChF,sEAAsE;QACtE,IAAI,MAAA,MAAA,mBAAmB,CAAC,WAAW,CAAC,MAAM,0CAAG,CAAC,CAAC,0CAAE,UAAU,EAAE;YAC3D,gFAAgF;YAChF,yGAAyG;YACzG,mBAAmB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI;YACvD,sEAAsE;YACtE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CACvC,CAAC;SACH;aAAM;YACL,8CAA8C;YAC9C,EAAE;YACF,gFAAgF;YAChF,sEAAsE;YACtE,mBAAmB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SACtE;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AA/ED,sDA+EC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\nimport type { Program } from '@babel/types';\n\nimport * as recast from 'recast';\n\nimport { HANDLE_ERROR_TEMPLATE_V2 } from '../templates';\nimport { getAfterImportsInsertionIndex, hasSentryContent } from '../utils';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode } from 'magicast';\n\nexport function instrumentHandleError(\n originalEntryServerMod: ProxifiedModule<any>,\n serverEntryFilename: string,\n): boolean {\n const originalEntryServerModAST = originalEntryServerMod.$ast as Program;\n\n const handleErrorFunction = originalEntryServerModAST.body.find(\n (node) =>\n node.type === 'ExportNamedDeclaration' &&\n node.declaration?.type === 'FunctionDeclaration' &&\n node.declaration.id?.name === 'handleError',\n );\n\n if (!handleErrorFunction) {\n clack.log.warn(\n `Could not find function ${chalk.cyan('handleError')} in ${chalk.cyan(\n serverEntryFilename,\n )}. Creating one for you.`,\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const implementation = recast.parse(HANDLE_ERROR_TEMPLATE_V2).program\n .body[0];\n\n originalEntryServerModAST.body.splice(\n getAfterImportsInsertionIndex(originalEntryServerModAST),\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n recast.types.builders.exportNamedDeclaration(implementation),\n );\n } else if (\n hasSentryContent(\n generateCode(handleErrorFunction).code,\n originalEntryServerMod.$code,\n 'captureRemixServerException',\n )\n ) {\n return false;\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const implementation = recast.parse(HANDLE_ERROR_TEMPLATE_V2).program\n .body[0];\n\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n handleErrorFunction.declaration.body.body.unshift(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n recast.parse(HANDLE_ERROR_TEMPLATE_V2).program.body[0].body.body[0],\n );\n\n // First parameter is the error\n //\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n handleErrorFunction.declaration.params[0] = implementation.params[0];\n\n // Second parameter is the request inside an object\n // Merging the object properties to make sure it includes request\n //\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (handleErrorFunction.declaration.params?.[1]?.properties) {\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n handleErrorFunction.declaration.params[1].properties.push(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n implementation.params[1].properties[0],\n );\n } else {\n // Create second parameter if it doesn't exist\n //\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n handleErrorFunction.declaration.params[1] = implementation.params[1];\n }\n }\n\n return true;\n}\n"]}
|
|
@@ -66,7 +66,7 @@ function runRemixWizard(options) {
|
|
|
66
66
|
exports.runRemixWizard = runRemixWizard;
|
|
67
67
|
function runRemixWizardWithTelemetry(options) {
|
|
68
68
|
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
-
var remixConfig, packageJson, _a, selectedProject, authToken, sentryUrl, selfHosted, dsn, isTS, isV2, viteConfig, shouldCreateExamplePage;
|
|
69
|
+
var remixConfig, packageJson, _a, selectedProject, authToken, sentryUrl, selfHosted, dsn, isTS, isV2, viteConfig, instrumentationFile, serverFileInstrumented, shouldCreateExamplePage;
|
|
70
70
|
var _this = this;
|
|
71
71
|
return __generator(this, function (_b) {
|
|
72
72
|
switch (_b.label) {
|
|
@@ -215,19 +215,20 @@ function runRemixWizardWithTelemetry(options) {
|
|
|
215
215
|
}); })];
|
|
216
216
|
case 13:
|
|
217
217
|
_b.sent();
|
|
218
|
-
|
|
218
|
+
instrumentationFile = '';
|
|
219
|
+
return [4 /*yield*/, (0, telemetry_1.traceStep)('Create server instrumentation file', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
219
220
|
var e_5;
|
|
220
221
|
return __generator(this, function (_a) {
|
|
221
222
|
switch (_a.label) {
|
|
222
223
|
case 0:
|
|
223
224
|
_a.trys.push([0, 2, , 3]);
|
|
224
|
-
return [4 /*yield*/, (0, sdk_setup_1.
|
|
225
|
+
return [4 /*yield*/, (0, sdk_setup_1.createServerInstrumentationFile)(dsn)];
|
|
225
226
|
case 1:
|
|
226
|
-
_a.sent();
|
|
227
|
+
instrumentationFile = _a.sent();
|
|
227
228
|
return [3 /*break*/, 3];
|
|
228
229
|
case 2:
|
|
229
230
|
e_5 = _a.sent();
|
|
230
|
-
prompts_1.default.log.warn(
|
|
231
|
+
prompts_1.default.log.warn('Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/');
|
|
231
232
|
(0, debug_1.debug)(e_5);
|
|
232
233
|
return [3 /*break*/, 3];
|
|
233
234
|
case 3: return [2 /*return*/];
|
|
@@ -236,23 +237,20 @@ function runRemixWizardWithTelemetry(options) {
|
|
|
236
237
|
}); })];
|
|
237
238
|
case 14:
|
|
238
239
|
_b.sent();
|
|
239
|
-
|
|
240
|
-
|
|
240
|
+
serverFileInstrumented = false;
|
|
241
|
+
return [4 /*yield*/, (0, telemetry_1.traceStep)('Create server instrumentation file and import it', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
242
|
+
var e_6;
|
|
241
243
|
return __generator(this, function (_a) {
|
|
242
244
|
switch (_a.label) {
|
|
243
245
|
case 0:
|
|
244
246
|
_a.trys.push([0, 2, , 3]);
|
|
245
|
-
|
|
246
|
-
if (!hasExpressAdapter) {
|
|
247
|
-
return [2 /*return*/];
|
|
248
|
-
}
|
|
249
|
-
return [4 /*yield*/, (0, sdk_setup_1.instrumentExpressServer)()];
|
|
247
|
+
return [4 /*yield*/, (0, sdk_setup_1.insertServerInstrumentationFile)(dsn)];
|
|
250
248
|
case 1:
|
|
251
|
-
_a.sent();
|
|
249
|
+
serverFileInstrumented = _a.sent();
|
|
252
250
|
return [3 /*break*/, 3];
|
|
253
251
|
case 2:
|
|
254
252
|
e_6 = _a.sent();
|
|
255
|
-
prompts_1.default.log.warn(
|
|
253
|
+
prompts_1.default.log.warn('Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/');
|
|
256
254
|
(0, debug_1.debug)(e_6);
|
|
257
255
|
return [3 /*break*/, 3];
|
|
258
256
|
case 3: return [2 /*return*/];
|
|
@@ -261,10 +259,55 @@ function runRemixWizardWithTelemetry(options) {
|
|
|
261
259
|
}); })];
|
|
262
260
|
case 15:
|
|
263
261
|
_b.sent();
|
|
264
|
-
return [
|
|
262
|
+
if (!(!serverFileInstrumented && instrumentationFile)) return [3 /*break*/, 17];
|
|
263
|
+
return [4 /*yield*/, (0, telemetry_1.traceStep)('Update `start` script to import instrumentation file.', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
264
|
+
var e_7;
|
|
265
|
+
return __generator(this, function (_a) {
|
|
266
|
+
switch (_a.label) {
|
|
267
|
+
case 0:
|
|
268
|
+
_a.trys.push([0, 2, , 3]);
|
|
269
|
+
return [4 /*yield*/, (0, sdk_setup_1.updateStartScript)(instrumentationFile)];
|
|
270
|
+
case 1:
|
|
271
|
+
_a.sent();
|
|
272
|
+
return [3 /*break*/, 3];
|
|
273
|
+
case 2:
|
|
274
|
+
e_7 = _a.sent();
|
|
275
|
+
prompts_1.default.log
|
|
276
|
+
.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/");
|
|
277
|
+
(0, debug_1.debug)(e_7);
|
|
278
|
+
return [3 /*break*/, 3];
|
|
279
|
+
case 3: return [2 /*return*/];
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}); })];
|
|
265
283
|
case 16:
|
|
284
|
+
_b.sent();
|
|
285
|
+
_b.label = 17;
|
|
286
|
+
case 17: return [4 /*yield*/, (0, telemetry_1.traceStep)('Instrument server `handleError`', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
287
|
+
var e_8;
|
|
288
|
+
return __generator(this, function (_a) {
|
|
289
|
+
switch (_a.label) {
|
|
290
|
+
case 0:
|
|
291
|
+
_a.trys.push([0, 2, , 3]);
|
|
292
|
+
return [4 /*yield*/, (0, sdk_setup_1.instrumentSentryOnEntryServer)(isV2, isTS)];
|
|
293
|
+
case 1:
|
|
294
|
+
_a.sent();
|
|
295
|
+
return [3 /*break*/, 3];
|
|
296
|
+
case 2:
|
|
297
|
+
e_8 = _a.sent();
|
|
298
|
+
prompts_1.default.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/");
|
|
299
|
+
(0, debug_1.debug)(e_8);
|
|
300
|
+
return [3 /*break*/, 3];
|
|
301
|
+
case 3: return [2 /*return*/];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}); })];
|
|
305
|
+
case 18:
|
|
306
|
+
_b.sent();
|
|
307
|
+
return [4 /*yield*/, (0, clack_utils_1.askShouldCreateExamplePage)()];
|
|
308
|
+
case 19:
|
|
266
309
|
shouldCreateExamplePage = _b.sent();
|
|
267
|
-
if (!shouldCreateExamplePage) return [3 /*break*/,
|
|
310
|
+
if (!shouldCreateExamplePage) return [3 /*break*/, 21];
|
|
268
311
|
return [4 /*yield*/, (0, telemetry_1.traceStep)('Create example page', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
269
312
|
return __generator(this, function (_a) {
|
|
270
313
|
switch (_a.label) {
|
|
@@ -281,10 +324,10 @@ function runRemixWizardWithTelemetry(options) {
|
|
|
281
324
|
}
|
|
282
325
|
});
|
|
283
326
|
}); })];
|
|
284
|
-
case
|
|
327
|
+
case 20:
|
|
285
328
|
_b.sent();
|
|
286
|
-
_b.label =
|
|
287
|
-
case
|
|
329
|
+
_b.label = 21;
|
|
330
|
+
case 21:
|
|
288
331
|
prompts_1.default.outro("\n".concat(chalk_1.default.green('Sentry has been successfully configured for your Remix project.'), "\n\n").concat(chalk_1.default.cyan('You can now deploy your project to see Sentry in action.'), "\n\n").concat(chalk_1.default.cyan("To learn more about how to use Sentry with Remix, visit our documentation:\nhttps://docs.sentry.io/platforms/javascript/guides/remix/")));
|
|
289
332
|
return [2 /*return*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BAEtE,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 getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n rcCliSetupConfig,\n} from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport { WizardOptions } from '../utils/types';\nimport {\n initializeSentryOnEntryClient,\n initializeSentryOnEntryServer,\n updateBuildScript,\n instrumentRootRoute,\n isRemixV2,\n loadRemixConfig,\n runRemixReveal,\n instrumentExpressServer,\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 },\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\n await addSentryCliConfig({ authToken }, rcCliSetupConfig);\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 } 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);\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 await traceStep('Initialize Sentry on server entry', async () => {\n try {\n await initializeSentryOnEntryServer(dsn, 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 await traceStep('Instrument custom Express server', async () => {\n try {\n const hasExpressAdapter = hasPackageInstalled(\n '@remix-run/express',\n packageJson,\n );\n\n if (!hasExpressAdapter) {\n return;\n }\n\n await instrumentExpressServer();\n } catch (e) {\n clack.log.warn(`Could not instrument custom Express server.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/#custom-express-server`);\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 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAE1B,oDAW8B;AAC9B,sDAA4D;AAE5D,yCAWqB;AACrB,wCAAuC;AACvC,0CAAwD;AACxD,iCAAwC;AACxC,iDAAkD;AAClD,gDAA8C;AAC9C,iDAA+D;AAC/D,6CAAkD;AAElD,SAAsB,cAAc,CAAC,OAAsB;;;YACzD,sBAAO,IAAA,yBAAa,EAClB;oBACE,OAAO,EAAE,OAAO,CAAC,g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F,SAQE,CAAC;;;oBAGL,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 getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n rcCliSetupConfig,\n} from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport { 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 },\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\n await addSentryCliConfig({ authToken }, rcCliSetupConfig);\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 } 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);\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(dsn);\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(dsn);\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 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"]}
|
|
@@ -95,7 +95,7 @@ function getSentryExamplePageContents(options) {
|
|
|
95
95
|
var issuesPageLink = options.selfHosted
|
|
96
96
|
? "".concat(options.url, "organizations/").concat(options.orgSlug, "/issues/?project=").concat(options.projectId)
|
|
97
97
|
: "https://".concat(options.orgSlug, ".sentry.io/issues/?project=").concat(options.projectId);
|
|
98
|
-
return "\
|
|
98
|
+
return "\nexport default function SentryExamplePage() {\n return (\n <div>\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n {/* biome-ignore lint/a11y/noSvgWithoutTitle: <explanation> */}\n <svg\n style={{\n height: \"1em\",\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 200 44\"\n >\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 </h1>\n\n <p>Get started by sending us a sample error:</p>\n\n <button\n type=\"button\"\n style={{\n padding: \"12px\",\n cursor: \"pointer\",\n backgroundColor: \"#AD6CAA\",\n borderRadius: \"4px\",\n border: \"none\",\n color: \"white\",\n fontSize: \"14px\",\n margin: \"18px\",\n }}\n onClick={() => {\n throw new Error(\"Sentry Example Frontend Error\");\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"".concat(issuesPageLink, "\">Issues Page</a>.\n </p>\n <p style={{ marginTop: \"24px\" }}>\n For more information, see{\" \"}\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/remix/\">\n https://docs.sentry.io/platforms/javascript/guides/remix/\n </a>\n </p>\n </main>\n </div>\n );\n}\n");
|
|
99
99
|
}
|
|
100
100
|
exports.getSentryExamplePageContents = getSentryExamplePageContents;
|
|
101
101
|
//# sourceMappingURL=sdk-example.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-example.js","sourceRoot":"","sources":["../../../src/remix/sdk-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAC7B,yEAAyE;AACzE,2DAAmC;AAEnC;;GAEG;AACH,SAAsB,iBAAiB,CAAC,OAMvC;;;;;;oBACO,gBAAgB,GAAG,yCACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MACzB,CAAC;oBAEJ,IAAI,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;wBACnC,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,8DAAuD,IAAI,CAAC,QAAQ,CAClE,gBAAgB,CACjB,2CAAwC,CAC1C,CAAC;wBACF,sBAAO;qBACR;oBAED,qBAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,gBAAgB,EAChB,4BAA4B,CAAC,OAAO,CAAC,CACtC,EAAA;;oBAHD,SAGC,CAAC;oBAEF,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,yCAAkC,gBAAgB,MAAG,CAAC,CAAC;;;;;CACvE;AA1BD,8CA0BC;AAED,SAAgB,4BAA4B,CAAC,OAM5C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,
|
|
1
|
+
{"version":3,"file":"sdk-example.js","sourceRoot":"","sources":["../../../src/remix/sdk-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAC7B,yEAAyE;AACzE,2DAAmC;AAEnC;;GAEG;AACH,SAAsB,iBAAiB,CAAC,OAMvC;;;;;;oBACO,gBAAgB,GAAG,yCACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MACzB,CAAC;oBAEJ,IAAI,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;wBACnC,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,8DAAuD,IAAI,CAAC,QAAQ,CAClE,gBAAgB,CACjB,2CAAwC,CAC1C,CAAC;wBACF,sBAAO;qBACR;oBAED,qBAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,gBAAgB,EAChB,4BAA4B,CAAC,OAAO,CAAC,CACtC,EAAA;;oBAHD,SAGC,CAAC;oBAEF,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,yCAAkC,gBAAgB,MAAG,CAAC,CAAC;;;;;CACvE;AA1BD,8CA0BC;AAED,SAAgB,4BAA4B,CAAC,OAM5C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,85FAqDkB,cAAc,0YAYxC,CAAC;AACF,CAAC;AA7ED,oEA6EC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n\n/**\n * Creates an example Remix page to test Sentry\n */\nexport async function createExamplePage(options: {\n selfHosted: boolean;\n orgSlug: string;\n projectId: string;\n url: string;\n isTS: boolean;\n}) {\n const exampleRoutePath = `app/routes/sentry-example-page.${\n options.isTS ? 'ts' : 'js'\n }x`;\n\n if (fs.existsSync(exampleRoutePath)) {\n clack.log.warn(\n `It seems like a sentry example page already exists (${path.basename(\n exampleRoutePath,\n )}). Skipping creation of example route.`,\n );\n return;\n }\n\n await fs.promises.writeFile(\n exampleRoutePath,\n getSentryExamplePageContents(options),\n );\n\n clack.log.info(`Created sentry example page at ${exampleRoutePath}.`);\n}\n\nexport function getSentryExamplePageContents(options: {\n selfHosted: boolean;\n orgSlug: string;\n projectId: string;\n url: string;\n isTS?: boolean;\n}) {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `\nexport default function SentryExamplePage() {\n return (\n <div>\n <main\n style={{\n minHeight: \"100vh\",\n display: \"flex\",\n flexDirection: \"column\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n >\n\n <h1 style={{ fontSize: \"4rem\", margin: \"14px 0\" }}>\n {/* biome-ignore lint/a11y/noSvgWithoutTitle: <explanation> */}\n <svg\n style={{\n height: \"1em\",\n }}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 200 44\"\n >\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 </h1>\n\n <p>Get started by sending us a sample error:</p>\n\n <button\n type=\"button\"\n style={{\n padding: \"12px\",\n cursor: \"pointer\",\n backgroundColor: \"#AD6CAA\",\n borderRadius: \"4px\",\n border: \"none\",\n color: \"white\",\n fontSize: \"14px\",\n margin: \"18px\",\n }}\n onClick={() => {\n throw new Error(\"Sentry Example Frontend Error\");\n }}\n >\n Throw error!\n </button>\n\n <p>\n Next, look for the error on the{\" \"}\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style={{ marginTop: \"24px\" }}>\n For more information, see{\" \"}\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/remix/\">\n https://docs.sentry.io/platforms/javascript/guides/remix/\n </a>\n </p>\n </main>\n </div>\n );\n}\n`;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PackageDotJson } from '../utils/package-json';
|
|
1
|
+
import type { PackageDotJson } from '../utils/package-json';
|
|
2
2
|
export type PartialRemixConfig = {
|
|
3
3
|
unstable_dev?: boolean;
|
|
4
4
|
future?: {
|
|
@@ -11,6 +11,8 @@ export type PartialRemixConfig = {
|
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
export declare function runRemixReveal(isTS: boolean): void;
|
|
14
|
+
export declare function createServerInstrumentationFile(dsn: string): Promise<string>;
|
|
15
|
+
export declare function insertServerInstrumentationFile(dsn: string): Promise<boolean>;
|
|
14
16
|
export declare function isRemixV2(remixConfig: PartialRemixConfig, packageJson: PackageDotJson): boolean;
|
|
15
17
|
export declare function loadRemixConfig(): Promise<PartialRemixConfig>;
|
|
16
18
|
export declare function instrumentRootRoute(isV2?: boolean, isTS?: boolean): Promise<void>;
|
|
@@ -21,5 +23,5 @@ export declare function updateBuildScript(args: {
|
|
|
21
23
|
isHydrogen: boolean;
|
|
22
24
|
}): Promise<void>;
|
|
23
25
|
export declare function initializeSentryOnEntryClient(dsn: string, isTS: boolean): Promise<void>;
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
+
export declare function updateStartScript(instrumentationFile: string): Promise<void>;
|
|
27
|
+
export declare function instrumentSentryOnEntryServer(isV2: boolean, isTS: boolean): Promise<void>;
|
|
@@ -63,7 +63,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
63
63
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
64
64
|
};
|
|
65
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
-
exports.
|
|
66
|
+
exports.instrumentSentryOnEntryServer = exports.updateStartScript = exports.initializeSentryOnEntryClient = exports.updateBuildScript = exports.instrumentRootRoute = exports.loadRemixConfig = exports.isRemixV2 = exports.insertServerInstrumentationFile = exports.createServerInstrumentationFile = exports.runRemixReveal = void 0;
|
|
67
67
|
var fs = __importStar(require("fs"));
|
|
68
68
|
var path = __importStar(require("path"));
|
|
69
69
|
var url = __importStar(require("url"));
|
|
@@ -72,15 +72,14 @@ var childProcess = __importStar(require("child_process"));
|
|
|
72
72
|
var prompts_1 = __importDefault(require("@clack/prompts"));
|
|
73
73
|
var chalk_1 = __importDefault(require("chalk"));
|
|
74
74
|
var semver_1 = require("semver");
|
|
75
|
-
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
76
75
|
var magicast_1 = require("magicast");
|
|
77
76
|
var package_json_1 = require("../utils/package-json");
|
|
78
77
|
var utils_1 = require("./utils");
|
|
79
78
|
var root_v1_1 = require("./codemods/root-v1");
|
|
80
79
|
var root_v2_1 = require("./codemods/root-v2");
|
|
81
80
|
var handle_error_1 = require("./codemods/handle-error");
|
|
82
|
-
var express_server_1 = require("./codemods/express-server");
|
|
83
81
|
var clack_utils_1 = require("../utils/clack-utils");
|
|
82
|
+
var express_server_1 = require("./codemods/express-server");
|
|
84
83
|
var REMIX_CONFIG_FILE = 'remix.config.js';
|
|
85
84
|
var REMIX_REVEAL_COMMAND = 'npx remix reveal';
|
|
86
85
|
function runRemixReveal(isTS) {
|
|
@@ -110,24 +109,74 @@ function insertClientInitCall(dsn, originalHooksMod) {
|
|
|
110
109
|
],
|
|
111
110
|
});
|
|
112
111
|
var originalHooksModAST = originalHooksMod.$ast;
|
|
113
|
-
var initCallInsertionIndex = (0, utils_1.
|
|
112
|
+
var initCallInsertionIndex = (0, utils_1.getAfterImportsInsertionIndex)(originalHooksModAST);
|
|
114
113
|
originalHooksModAST.body.splice(initCallInsertionIndex, 0,
|
|
115
114
|
// @ts-expect-error - string works here because the AST is proxified by magicast
|
|
116
115
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
117
116
|
(0, magicast_1.generateCode)(initCall).code);
|
|
118
117
|
}
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
function createServerInstrumentationFile(dsn) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
+
var instrumentationFile, instrumentationFileMod, initCall, instrumentationFileModAST, initCallInsertionIndex;
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
instrumentationFile = 'instrumentation.server.mjs';
|
|
125
|
+
instrumentationFileMod = (0, magicast_1.parseModule)('');
|
|
126
|
+
instrumentationFileMod.imports.$add({
|
|
127
|
+
from: '@sentry/remix',
|
|
128
|
+
imported: '*',
|
|
129
|
+
local: 'Sentry',
|
|
130
|
+
});
|
|
131
|
+
initCall = magicast_1.builders.functionCall('Sentry.init', {
|
|
132
|
+
dsn: dsn,
|
|
133
|
+
tracesSampleRate: 1.0,
|
|
134
|
+
autoInstrumentRemix: true,
|
|
135
|
+
});
|
|
136
|
+
instrumentationFileModAST = instrumentationFileMod.$ast;
|
|
137
|
+
initCallInsertionIndex = (0, utils_1.getAfterImportsInsertionIndex)(instrumentationFileModAST);
|
|
138
|
+
instrumentationFileModAST.body.splice(initCallInsertionIndex, 0,
|
|
139
|
+
// @ts-expect-error - string works here because the AST is proxified by magicast
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
141
|
+
(0, magicast_1.generateCode)(initCall).code);
|
|
142
|
+
return [4 /*yield*/, (0, magicast_1.writeFile)(instrumentationFileModAST, instrumentationFile)];
|
|
143
|
+
case 1:
|
|
144
|
+
_a.sent();
|
|
145
|
+
return [2 /*return*/, instrumentationFile];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
123
148
|
});
|
|
124
|
-
var originalHooksModAST = originalHooksMod.$ast;
|
|
125
|
-
var initCallInsertionIndex = (0, utils_1.getInitCallInsertionIndex)(originalHooksModAST);
|
|
126
|
-
originalHooksModAST.body.splice(initCallInsertionIndex, 0,
|
|
127
|
-
// @ts-expect-error - string works here because the AST is proxified by magicast
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
129
|
-
(0, magicast_1.generateCode)(initCall).code);
|
|
130
149
|
}
|
|
150
|
+
exports.createServerInstrumentationFile = createServerInstrumentationFile;
|
|
151
|
+
function insertServerInstrumentationFile(dsn) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
153
|
+
var instrumentationFile, expressServerPath, originalExpressServerMod;
|
|
154
|
+
return __generator(this, function (_a) {
|
|
155
|
+
switch (_a.label) {
|
|
156
|
+
case 0: return [4 /*yield*/, createServerInstrumentationFile(dsn)];
|
|
157
|
+
case 1:
|
|
158
|
+
instrumentationFile = _a.sent();
|
|
159
|
+
return [4 /*yield*/, (0, express_server_1.findCustomExpressServerImplementation)()];
|
|
160
|
+
case 2:
|
|
161
|
+
expressServerPath = _a.sent();
|
|
162
|
+
if (!expressServerPath) {
|
|
163
|
+
return [2 /*return*/, false];
|
|
164
|
+
}
|
|
165
|
+
return [4 /*yield*/, (0, magicast_1.loadFile)(expressServerPath)];
|
|
166
|
+
case 3:
|
|
167
|
+
originalExpressServerMod = _a.sent();
|
|
168
|
+
if ((0, utils_1.serverHasInstrumentationImport)(expressServerPath, originalExpressServerMod.$code)) {
|
|
169
|
+
prompts_1.default.log.warn("File ".concat(chalk_1.default.cyan(path.basename(expressServerPath)), " already contains instrumentation import.\nSkipping adding instrumentation functionality to ").concat(chalk_1.default.cyan(path.basename(expressServerPath)), "."));
|
|
170
|
+
return [2 /*return*/, true];
|
|
171
|
+
}
|
|
172
|
+
originalExpressServerMod.$code = "import './".concat(instrumentationFile, "';\n").concat(originalExpressServerMod.$code);
|
|
173
|
+
fs.writeFileSync(expressServerPath, originalExpressServerMod.$code);
|
|
174
|
+
return [2 /*return*/, true];
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
exports.insertServerInstrumentationFile = insertServerInstrumentationFile;
|
|
131
180
|
function isRemixV2(remixConfig, packageJson) {
|
|
132
181
|
var _a;
|
|
133
182
|
var remixVersion = (0, package_json_1.getPackageVersion)('@remix-run/react', packageJson);
|
|
@@ -282,7 +331,40 @@ function initializeSentryOnEntryClient(dsn, isTS) {
|
|
|
282
331
|
});
|
|
283
332
|
}
|
|
284
333
|
exports.initializeSentryOnEntryClient = initializeSentryOnEntryClient;
|
|
285
|
-
function
|
|
334
|
+
function updateStartScript(instrumentationFile) {
|
|
335
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
336
|
+
var packageJson, startCommand;
|
|
337
|
+
return __generator(this, function (_a) {
|
|
338
|
+
switch (_a.label) {
|
|
339
|
+
case 0: return [4 /*yield*/, (0, clack_utils_1.getPackageDotJson)()];
|
|
340
|
+
case 1:
|
|
341
|
+
packageJson = _a.sent();
|
|
342
|
+
if (!packageJson.scripts || !packageJson.scripts.start) {
|
|
343
|
+
throw new Error("Couldn't find a `start` script in your package.json. Please add one manually.");
|
|
344
|
+
}
|
|
345
|
+
if (packageJson.scripts.start.includes('NODE_OPTIONS')) {
|
|
346
|
+
prompts_1.default.log.warn("Found existing NODE_OPTIONS in ".concat(chalk_1.default.cyan('start'), " script. Skipping adding Sentry initialization."));
|
|
347
|
+
return [2 /*return*/];
|
|
348
|
+
}
|
|
349
|
+
if (!packageJson.scripts.start.includes('remix-serve') &&
|
|
350
|
+
// Adding a following empty space not to match a path that includes `node`
|
|
351
|
+
!packageJson.scripts.start.includes('node ')) {
|
|
352
|
+
prompts_1.default.log.warn("Found a ".concat(chalk_1.default.cyan('start'), " script that doesn't use ").concat(chalk_1.default.cyan('remix-serve'), " or ").concat(chalk_1.default.cyan('node'), ". Skipping adding Sentry initialization."));
|
|
353
|
+
return [2 /*return*/];
|
|
354
|
+
}
|
|
355
|
+
startCommand = packageJson.scripts.start;
|
|
356
|
+
packageJson.scripts.start = "NODE_OPTIONS='--import ./".concat(instrumentationFile, "' ").concat(startCommand);
|
|
357
|
+
return [4 /*yield*/, fs.promises.writeFile(path.join(process.cwd(), 'package.json'), JSON.stringify(packageJson, null, 2))];
|
|
358
|
+
case 2:
|
|
359
|
+
_a.sent();
|
|
360
|
+
prompts_1.default.log.success("Successfully updated ".concat(chalk_1.default.cyan('start'), " script in ").concat(chalk_1.default.cyan('package.json'), " to include Sentry initialization on start."));
|
|
361
|
+
return [2 /*return*/];
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
exports.updateStartScript = updateStartScript;
|
|
367
|
+
function instrumentSentryOnEntryServer(isV2, isTS) {
|
|
286
368
|
return __awaiter(this, void 0, void 0, function () {
|
|
287
369
|
var serverEntryFilename, originalEntryServer, originalEntryServerMod, handleErrorInstrumented;
|
|
288
370
|
return __generator(this, function (_a) {
|
|
@@ -301,7 +383,6 @@ function initializeSentryOnEntryServer(dsn, isV2, isTS) {
|
|
|
301
383
|
imported: '*',
|
|
302
384
|
local: 'Sentry',
|
|
303
385
|
});
|
|
304
|
-
insertServerInitCall(dsn, originalEntryServerMod);
|
|
305
386
|
if (isV2) {
|
|
306
387
|
handleErrorInstrumented = (0, handle_error_1.instrumentHandleError)(originalEntryServerMod, serverEntryFilename);
|
|
307
388
|
if (handleErrorInstrumented) {
|
|
@@ -317,26 +398,5 @@ function initializeSentryOnEntryServer(dsn, isV2, isTS) {
|
|
|
317
398
|
});
|
|
318
399
|
});
|
|
319
400
|
}
|
|
320
|
-
exports.
|
|
321
|
-
function instrumentExpressServer() {
|
|
322
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
323
|
-
var expressServerPath;
|
|
324
|
-
return __generator(this, function (_a) {
|
|
325
|
-
switch (_a.label) {
|
|
326
|
-
case 0: return [4 /*yield*/, (0, express_server_1.findCustomExpressServerImplementation)()];
|
|
327
|
-
case 1:
|
|
328
|
-
expressServerPath = _a.sent();
|
|
329
|
-
if (!expressServerPath) {
|
|
330
|
-
prompts_1.default.log.warn("Could not find custom Express server implementation. Please instrument it manually.");
|
|
331
|
-
return [2 /*return*/];
|
|
332
|
-
}
|
|
333
|
-
return [4 /*yield*/, (0, express_server_1.instrumentExpressCreateRequestHandler)(expressServerPath)];
|
|
334
|
-
case 2:
|
|
335
|
-
_a.sent();
|
|
336
|
-
return [2 /*return*/];
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
exports.instrumentExpressServer = instrumentExpressServer;
|
|
401
|
+
exports.instrumentSentryOnEntryServer = instrumentSentryOnEntryServer;
|
|
342
402
|
//# sourceMappingURL=sdk-setup.js.map
|