@sentry/wizard 5.4.0 → 6.0.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.0.0
4
+
5
+ ### Breaking Changes
6
+
7
+ - remove(remix)!: Drop Remix v1 support ([#1013](https://github.com/getsentry/sentry-wizard/pull/1013))
8
+
3
9
  ## 5.4.0
4
10
 
5
11
  - feat: Introduce run build command and prompts in sourcemaps wizard ([#1024](https://github.com/getsentry/sentry-wizard/pull/1024))
@@ -54,8 +54,7 @@ originalEntryServerMod, serverEntryFilename) {
54
54
  !handleErrorFunctionVariableDeclarationExport) {
55
55
  prompts_1.default.log.warn(`Could not find function ${chalk_1.default.cyan('handleError')} in ${chalk_1.default.cyan(serverEntryFilename)}. Creating one for you.`);
56
56
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
57
- const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program
58
- .body[0];
57
+ const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE).program.body[0];
59
58
  originalEntryServerModAST.body.splice((0, utils_1.getAfterImportsInsertionIndex)(originalEntryServerModAST), 0,
60
59
  // @ts-expect-error - string works here because the AST is proxified by magicast
61
60
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@@ -69,8 +68,7 @@ originalEntryServerMod, serverEntryFilename) {
69
68
  }
70
69
  else if (handleErrorFunctionExport) {
71
70
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
72
- const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program
73
- .body[0];
71
+ const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE).program.body[0];
74
72
  // If the current handleError function has a body, we need to merge the new implementation with the existing one
75
73
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
76
74
  implementation.declarations[0].init.arguments[0].body.body.unshift(
@@ -82,8 +80,7 @@ originalEntryServerMod, serverEntryFilename) {
82
80
  }
83
81
  else if (handleErrorFunctionVariableDeclarationExport) {
84
82
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
85
- const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program
86
- .body[0];
83
+ const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE).program.body[0];
87
84
  // If the current handleError function has a body, we need to merge the new implementation with the existing one
88
85
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
89
86
  implementation.declarations[0].init.arguments[0].body.body.unshift(
@@ -1 +1 @@
1
- {"version":3,"file":"handle-error.js","sourceRoot":"","sources":["../../../../src/remix/codemods/handle-error.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM5D,+CAAiC;AAEjC,4CAAwD;AACxD,oCAA2E;AAE3E,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,kFAAkF;AAClF,uCAAwC;AAExC,SAAgB,qBAAqB;AACnC,iFAAiF;AACjF,8DAA8D;AAC9D,sBAA4C,EAC5C,mBAA2B;IAE3B,MAAM,yBAAyB,GAAG,sBAAsB,CAAC,IAAe,CAAC;IAEzE,MAAM,yBAAyB,GAAG,yBAAyB,CAAC,IAAI,CAAC,IAAI,CACnE,CAAC,IAAI,EAAE,EAAE;QACP,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,wBAAwB;YACtC,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,qBAAqB;YAChD,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,KAAK,aAAa,CAC5C,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,MAAM,4CAA4C,GAChD,yBAAyB,CAAC,IAAI,CAAC,IAAI,CACjC,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,IAAI,KAAK,wBAAwB;QACtC,IA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QACpC,sEAAsE;QACtE,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,oCAAwB,CAAC,CAAC,OAAO;aAClE,IAAI,CAAC,CAAC,CAAC,CAAC;QAEX,gHAAgH;QAChH,yGAAyG;QACzG,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;QAChE,qFAAqF;QACrF,sEAAsE;QACtE,GAAG,yBAAyB,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CACnD,CAAC;QAEF,qFAAqF;QACrF,yBAAyB,CAAC,WAAW,GAAG,cAAc,CAAC;KACxD;SAAM,IAAI,4CAA4C,EAAE;QACvD,sEAAsE;QACtE,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,oCAAwB,CAAC,CAAC,OAAO;aAClE,IAAI,CAAC,CAAC,CAAC,CAAC;QAEX,gHAAgH;QAChH,yGAAyG;QACzG,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;QAChE,qFAAqF;QACrF,sEAAsE;QACtE,GAAG,4CAA4C,CAAC,WAAW;aACxD,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAClC,CAAC;QAEF,qFAAqF;QACrF,4CAA4C,CAAC,WAAW,GAAG,cAAc,CAAC;KAC3E;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AArGD,sDAqGC","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 // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalEntryServerMod: ProxifiedModule<any>,\n serverEntryFilename: string,\n): boolean {\n const originalEntryServerModAST = originalEntryServerMod.$ast as Program;\n\n const handleErrorFunctionExport = originalEntryServerModAST.body.find(\n (node) => {\n return (\n node.type === 'ExportNamedDeclaration' &&\n node.declaration?.type === 'FunctionDeclaration' &&\n node.declaration.id?.name === 'handleError'\n );\n },\n );\n\n const handleErrorFunctionVariableDeclarationExport =\n originalEntryServerModAST.body.find(\n (node) =>\n node.type === 'ExportNamedDeclaration' &&\n node.declaration?.type === 'VariableDeclaration' &&\n // @ts-expect-error - id should always have a name in this case\n node.declaration.declarations[0].id.name === 'handleError',\n );\n\n if (\n !handleErrorFunctionExport &&\n !handleErrorFunctionVariableDeclarationExport\n ) {\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 (handleErrorFunctionExport &&\n ['wrapHandleErrorWithSentry', 'sentryHandleError'].some((util) =>\n hasSentryContent(\n generateCode(handleErrorFunctionExport).code,\n originalEntryServerMod.$code,\n util,\n ),\n )) ||\n (handleErrorFunctionVariableDeclarationExport &&\n ['wrapHandleErrorWithSentry', 'sentryHandleError'].some((util) =>\n hasSentryContent(\n generateCode(handleErrorFunctionVariableDeclarationExport).code,\n originalEntryServerMod.$code,\n util,\n ),\n ))\n ) {\n return false;\n } else if (handleErrorFunctionExport) {\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 // If the current handleError function has a body, we need to merge the new implementation with the existing one\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n implementation.declarations[0].init.arguments[0].body.body.unshift(\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ...handleErrorFunctionExport.declaration.body.body,\n );\n\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n handleErrorFunctionExport.declaration = implementation;\n } else if (handleErrorFunctionVariableDeclarationExport) {\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 // If the current handleError function has a body, we need to merge the new implementation with the existing one\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n implementation.declarations[0].init.arguments[0].body.body.unshift(\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ...handleErrorFunctionVariableDeclarationExport.declaration\n .declarations[0].init.body.body,\n );\n\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n handleErrorFunctionVariableDeclarationExport.declaration = implementation;\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"handle-error.js","sourceRoot":"","sources":["../../../../src/remix/codemods/handle-error.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM5D,+CAAiC;AAEjC,4CAAqD;AACrD,oCAA2E;AAE3E,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,kFAAkF;A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CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;QAChE,qFAAqF;QACrF,sEAAsE;QACtE,GAAG,4CAA4C,CAAC,WAAW;aACxD,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAClC,CAAC;QAEF,qFAAqF;QACrF,4CAA4C,CAAC,WAAW,GAAG,cAAc,CAAC;KAC3E;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAlGD,sDAkGC","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 } 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 // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalEntryServerMod: ProxifiedModule<any>,\n serverEntryFilename: string,\n): boolean {\n const originalEntryServerModAST = originalEntryServerMod.$ast as Program;\n\n const handleErrorFunctionExport = originalEntryServerModAST.body.find(\n (node) => {\n return (\n node.type === 'ExportNamedDeclaration' &&\n node.declaration?.type === 'FunctionDeclaration' &&\n node.declaration.id?.name === 'handleError'\n );\n },\n );\n\n const handleErrorFunctionVariableDeclarationExport =\n originalEntryServerModAST.body.find(\n (node) =>\n node.type === 'ExportNamedDeclaration' &&\n node.declaration?.type === 'VariableDeclaration' &&\n // @ts-expect-error - id should always have a name in this case\n node.declaration.declarations[0].id.name === 'handleError',\n );\n\n if (\n !handleErrorFunctionExport &&\n !handleErrorFunctionVariableDeclarationExport\n ) {\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).program.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 (handleErrorFunctionExport &&\n ['wrapHandleErrorWithSentry', 'sentryHandleError'].some((util) =>\n hasSentryContent(\n generateCode(handleErrorFunctionExport).code,\n originalEntryServerMod.$code,\n util,\n ),\n )) ||\n (handleErrorFunctionVariableDeclarationExport &&\n ['wrapHandleErrorWithSentry', 'sentryHandleError'].some((util) =>\n hasSentryContent(\n generateCode(handleErrorFunctionVariableDeclarationExport).code,\n originalEntryServerMod.$code,\n util,\n ),\n ))\n ) {\n return false;\n } else if (handleErrorFunctionExport) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const implementation = recast.parse(HANDLE_ERROR_TEMPLATE).program.body[0];\n\n // If the current handleError function has a body, we need to merge the new implementation with the existing one\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n implementation.declarations[0].init.arguments[0].body.body.unshift(\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ...handleErrorFunctionExport.declaration.body.body,\n );\n\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n handleErrorFunctionExport.declaration = implementation;\n } else if (handleErrorFunctionVariableDeclarationExport) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const implementation = recast.parse(HANDLE_ERROR_TEMPLATE).program.body[0];\n\n // If the current handleError function has a body, we need to merge the new implementation with the existing one\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n implementation.declarations[0].init.arguments[0].body.body.unshift(\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ...handleErrorFunctionVariableDeclarationExport.declaration\n .declarations[0].init.body.body,\n );\n\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n handleErrorFunctionVariableDeclarationExport.declaration = implementation;\n }\n\n return true;\n}\n"]}
@@ -1,2 +1,3 @@
1
1
  import { ProxifiedModule } from 'magicast';
2
2
  export declare function wrapAppWithSentry(rootRouteAst: ProxifiedModule, rootFileName: string): void;
3
+ export declare function instrumentRoot(rootFileName: string): Promise<void>;
@@ -1,8 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
3
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
4
- /* eslint-disable @typescript-eslint/no-unsafe-call */
5
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
6
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
3
  if (k2 === undefined) k2 = k;
8
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -26,16 +22,55 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
22
  __setModuleDefault(result, mod);
27
23
  return result;
28
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
29
28
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.instrumentRootRouteV2 = void 0;
29
+ exports.instrumentRoot = exports.wrapAppWithSentry = void 0;
30
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
31
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
32
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
33
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
31
34
  const recast = __importStar(require("recast"));
32
35
  const path = __importStar(require("path"));
33
- // @ts-expect-error - magicast is ESM and TS complains about that. It works though
34
36
  const magicast_1 = require("magicast");
35
37
  const templates_1 = require("../templates");
36
38
  const utils_1 = require("../utils");
37
- const root_common_1 = require("./root-common");
38
- async function instrumentRootRouteV2(rootFileName) {
39
+ const chalk_1 = __importDefault(require("chalk"));
40
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
41
+ const clack = __importStar(require("@clack/prompts"));
42
+ function wrapAppWithSentry(rootRouteAst, rootFileName) {
43
+ rootRouteAst.imports.$add({
44
+ from: '@sentry/remix',
45
+ imported: 'withSentry',
46
+ local: 'withSentry',
47
+ });
48
+ recast.visit(rootRouteAst.$ast, {
49
+ visitExportDefaultDeclaration(path) {
50
+ if (path.value.declaration.type === 'FunctionDeclaration') {
51
+ // Move the function declaration just before the default export
52
+ path.insertBefore(path.value.declaration);
53
+ // Get the name of the function to be wrapped
54
+ const functionName = path.value.declaration.id.name;
55
+ // Create the wrapped function call
56
+ const functionCall = recast.types.builders.callExpression(recast.types.builders.identifier('withSentry'), [recast.types.builders.identifier(functionName)]);
57
+ // Replace the default export with the wrapped function call
58
+ path.value.declaration = functionCall;
59
+ }
60
+ else if (path.value.declaration.type === 'Identifier') {
61
+ const rootRouteExport = rootRouteAst.exports.default;
62
+ const expressionToWrap = (0, magicast_1.generateCode)(rootRouteExport.$ast).code;
63
+ rootRouteAst.exports.default = magicast_1.builders.raw(`withSentry(${expressionToWrap})`);
64
+ }
65
+ else {
66
+ clack.log.warn(chalk_1.default.yellow(`Couldn't instrument ${chalk_1.default.bold(rootFileName)} automatically. Wrap your default export with: ${chalk_1.default.dim('withSentry()')}\n`));
67
+ }
68
+ this.traverse(path);
69
+ },
70
+ });
71
+ }
72
+ exports.wrapAppWithSentry = wrapAppWithSentry;
73
+ async function instrumentRoot(rootFileName) {
39
74
  const rootRouteAst = await (0, magicast_1.loadFile)(path.join(process.cwd(), 'app', rootFileName));
40
75
  const exportsAst = rootRouteAst.exports.$ast;
41
76
  const namedExports = exportsAst.body.filter((node) => node.type === 'ExportNamedDeclaration');
@@ -73,7 +108,7 @@ async function instrumentRootRouteV2(rootFileName) {
73
108
  });
74
109
  recast.visit(rootRouteAst.$ast, {
75
110
  visitExportDefaultDeclaration(path) {
76
- const implementation = recast.parse(templates_1.ERROR_BOUNDARY_TEMPLATE_V2).program
111
+ const implementation = recast.parse(templates_1.ERROR_BOUNDARY_TEMPLATE).program
77
112
  .body[0];
78
113
  path.insertBefore(recast.types.builders.exportDeclaration(false, implementation));
79
114
  this.traverse(path);
@@ -87,7 +122,7 @@ async function instrumentRootRouteV2(rootFileName) {
87
122
  imported: 'captureRemixErrorBoundaryError',
88
123
  local: 'captureRemixErrorBoundaryError',
89
124
  });
90
- (0, root_common_1.wrapAppWithSentry)(rootRouteAst, rootFileName);
125
+ wrapAppWithSentry(rootRouteAst, rootFileName);
91
126
  recast.visit(rootRouteAst.$ast, {
92
127
  visitExportNamedDeclaration(path) {
93
128
  // Find ErrorBoundary export
@@ -128,5 +163,5 @@ async function instrumentRootRouteV2(rootFileName) {
128
163
  }
129
164
  await (0, magicast_1.writeFile)(rootRouteAst.$ast, path.join(process.cwd(), 'app', rootFileName));
130
165
  }
131
- exports.instrumentRootRouteV2 = instrumentRootRouteV2;
132
- //# sourceMappingURL=root-v2.js.map
166
+ exports.instrumentRoot = instrumentRoot;
167
+ //# sourceMappingURL=root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.js","sourceRoot":"","sources":["../../../../src/remix/codemods/root.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,0DAA0D;AAC1D,+CAAiC;AACjC,2CAA6B;AAI7B,uCAOkB;AAElB,4CAAuD;AACvD,oCAA4C;AAC5C,kDAA0B;AAE1B,+EAA+E;AAC/E,sDAAwC;AAExC,SAAgB,iBAAiB,CAC/B,YAA6B,EAC7B,YAAoB;IAEpB,YAAY,CA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B,CAAC;iBACH;gBACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;SACF,CAAC,CAAC;KACJ;IAED,MAAM,IAAA,oBAAS,EACb,YAAY,CAAC,IAAI,EACjB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,CAC9C,CAAC;AACJ,CAAC;AArID,wCAqIC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\nimport * as recast from 'recast';\nimport * as path from 'path';\n\nimport type { ExportNamedDeclaration, Program } from '@babel/types';\n\nimport {\n builders,\n generateCode,\n loadFile,\n ProxifiedModule,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\n\nimport { ERROR_BOUNDARY_TEMPLATE } from '../templates';\nimport { hasSentryContent } from '../utils';\nimport chalk from 'chalk';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n\nexport function wrapAppWithSentry(\n rootRouteAst: ProxifiedModule,\n rootFileName: string,\n) {\n rootRouteAst.imports.$add({\n from: '@sentry/remix',\n imported: 'withSentry',\n local: 'withSentry',\n });\n\n recast.visit(rootRouteAst.$ast, {\n visitExportDefaultDeclaration(path) {\n if (path.value.declaration.type === 'FunctionDeclaration') {\n // Move the function declaration just before the default export\n path.insertBefore(path.value.declaration);\n\n // Get the name of the function to be wrapped\n const functionName: string = path.value.declaration.id.name as string;\n\n // Create the wrapped function call\n const functionCall = recast.types.builders.callExpression(\n recast.types.builders.identifier('withSentry'),\n [recast.types.builders.identifier(functionName)],\n );\n\n // Replace the default export with the wrapped function call\n path.value.declaration = functionCall;\n } else if (path.value.declaration.type === 'Identifier') {\n const rootRouteExport = rootRouteAst.exports.default;\n\n const expressionToWrap = generateCode(rootRouteExport.$ast).code;\n\n rootRouteAst.exports.default = builders.raw(\n `withSentry(${expressionToWrap})`,\n );\n } else {\n clack.log.warn(\n chalk.yellow(\n `Couldn't instrument ${chalk.bold(\n rootFileName,\n )} automatically. Wrap your default export with: ${chalk.dim(\n 'withSentry()',\n )}\\n`,\n ),\n );\n }\n\n this.traverse(path);\n },\n });\n}\n\nexport async function instrumentRoot(rootFileName: string): Promise<void> {\n const rootRouteAst = await loadFile(\n path.join(process.cwd(), 'app', rootFileName),\n );\n\n const exportsAst = rootRouteAst.exports.$ast as Program;\n\n const namedExports = exportsAst.body.filter(\n (node) => node.type === 'ExportNamedDeclaration',\n ) as ExportNamedDeclaration[];\n\n let foundErrorBoundary = false;\n\n namedExports.forEach((namedExport) => {\n const declaration = namedExport.declaration;\n\n if (!declaration) {\n return;\n }\n\n if (declaration.type === 'FunctionDeclaration') {\n if (declaration.id?.name === 'ErrorBoundary') {\n foundErrorBoundary = true;\n }\n } else if (declaration.type === 'VariableDeclaration') {\n const declarations = declaration.declarations;\n\n declarations.forEach((declaration) => {\n // @ts-expect-error - id should always have a name in this case\n if (declaration.id?.name === 'ErrorBoundary') {\n foundErrorBoundary = true;\n }\n });\n }\n });\n\n if (!foundErrorBoundary) {\n rootRouteAst.imports.$add({\n from: '@sentry/remix',\n imported: 'captureRemixErrorBoundaryError',\n local: 'captureRemixErrorBoundaryError',\n });\n\n rootRouteAst.imports.$add({\n from: '@remix-run/react',\n imported: 'useRouteError',\n local: 'useRouteError',\n });\n\n recast.visit(rootRouteAst.$ast, {\n visitExportDefaultDeclaration(path) {\n const implementation = recast.parse(ERROR_BOUNDARY_TEMPLATE).program\n .body[0];\n\n path.insertBefore(\n recast.types.builders.exportDeclaration(false, implementation),\n );\n\n this.traverse(path);\n },\n });\n // If there is already a ErrorBoundary export, and it doesn't have Sentry content\n } else if (!hasSentryContent(rootFileName, rootRouteAst.$code)) {\n rootRouteAst.imports.$add({\n from: '@sentry/remix',\n imported: 'captureRemixErrorBoundaryError',\n local: 'captureRemixErrorBoundaryError',\n });\n\n wrapAppWithSentry(rootRouteAst, rootFileName);\n\n recast.visit(rootRouteAst.$ast, {\n visitExportNamedDeclaration(path) {\n // Find ErrorBoundary export\n if (path.value.declaration?.id?.name === 'ErrorBoundary') {\n const errorBoundaryExport = path.value.declaration;\n\n let errorIdentifier;\n\n // check if useRouteError is called\n recast.visit(errorBoundaryExport, {\n visitVariableDeclaration(path) {\n const variableDeclaration = path.value.declarations[0];\n const initializer = variableDeclaration.init;\n\n if (\n initializer.type === 'CallExpression' &&\n initializer.callee.name === 'useRouteError'\n ) {\n errorIdentifier = variableDeclaration.id.name;\n }\n\n this.traverse(path);\n },\n });\n\n // We don't have an errorIdentifier, which means useRouteError is not called / imported\n // We need to add it and capture the error\n if (!errorIdentifier) {\n rootRouteAst.imports.$add({\n from: '@remix-run/react',\n imported: 'useRouteError',\n local: 'useRouteError',\n });\n\n const useRouteErrorCall = recast.parse(\n `const error = useRouteError();`,\n ).program.body[0];\n\n // Insert at the top of ErrorBoundary body\n errorBoundaryExport.body.body.splice(0, 0, useRouteErrorCall);\n }\n\n const captureErrorCall = recast.parse(\n `captureRemixErrorBoundaryError(error);`,\n ).program.body[0];\n\n // Insert just before the the fallback page is returned\n errorBoundaryExport.body.body.splice(\n errorBoundaryExport.body.body.length - 1,\n 0,\n captureErrorCall,\n );\n }\n this.traverse(path);\n },\n });\n }\n\n await writeFile(\n rootRouteAst.$ast,\n path.join(process.cwd(), 'app', rootFileName),\n );\n}\n"]}
@@ -32,12 +32,15 @@ async function runRemixWizardWithTelemetry(options) {
32
32
  promoCode,
33
33
  telemetryEnabled,
34
34
  });
35
+ const packageJson = await (0, clack_1.getPackageDotJson)();
36
+ if (!(0, sdk_setup_1.isRemixV2)(packageJson)) {
37
+ prompts_1.default.log.error(`Sentry only supports Remix v2 and above. Please upgrade your Remix version to use Sentry.`);
38
+ return;
39
+ }
35
40
  await (0, clack_1.confirmContinueIfNoOrDirtyGitRepo)({
36
41
  ignoreGitChanges: options.ignoreGitChanges,
37
42
  cwd: undefined,
38
43
  });
39
- const remixConfig = await (0, sdk_setup_1.loadRemixConfig)();
40
- const packageJson = await (0, clack_1.getPackageDotJson)();
41
44
  // We expect `@remix-run/dev` to be installed for every Remix project
42
45
  await (0, clack_1.ensurePackageIsInstalled)(packageJson, '@remix-run/dev', 'Remix');
43
46
  const { selectedProject, authToken, sentryUrl, selfHosted } = await (0, clack_1.getOrAskForProjectData)(options, 'javascript-remix');
@@ -49,7 +52,6 @@ async function runRemixWizardWithTelemetry(options) {
49
52
  });
50
53
  const dsn = selectedProject.keys[0].dsn.public;
51
54
  const isTS = (0, clack_1.isUsingTypeScript)();
52
- const isV2 = (0, sdk_setup_1.isRemixV2)(remixConfig, packageJson);
53
55
  const viteConfig = (0, ast_utils_1.findFile)('vite.config');
54
56
  const selectedFeatures = await (0, clack_1.featureSelectionPrompt)([
55
57
  {
@@ -103,7 +105,7 @@ async function runRemixWizardWithTelemetry(options) {
103
105
  }
104
106
  await (0, telemetry_1.traceStep)('Instrument root route', async () => {
105
107
  try {
106
- await (0, sdk_setup_1.instrumentRootRoute)(isV2, isTS);
108
+ await (0, sdk_setup_1.instrumentRootRoute)(isTS);
107
109
  }
108
110
  catch (e) {
109
111
  prompts_1.default.log.warn(`Could not instrument root route.
@@ -166,7 +168,7 @@ async function runRemixWizardWithTelemetry(options) {
166
168
  }
167
169
  await (0, telemetry_1.traceStep)('Instrument server `handleError`', async () => {
168
170
  try {
169
- await (0, sdk_setup_1.instrumentSentryOnEntryServer)(isV2, isTS);
171
+ await (0, sdk_setup_1.instrumentSentryOnEntryServer)(isTS);
170
172
  }
171
173
  catch (e) {
172
174
  prompts_1.default.log.warn(`Could not initialize Sentry on server entry.
@@ -1 +1 @@
1
- {"version":3,"file":"remix-wizard.js","sourceRoot":"","sources":["../../../src/remix/remix-wizard.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0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AA,yCAA6B,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACjD;QAAC,OAAO,CAAC,EAAE;YACV,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC;uHACkG,CAAC,CAAC;YACnH,IAAA,aAAK,EAAC,CAAC,CAAC,CAAC;SACV;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,uBAAuB,GAAG,MAAM,IAAA,kCAA0B,GAAE,CAAC;IAEnE,IAAI,uBAAuB,EAAE;QAC3B,MAAM,IAAA,qBAAS,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,IAAA,+BAAiB,EAAC;gBACtB,IAAI;gBACJ,UAAU;gBACV,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;gBAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;gBAC7B,GAAG,EAAE,SAAS;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;KACJ;IAED,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAEjD,iBAAK,CAAC,KAAK,CAAC;EACZ,eAAK,CAAC,KAAK,CACX,iEAAiE,CAClE;;EAEC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC;;EAEtE,eAAK,CAAC,IAAI,CACV;0DACwD,CACzD,EAAE,CAAC,CAAC;AACL,CAAC","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 { DEFAULT_URL } from '../../lib/Constants';\nimport { configureVitePlugin } from '../sourcemaps/tools/vite';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { findFile } from '../utils/ast-utils';\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';\nimport { debug } from '../utils/debug';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { createExamplePage } from './sdk-example';\nimport {\n createServerInstrumentationFile,\n initializeSentryOnEntryClient,\n insertServerInstrumentationFile,\n instrumentRootRoute,\n instrumentSentryOnEntryServer,\n isRemixV2,\n loadRemixConfig,\n runRemixReveal,\n updateBuildScript,\n updateStartScript,\n} from './sdk-setup';\nimport { isHydrogenApp } from './utils';\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 const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Remix Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\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@^9',\n packageNameDisplayLabel: '@sentry/remix',\n alreadyInstalled: hasPackageInstalled('@sentry/remix', packageJson),\n forceInstall,\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 '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({ cwd: undefined });\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":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CAAC,CACF,CAAC;KACH;IAED,MAAM,IAAA,qBAAS,EAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC5D,IAAI;YACF,MAAM,IAAA,yCAA6B,EAAC,IAAI,CAAC,CAAC;SAC3C;QAAC,OAAO,CAAC,EAAE;YACV,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC;uHACkG,CAAC,CAAC;YACnH,IAAA,aAAK,EAAC,CAAC,CAAC,CAAC;SACV;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,uBAAuB,GAAG,MAAM,IAAA,kCAA0B,GAAE,CAAC;IAEnE,IAAI,uBAAuB,EAAE;QAC3B,MAAM,IAAA,qBAAS,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,IAAA,+BAAiB,EAAC;gBACtB,IAAI;gBACJ,UAAU;gBACV,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;gBAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;gBAC7B,GAAG,EAAE,SAAS;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;KACJ;IAED,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAEjD,iBAAK,CAAC,KAAK,CAAC;EACZ,eAAK,CAAC,KAAK,CACX,iEAAiE,CAClE;;EAEC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC;;EAEtE,eAAK,CAAC,IAAI,CACV;0DACwD,CACzD,EAAE,CAAC,CAAC;AACL,CAAC","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 { DEFAULT_URL } from '../../lib/Constants';\nimport { configureVitePlugin } from '../sourcemaps/tools/vite';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { findFile } from '../utils/ast-utils';\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';\nimport { debug } from '../utils/debug';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { createExamplePage } from './sdk-example';\nimport {\n createServerInstrumentationFile,\n initializeSentryOnEntryClient,\n insertServerInstrumentationFile,\n instrumentRootRoute,\n instrumentSentryOnEntryServer,\n isRemixV2,\n runRemixReveal,\n updateBuildScript,\n updateStartScript,\n} from './sdk-setup';\nimport { isHydrogenApp } from './utils';\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 const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Remix Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n const packageJson = await getPackageDotJson();\n\n if (!isRemixV2(packageJson)) {\n clack.log.error(\n `Sentry only supports Remix v2 and above. Please upgrade your Remix version to use Sentry.`,\n );\n return;\n }\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\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@^9',\n packageNameDisplayLabel: '@sentry/remix',\n alreadyInstalled: hasPackageInstalled('@sentry/remix', packageJson),\n forceInstall,\n });\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const isTS = isUsingTypeScript();\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 '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(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(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({ cwd: undefined });\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"]}
@@ -2,14 +2,6 @@ import type { ProxifiedModule } from 'magicast';
2
2
  import type { PackageDotJson } from '../utils/package-json';
3
3
  export type PartialRemixConfig = {
4
4
  unstable_dev?: boolean;
5
- future?: {
6
- v2_dev?: boolean;
7
- v2_errorBoundary?: boolean;
8
- v2_headers?: boolean;
9
- v2_meta?: boolean;
10
- v2_normalizeFormMethod?: boolean;
11
- v2_routeConvention?: boolean;
12
- };
13
5
  };
14
6
  export declare function runRemixReveal(isTS: boolean): void;
15
7
  export declare function generateServerInstrumentationFile(dsn: string, selectedFeatures: {
@@ -27,9 +19,9 @@ export declare function insertServerInstrumentationFile(dsn: string, selectedFea
27
19
  performance: boolean;
28
20
  replay: boolean;
29
21
  }): Promise<boolean>;
30
- export declare function isRemixV2(remixConfig: PartialRemixConfig, packageJson: PackageDotJson): boolean;
22
+ export declare function isRemixV2(packageJson: PackageDotJson): boolean;
31
23
  export declare function loadRemixConfig(): Promise<PartialRemixConfig>;
32
- export declare function instrumentRootRoute(isV2?: boolean, isTS?: boolean): Promise<void>;
24
+ export declare function instrumentRootRoute(isTS?: boolean): Promise<void>;
33
25
  export declare function updateBuildScript(args: {
34
26
  org: string;
35
27
  project: string;
@@ -45,4 +37,4 @@ export declare function initializeSentryOnEntryClient(dsn: string, isTS: boolean
45
37
  replay: boolean;
46
38
  }): Promise<void>;
47
39
  export declare function updateStartScript(instrumentationFile: string): Promise<void>;
48
- export declare function instrumentSentryOnEntryServer(isV2: boolean, isTS: boolean): Promise<void>;
40
+ export declare function instrumentSentryOnEntryServer(isTS: boolean): Promise<void>;
@@ -39,8 +39,7 @@ const semver_1 = require("semver");
39
39
  const magicast_1 = require("magicast");
40
40
  const package_json_1 = require("../utils/package-json");
41
41
  const utils_1 = require("./utils");
42
- const root_v1_1 = require("./codemods/root-v1");
43
- const root_v2_1 = require("./codemods/root-v2");
42
+ const root_1 = require("./codemods/root");
44
43
  const handle_error_1 = require("./codemods/handle-error");
45
44
  const clack_1 = require("../utils/clack");
46
45
  const express_server_1 = require("./codemods/express-server");
@@ -143,7 +142,7 @@ Skipping adding instrumentation functionality to ${chalk_1.default.cyan(path.bas
143
142
  return true;
144
143
  }
145
144
  exports.insertServerInstrumentationFile = insertServerInstrumentationFile;
146
- function isRemixV2(remixConfig, packageJson) {
145
+ function isRemixV2(packageJson) {
147
146
  const remixVersion = (0, package_json_1.getPackageVersion)('@remix-run/react', packageJson);
148
147
  if (!remixVersion) {
149
148
  return false;
@@ -152,8 +151,7 @@ function isRemixV2(remixConfig, packageJson) {
152
151
  if (!minVer) {
153
152
  return false;
154
153
  }
155
- const isV2Remix = (0, semver_1.gte)(minVer, '2.0.0');
156
- return isV2Remix || remixConfig?.future?.v2_errorBoundary || false;
154
+ return (0, semver_1.gte)(minVer, '2.0.0');
157
155
  }
158
156
  exports.isRemixV2 = isRemixV2;
159
157
  async function loadRemixConfig() {
@@ -177,14 +175,9 @@ async function loadRemixConfig() {
177
175
  }
178
176
  }
179
177
  exports.loadRemixConfig = loadRemixConfig;
180
- async function instrumentRootRoute(isV2, isTS) {
178
+ async function instrumentRootRoute(isTS) {
181
179
  const rootFilename = `root.${isTS ? 'tsx' : 'jsx'}`;
182
- if (isV2) {
183
- await (0, root_v2_1.instrumentRootRouteV2)(rootFilename);
184
- }
185
- else {
186
- await (0, root_v1_1.instrumentRootRouteV1)(rootFilename);
187
- }
180
+ await (0, root_1.instrumentRoot)(rootFilename);
188
181
  prompts_1.default.log.success(`Successfully instrumented root route ${chalk_1.default.cyan(rootFilename)}.`);
189
182
  /* eslint-enable @typescript-eslint/no-unsafe-member-access */
190
183
  }
@@ -285,7 +278,7 @@ async function updateStartScript(instrumentationFile) {
285
278
  prompts_1.default.log.success(`Successfully updated ${chalk_1.default.cyan('start')} script in ${chalk_1.default.cyan('package.json')} to include Sentry initialization on start.`);
286
279
  }
287
280
  exports.updateStartScript = updateStartScript;
288
- async function instrumentSentryOnEntryServer(isV2, isTS) {
281
+ async function instrumentSentryOnEntryServer(isTS) {
289
282
  const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;
290
283
  const originalEntryServer = path.join(process.cwd(), 'app', serverEntryFilename);
291
284
  const originalEntryServerMod = await (0, magicast_1.loadFile)(originalEntryServer);
@@ -297,11 +290,9 @@ async function instrumentSentryOnEntryServer(isV2, isTS) {
297
290
  imported: '*',
298
291
  local: 'Sentry',
299
292
  });
300
- if (isV2) {
301
- const handleErrorInstrumented = (0, handle_error_1.instrumentHandleError)(originalEntryServerMod, serverEntryFilename);
302
- if (handleErrorInstrumented) {
303
- prompts_1.default.log.success(`Instrumented ${chalk_1.default.cyan('handleError')} in ${chalk_1.default.cyan(`${serverEntryFilename}`)}`);
304
- }
293
+ const handleErrorInstrumented = (0, handle_error_1.instrumentHandleError)(originalEntryServerMod, serverEntryFilename);
294
+ if (handleErrorInstrumented) {
295
+ prompts_1.default.log.success(`Instrumented ${chalk_1.default.cyan('handleError')} in ${chalk_1.default.cyan(`${serverEntryFilename}`)}`);
305
296
  }
306
297
  await (0, magicast_1.writeFile)(originalEntryServerMod.$ast, path.join(process.cwd(), 'app', serverEntryFilename));
307
298
  prompts_1.default.log.success(`Successfully initialized Sentry on server entry point ${chalk_1.default.cyan(serverEntryFilename)}.`);
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/remix/sdk-setup.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO5D,uCAAyB;AACzB,2CAA6B;AAC7B,yCAA2B;AAC3B,4DAA8C;AAE9C,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,mCAAyC;AAEzC,uCAOkB;AAElB,wDAA0D;AAC1D,mCAIiB;AACjB,gDAA2D;AAC3D,gDAA2D;AAC3D,0DAAgE;AAChE,0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,GAAG,EAAE,EACb,KAAK,EACL,mBAAmB,CACpB,CAAC;IAEF,MAAM,sBAAsB,GAAG,MAAM,IAAA,mBAAQ,EAAC,mBAAmB,CAAC,CAAC;IAEnE,IAAI,IAAA,wBAAgB,EAAC,mBAAmB,EAAE,sBAAsB,CAAC,KAAK,CAAC,EAAE;QACvE,OAAO;KACR;IAED,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC;QAClC,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,GAAG;QACb,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IAEH,IAAI,IAAI,EAAE;QACR,MAAM,uBAAuB,GAAG,IAAA,oCAAqB,EACnD,sBAAsB,EACtB,mBAAmB,CACpB,CAAC;QAEF,IAAI,uBAAuB,EAAE;YAC3B,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,gBAAgB,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,eAAK,CAAC,IAAI,CACxD,GAAG,mBAAmB,EAAE,CACzB,EAAE,CACJ,CAAC;SACH;KACF;IAED,MAAM,IAAA,oBAAS,EACb,sBAAsB,CAAC,IAAI,EAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CACrD,CAAC;IAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,yDAAyD,eAAK,CAAC,IAAI,CACjE,mBAAmB,CACpB,GAAG,CACL,CAAC;AACJ,CAAC;AAjDD,sEAiDC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport type { Program } from '@babel/types';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { Proxified, ProxifiedModule } from 'magicast';\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport * as childProcess from 'child_process';\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';\nimport { gte, minVersion } from 'semver';\n\nimport {\n builders,\n generateCode,\n loadFile,\n parseModule,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\nimport type { PackageDotJson } from '../utils/package-json';\nimport { getPackageVersion } from '../utils/package-json';\nimport {\n getAfterImportsInsertionIndex,\n hasSentryContent,\n serverHasInstrumentationImport,\n} from './utils';\nimport { instrumentRootRouteV1 } from './codemods/root-v1';\nimport { instrumentRootRouteV2 } from './codemods/root-v2';\nimport { instrumentHandleError } from './codemods/handle-error';\nimport { getPackageDotJson } from '../utils/clack';\nimport { findCustomExpressServerImplementation } from './codemods/express-server';\n\nexport type PartialRemixConfig = {\n unstable_dev?: boolean;\n future?: {\n v2_dev?: boolean;\n v2_errorBoundary?: boolean;\n v2_headers?: boolean;\n v2_meta?: boolean;\n v2_normalizeFormMethod?: boolean;\n v2_routeConvention?: boolean;\n };\n};\n\nconst REMIX_CONFIG_FILE = 'remix.config.js';\nconst REMIX_REVEAL_COMMAND = 'npx remix reveal';\n\nexport function runRemixReveal(isTS: boolean): void {\n // Check if entry files already exist\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const clientEntryPath = path.join(process.cwd(), 'app', clientEntryFilename);\n const serverEntryPath = path.join(process.cwd(), 'app', serverEntryFilename);\n\n if (fs.existsSync(clientEntryPath) && fs.existsSync(serverEntryPath)) {\n clack.log.info(\n `Found entry files ${chalk.cyan(clientEntryFilename)} and ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n } else {\n clack.log.info(\n `Couldn't find entry files in your project. Trying to run ${chalk.cyan(\n REMIX_REVEAL_COMMAND,\n )}...`,\n );\n\n clack.log.info(childProcess.execSync(REMIX_REVEAL_COMMAND).toString());\n }\n}\n\ninterface SdkAstOptions {\n dsn: string;\n tracesSampleRate?: number;\n replaysSessionSampleRate?: number;\n replaysOnErrorSampleRate?: number;\n integrations?: Array<Proxified>;\n}\n\nfunction getInitCallArgs(\n dsn: string,\n type: 'client' | 'server',\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const initCallArgs: SdkAstOptions = {\n dsn,\n };\n\n // Adding tracing sample rate for both client and server\n if (selectedFeatures.performance) {\n initCallArgs.tracesSampleRate = 1.0;\n }\n\n // Adding integrations and replay options only for client\n if (\n type === 'client' &&\n (selectedFeatures.performance || selectedFeatures.replay)\n ) {\n initCallArgs.integrations = [] as Array<Proxified>;\n\n if (selectedFeatures.performance) {\n initCallArgs.integrations.push(\n builders.functionCall(\n 'browserTracingIntegration',\n builders.raw('{ useEffect, useLocation, useMatches }'),\n ),\n );\n }\n\n if (selectedFeatures.replay) {\n initCallArgs.integrations.push(\n builders.functionCall('replayIntegration', {\n maskAllText: true,\n blockAllMedia: true,\n }),\n );\n\n initCallArgs.replaysSessionSampleRate = 0.1;\n initCallArgs.replaysOnErrorSampleRate = 1.0;\n }\n }\n\n return initCallArgs;\n}\n\nfunction insertClientInitCall(\n dsn: string,\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalHooksMod: ProxifiedModule<any>,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): void {\n const initCallArgs = getInitCallArgs(dsn, 'client', selectedFeatures);\n const initCall = builders.functionCall('init', initCallArgs);\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n const initCallInsertionIndex =\n getAfterImportsInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\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 generateCode(initCall).code,\n );\n}\n\nexport function generateServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n // create an empty file named `instrument.server.mjs`\n const instrumentationFile = 'instrumentation.server.mjs';\n const instrumentationFileMod = parseModule('');\n\n instrumentationFileMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n const initCallArgs = getInitCallArgs(dsn, 'server', selectedFeatures);\n const initCall = builders.functionCall('Sentry.init', initCallArgs);\n\n const instrumentationFileModAST = instrumentationFileMod.$ast as Program;\n\n const initCallInsertionIndex = getAfterImportsInsertionIndex(\n instrumentationFileModAST,\n );\n\n instrumentationFileModAST.body.splice(\n initCallInsertionIndex,\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 generateCode(initCall).code,\n );\n\n return { instrumentationFile, instrumentationFileMod };\n}\n\nexport async function createServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const { instrumentationFile, instrumentationFileMod } =\n generateServerInstrumentationFile(dsn, selectedFeatures);\n\n await writeFile(instrumentationFileMod.$ast, instrumentationFile);\n\n return instrumentationFile;\n}\n\nexport async function insertServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n\n const expressServerPath = await findCustomExpressServerImplementation();\n\n if (!expressServerPath) {\n return false;\n }\n\n const originalExpressServerMod = await loadFile(expressServerPath);\n\n if (\n serverHasInstrumentationImport(\n expressServerPath,\n originalExpressServerMod.$code,\n )\n ) {\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(expressServerPath),\n )} already contains instrumentation import.\nSkipping adding instrumentation functionality to ${chalk.cyan(\n path.basename(expressServerPath),\n )}.`,\n );\n\n return true;\n }\n\n originalExpressServerMod.$code = `import './${instrumentationFile}';\\n${originalExpressServerMod.$code}`;\n\n fs.writeFileSync(expressServerPath, originalExpressServerMod.$code);\n\n return true;\n}\n\nexport function isRemixV2(\n remixConfig: PartialRemixConfig,\n packageJson: PackageDotJson,\n): boolean {\n const remixVersion = getPackageVersion('@remix-run/react', packageJson);\n if (!remixVersion) {\n return false;\n }\n\n const minVer = minVersion(remixVersion);\n\n if (!minVer) {\n return false;\n }\n\n const isV2Remix = gte(minVer, '2.0.0');\n\n return isV2Remix || remixConfig?.future?.v2_errorBoundary || false;\n}\n\nexport async function loadRemixConfig(): Promise<PartialRemixConfig> {\n const configFilePath = path.join(process.cwd(), REMIX_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const remixConfigModule = (await import(configUrl)) as {\n default: PartialRemixConfig;\n };\n\n return remixConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${REMIX_CONFIG_FILE}.`);\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\n return {};\n }\n}\n\nexport async function instrumentRootRoute(\n isV2?: boolean,\n isTS?: boolean,\n): Promise<void> {\n const rootFilename = `root.${isTS ? 'tsx' : 'jsx'}`;\n\n if (isV2) {\n await instrumentRootRouteV2(rootFilename);\n } else {\n await instrumentRootRouteV1(rootFilename);\n }\n\n clack.log.success(\n `Successfully instrumented root route ${chalk.cyan(rootFilename)}.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport async function updateBuildScript(args: {\n org: string;\n project: string;\n url?: string;\n isHydrogen: boolean;\n}): Promise<void> {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n const buildCommand = args.isHydrogen\n ? 'shopify hydrogen build'\n : 'remix build';\n\n const instrumentedBuildCommand =\n `${buildCommand} --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +\n (args.url ? ` --url ${args.url}` : '') +\n (args.isHydrogen ? ' --buildPath ./dist' : '');\n\n if (!packageJson.scripts.build) {\n packageJson.scripts.build = instrumentedBuildCommand;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n } else if (packageJson.scripts.build.includes(buildCommand)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n packageJson.scripts.build = packageJson.scripts.build.replace(\n buildCommand,\n instrumentedBuildCommand,\n );\n } else {\n throw new Error(\n \"`build` script doesn't contain a known build command. Please update it manually.\",\n );\n }\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('build')} script in ${chalk.cyan(\n 'package.json',\n )} to generate and upload sourcemaps.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport function updateEntryClientMod(\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalEntryClientMod: ProxifiedModule<any>,\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): ProxifiedModule<any> {\n const imports = ['init'];\n if (selectedFeatures.replay) {\n imports.push('replayIntegration');\n }\n if (selectedFeatures.performance) {\n imports.push('browserTracingIntegration');\n }\n originalEntryClientMod.imports.$add({\n from: '@sentry/remix',\n imported: `${imports.join(', ')}`,\n });\n\n if (selectedFeatures.performance) {\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useLocation',\n local: 'useLocation',\n });\n\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useMatches',\n local: 'useMatches',\n });\n\n originalEntryClientMod.imports.$add({\n from: 'react',\n imported: 'useEffect',\n local: 'useEffect',\n });\n }\n\n insertClientInitCall(dsn, originalEntryClientMod, selectedFeatures);\n\n return originalEntryClientMod;\n}\n\nexport async function initializeSentryOnEntryClient(\n dsn: string,\n isTS: boolean,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): Promise<void> {\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryClient = path.join(\n process.cwd(),\n 'app',\n clientEntryFilename,\n );\n\n const originalEntryClientMod = await loadFile(originalEntryClient);\n\n if (hasSentryContent(originalEntryClient, originalEntryClientMod.$code)) {\n return;\n }\n\n const updatedEntryClientMod = updateEntryClientMod(\n originalEntryClientMod,\n dsn,\n selectedFeatures,\n );\n\n await writeFile(\n updatedEntryClientMod.$ast,\n path.join(process.cwd(), 'app', clientEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on client entry point ${chalk.cyan(\n clientEntryFilename,\n )}`,\n );\n}\n\nexport async function updateStartScript(instrumentationFile: string) {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts || !packageJson.scripts.start) {\n throw new Error(\n \"Couldn't find a `start` script in your package.json. Please add one manually.\",\n );\n }\n\n if (packageJson.scripts.start.includes('NODE_OPTIONS')) {\n clack.log.warn(\n `Found existing NODE_OPTIONS in ${chalk.cyan(\n 'start',\n )} script. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n if (\n !packageJson.scripts.start.includes('remix-serve') &&\n // Adding a following empty space not to match a path that includes `node`\n !packageJson.scripts.start.includes('node ')\n ) {\n clack.log.warn(\n `Found a ${chalk.cyan('start')} script that doesn't use ${chalk.cyan(\n 'remix-serve',\n )} or ${chalk.cyan('node')}. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n const startCommand = packageJson.scripts.start;\n\n packageJson.scripts.start = `NODE_OPTIONS='--import ./${instrumentationFile}' ${startCommand}`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('start')} script in ${chalk.cyan(\n 'package.json',\n )} to include Sentry initialization on start.`,\n );\n}\n\nexport async function instrumentSentryOnEntryServer(\n isV2: boolean,\n isTS: boolean,\n): Promise<void> {\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryServer = path.join(\n process.cwd(),\n 'app',\n serverEntryFilename,\n );\n\n const originalEntryServerMod = await loadFile(originalEntryServer);\n\n if (hasSentryContent(originalEntryServer, originalEntryServerMod.$code)) {\n return;\n }\n\n originalEntryServerMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n if (isV2) {\n const handleErrorInstrumented = instrumentHandleError(\n originalEntryServerMod,\n serverEntryFilename,\n );\n\n if (handleErrorInstrumented) {\n clack.log.success(\n `Instrumented ${chalk.cyan('handleError')} in ${chalk.cyan(\n `${serverEntryFilename}`,\n )}`,\n );\n }\n }\n\n await writeFile(\n originalEntryServerMod.$ast,\n path.join(process.cwd(), 'app', serverEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on server entry point ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n}\n"]}
1
+ {"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/remix/sdk-setup.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO5D,uCAAyB;AACzB,2CAA6B;AAC7B,yCAA2B;AAC3B,4DAA8C;AAE9C,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,mCAAyC;AAEzC,uCAOkB;AAElB,wDAA0D;AAC1D,mCAIiB;AACjB,0CAAiD;AACjD,0DAAgE;AAChE,0CAAmD;AACnD,8DAAkF;AAMlF,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAC5C,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEhD,SAAgB,cAAc,CAAC,IAAa;IAC1C,qCAAqC;IACrC,MAAM,mBAAmB,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IACnE,MAAM,mBAAmB,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IAEnE,MAAM,eAA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,EAAE,CACzB,EAAE,CACJ,CAAC;KACH;IAED,MAAM,IAAA,oBAAS,EACb,sBAAsB,CAAC,IAAI,EAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CACrD,CAAC;IAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,yDAAyD,eAAK,CAAC,IAAI,CACjE,mBAAmB,CACpB,GAAG,CACL,CAAC;AACJ,CAAC;AA9CD,sEA8CC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport type { Program } from '@babel/types';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { Proxified, ProxifiedModule } from 'magicast';\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport * as childProcess from 'child_process';\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';\nimport { gte, minVersion } from 'semver';\n\nimport {\n builders,\n generateCode,\n loadFile,\n parseModule,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\nimport type { PackageDotJson } from '../utils/package-json';\nimport { getPackageVersion } from '../utils/package-json';\nimport {\n getAfterImportsInsertionIndex,\n hasSentryContent,\n serverHasInstrumentationImport,\n} from './utils';\nimport { instrumentRoot } from './codemods/root';\nimport { instrumentHandleError } from './codemods/handle-error';\nimport { getPackageDotJson } from '../utils/clack';\nimport { findCustomExpressServerImplementation } from './codemods/express-server';\n\nexport type PartialRemixConfig = {\n unstable_dev?: boolean;\n};\n\nconst REMIX_CONFIG_FILE = 'remix.config.js';\nconst REMIX_REVEAL_COMMAND = 'npx remix reveal';\n\nexport function runRemixReveal(isTS: boolean): void {\n // Check if entry files already exist\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const clientEntryPath = path.join(process.cwd(), 'app', clientEntryFilename);\n const serverEntryPath = path.join(process.cwd(), 'app', serverEntryFilename);\n\n if (fs.existsSync(clientEntryPath) && fs.existsSync(serverEntryPath)) {\n clack.log.info(\n `Found entry files ${chalk.cyan(clientEntryFilename)} and ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n } else {\n clack.log.info(\n `Couldn't find entry files in your project. Trying to run ${chalk.cyan(\n REMIX_REVEAL_COMMAND,\n )}...`,\n );\n\n clack.log.info(childProcess.execSync(REMIX_REVEAL_COMMAND).toString());\n }\n}\n\ninterface SdkAstOptions {\n dsn: string;\n tracesSampleRate?: number;\n replaysSessionSampleRate?: number;\n replaysOnErrorSampleRate?: number;\n integrations?: Array<Proxified>;\n}\n\nfunction getInitCallArgs(\n dsn: string,\n type: 'client' | 'server',\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const initCallArgs: SdkAstOptions = {\n dsn,\n };\n\n // Adding tracing sample rate for both client and server\n if (selectedFeatures.performance) {\n initCallArgs.tracesSampleRate = 1.0;\n }\n\n // Adding integrations and replay options only for client\n if (\n type === 'client' &&\n (selectedFeatures.performance || selectedFeatures.replay)\n ) {\n initCallArgs.integrations = [] as Array<Proxified>;\n\n if (selectedFeatures.performance) {\n initCallArgs.integrations.push(\n builders.functionCall(\n 'browserTracingIntegration',\n builders.raw('{ useEffect, useLocation, useMatches }'),\n ),\n );\n }\n\n if (selectedFeatures.replay) {\n initCallArgs.integrations.push(\n builders.functionCall('replayIntegration', {\n maskAllText: true,\n blockAllMedia: true,\n }),\n );\n\n initCallArgs.replaysSessionSampleRate = 0.1;\n initCallArgs.replaysOnErrorSampleRate = 1.0;\n }\n }\n\n return initCallArgs;\n}\n\nfunction insertClientInitCall(\n dsn: string,\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalHooksMod: ProxifiedModule<any>,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): void {\n const initCallArgs = getInitCallArgs(dsn, 'client', selectedFeatures);\n const initCall = builders.functionCall('init', initCallArgs);\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n const initCallInsertionIndex =\n getAfterImportsInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\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 generateCode(initCall).code,\n );\n}\n\nexport function generateServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n // create an empty file named `instrument.server.mjs`\n const instrumentationFile = 'instrumentation.server.mjs';\n const instrumentationFileMod = parseModule('');\n\n instrumentationFileMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n const initCallArgs = getInitCallArgs(dsn, 'server', selectedFeatures);\n const initCall = builders.functionCall('Sentry.init', initCallArgs);\n\n const instrumentationFileModAST = instrumentationFileMod.$ast as Program;\n\n const initCallInsertionIndex = getAfterImportsInsertionIndex(\n instrumentationFileModAST,\n );\n\n instrumentationFileModAST.body.splice(\n initCallInsertionIndex,\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 generateCode(initCall).code,\n );\n\n return { instrumentationFile, instrumentationFileMod };\n}\n\nexport async function createServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const { instrumentationFile, instrumentationFileMod } =\n generateServerInstrumentationFile(dsn, selectedFeatures);\n\n await writeFile(instrumentationFileMod.$ast, instrumentationFile);\n\n return instrumentationFile;\n}\n\nexport async function insertServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n\n const expressServerPath = await findCustomExpressServerImplementation();\n\n if (!expressServerPath) {\n return false;\n }\n\n const originalExpressServerMod = await loadFile(expressServerPath);\n\n if (\n serverHasInstrumentationImport(\n expressServerPath,\n originalExpressServerMod.$code,\n )\n ) {\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(expressServerPath),\n )} already contains instrumentation import.\nSkipping adding instrumentation functionality to ${chalk.cyan(\n path.basename(expressServerPath),\n )}.`,\n );\n\n return true;\n }\n\n originalExpressServerMod.$code = `import './${instrumentationFile}';\\n${originalExpressServerMod.$code}`;\n\n fs.writeFileSync(expressServerPath, originalExpressServerMod.$code);\n\n return true;\n}\n\nexport function isRemixV2(packageJson: PackageDotJson): boolean {\n const remixVersion = getPackageVersion('@remix-run/react', packageJson);\n if (!remixVersion) {\n return false;\n }\n\n const minVer = minVersion(remixVersion);\n\n if (!minVer) {\n return false;\n }\n\n return gte(minVer, '2.0.0');\n}\n\nexport async function loadRemixConfig(): Promise<PartialRemixConfig> {\n const configFilePath = path.join(process.cwd(), REMIX_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const remixConfigModule = (await import(configUrl)) as {\n default: PartialRemixConfig;\n };\n\n return remixConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${REMIX_CONFIG_FILE}.`);\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\n return {};\n }\n}\n\nexport async function instrumentRootRoute(isTS?: boolean): Promise<void> {\n const rootFilename = `root.${isTS ? 'tsx' : 'jsx'}`;\n\n await instrumentRoot(rootFilename);\n\n clack.log.success(\n `Successfully instrumented root route ${chalk.cyan(rootFilename)}.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport async function updateBuildScript(args: {\n org: string;\n project: string;\n url?: string;\n isHydrogen: boolean;\n}): Promise<void> {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n const buildCommand = args.isHydrogen\n ? 'shopify hydrogen build'\n : 'remix build';\n\n const instrumentedBuildCommand =\n `${buildCommand} --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +\n (args.url ? ` --url ${args.url}` : '') +\n (args.isHydrogen ? ' --buildPath ./dist' : '');\n\n if (!packageJson.scripts.build) {\n packageJson.scripts.build = instrumentedBuildCommand;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n } else if (packageJson.scripts.build.includes(buildCommand)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n packageJson.scripts.build = packageJson.scripts.build.replace(\n buildCommand,\n instrumentedBuildCommand,\n );\n } else {\n throw new Error(\n \"`build` script doesn't contain a known build command. Please update it manually.\",\n );\n }\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('build')} script in ${chalk.cyan(\n 'package.json',\n )} to generate and upload sourcemaps.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport function updateEntryClientMod(\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalEntryClientMod: ProxifiedModule<any>,\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): ProxifiedModule<any> {\n const imports = ['init'];\n if (selectedFeatures.replay) {\n imports.push('replayIntegration');\n }\n if (selectedFeatures.performance) {\n imports.push('browserTracingIntegration');\n }\n originalEntryClientMod.imports.$add({\n from: '@sentry/remix',\n imported: `${imports.join(', ')}`,\n });\n\n if (selectedFeatures.performance) {\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useLocation',\n local: 'useLocation',\n });\n\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useMatches',\n local: 'useMatches',\n });\n\n originalEntryClientMod.imports.$add({\n from: 'react',\n imported: 'useEffect',\n local: 'useEffect',\n });\n }\n\n insertClientInitCall(dsn, originalEntryClientMod, selectedFeatures);\n\n return originalEntryClientMod;\n}\n\nexport async function initializeSentryOnEntryClient(\n dsn: string,\n isTS: boolean,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): Promise<void> {\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryClient = path.join(\n process.cwd(),\n 'app',\n clientEntryFilename,\n );\n\n const originalEntryClientMod = await loadFile(originalEntryClient);\n\n if (hasSentryContent(originalEntryClient, originalEntryClientMod.$code)) {\n return;\n }\n\n const updatedEntryClientMod = updateEntryClientMod(\n originalEntryClientMod,\n dsn,\n selectedFeatures,\n );\n\n await writeFile(\n updatedEntryClientMod.$ast,\n path.join(process.cwd(), 'app', clientEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on client entry point ${chalk.cyan(\n clientEntryFilename,\n )}`,\n );\n}\n\nexport async function updateStartScript(instrumentationFile: string) {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts || !packageJson.scripts.start) {\n throw new Error(\n \"Couldn't find a `start` script in your package.json. Please add one manually.\",\n );\n }\n\n if (packageJson.scripts.start.includes('NODE_OPTIONS')) {\n clack.log.warn(\n `Found existing NODE_OPTIONS in ${chalk.cyan(\n 'start',\n )} script. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n if (\n !packageJson.scripts.start.includes('remix-serve') &&\n // Adding a following empty space not to match a path that includes `node`\n !packageJson.scripts.start.includes('node ')\n ) {\n clack.log.warn(\n `Found a ${chalk.cyan('start')} script that doesn't use ${chalk.cyan(\n 'remix-serve',\n )} or ${chalk.cyan('node')}. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n const startCommand = packageJson.scripts.start;\n\n packageJson.scripts.start = `NODE_OPTIONS='--import ./${instrumentationFile}' ${startCommand}`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('start')} script in ${chalk.cyan(\n 'package.json',\n )} to include Sentry initialization on start.`,\n );\n}\n\nexport async function instrumentSentryOnEntryServer(\n isTS: boolean,\n): Promise<void> {\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryServer = path.join(\n process.cwd(),\n 'app',\n serverEntryFilename,\n );\n\n const originalEntryServerMod = await loadFile(originalEntryServer);\n\n if (hasSentryContent(originalEntryServer, originalEntryServerMod.$code)) {\n return;\n }\n\n originalEntryServerMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n const handleErrorInstrumented = instrumentHandleError(\n originalEntryServerMod,\n serverEntryFilename,\n );\n\n if (handleErrorInstrumented) {\n clack.log.success(\n `Instrumented ${chalk.cyan('handleError')} in ${chalk.cyan(\n `${serverEntryFilename}`,\n )}`,\n );\n }\n\n await writeFile(\n originalEntryServerMod.$ast,\n path.join(process.cwd(), 'app', serverEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on server entry point ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const ERROR_BOUNDARY_TEMPLATE_V2 = "const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};\n";
2
- export declare const HANDLE_ERROR_TEMPLATE_V2 = "const handleError = Sentry.wrapHandleErrorWithSentry((error, { request }) => {\n // Custom handleError implementation\n});\n";
1
+ export declare const ERROR_BOUNDARY_TEMPLATE = "const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};\n";
2
+ export declare const HANDLE_ERROR_TEMPLATE = "const handleError = Sentry.wrapHandleErrorWithSentry((error, { request }) => {\n // Custom handleError implementation\n});\n";
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HANDLE_ERROR_TEMPLATE_V2 = exports.ERROR_BOUNDARY_TEMPLATE_V2 = void 0;
4
- exports.ERROR_BOUNDARY_TEMPLATE_V2 = `const ErrorBoundary = () => {
3
+ exports.HANDLE_ERROR_TEMPLATE = exports.ERROR_BOUNDARY_TEMPLATE = void 0;
4
+ exports.ERROR_BOUNDARY_TEMPLATE = `const ErrorBoundary = () => {
5
5
  const error = useRouteError();
6
6
  captureRemixErrorBoundaryError(error);
7
7
  return <div>Something went wrong</div>;
8
8
  };
9
9
  `;
10
- exports.HANDLE_ERROR_TEMPLATE_V2 = `const handleError = Sentry.wrapHandleErrorWithSentry((error, { request }) => {
10
+ exports.HANDLE_ERROR_TEMPLATE = `const handleError = Sentry.wrapHandleErrorWithSentry((error, { request }) => {
11
11
  // Custom handleError implementation
12
12
  });
13
13
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/remix/templates.ts"],"names":[],"mappings":";;;AAAa,QAAA,0BAA0B,GAAG;;;;;CAKzC,CAAC;AAEW,QAAA,wBAAwB,GAAG;;;CAGvC,CAAC","sourcesContent":["export const ERROR_BOUNDARY_TEMPLATE_V2 = `const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};\n`;\n\nexport const HANDLE_ERROR_TEMPLATE_V2 = `const handleError = Sentry.wrapHandleErrorWithSentry((error, { request }) => {\n // Custom handleError implementation\n});\n`;\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/remix/templates.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG;;;;;CAKtC,CAAC;AAEW,QAAA,qBAAqB,GAAG;;;CAGpC,CAAC","sourcesContent":["export const ERROR_BOUNDARY_TEMPLATE = `const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};\n`;\n\nexport const HANDLE_ERROR_TEMPLATE = `const handleError = Sentry.wrapHandleErrorWithSentry((error, { request }) => {\n // Custom handleError implementation\n});\n`;\n"]}
@@ -1 +1 @@
1
- export declare const WIZARD_VERSION = "5.4.0";
1
+ export declare const WIZARD_VERSION = "6.0.0";
@@ -3,5 +3,5 @@
3
3
  // This is file is updated at release time.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.WIZARD_VERSION = void 0;
6
- exports.WIZARD_VERSION = '5.4.0';
6
+ exports.WIZARD_VERSION = '6.0.0';
7
7
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA,oCAAoC;AACpC,2CAA2C;;;AAE9B,QAAA,cAAc,GAAG,OAAO,CAAC","sourcesContent":["// DO NOT modify this file manually!\n// This is file is updated at release time.\n\nexport const WIZARD_VERSION = '5.4.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA,oCAAoC;AACpC,2CAA2C;;;AAE9B,QAAA,cAAc,GAAG,OAAO,CAAC","sourcesContent":["// DO NOT modify this file manually!\n// This is file is updated at release time.\n\nexport const WIZARD_VERSION = '6.0.0';\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // @ts-expect-error - magicast is ESM and TS complains about that. It works though
4
+ const magicast_1 = require("magicast");
5
+ const vitest_1 = require("vitest");
6
+ const root_1 = require("../../src/remix/codemods/root");
7
+ (0, vitest_1.describe)('wrapAppWithSentry', () => {
8
+ (0, vitest_1.it)('should wrap the app with Sentry', () => {
9
+ // Empty root.tsx file for testing
10
+ const originalRootAst = (0, magicast_1.parseModule)(`
11
+ import { Outlet } from '@remix-run/react';
12
+
13
+ export default function App() {
14
+ return <Outlet />;
15
+ }
16
+ `);
17
+ (0, root_1.wrapAppWithSentry)(originalRootAst, 'root.tsx');
18
+ const result = originalRootAst.generate().code;
19
+ (0, vitest_1.expect)(result).toMatchInlineSnapshot(`
20
+ "import {withSentry} from '@sentry/remix';
21
+ import { Outlet } from '@remix-run/react';
22
+
23
+ function App() {
24
+ return <Outlet />;
25
+ }
26
+
27
+ export default withSentry(App);"
28
+ `);
29
+ });
30
+ });
31
+ //# sourceMappingURL=root.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.test.js","sourceRoot":"","sources":["../../../test/remix/root.test.ts"],"names":[],"mappings":";;AAAA,kFAAkF;AAClF,uCAAuC;AACvC,mCAA8C;AAC9C,wDAAkE;AAElE,IAAA,iBAAQ,EAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAA,WAAE,EAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,kCAAkC;QAClC,MAAM,eAAe,GAAG,IAAA,sBAAW,EAAC;;;;;;KAMnC,CAAC,CAAC;QAEH,IAAA,wBAAiB,EAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QAE/C,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;QAE/C,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;KASpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { parseModule } from 'magicast';\nimport { describe, expect, it } from 'vitest';\nimport { wrapAppWithSentry } from '../../src/remix/codemods/root';\n\ndescribe('wrapAppWithSentry', () => {\n it('should wrap the app with Sentry', () => {\n // Empty root.tsx file for testing\n const originalRootAst = parseModule(`\n import { Outlet } from '@remix-run/react';\n\n export default function App() {\n return <Outlet />;\n }\n `);\n\n wrapAppWithSentry(originalRootAst, 'root.tsx');\n\n const result = originalRootAst.generate().code;\n\n expect(result).toMatchInlineSnapshot(`\n \"import {withSentry} from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n function App() {\n return <Outlet />;\n }\n\n export default withSentry(App);\"\n `);\n });\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/wizard",
3
- "version": "5.4.0",
3
+ "version": "6.0.0",
4
4
  "homepage": "https://github.com/getsentry/sentry-wizard",
5
5
  "repository": "https://github.com/getsentry/sentry-wizard",
6
6
  "description": "Sentry wizard helping you to configure your project",
@@ -1,70 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
3
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
4
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
- var __importDefault = (this && this.__importDefault) || function (mod) {
29
- return (mod && mod.__esModule) ? mod : { "default": mod };
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.wrapAppWithSentry = void 0;
33
- const recast = __importStar(require("recast"));
34
- // @ts-expect-error - clack is ESM and TS complains about that. It works though
35
- const prompts_1 = __importDefault(require("@clack/prompts"));
36
- const chalk_1 = __importDefault(require("chalk"));
37
- // @ts-expect-error - magicast is ESM and TS complains about that. It works though
38
- const magicast_1 = require("magicast");
39
- function wrapAppWithSentry(rootRouteAst, rootFileName) {
40
- rootRouteAst.imports.$add({
41
- from: '@sentry/remix',
42
- imported: 'withSentry',
43
- local: 'withSentry',
44
- });
45
- recast.visit(rootRouteAst.$ast, {
46
- visitExportDefaultDeclaration(path) {
47
- if (path.value.declaration.type === 'FunctionDeclaration') {
48
- // Move the function declaration just before the default export
49
- path.insertBefore(path.value.declaration);
50
- // Get the name of the function to be wrapped
51
- const functionName = path.value.declaration.id.name;
52
- // Create the wrapped function call
53
- const functionCall = recast.types.builders.callExpression(recast.types.builders.identifier('withSentry'), [recast.types.builders.identifier(functionName)]);
54
- // Replace the default export with the wrapped function call
55
- path.value.declaration = functionCall;
56
- }
57
- else if (path.value.declaration.type === 'Identifier') {
58
- const rootRouteExport = rootRouteAst.exports.default;
59
- const expressionToWrap = (0, magicast_1.generateCode)(rootRouteExport.$ast).code;
60
- rootRouteAst.exports.default = magicast_1.builders.raw(`withSentry(${expressionToWrap})`);
61
- }
62
- else {
63
- prompts_1.default.log.warn(chalk_1.default.yellow(`Couldn't instrument ${chalk_1.default.bold(rootFileName)} automatically. Wrap your default export with: ${chalk_1.default.dim('withSentry()')}\n`));
64
- }
65
- this.traverse(path);
66
- },
67
- });
68
- }
69
- exports.wrapAppWithSentry = wrapAppWithSentry;
70
- //# sourceMappingURL=root-common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"root-common.js","sourceRoot":"","sources":["../../../../src/remix/codemods/root-common.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+DAA+D;AAC/D,0DAA0D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1D,+CAAiC;AACjC,+EAA+E;AAC/E,6DAA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AC;aACH;iBAAM;gBACL,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,eAAK,CAAC,MAAM,CACV,uBAAuB,eAAK,CAAC,IAAI,CAC/B,YAAY,CACb,kDAAkD,eAAK,CAAC,GAAG,CAC1D,cAAc,CACf,IAAI,CACN,CACF,CAAC;aACH;YAED,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAlDD,8CAkDC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\n\nimport * as recast from 'recast';\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 { builders, ProxifiedModule, generateCode } from 'magicast';\n\nexport function wrapAppWithSentry(\n rootRouteAst: ProxifiedModule,\n rootFileName: string,\n) {\n rootRouteAst.imports.$add({\n from: '@sentry/remix',\n imported: 'withSentry',\n local: 'withSentry',\n });\n\n recast.visit(rootRouteAst.$ast, {\n visitExportDefaultDeclaration(path) {\n if (path.value.declaration.type === 'FunctionDeclaration') {\n // Move the function declaration just before the default export\n path.insertBefore(path.value.declaration);\n\n // Get the name of the function to be wrapped\n const functionName: string = path.value.declaration.id.name as string;\n\n // Create the wrapped function call\n const functionCall = recast.types.builders.callExpression(\n recast.types.builders.identifier('withSentry'),\n [recast.types.builders.identifier(functionName)],\n );\n\n // Replace the default export with the wrapped function call\n path.value.declaration = functionCall;\n } else if (path.value.declaration.type === 'Identifier') {\n const rootRouteExport = rootRouteAst.exports.default;\n\n const expressionToWrap = generateCode(rootRouteExport.$ast).code;\n\n rootRouteAst.exports.default = builders.raw(\n `withSentry(${expressionToWrap})`,\n );\n } else {\n clack.log.warn(\n chalk.yellow(\n `Couldn't instrument ${chalk.bold(\n rootFileName,\n )} automatically. Wrap your default export with: ${chalk.dim(\n 'withSentry()',\n )}\\n`,\n ),\n );\n }\n\n this.traverse(path);\n },\n });\n}\n"]}
@@ -1 +0,0 @@
1
- export declare function instrumentRootRouteV1(rootFileName: string): Promise<void>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- var __importDefault = (this && this.__importDefault) || function (mod) {
27
- return (mod && mod.__esModule) ? mod : { "default": mod };
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.instrumentRootRouteV1 = void 0;
31
- const path = __importStar(require("path"));
32
- // @ts-expect-error - clack is ESM and TS complains about that. It works though
33
- const prompts_1 = __importDefault(require("@clack/prompts"));
34
- const chalk_1 = __importDefault(require("chalk"));
35
- // @ts-expect-error - magicast is ESM and TS complains about that. It works though
36
- const magicast_1 = require("magicast");
37
- const root_common_1 = require("./root-common");
38
- async function instrumentRootRouteV1(rootFileName) {
39
- try {
40
- const rootRouteAst = await (0, magicast_1.loadFile)(path.join(process.cwd(), 'app', rootFileName));
41
- (0, root_common_1.wrapAppWithSentry)(rootRouteAst, rootFileName);
42
- await (0, magicast_1.writeFile)(rootRouteAst.$ast, path.join(process.cwd(), 'app', rootFileName));
43
- }
44
- catch (e) {
45
- // eslint-disable-next-line no-console
46
- console.error(e);
47
- prompts_1.default.log.warn(chalk_1.default.yellow(`Something went wrong writing to ${chalk_1.default.bold(rootFileName)}`));
48
- prompts_1.default.log.info(`Please put the following code snippet into ${chalk_1.default.bold(rootFileName)}: ${chalk_1.default.dim('You probably have to clean it up a bit.')}\n`);
49
- }
50
- }
51
- exports.instrumentRootRouteV1 = instrumentRootRouteV1;
52
- //# sourceMappingURL=root-v1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"root-v1.js","sourceRoot":"","sources":["../../../../src/remix/codemods/root-v1.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5D,2CAA6B;AAE7B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,kFAAkF;AAClF,uCAA+C;AAC/C,+CAAkD;AAE3C,KAAK,UAAU,qBAAqB,CACzC,YAAoB;IAEpB,IAAI;QACF,MAAM,YAAY,GAAG,MAAM,IAAA,mBAAQ,EACjC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,CAC9C,CAAC;QAEF,IAAA,+BAAiB,EAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAE9C,MAAM,IAAA,oBAAS,EACb,YAAY,CAAC,IAAI,EACjB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,CAC9C,CAAC;KACH;IAAC,OAAO,CAAU,EAAE;QACnB,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,eAAK,CAAC,MAAM,CACV,mCAAmC,eAAK,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAC9D,CACF,CAAC;QACF,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,8CAA8C,eAAK,CAAC,IAAI,CACtD,YAAY,CACb,KAAK,eAAK,CAAC,GAAG,CAAC,yCAAyC,CAAC,IAAI,CAC/D,CAAC;KACH;AACH,CAAC;AA5BD,sDA4BC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport * as path from 'path';\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 { loadFile, writeFile } from 'magicast';\nimport { wrapAppWithSentry } from './root-common';\n\nexport async function instrumentRootRouteV1(\n rootFileName: string,\n): Promise<void> {\n try {\n const rootRouteAst = await loadFile(\n path.join(process.cwd(), 'app', rootFileName),\n );\n\n wrapAppWithSentry(rootRouteAst, rootFileName);\n\n await writeFile(\n rootRouteAst.$ast,\n path.join(process.cwd(), 'app', rootFileName),\n );\n } catch (e: unknown) {\n // eslint-disable-next-line no-console\n console.error(e);\n clack.log.warn(\n chalk.yellow(\n `Something went wrong writing to ${chalk.bold(rootFileName)}`,\n ),\n );\n clack.log.info(\n `Please put the following code snippet into ${chalk.bold(\n rootFileName,\n )}: ${chalk.dim('You probably have to clean it up a bit.')}\\n`,\n );\n }\n}\n"]}
@@ -1 +0,0 @@
1
- export declare function instrumentRootRouteV2(rootFileName: string): Promise<void>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"root-v2.js","sourceRoot":"","sources":["../../../../src/remix/codemods/root-v2.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,0DAA0D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1D,+CAAiC;AACjC,2CAA6B;AAI7B,kFAAkF;AAClF,uCAA+C;AAE/C,4CA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C,IAAI,EACjB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,CAC9C,CAAC;AACJ,CAAC;AAvID,sDAuIC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\n\nimport * as recast from 'recast';\nimport * as path from 'path';\n\nimport type { ExportNamedDeclaration, Program } from '@babel/types';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { loadFile, writeFile } from 'magicast';\n\nimport { ERROR_BOUNDARY_TEMPLATE_V2 } from '../templates';\nimport { hasSentryContent } from '../utils';\nimport { wrapAppWithSentry } from './root-common';\n\nexport async function instrumentRootRouteV2(\n rootFileName: string,\n): Promise<void> {\n const rootRouteAst = await loadFile(\n path.join(process.cwd(), 'app', rootFileName),\n );\n\n const exportsAst = rootRouteAst.exports.$ast as Program;\n\n const namedExports = exportsAst.body.filter(\n (node) => node.type === 'ExportNamedDeclaration',\n ) as ExportNamedDeclaration[];\n\n let foundErrorBoundary = false;\n\n namedExports.forEach((namedExport) => {\n const declaration = namedExport.declaration;\n\n if (!declaration) {\n return;\n }\n\n if (declaration.type === 'FunctionDeclaration') {\n if (declaration.id?.name === 'ErrorBoundary') {\n foundErrorBoundary = true;\n }\n } else if (declaration.type === 'VariableDeclaration') {\n const declarations = declaration.declarations;\n\n declarations.forEach((declaration) => {\n // @ts-expect-error - id should always have a name in this case\n if (declaration.id?.name === 'ErrorBoundary') {\n foundErrorBoundary = true;\n }\n });\n }\n });\n\n if (!foundErrorBoundary) {\n rootRouteAst.imports.$add({\n from: '@sentry/remix',\n imported: 'captureRemixErrorBoundaryError',\n local: 'captureRemixErrorBoundaryError',\n });\n\n rootRouteAst.imports.$add({\n from: '@remix-run/react',\n imported: 'useRouteError',\n local: 'useRouteError',\n });\n\n recast.visit(rootRouteAst.$ast, {\n visitExportDefaultDeclaration(path) {\n const implementation = recast.parse(ERROR_BOUNDARY_TEMPLATE_V2).program\n .body[0];\n\n path.insertBefore(\n recast.types.builders.exportDeclaration(false, implementation),\n );\n\n this.traverse(path);\n },\n });\n // If there is already a ErrorBoundary export, and it doesn't have Sentry content\n } else if (!hasSentryContent(rootFileName, rootRouteAst.$code)) {\n rootRouteAst.imports.$add({\n from: '@sentry/remix',\n imported: 'captureRemixErrorBoundaryError',\n local: 'captureRemixErrorBoundaryError',\n });\n\n wrapAppWithSentry(rootRouteAst, rootFileName);\n\n recast.visit(rootRouteAst.$ast, {\n visitExportNamedDeclaration(path) {\n // Find ErrorBoundary export\n if (path.value.declaration?.id?.name === 'ErrorBoundary') {\n const errorBoundaryExport = path.value.declaration;\n\n let errorIdentifier;\n\n // check if useRouteError is called\n recast.visit(errorBoundaryExport, {\n visitVariableDeclaration(path) {\n const variableDeclaration = path.value.declarations[0];\n const initializer = variableDeclaration.init;\n\n if (\n initializer.type === 'CallExpression' &&\n initializer.callee.name === 'useRouteError'\n ) {\n errorIdentifier = variableDeclaration.id.name;\n }\n\n this.traverse(path);\n },\n });\n\n // We don't have an errorIdentifier, which means useRouteError is not called / imported\n // We need to add it and capture the error\n if (!errorIdentifier) {\n rootRouteAst.imports.$add({\n from: '@remix-run/react',\n imported: 'useRouteError',\n local: 'useRouteError',\n });\n\n const useRouteErrorCall = recast.parse(\n `const error = useRouteError();`,\n ).program.body[0];\n\n // Insert at the top of ErrorBoundary body\n errorBoundaryExport.body.body.splice(0, 0, useRouteErrorCall);\n }\n\n const captureErrorCall = recast.parse(\n `captureRemixErrorBoundaryError(error);`,\n ).program.body[0];\n\n // Insert just before the the fallback page is returned\n errorBoundaryExport.body.body.splice(\n errorBoundaryExport.body.body.length - 1,\n 0,\n captureErrorCall,\n );\n }\n this.traverse(path);\n },\n });\n }\n\n await writeFile(\n rootRouteAst.$ast,\n path.join(process.cwd(), 'app', rootFileName),\n );\n}\n"]}