@sentry/wizard 6.12.0 → 6.13.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 +15 -0
- package/dist/bin.js +16 -1
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/tests/angular-17.test.js +3 -4
- package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
- package/dist/e2e-tests/tests/angular-19.test.js +3 -4
- package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
- package/dist/e2e-tests/tests/flutter.test.js +60 -0
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
- package/dist/e2e-tests/tests/help-message.test.js +8 -3
- package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +12 -6
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +12 -6
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/pnpm-workspace.test.js +6 -3
- package/dist/e2e-tests/tests/pnpm-workspace.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-router-instrumentation-api.test.js +4 -4
- package/dist/e2e-tests/tests/react-router-instrumentation-api.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-router.test.js +3 -6
- package/dist/e2e-tests/tests/react-router.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +2 -4
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js +24 -8
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js +6 -3
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
- package/dist/lib/Constants.d.ts +1 -0
- package/dist/lib/Constants.js +5 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.js +2 -2
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/src/android/android-wizard.js +3 -0
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/angular/codemods/main.d.ts +1 -1
- package/dist/src/angular/codemods/main.js +0 -1
- package/dist/src/angular/codemods/main.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +2 -3
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/check-installed-cli.d.ts +1 -1
- package/dist/src/apple/check-installed-cli.js +13 -7
- package/dist/src/apple/check-installed-cli.js.map +1 -1
- package/dist/src/apple/configure-xcode-project.js +8 -1
- package/dist/src/apple/configure-xcode-project.js.map +1 -1
- package/dist/src/apple/lookup-xcode-project.d.ts +8 -5
- package/dist/src/apple/lookup-xcode-project.js +22 -17
- package/dist/src/apple/lookup-xcode-project.js.map +1 -1
- package/dist/src/apple/options.d.ts +5 -0
- package/dist/src/apple/options.js.map +1 -1
- package/dist/src/apple/sentry-swift-package.d.ts +4 -0
- package/dist/src/apple/sentry-swift-package.js +17 -0
- package/dist/src/apple/sentry-swift-package.js.map +1 -0
- package/dist/src/apple/snapshots/apple-snapshots-wizard.d.ts +2 -0
- package/dist/src/apple/snapshots/apple-snapshots-wizard.js +251 -0
- package/dist/src/apple/snapshots/apple-snapshots-wizard.js.map +1 -0
- package/dist/src/apple/snapshots/configure-snapshotpreviews-xcode-project.d.ts +13 -0
- package/dist/src/apple/snapshots/configure-snapshotpreviews-xcode-project.js +48 -0
- package/dist/src/apple/snapshots/configure-snapshotpreviews-xcode-project.js.map +1 -0
- package/dist/src/apple/snapshots/snapshot-test-file.d.ts +18 -0
- package/dist/src/apple/snapshots/snapshot-test-file.js +122 -0
- package/dist/src/apple/snapshots/snapshot-test-file.js.map +1 -0
- package/dist/src/apple/snapshots/snapshot-verification-scheme.d.ts +6 -0
- package/dist/src/apple/snapshots/snapshot-verification-scheme.js +147 -0
- package/dist/src/apple/snapshots/snapshot-verification-scheme.js.map +1 -0
- package/dist/src/apple/snapshots/snapshotpreviews-package.d.ts +4 -0
- package/dist/src/apple/snapshots/snapshotpreviews-package.js +8 -0
- package/dist/src/apple/snapshots/snapshotpreviews-package.js.map +1 -0
- package/dist/src/apple/snapshots/snapshots-cli-preflight.d.ts +23 -0
- package/dist/src/apple/snapshots/snapshots-cli-preflight.js +136 -0
- package/dist/src/apple/snapshots/snapshots-cli-preflight.js.map +1 -0
- package/dist/src/apple/xcode-manager.d.ts +59 -1
- package/dist/src/apple/xcode-manager.js +507 -106
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/flutter/flutter-wizard.js +3 -0
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.js +12 -6
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nuxt/templates.js +12 -6
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/react-router/codemods/client.entry.d.ts +1 -1
- package/dist/src/react-router/codemods/client.entry.js +93 -52
- package/dist/src/react-router/codemods/client.entry.js.map +1 -1
- package/dist/src/react-router/codemods/server-entry.js +8 -7
- package/dist/src/react-router/codemods/server-entry.js.map +1 -1
- package/dist/src/react-router/react-router-wizard.js +13 -19
- package/dist/src/react-router/react-router-wizard.js.map +1 -1
- package/dist/src/react-router/sdk-setup.d.ts +2 -2
- package/dist/src/react-router/sdk-setup.js +16 -15
- package/dist/src/react-router/sdk-setup.js.map +1 -1
- package/dist/src/react-router/templates.d.ts +1 -3
- package/dist/src/react-router/templates.js +24 -92
- package/dist/src/react-router/templates.js.map +1 -1
- package/dist/src/remix/sdk-setup.js +1 -2
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/run.d.ts +4 -1
- package/dist/src/run.js +13 -0
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/tools/remix.js +4 -4
- package/dist/src/sourcemaps/tools/remix.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup/setup.js +17 -4
- package/dist/src/sveltekit/sdk-setup/setup.js.map +1 -1
- package/dist/src/sveltekit/templates.js +12 -6
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/utils/clack/index.d.ts +2 -1
- package/dist/src/utils/clack/index.js +17 -6
- package/dist/src/utils/clack/index.js.map +1 -1
- package/dist/src/utils/files.d.ts +2 -0
- package/dist/src/utils/files.js +58 -0
- package/dist/src/utils/files.js.map +1 -0
- package/dist/src/utils/git.d.ts +3 -1
- package/dist/src/utils/git.js +2 -1
- package/dist/src/utils/git.js.map +1 -1
- package/dist/src/utils/line-endings.d.ts +1 -0
- package/dist/src/utils/line-endings.js +76 -0
- package/dist/src/utils/line-endings.js.map +1 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/angular/angular-wizard.test.js +0 -5
- package/dist/test/angular/angular-wizard.test.js.map +1 -1
- package/dist/test/apple/lookup-xcode-project.test.js +167 -0
- package/dist/test/apple/lookup-xcode-project.test.js.map +1 -0
- package/dist/test/apple/snapshots/apple-snapshots-wizard.test.d.ts +1 -0
- package/dist/test/apple/snapshots/apple-snapshots-wizard.test.js +487 -0
- package/dist/test/apple/snapshots/apple-snapshots-wizard.test.js.map +1 -0
- package/dist/test/apple/snapshots/hosted-test-target-fixture.d.ts +24 -0
- package/dist/test/apple/snapshots/hosted-test-target-fixture.js +191 -0
- package/dist/test/apple/snapshots/hosted-test-target-fixture.js.map +1 -0
- package/dist/test/apple/snapshots/snapshot-test-file.test.d.ts +1 -0
- package/dist/test/apple/snapshots/snapshot-test-file.test.js +110 -0
- package/dist/test/apple/snapshots/snapshot-test-file.test.js.map +1 -0
- package/dist/test/apple/snapshots/snapshot-verification-scheme.test.d.ts +1 -0
- package/dist/test/apple/snapshots/snapshot-verification-scheme.test.js +146 -0
- package/dist/test/apple/snapshots/snapshot-verification-scheme.test.js.map +1 -0
- package/dist/test/apple/snapshots/snapshotpreviews-xcode-smoke.test.d.ts +1 -0
- package/dist/test/apple/snapshots/snapshotpreviews-xcode-smoke.test.js +186 -0
- package/dist/test/apple/snapshots/snapshotpreviews-xcode-smoke.test.js.map +1 -0
- package/dist/test/apple/snapshots/snapshots-cli-preflight.test.d.ts +1 -0
- package/dist/test/apple/snapshots/snapshots-cli-preflight.test.js +192 -0
- package/dist/test/apple/snapshots/snapshots-cli-preflight.test.js.map +1 -0
- package/dist/test/apple/snapshots/source-file-insertion.test.d.ts +1 -0
- package/dist/test/apple/snapshots/source-file-insertion.test.js +77 -0
- package/dist/test/apple/snapshots/source-file-insertion.test.js.map +1 -0
- package/dist/test/apple/xcode-manager.test.js +452 -43
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/constants.test.d.ts +1 -0
- package/dist/test/constants.test.js +12 -0
- package/dist/test/constants.test.js.map +1 -0
- package/dist/test/nextjs/templates.test.js +66 -33
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/nuxt/templates.test.js +66 -36
- package/dist/test/nuxt/templates.test.js.map +1 -1
- package/dist/test/react-router/codemods/client-entry.test.js +15 -11
- package/dist/test/react-router/codemods/client-entry.test.js.map +1 -1
- package/dist/test/react-router/codemods/server-entry.test.js +21 -8
- package/dist/test/react-router/codemods/server-entry.test.js.map +1 -1
- package/dist/test/react-router/sdk-setup.test.js +46 -10
- package/dist/test/react-router/sdk-setup.test.js.map +1 -1
- package/dist/test/react-router/templates.test.js +26 -64
- package/dist/test/react-router/templates.test.js.map +1 -1
- package/dist/test/remix/build-script.test.d.ts +1 -0
- package/dist/test/remix/build-script.test.js +124 -0
- package/dist/test/remix/build-script.test.js.map +1 -0
- package/dist/test/remix/client-entry.test.js +4 -10
- package/dist/test/remix/client-entry.test.js.map +1 -1
- package/dist/test/run.test.d.ts +1 -0
- package/dist/test/run.test.js +137 -0
- package/dist/test/run.test.js.map +1 -0
- package/dist/test/sveltekit/templates.test.js +78 -27
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/dist/test/utils/clack/index.test.js +101 -0
- package/dist/test/utils/clack/index.test.js.map +1 -1
- package/dist/test/utils/git.test.js +10 -0
- package/dist/test/utils/git.test.js.map +1 -1
- package/dist/test/utils/line-endings.test.d.ts +1 -0
- package/dist/test/utils/line-endings.test.js +103 -0
- package/dist/test/utils/line-endings.test.js.map +1 -0
- package/package.json +2 -2
- package/dist/src/react-router/codemods/root.d.ts +0 -1
- package/dist/src/react-router/codemods/root.js +0 -170
- package/dist/src/react-router/codemods/root.js.map +0 -1
- package/dist/test/react-router/codemods/root.test.js +0 -182
- package/dist/test/react-router/codemods/root.test.js.map +0 -1
- /package/dist/test/{react-router/codemods/root.test.d.ts → apple/lookup-xcode-project.test.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-entry.js","sourceRoot":"","sources":["../../../../src/react-router/codemods/server-entry.ts"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,uDAAuD;AACvD,sDAAsD;AACtD,+DAA+D;AAC/D,wDAAwD;AACxD,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK5D,+CAAiC;AAGjC,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,kFAAkF;AAClF,uCAA6D;AAC7D,6CAA0C;AAC1C,qDAI+B;AAC/B,mCAAwD;AAEjD,KAAK,UAAU,qBAAqB,CACzC,eAAuB,EACvB,qBAAqB,GAAG,KAAK;IAE7B,MAAM,cAAc,GAAG,MAAM,IAAA,mBAAQ,EAAC,eAAe,CAAC,CAAC;IAEvD,IAAI,CAAC,IAAA,4BAAgB,EAAC,cAAc,CAAC,IAAiB,CAAC,EAAE;QACvD,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC;YAC1B,IAAI,EAAE,sBAAsB;YAC5B,QAAQ,EAAE,GAAG;YACb,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;KACJ;IAED,qBAAqB,CAAC,cAAc,CAAC,CAAC;IACtC,uBAAuB,CAAC,cAAc,CAAC,CAAC;IAExC,IAAI,qBAAqB,EAAE;QAC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,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACzE,8DAA8D;SAC/D;aAAM,IACL,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe;YAC1C,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAChC,CAAC,IAAsB,EAAE,EAAE,CACzB,IAAA,iCAAqB,EAAC,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,CAChD,EACD;YACA,cAAc,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACjD;QAED,2CAA2C;QAC3C,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KACpC;AACH,CAAC;AAjLD,sDAiLC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* 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';\n\nimport * as recast from 'recast';\nimport type { namedTypes as t } from 'ast-types';\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, loadFile, writeFile } from 'magicast';\nimport { debug } from '../../utils/debug';\nimport {\n hasSentryContent,\n safeCalleeIdentifierMatch,\n safeGetIdentifierName,\n} from '../../utils/ast-utils';\nimport { getAfterImportsInsertionIndex } from './utils';\n\nexport async function instrumentServerEntry(\n serverEntryPath: string,\n useInstrumentationAPI = false,\n): Promise<void> {\n const serverEntryAst = await loadFile(serverEntryPath);\n\n if (!hasSentryContent(serverEntryAst.$ast as t.Program)) {\n serverEntryAst.imports.$add({\n from: '@sentry/react-router',\n imported: '*',\n local: 'Sentry',\n });\n }\n\n instrumentHandleError(serverEntryAst);\n instrumentHandleRequest(serverEntryAst);\n\n if (useInstrumentationAPI) {\n instrumentUnstableInstrumentations(serverEntryAst);\n }\n\n await writeFile(serverEntryAst.$ast, serverEntryPath);\n}\n\nfunction instrumentUnstableInstrumentations(\n originalEntryServerMod: ProxifiedModule<any>,\n): void {\n const originalEntryServerModAST = originalEntryServerMod.$ast as t.Program;\n\n const hasUnstableInstrumentations = originalEntryServerModAST.body.some(\n (node) => {\n if (\n node.type !== 'ExportNamedDeclaration' ||\n node.declaration?.type !== 'VariableDeclaration'\n ) {\n return false;\n }\n\n const declarations = node.declaration.declarations;\n if (!declarations || declarations.length === 0) {\n return false;\n }\n\n const firstDeclaration = declarations[0];\n if (!firstDeclaration || firstDeclaration.type !== 'VariableDeclarator') {\n return false;\n }\n\n const id = firstDeclaration.id;\n return (\n id &&\n id.type === 'Identifier' &&\n id.name === 'unstable_instrumentations'\n );\n },\n );\n\n if (hasUnstableInstrumentations) {\n debug(\n 'unstable_instrumentations export already exists, skipping adding it again',\n );\n return;\n }\n\n const instrumentationsExport = recast.parse(\n `export const unstable_instrumentations = [Sentry.createSentryServerInstrumentation()];`,\n ).program.body[0];\n\n originalEntryServerModAST.body.push(instrumentationsExport);\n}\n\nexport function instrumentHandleRequest(\n originalEntryServerMod: ProxifiedModule<any>,\n): void {\n const originalEntryServerModAST = originalEntryServerMod.$ast as t.Program;\n\n const defaultServerEntryExport = originalEntryServerModAST.body.find(\n (node) => {\n return node.type === 'ExportDefaultDeclaration';\n },\n );\n\n if (!defaultServerEntryExport) {\n clack.log.warn(\n `Could not find function ${chalk.cyan(\n 'handleRequest',\n )} in your server entry file. Creating one for you.`,\n );\n\n let foundServerRouterImport = false;\n let foundRenderToPipeableStreamImport = false;\n let foundCreateReadableStreamFromReadableImport = false;\n\n originalEntryServerMod.imports.$items.forEach((item) => {\n if (item.imported === 'ServerRouter' && item.from === 'react-router') {\n foundServerRouterImport = true;\n }\n if (\n item.imported === 'renderToPipeableStream' &&\n item.from === 'react-dom/server'\n ) {\n foundRenderToPipeableStreamImport = true;\n }\n if (\n item.imported === 'createReadableStreamFromReadable' &&\n item.from === '@react-router/node'\n ) {\n foundCreateReadableStreamFromReadableImport = true;\n }\n });\n\n if (!foundServerRouterImport) {\n originalEntryServerMod.imports.$add({\n from: 'react-router',\n imported: 'ServerRouter',\n local: 'ServerRouter',\n });\n }\n\n if (!foundRenderToPipeableStreamImport) {\n originalEntryServerMod.imports.$add({\n from: 'react-dom/server',\n imported: 'renderToPipeableStream',\n local: 'renderToPipeableStream',\n });\n }\n\n if (!foundCreateReadableStreamFromReadableImport) {\n originalEntryServerMod.imports.$add({\n from: '@react-router/node',\n imported: 'createReadableStreamFromReadable',\n local: 'createReadableStreamFromReadable',\n });\n }\n\n const implementation =\n recast.parse(`const handleRequest = Sentry.createSentryHandleRequest({\n ServerRouter,\n renderToPipeableStream,\n createReadableStreamFromReadable,\n})`).program.body[0];\n\n try {\n originalEntryServerModAST.body.splice(\n getAfterImportsInsertionIndex(originalEntryServerModAST),\n 0,\n implementation,\n );\n\n originalEntryServerModAST.body.push({\n type: 'ExportDefaultDeclaration',\n declaration: {\n type: 'Identifier',\n name: 'handleRequest',\n },\n });\n } catch (error) {\n debug('Failed to insert handleRequest implementation:', error);\n throw new Error(\n 'Could not automatically instrument handleRequest. Please add it manually.',\n );\n }\n } else if (\n defaultServerEntryExport &&\n // @ts-expect-error - StatementKind works here because the AST is proxified by magicast\n generateCode(defaultServerEntryExport).code.includes(\n 'wrapSentryHandleRequest',\n )\n ) {\n debug('wrapSentryHandleRequest is already used, skipping wrapping again');\n clack.log.info(\n 'Sentry handleRequest wrapper already detected, skipping instrumentation.',\n );\n } else {\n let defaultExportNode: recast.types.namedTypes.ExportDefaultDeclaration | null =\n null;\n const defaultExportIndex = originalEntryServerModAST.body.findIndex(\n (node) => {\n const found = node.type === 'ExportDefaultDeclaration';\n\n if (found) {\n defaultExportNode = node;\n }\n\n return found;\n },\n );\n\n if (defaultExportIndex !== -1 && defaultExportNode !== null) {\n recast.visit(defaultExportNode, {\n visitCallExpression(path) {\n if (\n safeCalleeIdentifierMatch(path.value.callee, 'pipe') &&\n path.value.arguments.length &&\n path.value.arguments[0].type === 'Identifier' &&\n safeGetIdentifierName(path.value.arguments[0]) === 'body'\n ) {\n const wrapped = recast.types.builders.callExpression(\n recast.types.builders.memberExpression(\n recast.types.builders.identifier('Sentry'),\n recast.types.builders.identifier('getMetaTagTransformer'),\n ),\n [path.value.arguments[0]],\n );\n\n path.value.arguments[0] = wrapped;\n }\n\n this.traverse(path);\n },\n });\n\n // Replace the existing default export with the unwrapped function declaration\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n const funcDeclaration = defaultExportNode.declaration;\n // Make non-async functions async so the return type matches wrapSentryHandleRequest\n if (\n funcDeclaration.type === 'FunctionDeclaration' &&\n !funcDeclaration.async\n ) {\n funcDeclaration.async = true;\n }\n originalEntryServerModAST.body.splice(\n defaultExportIndex,\n 1,\n funcDeclaration,\n );\n\n // Adding our wrapped export\n originalEntryServerModAST.body.push(\n recast.types.builders.exportDefaultDeclaration(\n recast.types.builders.callExpression(\n recast.types.builders.memberExpression(\n recast.types.builders.identifier('Sentry'),\n recast.types.builders.identifier('wrapSentryHandleRequest'),\n ),\n [recast.types.builders.identifier('handleRequest')],\n ),\n ),\n );\n }\n }\n}\n\nexport function instrumentHandleError(\n originalEntryServerMod: ProxifiedModule<any>,\n): void {\n const originalEntryServerModAST = originalEntryServerMod.$ast as t.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((node) => {\n if (\n node.type !== 'ExportNamedDeclaration' ||\n node.declaration?.type !== 'VariableDeclaration'\n ) {\n return false;\n }\n\n const declarations = node.declaration.declarations;\n if (!declarations || declarations.length === 0) {\n return false;\n }\n\n const firstDeclaration = declarations[0];\n if (!firstDeclaration || firstDeclaration.type !== 'VariableDeclarator') {\n return false;\n }\n\n const id = firstDeclaration.id;\n return id && id.type === 'Identifier' && id.name === 'handleError';\n });\n\n if (\n !handleErrorFunctionExport &&\n !handleErrorFunctionVariableDeclarationExport\n ) {\n clack.log.warn(\n `Could not find function ${chalk.cyan(\n 'handleError',\n )} in your server entry file. Creating one for you.`,\n );\n\n const implementation =\n recast.parse(`const handleError = Sentry.createSentryHandleError({\n logErrors: false\n})`).program.body[0];\n\n originalEntryServerModAST.body.splice(\n getAfterImportsInsertionIndex(originalEntryServerModAST),\n 0,\n recast.types.builders.exportNamedDeclaration(implementation),\n );\n } else if (\n (handleErrorFunctionExport &&\n // @ts-expect-error - StatementKind works here because the AST is proxified by magicast\n generateCode(handleErrorFunctionExport).code.includes(\n 'captureException',\n )) ||\n (handleErrorFunctionVariableDeclarationExport &&\n // @ts-expect-error - StatementKind works here because the AST is proxified by magicast\n generateCode(handleErrorFunctionVariableDeclarationExport).code.includes(\n 'captureException',\n ))\n ) {\n debug(\n 'Found captureException inside handleError, skipping adding it again',\n );\n } else if (\n (handleErrorFunctionExport &&\n // @ts-expect-error - StatementKind works here because the AST is proxified by magicast\n generateCode(handleErrorFunctionExport).code.includes(\n 'createSentryHandleError',\n )) ||\n (handleErrorFunctionVariableDeclarationExport &&\n // @ts-expect-error - StatementKind works here because the AST is proxified by magicast\n generateCode(handleErrorFunctionVariableDeclarationExport).code.includes(\n 'createSentryHandleError',\n ))\n ) {\n debug('createSentryHandleError is already used, skipping adding it again');\n } else if (handleErrorFunctionExport) {\n // Create the Sentry captureException call as an IfStatement\n const sentryCall = recast.parse(`if (!request.signal.aborted) {\n Sentry.captureException(error);\n}`).program.body[0];\n\n // Safely insert the Sentry call at the beginning of the handleError function body\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n const declaration = handleErrorFunctionExport.declaration;\n if (\n declaration &&\n declaration.body &&\n declaration.body.body &&\n Array.isArray(declaration.body.body)\n ) {\n declaration.body.body.unshift(sentryCall);\n } else {\n debug(\n 'Cannot safely access handleError function body, skipping instrumentation',\n );\n }\n } else if (handleErrorFunctionVariableDeclarationExport) {\n // Create the Sentry captureException call as an IfStatement\n const sentryCall = recast.parse(`if (!request.signal.aborted) {\n Sentry.captureException(error);\n}`).program.body[0];\n\n // Safe access to existing handle error implementation with proper null checks\n // We know this is ExportNamedDeclaration with VariableDeclaration from the earlier find\n const exportDeclaration =\n handleErrorFunctionVariableDeclarationExport as any;\n if (\n !exportDeclaration.declaration ||\n exportDeclaration.declaration.type !== 'VariableDeclaration' ||\n !exportDeclaration.declaration.declarations ||\n exportDeclaration.declaration.declarations.length === 0\n ) {\n debug(\n 'Cannot safely access handleError variable declaration, skipping instrumentation',\n );\n return;\n }\n\n const firstDeclaration = exportDeclaration.declaration.declarations[0];\n if (\n !firstDeclaration ||\n firstDeclaration.type !== 'VariableDeclarator' ||\n !firstDeclaration.init\n ) {\n debug(\n 'Cannot safely access handleError variable declarator init, skipping instrumentation',\n );\n return;\n }\n\n const existingHandleErrorImplementation = firstDeclaration.init;\n const existingParams = existingHandleErrorImplementation.params;\n const existingBody = existingHandleErrorImplementation.body;\n\n const requestParam = {\n ...recast.types.builders.property(\n 'init',\n recast.types.builders.identifier('request'), // key\n recast.types.builders.identifier('request'), // value\n ),\n shorthand: true,\n };\n // Add error and {request} parameters to handleError function if not present\n // When none of the parameters exist\n if (existingParams.length === 0) {\n existingParams.push(\n recast.types.builders.identifier('error'),\n recast.types.builders.objectPattern([requestParam]),\n );\n // When only error parameter exists\n } else if (existingParams.length === 1) {\n existingParams.push(recast.types.builders.objectPattern([requestParam]));\n // When both parameters exist, but request is not destructured\n } else if (\n existingParams[1].type === 'ObjectPattern' &&\n !existingParams[1].properties.some(\n (prop: t.ObjectProperty) =>\n safeGetIdentifierName(prop.key) === 'request',\n )\n ) {\n existingParams[1].properties.push(requestParam);\n }\n\n // Add the Sentry call to the function body\n existingBody.body.push(sentryCall);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"server-entry.js","sourceRoot":"","sources":["../../../../src/react-router/codemods/server-entry.ts"],"names":[],"mappings":";AAAA,0DAA0D;AAC1D,uDAAuD;AACvD,sDAAsD;AACtD,+DAA+D;AAC/D,wDAAwD;AACxD,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK5D,+CAAiC;AAGjC,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,kFAAkF;AAClF,uCAA6D;AAC7D,6CAA0C;AAC1C,qDAI+B;AAC/B,mCAAwD;AAEjD,KAAK,UAAU,qBAAqB,CACzC,eAAuB,EACvB,qBAAqB,GAAG,KAAK;IAE7B,MAAM,cAAc,GAAG,MAAM,IAAA,mBAAQ,EAAC,eAAe,CAAC,CAAC;IAEvD,IAAI,CAAC,IAAA,4BAAgB,EAAC,cAAc,CAAC,IAAiB,CAAC,EAAE;QACvD,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC;YAC1B,IAAI,EAAE,sBAAsB;YAC5B,QAAQ,EAAE,GAAG;YACb,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;KACJ;IAED,qBAAqB,CAAC,cAAc,CAAC,CAAC;IACtC,uBAAuB,CAAC,cAAc,CAAC,CAAC;IAExC,IAAI,qBAAqB,EAAE;QACzB,0BAA0B,CAAC,cAAc,CAAC,CAAC;KAC5C;IAED,MAAM,IAAA,oBAAS,EAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACxD,CAAC;AAtBD,sDAsBC;AAED,SAAS,0BAA0B,CACjC,sBAA4C;IAE5C,MAAM,yBAAyB,GAAG,sBAAsB,CAAC,IAAiB,CAAC;IAE3E,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE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AAI,CAAC,GAAG,CAAC,KAAK,SAAS,CAChD,EACD;YACA,cAAc,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACjD;QAED,2CAA2C;QAC3C,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KACpC;AACH,CAAC;AAjLD,sDAiLC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* 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';\n\nimport * as recast from 'recast';\nimport type { namedTypes as t } from 'ast-types';\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, loadFile, writeFile } from 'magicast';\nimport { debug } from '../../utils/debug';\nimport {\n hasSentryContent,\n safeCalleeIdentifierMatch,\n safeGetIdentifierName,\n} from '../../utils/ast-utils';\nimport { getAfterImportsInsertionIndex } from './utils';\n\nexport async function instrumentServerEntry(\n serverEntryPath: string,\n useInstrumentationAPI = false,\n): Promise<void> {\n const serverEntryAst = await loadFile(serverEntryPath);\n\n if (!hasSentryContent(serverEntryAst.$ast as t.Program)) {\n serverEntryAst.imports.$add({\n from: '@sentry/react-router',\n imported: '*',\n local: 'Sentry',\n });\n }\n\n instrumentHandleError(serverEntryAst);\n instrumentHandleRequest(serverEntryAst);\n\n if (useInstrumentationAPI) {\n instrumentInstrumentations(serverEntryAst);\n }\n\n await writeFile(serverEntryAst.$ast, serverEntryPath);\n}\n\nfunction instrumentInstrumentations(\n originalEntryServerMod: ProxifiedModule<any>,\n): void {\n const originalEntryServerModAST = originalEntryServerMod.$ast as t.Program;\n\n const hasInstrumentations = originalEntryServerModAST.body.some((node) => {\n if (\n node.type !== 'ExportNamedDeclaration' ||\n node.declaration?.type !== 'VariableDeclaration'\n ) {\n return false;\n }\n\n const declarations = node.declaration.declarations;\n if (!declarations || declarations.length === 0) {\n return false;\n }\n\n const firstDeclaration = declarations[0];\n if (!firstDeclaration || firstDeclaration.type !== 'VariableDeclarator') {\n return false;\n }\n\n const id = firstDeclaration.id;\n return (\n id &&\n id.type === 'Identifier' &&\n (id.name === 'instrumentations' ||\n id.name === 'unstable_instrumentations')\n );\n });\n\n if (hasInstrumentations) {\n debug('instrumentations export already exists, skipping adding it again');\n return;\n }\n\n const instrumentationsExport = recast.parse(\n `export const instrumentations = [Sentry.createSentryServerInstrumentation()];`,\n ).program.body[0];\n\n originalEntryServerModAST.body.push(instrumentationsExport);\n}\n\nexport function instrumentHandleRequest(\n originalEntryServerMod: ProxifiedModule<any>,\n): void {\n const originalEntryServerModAST = originalEntryServerMod.$ast as t.Program;\n\n const defaultServerEntryExport = originalEntryServerModAST.body.find(\n (node) => {\n return node.type === 'ExportDefaultDeclaration';\n },\n );\n\n if (!defaultServerEntryExport) {\n clack.log.warn(\n `Could not find function ${chalk.cyan(\n 'handleRequest',\n )} in your server entry file. Creating one for you.`,\n );\n\n let foundServerRouterImport = false;\n let foundRenderToPipeableStreamImport = false;\n let foundCreateReadableStreamFromReadableImport = false;\n\n originalEntryServerMod.imports.$items.forEach((item) => {\n if (item.imported === 'ServerRouter' && item.from === 'react-router') {\n foundServerRouterImport = true;\n }\n if (\n item.imported === 'renderToPipeableStream' &&\n item.from === 'react-dom/server'\n ) {\n foundRenderToPipeableStreamImport = true;\n }\n if (\n item.imported === 'createReadableStreamFromReadable' &&\n item.from === '@react-router/node'\n ) {\n foundCreateReadableStreamFromReadableImport = true;\n }\n });\n\n if (!foundServerRouterImport) {\n originalEntryServerMod.imports.$add({\n from: 'react-router',\n imported: 'ServerRouter',\n local: 'ServerRouter',\n });\n }\n\n if (!foundRenderToPipeableStreamImport) {\n originalEntryServerMod.imports.$add({\n from: 'react-dom/server',\n imported: 'renderToPipeableStream',\n local: 'renderToPipeableStream',\n });\n }\n\n if (!foundCreateReadableStreamFromReadableImport) {\n originalEntryServerMod.imports.$add({\n from: '@react-router/node',\n imported: 'createReadableStreamFromReadable',\n local: 'createReadableStreamFromReadable',\n });\n }\n\n const implementation =\n recast.parse(`const handleRequest = Sentry.createSentryHandleRequest({\n ServerRouter,\n renderToPipeableStream,\n createReadableStreamFromReadable,\n})`).program.body[0];\n\n try {\n originalEntryServerModAST.body.splice(\n getAfterImportsInsertionIndex(originalEntryServerModAST),\n 0,\n implementation,\n );\n\n originalEntryServerModAST.body.push({\n type: 'ExportDefaultDeclaration',\n declaration: {\n type: 'Identifier',\n name: 'handleRequest',\n },\n });\n } catch (error) {\n debug('Failed to insert handleRequest implementation:', error);\n throw new Error(\n 'Could not automatically instrument handleRequest. Please add it manually.',\n );\n }\n } else if (\n defaultServerEntryExport &&\n // @ts-expect-error - StatementKind works here because the AST is proxified by magicast\n generateCode(defaultServerEntryExport).code.includes(\n 'wrapSentryHandleRequest',\n )\n ) {\n debug('wrapSentryHandleRequest is already used, skipping wrapping again');\n clack.log.info(\n 'Sentry handleRequest wrapper already detected, skipping instrumentation.',\n );\n } else {\n let defaultExportNode: recast.types.namedTypes.ExportDefaultDeclaration | null =\n null;\n const defaultExportIndex = originalEntryServerModAST.body.findIndex(\n (node) => {\n const found = node.type === 'ExportDefaultDeclaration';\n\n if (found) {\n defaultExportNode = node;\n }\n\n return found;\n },\n );\n\n if (defaultExportIndex !== -1 && defaultExportNode !== null) {\n recast.visit(defaultExportNode, {\n visitCallExpression(path) {\n if (\n safeCalleeIdentifierMatch(path.value.callee, 'pipe') &&\n path.value.arguments.length &&\n path.value.arguments[0].type === 'Identifier' &&\n safeGetIdentifierName(path.value.arguments[0]) === 'body'\n ) {\n const wrapped = recast.types.builders.callExpression(\n recast.types.builders.memberExpression(\n recast.types.builders.identifier('Sentry'),\n recast.types.builders.identifier('getMetaTagTransformer'),\n ),\n [path.value.arguments[0]],\n );\n\n path.value.arguments[0] = wrapped;\n }\n\n this.traverse(path);\n },\n });\n\n // Replace the existing default export with the unwrapped function declaration\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n const funcDeclaration = defaultExportNode.declaration;\n // Make non-async functions async so the return type matches wrapSentryHandleRequest\n if (\n funcDeclaration.type === 'FunctionDeclaration' &&\n !funcDeclaration.async\n ) {\n funcDeclaration.async = true;\n }\n originalEntryServerModAST.body.splice(\n defaultExportIndex,\n 1,\n funcDeclaration,\n );\n\n // Adding our wrapped export\n originalEntryServerModAST.body.push(\n recast.types.builders.exportDefaultDeclaration(\n recast.types.builders.callExpression(\n recast.types.builders.memberExpression(\n recast.types.builders.identifier('Sentry'),\n recast.types.builders.identifier('wrapSentryHandleRequest'),\n ),\n [recast.types.builders.identifier('handleRequest')],\n ),\n ),\n );\n }\n }\n}\n\nexport function instrumentHandleError(\n originalEntryServerMod: ProxifiedModule<any>,\n): void {\n const originalEntryServerModAST = originalEntryServerMod.$ast as t.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((node) => {\n if (\n node.type !== 'ExportNamedDeclaration' ||\n node.declaration?.type !== 'VariableDeclaration'\n ) {\n return false;\n }\n\n const declarations = node.declaration.declarations;\n if (!declarations || declarations.length === 0) {\n return false;\n }\n\n const firstDeclaration = declarations[0];\n if (!firstDeclaration || firstDeclaration.type !== 'VariableDeclarator') {\n return false;\n }\n\n const id = firstDeclaration.id;\n return id && id.type === 'Identifier' && id.name === 'handleError';\n });\n\n if (\n !handleErrorFunctionExport &&\n !handleErrorFunctionVariableDeclarationExport\n ) {\n clack.log.warn(\n `Could not find function ${chalk.cyan(\n 'handleError',\n )} in your server entry file. Creating one for you.`,\n );\n\n const implementation =\n recast.parse(`const handleError = Sentry.createSentryHandleError({\n logErrors: false\n})`).program.body[0];\n\n originalEntryServerModAST.body.splice(\n getAfterImportsInsertionIndex(originalEntryServerModAST),\n 0,\n recast.types.builders.exportNamedDeclaration(implementation),\n );\n } else if (\n (handleErrorFunctionExport &&\n // @ts-expect-error - StatementKind works here because the AST is proxified by magicast\n generateCode(handleErrorFunctionExport).code.includes(\n 'captureException',\n )) ||\n (handleErrorFunctionVariableDeclarationExport &&\n // @ts-expect-error - StatementKind works here because the AST is proxified by magicast\n generateCode(handleErrorFunctionVariableDeclarationExport).code.includes(\n 'captureException',\n ))\n ) {\n debug(\n 'Found captureException inside handleError, skipping adding it again',\n );\n } else if (\n (handleErrorFunctionExport &&\n // @ts-expect-error - StatementKind works here because the AST is proxified by magicast\n generateCode(handleErrorFunctionExport).code.includes(\n 'createSentryHandleError',\n )) ||\n (handleErrorFunctionVariableDeclarationExport &&\n // @ts-expect-error - StatementKind works here because the AST is proxified by magicast\n generateCode(handleErrorFunctionVariableDeclarationExport).code.includes(\n 'createSentryHandleError',\n ))\n ) {\n debug('createSentryHandleError is already used, skipping adding it again');\n } else if (handleErrorFunctionExport) {\n // Create the Sentry captureException call as an IfStatement\n const sentryCall = recast.parse(`if (!request.signal.aborted) {\n Sentry.captureException(error);\n}`).program.body[0];\n\n // Safely insert the Sentry call at the beginning of the handleError function body\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n const declaration = handleErrorFunctionExport.declaration;\n if (\n declaration &&\n declaration.body &&\n declaration.body.body &&\n Array.isArray(declaration.body.body)\n ) {\n declaration.body.body.unshift(sentryCall);\n } else {\n debug(\n 'Cannot safely access handleError function body, skipping instrumentation',\n );\n }\n } else if (handleErrorFunctionVariableDeclarationExport) {\n // Create the Sentry captureException call as an IfStatement\n const sentryCall = recast.parse(`if (!request.signal.aborted) {\n Sentry.captureException(error);\n}`).program.body[0];\n\n // Safe access to existing handle error implementation with proper null checks\n // We know this is ExportNamedDeclaration with VariableDeclaration from the earlier find\n const exportDeclaration =\n handleErrorFunctionVariableDeclarationExport as any;\n if (\n !exportDeclaration.declaration ||\n exportDeclaration.declaration.type !== 'VariableDeclaration' ||\n !exportDeclaration.declaration.declarations ||\n exportDeclaration.declaration.declarations.length === 0\n ) {\n debug(\n 'Cannot safely access handleError variable declaration, skipping instrumentation',\n );\n return;\n }\n\n const firstDeclaration = exportDeclaration.declaration.declarations[0];\n if (\n !firstDeclaration ||\n firstDeclaration.type !== 'VariableDeclarator' ||\n !firstDeclaration.init\n ) {\n debug(\n 'Cannot safely access handleError variable declarator init, skipping instrumentation',\n );\n return;\n }\n\n const existingHandleErrorImplementation = firstDeclaration.init;\n const existingParams = existingHandleErrorImplementation.params;\n const existingBody = existingHandleErrorImplementation.body;\n\n const requestParam = {\n ...recast.types.builders.property(\n 'init',\n recast.types.builders.identifier('request'), // key\n recast.types.builders.identifier('request'), // value\n ),\n shorthand: true,\n };\n // Add error and {request} parameters to handleError function if not present\n // When none of the parameters exist\n if (existingParams.length === 0) {\n existingParams.push(\n recast.types.builders.identifier('error'),\n recast.types.builders.objectPattern([requestParam]),\n );\n // When only error parameter exists\n } else if (existingParams.length === 1) {\n existingParams.push(recast.types.builders.objectPattern([requestParam]));\n // When both parameters exist, but request is not destructured\n } else if (\n existingParams[1].type === 'ObjectPattern' &&\n !existingParams[1].properties.some(\n (prop: t.ObjectProperty) =>\n safeGetIdentifierName(prop.key) === 'request',\n )\n ) {\n existingParams[1].properties.push(requestParam);\n }\n\n // Add the Sentry call to the function body\n existingBody.body.push(sentryCall);\n }\n}\n"]}
|
|
@@ -135,20 +135,30 @@ Please create your entry files manually using React Router v7 commands.`);
|
|
|
135
135
|
if (useInstrumentationAPI && !(0, sdk_setup_1.supportsInstrumentationAPI)(packageJson)) {
|
|
136
136
|
Sentry.setTag('instrumentation-api-version-guard', true);
|
|
137
137
|
const detectedVersion = (0, sdk_setup_1.getReactRouterVersion)(packageJson) ?? 'unknown';
|
|
138
|
-
prompts_1.default.log.warn(`The Instrumentation API requires React Router ${chalk_1.default.cyan('>=7.
|
|
138
|
+
prompts_1.default.log.warn(`The Instrumentation API requires React Router ${chalk_1.default.cyan('>=7.15.0')} (detected ${chalk_1.default.cyan(detectedVersion)}). Your version does not meet this requirement.\n` +
|
|
139
139
|
`Continuing without the Instrumentation API. Please upgrade React Router to use this feature:\n` +
|
|
140
140
|
chalk_1.default.dim('https://docs.sentry.io/platforms/javascript/guides/react-router/'));
|
|
141
141
|
useInstrumentationAPI = false;
|
|
142
142
|
}
|
|
143
143
|
Sentry.setTag('use-instrumentation-api', useInstrumentationAPI);
|
|
144
|
+
let useOnError = true;
|
|
145
|
+
if (!(0, sdk_setup_1.supportsOnError)(packageJson)) {
|
|
146
|
+
Sentry.setTag('on-error-version-guard', true);
|
|
147
|
+
const detectedVersion = (0, sdk_setup_1.getReactRouterVersion)(packageJson) ?? 'unknown';
|
|
148
|
+
prompts_1.default.log.warn(`The ${chalk_1.default.cyan('onError')} prop on HydratedRouter requires React Router ${chalk_1.default.cyan('>=7.11.0')} (detected ${chalk_1.default.cyan(detectedVersion)}).\n` +
|
|
149
|
+
`Skipping automatic error handler setup. Please upgrade React Router and follow the manual setup guide:\n` +
|
|
150
|
+
chalk_1.default.dim('https://docs.sentry.io/platforms/javascript/guides/react-router/'));
|
|
151
|
+
useOnError = false;
|
|
152
|
+
}
|
|
153
|
+
Sentry.setTag('use-on-error', useOnError);
|
|
144
154
|
await (0, telemetry_1.traceStep)('Initialize Sentry on client entry', async () => {
|
|
145
155
|
try {
|
|
146
|
-
await (0, sdk_setup_1.initializeSentryOnEntryClient)(selectedProject.keys[0].dsn.public, featureSelection.performance, featureSelection.replay, featureSelection.logs, typeScriptDetected, useInstrumentationAPI);
|
|
156
|
+
await (0, sdk_setup_1.initializeSentryOnEntryClient)(selectedProject.keys[0].dsn.public, featureSelection.performance, featureSelection.replay, featureSelection.logs, typeScriptDetected, useInstrumentationAPI, useOnError);
|
|
147
157
|
}
|
|
148
158
|
catch (e) {
|
|
149
159
|
prompts_1.default.log.warn(`Could not initialize Sentry on client entry automatically.`);
|
|
150
160
|
const clientEntryFilename = `entry.client.${typeScriptDetected ? 'tsx' : 'jsx'}`;
|
|
151
|
-
const manualClientContent = (0, templates_1.getManualClientEntryContent)(selectedProject.keys[0].dsn.public, featureSelection.performance, featureSelection.replay, featureSelection.logs, useInstrumentationAPI);
|
|
161
|
+
const manualClientContent = (0, templates_1.getManualClientEntryContent)(selectedProject.keys[0].dsn.public, featureSelection.performance, featureSelection.replay, featureSelection.logs, useInstrumentationAPI, useOnError);
|
|
152
162
|
await (0, clack_1.showCopyPasteInstructions)({
|
|
153
163
|
filename: clientEntryFilename,
|
|
154
164
|
codeSnippet: manualClientContent,
|
|
@@ -157,22 +167,6 @@ Please create your entry files manually using React Router v7 commands.`);
|
|
|
157
167
|
(0, debug_1.debug)(e);
|
|
158
168
|
}
|
|
159
169
|
});
|
|
160
|
-
await (0, telemetry_1.traceStep)('Instrument root route', async () => {
|
|
161
|
-
try {
|
|
162
|
-
await (0, sdk_setup_1.instrumentRootRoute)(typeScriptDetected);
|
|
163
|
-
}
|
|
164
|
-
catch (e) {
|
|
165
|
-
prompts_1.default.log.warn(`Could not instrument root route automatically.`);
|
|
166
|
-
const rootFilename = `app/root.${typeScriptDetected ? 'tsx' : 'jsx'}`;
|
|
167
|
-
const manualRootContent = (0, templates_1.getManualRootContent)(typeScriptDetected);
|
|
168
|
-
await (0, clack_1.showCopyPasteInstructions)({
|
|
169
|
-
filename: rootFilename,
|
|
170
|
-
codeSnippet: manualRootContent,
|
|
171
|
-
hint: 'This adds error boundary integration to capture exceptions in your React Router app',
|
|
172
|
-
});
|
|
173
|
-
(0, debug_1.debug)(e);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
170
|
await (0, telemetry_1.traceStep)('Instrument server entry', async () => {
|
|
177
171
|
try {
|
|
178
172
|
await (0, sdk_setup_1.instrumentSentryOnEntryServer)(typeScriptDetected, useInstrumentationAPI);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-router-wizard.js","sourceRoot":"","sources":["../../../src/react-router/react-router-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,qDAAuC;AAGvC,4CAAwD;AACxD,0CAawB;AACxB,0DAAwE;AACxE,wDAA4D;AAC5D,0CAAuC;AACvC,+CAAkD;AAClD,2CAYqB;AACrB,2CAOqB;AACrB,kGAA0F;AAEnF,KAAK,UAAU,oBAAoB,CACxC,OAAsB;IAEtB,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,aAAa;QAC1B,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,iCAAiC,CAAC,OAAO,CAAC,CACjD,CAAC;AACJ,CAAC;AAXD,oDAWC;AAED,KAAK,UAAU,iCAAiC,CAC9C,OAAsB;IAEtB,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,4BAA4B;QACxC,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAE9C,IAAI,CAAC,WAAW,EAAE;QAChB,iBAAK,CAAC,GAAG,CAAC,KAAK,CACb,6DAA6D,CAC9D,CAAC;QACF,OAAO;KACR;IAED,MAAM,kBAAkB,GAAG,IAAA,yBAAiB,GAAE,CAAC;IAE/C,IAAI,CAAC,IAAA,2BAAe,EAAC,WAAW,CAAC,EAAE;QACjC,iBAAK,CAAC,GAAG,CAAC,KAAK,CACb,6KAA6K,CAC9K,CAAC;QACF,OAAO;KACR;IAED,MAAM,IAAA,yCAAiC,EAAC;QACtC,gBAAgB,EAAE,OAAO,CA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EF,iBAAK,CAAC,KAAK,CACT,GAAG,eAAK,CAAC,KAAK,CAAC,qDAAqD,CAAC,GACnE,0BAA0B;QACxB,CAAC,CAAC,+CAA+C,eAAK,CAAC,IAAI,CACvD,wBAAwB,CACzB,uBAAuB;QAC1B,CAAC,CAAC,EACN,EAAE,CACH,CAAC;AACJ,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';\nimport * as Sentry from '@sentry/node';\n\nimport type { WizardOptions } from '../utils/types';\nimport { withTelemetry, traceStep } from '../telemetry';\nimport {\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n isUsingTypeScript,\n printWelcome,\n installPackage,\n addDotEnvSentryBuildPluginFile,\n showCopyPasteInstructions,\n makeCodeSnippet,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport { debug } from '../utils/debug';\nimport { createExamplePage } from './sdk-example';\nimport {\n isReactRouterV7,\n getReactRouterVersion,\n supportsInstrumentationAPI,\n runReactRouterReveal,\n initializeSentryOnEntryClient,\n instrumentRootRoute,\n createServerInstrumentationFile,\n updatePackageJsonScripts,\n instrumentSentryOnEntryServer,\n configureReactRouterConfig,\n configureReactRouterVitePlugin,\n} from './sdk-setup';\nimport {\n getManualClientEntryContent,\n getManualServerEntryContent,\n getManualRootContent,\n getManualServerInstrumentContent,\n getManualReactRouterConfigContent,\n getManualViteConfigContent,\n} from './templates';\nimport { abortIfSpotlightNotSupported } from '../utils/abort-if-sportlight-not-supported';\n\nexport async function runReactRouterWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'reactRouter',\n wizardOptions: options,\n },\n () => runReactRouterWizardWithTelemetry(options),\n );\n}\n\nasync function runReactRouterWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry React Router Wizard',\n promoCode: options.promoCode,\n });\n\n const packageJson = await getPackageDotJson();\n\n if (!packageJson) {\n clack.log.error(\n 'Could not find a package.json file in the current directory',\n );\n return;\n }\n\n const typeScriptDetected = isUsingTypeScript();\n\n if (!isReactRouterV7(packageJson)) {\n clack.log.error(\n 'This wizard requires React Router v7. Please upgrade your React Router version to v7.0.0 or higher.\\n\\nFor upgrade instructions, visit: https://react-router.dev/upgrade/v7',\n );\n return;\n }\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const sentryAlreadyInstalled = hasPackageInstalled(\n '@sentry/react-router',\n packageJson,\n );\n\n const projectData = await getOrAskForProjectData(\n options,\n 'javascript-react-router',\n );\n\n if (projectData.spotlight) {\n return abortIfSpotlightNotSupported('React Router');\n }\n\n const { selectedProject, authToken, selfHosted, sentryUrl } = projectData;\n\n await installPackage({\n packageName: '@sentry/react-router',\n alreadyInstalled: sentryAlreadyInstalled,\n });\n\n const featureSelection = 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 {\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'recommended',\n },\n {\n id: 'profiling',\n prompt: `Do you want to enable ${chalk.bold(\n 'Profiling',\n )} to track application performance in detail?`,\n enabledHint: 'recommended for production debugging',\n },\n ]);\n\n // Only ask about Instrumentation API when Tracing is enabled, since it depends on it\n let instrumentationAPISelected = false;\n if (featureSelection.performance) {\n const instrumentationAPISelection = await featureSelectionPrompt([\n {\n id: 'instrumentationAPI',\n prompt: `Do you want to use the ${chalk.bold(\n 'Instrumentation API',\n )} for automatic tracing of loaders, actions, and middleware?`,\n enabledHint: 'recommended',\n },\n ]);\n instrumentationAPISelected = instrumentationAPISelection.instrumentationAPI;\n }\n\n if (featureSelection.profiling) {\n const profilingAlreadyInstalled = hasPackageInstalled(\n '@sentry/profiling-node',\n packageJson,\n );\n\n await installPackage({\n packageName: '@sentry/profiling-node',\n alreadyInstalled: profilingAlreadyInstalled,\n });\n }\n\n const createExamplePageSelection = await askShouldCreateExamplePage();\n\n traceStep('Reveal missing entry files', () => {\n try {\n runReactRouterReveal();\n clack.log.success('Entry files are ready for instrumentation');\n } catch (e) {\n clack.log.warn(`Could not run 'npx react-router reveal'.\nPlease create your entry files manually using React Router v7 commands.`);\n debug(e);\n }\n });\n\n Sentry.setTag('instrumentation-api-selected', instrumentationAPISelected);\n\n let useInstrumentationAPI = instrumentationAPISelected;\n\n if (useInstrumentationAPI && !supportsInstrumentationAPI(packageJson)) {\n Sentry.setTag('instrumentation-api-version-guard', true);\n const detectedVersion = getReactRouterVersion(packageJson) ?? 'unknown';\n clack.log.warn(\n `The Instrumentation API requires React Router ${chalk.cyan(\n '>=7.9.5',\n )} (detected ${chalk.cyan(\n detectedVersion,\n )}). Your version does not meet this requirement.\\n` +\n `Continuing without the Instrumentation API. Please upgrade React Router to use this feature:\\n` +\n chalk.dim(\n 'https://docs.sentry.io/platforms/javascript/guides/react-router/',\n ),\n );\n useInstrumentationAPI = false;\n }\n\n Sentry.setTag('use-instrumentation-api', useInstrumentationAPI);\n\n await traceStep('Initialize Sentry on client entry', async () => {\n try {\n await initializeSentryOnEntryClient(\n selectedProject.keys[0].dsn.public,\n featureSelection.performance,\n featureSelection.replay,\n featureSelection.logs,\n typeScriptDetected,\n useInstrumentationAPI,\n );\n } catch (e) {\n clack.log.warn(\n `Could not initialize Sentry on client entry automatically.`,\n );\n\n const clientEntryFilename = `entry.client.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n\n const manualClientContent = getManualClientEntryContent(\n selectedProject.keys[0].dsn.public,\n featureSelection.performance,\n featureSelection.replay,\n featureSelection.logs,\n useInstrumentationAPI,\n );\n\n await showCopyPasteInstructions({\n filename: clientEntryFilename,\n codeSnippet: manualClientContent,\n hint: 'This enables error tracking and performance monitoring for your React Router app',\n });\n\n debug(e);\n }\n });\n\n await traceStep('Instrument root route', async () => {\n try {\n await instrumentRootRoute(typeScriptDetected);\n } catch (e) {\n clack.log.warn(`Could not instrument root route automatically.`);\n\n const rootFilename = `app/root.${typeScriptDetected ? 'tsx' : 'jsx'}`;\n const manualRootContent = getManualRootContent(typeScriptDetected);\n\n await showCopyPasteInstructions({\n filename: rootFilename,\n codeSnippet: manualRootContent,\n hint: 'This adds error boundary integration to capture exceptions in your React Router app',\n });\n\n debug(e);\n }\n });\n\n await traceStep('Instrument server entry', async () => {\n try {\n await instrumentSentryOnEntryServer(\n typeScriptDetected,\n useInstrumentationAPI,\n );\n } catch (e) {\n clack.log.warn(\n `Could not initialize Sentry on server entry automatically.`,\n );\n\n const serverEntryFilename = `entry.server.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n const manualServerContent = getManualServerEntryContent(\n useInstrumentationAPI,\n );\n\n await showCopyPasteInstructions({\n filename: serverEntryFilename,\n codeSnippet: manualServerContent,\n hint: 'This configures server-side request handling and error tracking',\n });\n\n debug(e);\n }\n });\n\n await traceStep('Create server instrumentation file', async () => {\n try {\n createServerInstrumentationFile(selectedProject.keys[0].dsn.public, {\n performance: featureSelection.performance,\n replay: featureSelection.replay,\n logs: featureSelection.logs,\n profiling: featureSelection.profiling,\n });\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file automatically.',\n );\n\n const manualServerInstrumentContent = getManualServerInstrumentContent(\n selectedProject.keys[0].dsn.public,\n featureSelection.performance,\n featureSelection.profiling,\n featureSelection.logs,\n );\n\n await showCopyPasteInstructions({\n filename: 'instrument.server.mjs',\n codeSnippet: manualServerInstrumentContent,\n hint: 'Create the file if it does not exist - this initializes Sentry before your application starts',\n });\n\n debug(e);\n }\n });\n\n await traceStep('Update package.json scripts', async () => {\n try {\n await updatePackageJsonScripts();\n } catch (e) {\n clack.log.warn('Could not update start script automatically.');\n\n await showCopyPasteInstructions({\n filename: 'package.json',\n codeSnippet: makeCodeSnippet(true, (unchanged, plus, minus) => {\n return unchanged(`{\n scripts: {\n ${minus('\"start\": \"react-router dev\"')}\n ${plus(\n '\"start\": \"NODE_ENV=production NODE_OPTIONS=\\'--import ./instrument.server.mjs\\' react-router-serve ./build/server/index.js\"',\n )}\n ${minus('\"dev\": \"react-router dev\"')}\n ${plus(\n '\"dev\": \"NODE_OPTIONS=\\'--import ./instrument.server.mjs\\' react-router dev\"',\n )}\n },\n // ... rest of your package.json\n }`);\n }),\n });\n\n debug(e);\n }\n });\n\n await traceStep('Create build plugin env file', async () => {\n try {\n await addDotEnvSentryBuildPluginFile(authToken);\n } catch (e) {\n clack.log.warn(\n 'Could not create .env.sentry-build-plugin file. Please create it manually.',\n );\n debug(e);\n }\n });\n\n // Validate auth token before configuring sourcemap uploads\n if (!authToken) {\n clack.log.warn(\n `${chalk.yellow(\n 'Warning:',\n )} No auth token found. Sourcemap uploads will not work without ${chalk.cyan(\n 'SENTRY_AUTH_TOKEN',\n )}.\\n` +\n `Please set ${chalk.cyan('SENTRY_AUTH_TOKEN')} in your ${chalk.cyan(\n '.env.sentry-build-plugin',\n )} file or environment variables.`,\n );\n }\n\n // Configure Vite plugin for sourcemap uploads\n await traceStep('Configure Vite plugin for sourcemap uploads', async () => {\n try {\n await configureReactRouterVitePlugin(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n } catch (e) {\n clack.log.warn(\n `Could not configure Vite plugin for sourcemap uploads automatically.`,\n );\n\n await showCopyPasteInstructions({\n filename: `vite.config.${typeScriptDetected ? 'ts' : 'js'}`,\n codeSnippet: getManualViteConfigContent(\n selectedProject.organization.slug,\n selectedProject.slug,\n ),\n hint: 'This enables automatic sourcemap uploads during build for better error tracking',\n });\n\n debug(e);\n }\n });\n\n // Configure React Router config for build hook\n await traceStep('Configure React Router build hook', async () => {\n try {\n await configureReactRouterConfig(typeScriptDetected);\n } catch (e) {\n clack.log.warn(\n `Could not configure React Router build hook automatically.`,\n );\n\n await showCopyPasteInstructions({\n filename: `react-router.config.${typeScriptDetected ? 'ts' : 'js'}`,\n codeSnippet: getManualReactRouterConfigContent(typeScriptDetected),\n hint: 'This enables automatic sourcemap uploads at the end of the build process',\n });\n\n debug(e);\n }\n });\n\n // Create example page if requested\n if (createExamplePageSelection) {\n await traceStep('Create example page', async () => {\n await createExamplePage({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n isTS: typeScriptDetected,\n projectDir: process.cwd(),\n });\n });\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n clack.outro(\n `${chalk.green('Successfully installed the Sentry React Router SDK!')}${\n createExamplePageSelection\n ? `\\n\\nYou can validate your setup by visiting ${chalk.cyan(\n '\"/sentry-example-page\"',\n )} in your application.`\n : ''\n }`,\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"react-router-wizard.js","sourceRoot":"","sources":["../../../src/react-router/react-router-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,qDAAuC;AAGvC,4CAAwD;AACxD,0CAawB;AACxB,0DAAwE;AACxE,wDAA4D;AAC5D,0CAAuC;AACvC,+CAAkD;AAClD,2CAYqB;AACrB,2CAMqB;AACrB,kGAA0F;AAEnF,KAAK,UAAU,oBAAoB,CACxC,OAAsB;IAEtB,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,W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,CAAC;gBAClE,IAAI,EAAE,0EAA0E;aACjF,CAAC,CAAC;YAEH,IAAA,aAAK,EAAC,CAAC,CAAC,CAAC;SACV;IACH,CAAC,CAAC,CAAC;IAEH,mCAAmC;IACnC,IAAI,0BAA0B,EAAE;QAC9B,MAAM,IAAA,qBAAS,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,IAAA,+BAAiB,EAAC;gBACtB,UAAU;gBACV,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;gBAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;gBAC7B,GAAG,EAAE,SAAS;gBACd,IAAI,EAAE,kBAAkB;gBACxB,UAAU,EAAE,OAAO,CAAC,GAAG,EAAE;aAC1B,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;KACJ;IAED,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAEjD,iFAAiF;IACjF,MAAM,IAAA,wCAA2B,EAC/B,eAAe,CAAC,YAAY,CAAC,IAAI,EACjC,eAAe,CAAC,IAAI,CACrB,CAAC;IAEF,iBAAK,CAAC,KAAK,CACT,GAAG,eAAK,CAAC,KAAK,CAAC,qDAAqD,CAAC,GACnE,0BAA0B;QACxB,CAAC,CAAC,+CAA+C,eAAK,CAAC,IAAI,CACvD,wBAAwB,CACzB,uBAAuB;QAC1B,CAAC,CAAC,EACN,EAAE,CACH,CAAC;AACJ,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';\nimport * as Sentry from '@sentry/node';\n\nimport type { WizardOptions } from '../utils/types';\nimport { withTelemetry, traceStep } from '../telemetry';\nimport {\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n isUsingTypeScript,\n printWelcome,\n installPackage,\n addDotEnvSentryBuildPluginFile,\n showCopyPasteInstructions,\n makeCodeSnippet,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport { debug } from '../utils/debug';\nimport { createExamplePage } from './sdk-example';\nimport {\n isReactRouterV7,\n getReactRouterVersion,\n supportsInstrumentationAPI,\n supportsOnError,\n runReactRouterReveal,\n initializeSentryOnEntryClient,\n createServerInstrumentationFile,\n updatePackageJsonScripts,\n instrumentSentryOnEntryServer,\n configureReactRouterConfig,\n configureReactRouterVitePlugin,\n} from './sdk-setup';\nimport {\n getManualClientEntryContent,\n getManualServerEntryContent,\n getManualServerInstrumentContent,\n getManualReactRouterConfigContent,\n getManualViteConfigContent,\n} from './templates';\nimport { abortIfSpotlightNotSupported } from '../utils/abort-if-sportlight-not-supported';\n\nexport async function runReactRouterWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'reactRouter',\n wizardOptions: options,\n },\n () => runReactRouterWizardWithTelemetry(options),\n );\n}\n\nasync function runReactRouterWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry React Router Wizard',\n promoCode: options.promoCode,\n });\n\n const packageJson = await getPackageDotJson();\n\n if (!packageJson) {\n clack.log.error(\n 'Could not find a package.json file in the current directory',\n );\n return;\n }\n\n const typeScriptDetected = isUsingTypeScript();\n\n if (!isReactRouterV7(packageJson)) {\n clack.log.error(\n 'This wizard requires React Router v7. Please upgrade your React Router version to v7.0.0 or higher.\\n\\nFor upgrade instructions, visit: https://react-router.dev/upgrade/v7',\n );\n return;\n }\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const sentryAlreadyInstalled = hasPackageInstalled(\n '@sentry/react-router',\n packageJson,\n );\n\n const projectData = await getOrAskForProjectData(\n options,\n 'javascript-react-router',\n );\n\n if (projectData.spotlight) {\n return abortIfSpotlightNotSupported('React Router');\n }\n\n const { selectedProject, authToken, selfHosted, sentryUrl } = projectData;\n\n await installPackage({\n packageName: '@sentry/react-router',\n alreadyInstalled: sentryAlreadyInstalled,\n });\n\n const featureSelection = 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 {\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'recommended',\n },\n {\n id: 'profiling',\n prompt: `Do you want to enable ${chalk.bold(\n 'Profiling',\n )} to track application performance in detail?`,\n enabledHint: 'recommended for production debugging',\n },\n ]);\n\n // Only ask about Instrumentation API when Tracing is enabled, since it depends on it\n let instrumentationAPISelected = false;\n if (featureSelection.performance) {\n const instrumentationAPISelection = await featureSelectionPrompt([\n {\n id: 'instrumentationAPI',\n prompt: `Do you want to use the ${chalk.bold(\n 'Instrumentation API',\n )} for automatic tracing of loaders, actions, and middleware?`,\n enabledHint: 'recommended',\n },\n ]);\n instrumentationAPISelected = instrumentationAPISelection.instrumentationAPI;\n }\n\n if (featureSelection.profiling) {\n const profilingAlreadyInstalled = hasPackageInstalled(\n '@sentry/profiling-node',\n packageJson,\n );\n\n await installPackage({\n packageName: '@sentry/profiling-node',\n alreadyInstalled: profilingAlreadyInstalled,\n });\n }\n\n const createExamplePageSelection = await askShouldCreateExamplePage();\n\n traceStep('Reveal missing entry files', () => {\n try {\n runReactRouterReveal();\n clack.log.success('Entry files are ready for instrumentation');\n } catch (e) {\n clack.log.warn(`Could not run 'npx react-router reveal'.\nPlease create your entry files manually using React Router v7 commands.`);\n debug(e);\n }\n });\n\n Sentry.setTag('instrumentation-api-selected', instrumentationAPISelected);\n\n let useInstrumentationAPI = instrumentationAPISelected;\n\n if (useInstrumentationAPI && !supportsInstrumentationAPI(packageJson)) {\n Sentry.setTag('instrumentation-api-version-guard', true);\n const detectedVersion = getReactRouterVersion(packageJson) ?? 'unknown';\n clack.log.warn(\n `The Instrumentation API requires React Router ${chalk.cyan(\n '>=7.15.0',\n )} (detected ${chalk.cyan(\n detectedVersion,\n )}). Your version does not meet this requirement.\\n` +\n `Continuing without the Instrumentation API. Please upgrade React Router to use this feature:\\n` +\n chalk.dim(\n 'https://docs.sentry.io/platforms/javascript/guides/react-router/',\n ),\n );\n useInstrumentationAPI = false;\n }\n\n Sentry.setTag('use-instrumentation-api', useInstrumentationAPI);\n\n let useOnError = true;\n\n if (!supportsOnError(packageJson)) {\n Sentry.setTag('on-error-version-guard', true);\n const detectedVersion = getReactRouterVersion(packageJson) ?? 'unknown';\n clack.log.warn(\n `The ${chalk.cyan(\n 'onError',\n )} prop on HydratedRouter requires React Router ${chalk.cyan(\n '>=7.11.0',\n )} (detected ${chalk.cyan(detectedVersion)}).\\n` +\n `Skipping automatic error handler setup. Please upgrade React Router and follow the manual setup guide:\\n` +\n chalk.dim(\n 'https://docs.sentry.io/platforms/javascript/guides/react-router/',\n ),\n );\n useOnError = false;\n }\n\n Sentry.setTag('use-on-error', useOnError);\n\n await traceStep('Initialize Sentry on client entry', async () => {\n try {\n await initializeSentryOnEntryClient(\n selectedProject.keys[0].dsn.public,\n featureSelection.performance,\n featureSelection.replay,\n featureSelection.logs,\n typeScriptDetected,\n useInstrumentationAPI,\n useOnError,\n );\n } catch (e) {\n clack.log.warn(\n `Could not initialize Sentry on client entry automatically.`,\n );\n\n const clientEntryFilename = `entry.client.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n\n const manualClientContent = getManualClientEntryContent(\n selectedProject.keys[0].dsn.public,\n featureSelection.performance,\n featureSelection.replay,\n featureSelection.logs,\n useInstrumentationAPI,\n useOnError,\n );\n\n await showCopyPasteInstructions({\n filename: clientEntryFilename,\n codeSnippet: manualClientContent,\n hint: 'This enables error tracking and performance monitoring for your React Router app',\n });\n\n debug(e);\n }\n });\n\n await traceStep('Instrument server entry', async () => {\n try {\n await instrumentSentryOnEntryServer(\n typeScriptDetected,\n useInstrumentationAPI,\n );\n } catch (e) {\n clack.log.warn(\n `Could not initialize Sentry on server entry automatically.`,\n );\n\n const serverEntryFilename = `entry.server.${\n typeScriptDetected ? 'tsx' : 'jsx'\n }`;\n const manualServerContent = getManualServerEntryContent(\n useInstrumentationAPI,\n );\n\n await showCopyPasteInstructions({\n filename: serverEntryFilename,\n codeSnippet: manualServerContent,\n hint: 'This configures server-side request handling and error tracking',\n });\n\n debug(e);\n }\n });\n\n await traceStep('Create server instrumentation file', async () => {\n try {\n createServerInstrumentationFile(selectedProject.keys[0].dsn.public, {\n performance: featureSelection.performance,\n replay: featureSelection.replay,\n logs: featureSelection.logs,\n profiling: featureSelection.profiling,\n });\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file automatically.',\n );\n\n const manualServerInstrumentContent = getManualServerInstrumentContent(\n selectedProject.keys[0].dsn.public,\n featureSelection.performance,\n featureSelection.profiling,\n featureSelection.logs,\n );\n\n await showCopyPasteInstructions({\n filename: 'instrument.server.mjs',\n codeSnippet: manualServerInstrumentContent,\n hint: 'Create the file if it does not exist - this initializes Sentry before your application starts',\n });\n\n debug(e);\n }\n });\n\n await traceStep('Update package.json scripts', async () => {\n try {\n await updatePackageJsonScripts();\n } catch (e) {\n clack.log.warn('Could not update start script automatically.');\n\n await showCopyPasteInstructions({\n filename: 'package.json',\n codeSnippet: makeCodeSnippet(true, (unchanged, plus, minus) => {\n return unchanged(`{\n scripts: {\n ${minus('\"start\": \"react-router dev\"')}\n ${plus(\n '\"start\": \"NODE_ENV=production NODE_OPTIONS=\\'--import ./instrument.server.mjs\\' react-router-serve ./build/server/index.js\"',\n )}\n ${minus('\"dev\": \"react-router dev\"')}\n ${plus(\n '\"dev\": \"NODE_OPTIONS=\\'--import ./instrument.server.mjs\\' react-router dev\"',\n )}\n },\n // ... rest of your package.json\n }`);\n }),\n });\n\n debug(e);\n }\n });\n\n await traceStep('Create build plugin env file', async () => {\n try {\n await addDotEnvSentryBuildPluginFile(authToken);\n } catch (e) {\n clack.log.warn(\n 'Could not create .env.sentry-build-plugin file. Please create it manually.',\n );\n debug(e);\n }\n });\n\n // Validate auth token before configuring sourcemap uploads\n if (!authToken) {\n clack.log.warn(\n `${chalk.yellow(\n 'Warning:',\n )} No auth token found. Sourcemap uploads will not work without ${chalk.cyan(\n 'SENTRY_AUTH_TOKEN',\n )}.\\n` +\n `Please set ${chalk.cyan('SENTRY_AUTH_TOKEN')} in your ${chalk.cyan(\n '.env.sentry-build-plugin',\n )} file or environment variables.`,\n );\n }\n\n // Configure Vite plugin for sourcemap uploads\n await traceStep('Configure Vite plugin for sourcemap uploads', async () => {\n try {\n await configureReactRouterVitePlugin(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n } catch (e) {\n clack.log.warn(\n `Could not configure Vite plugin for sourcemap uploads automatically.`,\n );\n\n await showCopyPasteInstructions({\n filename: `vite.config.${typeScriptDetected ? 'ts' : 'js'}`,\n codeSnippet: getManualViteConfigContent(\n selectedProject.organization.slug,\n selectedProject.slug,\n ),\n hint: 'This enables automatic sourcemap uploads during build for better error tracking',\n });\n\n debug(e);\n }\n });\n\n // Configure React Router config for build hook\n await traceStep('Configure React Router build hook', async () => {\n try {\n await configureReactRouterConfig(typeScriptDetected);\n } catch (e) {\n clack.log.warn(\n `Could not configure React Router build hook automatically.`,\n );\n\n await showCopyPasteInstructions({\n filename: `react-router.config.${typeScriptDetected ? 'ts' : 'js'}`,\n codeSnippet: getManualReactRouterConfigContent(typeScriptDetected),\n hint: 'This enables automatic sourcemap uploads at the end of the build process',\n });\n\n debug(e);\n }\n });\n\n // Create example page if requested\n if (createExamplePageSelection) {\n await traceStep('Create example page', async () => {\n await createExamplePage({\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n isTS: typeScriptDetected,\n projectDir: process.cwd(),\n });\n });\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n clack.outro(\n `${chalk.green('Successfully installed the Sentry React Router SDK!')}${\n createExamplePageSelection\n ? `\\n\\nYou can validate your setup by visiting ${chalk.cyan(\n '\"/sentry-example-page\"',\n )} in your application.`\n : ''\n }`,\n );\n}\n"]}
|
|
@@ -4,9 +4,9 @@ export declare function tryRevealAndGetManualInstructions(missingFilename: strin
|
|
|
4
4
|
export declare function runReactRouterReveal(): void;
|
|
5
5
|
export declare function isReactRouterV7(packageJson: PackageDotJson): boolean;
|
|
6
6
|
export declare function getReactRouterVersion(packageJson: PackageDotJson): string | undefined;
|
|
7
|
+
export declare function supportsOnError(packageJson: PackageDotJson): boolean;
|
|
7
8
|
export declare function supportsInstrumentationAPI(packageJson: PackageDotJson): boolean;
|
|
8
|
-
export declare function initializeSentryOnEntryClient(dsn: string, enableTracing: boolean, enableReplay: boolean, enableLogs: boolean, isTS: boolean, useInstrumentationAPI?: boolean): Promise<void>;
|
|
9
|
-
export declare function instrumentRootRoute(isTS: boolean): Promise<void>;
|
|
9
|
+
export declare function initializeSentryOnEntryClient(dsn: string, enableTracing: boolean, enableReplay: boolean, enableLogs: boolean, isTS: boolean, useInstrumentationAPI?: boolean, useOnError?: boolean): Promise<void>;
|
|
10
10
|
export declare function createServerInstrumentationFile(dsn: string, selectedFeatures: {
|
|
11
11
|
performance: boolean;
|
|
12
12
|
replay: boolean;
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.configureReactRouterConfig = exports.configureReactRouterVitePlugin = exports.instrumentSentryOnEntryServer = exports.updatePackageJsonScripts = exports.createServerInstrumentationFile = exports.
|
|
29
|
+
exports.configureReactRouterConfig = exports.configureReactRouterVitePlugin = exports.instrumentSentryOnEntryServer = exports.updatePackageJsonScripts = exports.createServerInstrumentationFile = exports.initializeSentryOnEntryClient = exports.supportsInstrumentationAPI = exports.supportsOnError = exports.getReactRouterVersion = exports.isReactRouterV7 = exports.runReactRouterReveal = exports.tryRevealAndGetManualInstructions = exports.getRouteFilePath = void 0;
|
|
30
30
|
const fs = __importStar(require("fs"));
|
|
31
31
|
const path = __importStar(require("path"));
|
|
32
32
|
const childProcess = __importStar(require("child_process"));
|
|
@@ -37,7 +37,6 @@ const semver_1 = require("semver");
|
|
|
37
37
|
const package_json_1 = require("../utils/package-json");
|
|
38
38
|
const debug_1 = require("../utils/debug");
|
|
39
39
|
const templates_1 = require("./templates");
|
|
40
|
-
const root_1 = require("./codemods/root");
|
|
41
40
|
const server_entry_1 = require("./codemods/server-entry");
|
|
42
41
|
const clack_1 = require("../utils/clack");
|
|
43
42
|
const client_entry_1 = require("./codemods/client.entry");
|
|
@@ -137,6 +136,18 @@ function getReactRouterVersion(packageJson) {
|
|
|
137
136
|
return coerced ? coerced.version : rangeVersion;
|
|
138
137
|
}
|
|
139
138
|
exports.getReactRouterVersion = getReactRouterVersion;
|
|
139
|
+
function supportsOnError(packageJson) {
|
|
140
|
+
const reactRouterVersion = (0, package_json_1.getPackageVersion)('@react-router/dev', packageJson);
|
|
141
|
+
if (!reactRouterVersion) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
const minVer = (0, semver_1.minVersion)(reactRouterVersion);
|
|
145
|
+
if (!minVer) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
return (0, semver_1.gte)(minVer, '7.11.0');
|
|
149
|
+
}
|
|
150
|
+
exports.supportsOnError = supportsOnError;
|
|
140
151
|
function supportsInstrumentationAPI(packageJson) {
|
|
141
152
|
const reactRouterVersion = (0, package_json_1.getPackageVersion)('@react-router/dev', packageJson);
|
|
142
153
|
if (!reactRouterVersion) {
|
|
@@ -146,27 +157,17 @@ function supportsInstrumentationAPI(packageJson) {
|
|
|
146
157
|
if (!minVer) {
|
|
147
158
|
return false;
|
|
148
159
|
}
|
|
149
|
-
return (0, semver_1.gte)(minVer, '7.
|
|
160
|
+
return (0, semver_1.gte)(minVer, '7.15.0');
|
|
150
161
|
}
|
|
151
162
|
exports.supportsInstrumentationAPI = supportsInstrumentationAPI;
|
|
152
|
-
async function initializeSentryOnEntryClient(dsn, enableTracing, enableReplay, enableLogs, isTS, useInstrumentationAPI = false) {
|
|
163
|
+
async function initializeSentryOnEntryClient(dsn, enableTracing, enableReplay, enableLogs, isTS, useInstrumentationAPI = false, useOnError = false) {
|
|
153
164
|
const clientEntryPath = getAppFilePath('entry.client', isTS);
|
|
154
165
|
const clientEntryFilename = path.basename(clientEntryPath);
|
|
155
166
|
await ensureEntryFileExists(clientEntryFilename, clientEntryPath);
|
|
156
|
-
await (0, client_entry_1.instrumentClientEntry)(clientEntryPath, dsn, enableTracing, enableReplay, enableLogs, useInstrumentationAPI);
|
|
167
|
+
await (0, client_entry_1.instrumentClientEntry)(clientEntryPath, dsn, enableTracing, enableReplay, enableLogs, useInstrumentationAPI, useOnError);
|
|
157
168
|
prompts_1.default.log.success(`Updated ${chalk_1.default.cyan(clientEntryFilename)} with Sentry initialization.`);
|
|
158
169
|
}
|
|
159
170
|
exports.initializeSentryOnEntryClient = initializeSentryOnEntryClient;
|
|
160
|
-
async function instrumentRootRoute(isTS) {
|
|
161
|
-
const rootPath = getAppFilePath('root', isTS);
|
|
162
|
-
const rootFilename = path.basename(rootPath);
|
|
163
|
-
if (!fs.existsSync(rootPath)) {
|
|
164
|
-
throw new Error(`${rootFilename} not found in app directory. Please ensure your React Router v7 app has a root.tsx/jsx file in the app folder.`);
|
|
165
|
-
}
|
|
166
|
-
await (0, root_1.instrumentRoot)(rootFilename);
|
|
167
|
-
prompts_1.default.log.success(`Updated ${chalk_1.default.cyan(rootFilename)} with ErrorBoundary.`);
|
|
168
|
-
}
|
|
169
|
-
exports.instrumentRootRoute = instrumentRootRoute;
|
|
170
171
|
function createServerInstrumentationFile(dsn, selectedFeatures) {
|
|
171
172
|
const instrumentationPath = path.join(process.cwd(), INSTRUMENTATION_FILE);
|
|
172
173
|
const content = (0, templates_1.getSentryInstrumentationServerContent)(dsn, selectedFeatures.performance, selectedFeatures.profiling, selectedFeatures.logs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/react-router/sdk-setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,4DAA8C;AAE9C,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,mCAAiD;AAGjD,wDAA0D;AAC1D,0CAAuC;AACvC,2CAAoE;AACpE,0CAAiD;AACjD,0DAAgE;AAChE,0CAAmD;AACnD,0DAAgE;AAChE,0CAAuD;AACvD,wEAA6E;AAE7E,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAC9D,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AACrD,MAAM,aAAa,GAAG,KAAK,CAAC;AAC5B,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC,SAAS,yBAAyB,CAChC,QAAgB,EAChB,YAAoB,EACpB,YAAoB;IAEpB,OAAO,CACL,qCAAqC,QAAQ,KAAK,YAAY,IAAI;QAClE,wDAAwD;QACxD,GAAG,YAAY,EAAE,CAClB,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CACrB,QAAgB,EAChB,IAAa,EACb,MAAM,GAAG,IAAI;IAEb,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CA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C,EAAE,CAAC,CAAC,CAAC;QAClD,MAAM,YAAY,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,yBAAyB,CACvB,QAAQ,EACR,YAAY,EACZ,iDAAiD,CAClD,CACF,CAAC;KACH;AACH,CAAC;AApCD,gEAoCC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\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, coerce } from 'semver';\n\nimport type { PackageDotJson } from '../utils/package-json';\nimport { getPackageVersion } from '../utils/package-json';\nimport { debug } from '../utils/debug';\nimport { getSentryInstrumentationServerContent } from './templates';\nimport { instrumentRoot } from './codemods/root';\nimport { instrumentServerEntry } from './codemods/server-entry';\nimport { getPackageDotJson } from '../utils/clack';\nimport { instrumentClientEntry } from './codemods/client.entry';\nimport { instrumentViteConfig } from './codemods/vite';\nimport { instrumentReactRouterConfig } from './codemods/react-router-config';\n\nconst REACT_ROUTER_REVEAL_COMMAND = 'npx react-router reveal';\nconst INSTRUMENTATION_FILE = 'instrument.server.mjs';\nconst APP_DIRECTORY = 'app';\nconst ROUTES_DIRECTORY = 'routes';\n\nfunction _formatConfigErrorMessage(\n filename: string,\n errorMessage: string,\n fallbackHint: string,\n): string {\n return (\n `Could not automatically configure ${filename}. ${errorMessage}\\n` +\n `This may happen if your config has an unusual format. ` +\n `${fallbackHint}`\n );\n}\n\nfunction getAppFilePath(\n filename: string,\n isTS: boolean,\n isPage = true,\n): string {\n const ext = isPage ? (isTS ? 'tsx' : 'jsx') : isTS ? 'ts' : 'js';\n return path.join(process.cwd(), APP_DIRECTORY, `${filename}.${ext}`);\n}\n\nexport function getRouteFilePath(filename: string, isTS: boolean): string {\n const ext = isTS ? 'tsx' : 'jsx';\n return path.join(\n process.cwd(),\n APP_DIRECTORY,\n ROUTES_DIRECTORY,\n `${filename}.${ext}`,\n );\n}\n\nexport async function tryRevealAndGetManualInstructions(\n missingFilename: string,\n filePath: string,\n): Promise<boolean> {\n const shouldTryReveal = await clack.confirm({\n message: `Would you like to try running ${chalk.cyan(\n REACT_ROUTER_REVEAL_COMMAND,\n )} to generate entry files?`,\n initialValue: true,\n });\n\n if (shouldTryReveal) {\n try {\n clack.log.info(`Running ${chalk.cyan(REACT_ROUTER_REVEAL_COMMAND)}...`);\n const output = childProcess.execSync(REACT_ROUTER_REVEAL_COMMAND, {\n encoding: 'utf8',\n stdio: 'pipe',\n });\n clack.log.info(output);\n\n if (fs.existsSync(filePath)) {\n clack.log.success(\n `Found ${chalk.cyan(missingFilename)} after running reveal.`,\n );\n return true;\n } else {\n clack.log.warn(\n `${chalk.cyan(\n missingFilename,\n )} still not found after running reveal.`,\n );\n }\n } catch (e) {\n debug('Failed to run React Router reveal command:', e);\n clack.log.warn(\n `Failed to run ${chalk.cyan(\n REACT_ROUTER_REVEAL_COMMAND,\n )}. This command generates entry files for React Router v7.`,\n );\n }\n }\n\n return false; // File still doesn't exist, manual intervention needed\n}\n\nasync function ensureEntryFileExists(\n filename: string,\n filePath: string,\n): Promise<void> {\n if (fs.existsSync(filePath)) {\n return; // File exists, nothing to do\n }\n\n clack.log.warn(`Could not find ${chalk.cyan(filename)}.`);\n\n const fileExists = await tryRevealAndGetManualInstructions(\n filename,\n filePath,\n );\n\n if (!fileExists) {\n throw new Error(\n `Failed to create or find ${filename}. Please create this file manually or ensure your React Router v7 project structure is correct.`,\n );\n }\n}\n\nexport function runReactRouterReveal(): void {\n if (\n !fs.existsSync(path.join(process.cwd(), 'app', 'entry.client.tsx')) &&\n !fs.existsSync(path.join(process.cwd(), 'app', 'entry.client.jsx'))\n ) {\n try {\n childProcess.execSync(REACT_ROUTER_REVEAL_COMMAND, {\n encoding: 'utf8',\n stdio: 'pipe',\n });\n } catch (e) {\n debug('Failed to run React Router reveal command:', e);\n throw e;\n }\n }\n}\n\nexport function isReactRouterV7(packageJson: PackageDotJson): boolean {\n const reactRouterVersion = getPackageVersion(\n '@react-router/dev',\n packageJson,\n );\n if (!reactRouterVersion) {\n return false;\n }\n\n const minVer = minVersion(reactRouterVersion);\n\n if (!minVer) {\n return false;\n }\n\n return gte(minVer, '7.0.0');\n}\n\nexport function getReactRouterVersion(\n packageJson: PackageDotJson,\n): string | undefined {\n const rangeVersion = getPackageVersion('@react-router/dev', packageJson);\n if (!rangeVersion) {\n return undefined;\n }\n\n const coerced = coerce(rangeVersion);\n return coerced ? coerced.version : rangeVersion;\n}\n\nexport function supportsInstrumentationAPI(\n packageJson: PackageDotJson,\n): boolean {\n const reactRouterVersion = getPackageVersion(\n '@react-router/dev',\n packageJson,\n );\n if (!reactRouterVersion) {\n return false;\n }\n\n const minVer = minVersion(reactRouterVersion);\n\n if (!minVer) {\n return false;\n }\n\n return gte(minVer, '7.9.5');\n}\n\nexport async function initializeSentryOnEntryClient(\n dsn: string,\n enableTracing: boolean,\n enableReplay: boolean,\n enableLogs: boolean,\n isTS: boolean,\n useInstrumentationAPI = false,\n): Promise<void> {\n const clientEntryPath = getAppFilePath('entry.client', isTS);\n const clientEntryFilename = path.basename(clientEntryPath);\n\n await ensureEntryFileExists(clientEntryFilename, clientEntryPath);\n\n await instrumentClientEntry(\n clientEntryPath,\n dsn,\n enableTracing,\n enableReplay,\n enableLogs,\n useInstrumentationAPI,\n );\n\n clack.log.success(\n `Updated ${chalk.cyan(clientEntryFilename)} with Sentry initialization.`,\n );\n}\n\nexport async function instrumentRootRoute(isTS: boolean): Promise<void> {\n const rootPath = getAppFilePath('root', isTS);\n const rootFilename = path.basename(rootPath);\n\n if (!fs.existsSync(rootPath)) {\n throw new Error(\n `${rootFilename} not found in app directory. Please ensure your React Router v7 app has a root.tsx/jsx file in the app folder.`,\n );\n }\n\n await instrumentRoot(rootFilename);\n clack.log.success(`Updated ${chalk.cyan(rootFilename)} with ErrorBoundary.`);\n}\n\nexport function createServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n profiling: boolean;\n },\n): string {\n const instrumentationPath = path.join(process.cwd(), INSTRUMENTATION_FILE);\n\n const content = getSentryInstrumentationServerContent(\n dsn,\n selectedFeatures.performance,\n selectedFeatures.profiling,\n selectedFeatures.logs,\n );\n\n fs.writeFileSync(instrumentationPath, content);\n clack.log.success(`Created ${chalk.cyan(INSTRUMENTATION_FILE)}.`);\n return instrumentationPath;\n}\n\nexport async function updatePackageJsonScripts(): Promise<void> {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson?.scripts) {\n throw new Error(\n 'Could not find a `scripts` section in your package.json file. Please add scripts manually or ensure your package.json is valid.',\n );\n }\n\n if (!packageJson.scripts.start) {\n throw new Error(\n 'Could not find a `start` script in your package.json. Please add: \"start\": \"react-router-serve ./build/server/index.js\" and re-run the wizard.',\n );\n }\n\n function mergeNodeOptions(\n scriptCommand: string,\n instrumentPath = './instrument.server.mjs',\n ): string {\n if (scriptCommand.includes(instrumentPath)) {\n return scriptCommand;\n }\n\n const quotedMatch = scriptCommand.match(/NODE_OPTIONS=(['\"])([^'\"]*)\\1/);\n if (quotedMatch) {\n const existingOptions = quotedMatch[2];\n const mergedOptions =\n `${existingOptions} --import ${instrumentPath}`.trim();\n return scriptCommand.replace(\n /NODE_OPTIONS=(['\"])([^'\"]*)\\1/,\n `NODE_OPTIONS='${mergedOptions}'`,\n );\n }\n\n const unquotedMatch = scriptCommand.match(\n /NODE_OPTIONS=([^\\s]+(?:\\s+[^\\s]+)*?)(\\s+(?:react-router-serve|react-router|node|npx|tsx))/,\n );\n if (unquotedMatch) {\n const existingOptions = unquotedMatch[1];\n const commandPart = unquotedMatch[2];\n const mergedOptions =\n `${existingOptions} --import ${instrumentPath}`.trim();\n return scriptCommand.replace(\n /NODE_OPTIONS=([^\\s]+(?:\\s+[^\\s]+)*?)(\\s+(?:react-router-serve|react-router|node|npx|tsx))/,\n `NODE_OPTIONS='${mergedOptions}'${commandPart}`,\n );\n }\n\n return `NODE_OPTIONS='--import ${instrumentPath}' ${scriptCommand}`;\n }\n\n if (packageJson.scripts.dev) {\n packageJson.scripts.dev = mergeNodeOptions(packageJson.scripts.dev);\n }\n\n const startScript = packageJson.scripts.start;\n if (\n !startScript.includes(INSTRUMENTATION_FILE) &&\n !startScript.includes('NODE_OPTIONS')\n ) {\n packageJson.scripts.start = `NODE_OPTIONS='--import ./${INSTRUMENTATION_FILE}' react-router-serve ./build/server/index.js`;\n } else {\n packageJson.scripts.start = mergeNodeOptions(startScript);\n }\n\n // Prevent React CJS dev/prod bundle mismatch when --import loads react\n // before react-router-serve sets NODE_ENV\n if (\n packageJson.scripts.start.includes('--import') &&\n !packageJson.scripts.start.includes('NODE_ENV=')\n ) {\n packageJson.scripts.start = `NODE_ENV=production ${packageJson.scripts.start}`;\n }\n\n await fs.promises.writeFile(\n 'package.json',\n JSON.stringify(packageJson, null, 2),\n );\n}\n\nexport async function instrumentSentryOnEntryServer(\n isTS: boolean,\n useInstrumentationAPI = false,\n): Promise<void> {\n const serverEntryPath = getAppFilePath('entry.server', isTS);\n const serverEntryFilename = path.basename(serverEntryPath);\n\n await ensureEntryFileExists(serverEntryFilename, serverEntryPath);\n\n await instrumentServerEntry(serverEntryPath, useInstrumentationAPI);\n\n clack.log.success(\n `Updated ${chalk.cyan(serverEntryFilename)} with Sentry error handling.`,\n );\n}\n\nexport async function configureReactRouterVitePlugin(\n orgSlug: string,\n projectSlug: string,\n): Promise<void> {\n const configPath = fs.existsSync(path.join(process.cwd(), 'vite.config.ts'))\n ? path.join(process.cwd(), 'vite.config.ts')\n : path.join(process.cwd(), 'vite.config.js');\n const filename = chalk.cyan(path.basename(configPath));\n\n try {\n const { wasConverted } = await instrumentViteConfig(orgSlug, projectSlug);\n\n clack.log.success(`Updated ${filename} with sentryReactRouter plugin.`);\n\n if (wasConverted) {\n clack.log.info(\n `Converted your Vite config to function form ${chalk.dim(\n '(defineConfig(config => ({ ... })))',\n )} to support the Sentry React Router plugin.`,\n );\n }\n } catch (e) {\n debug('Failed to modify vite config:', e);\n const errorMessage = e instanceof Error ? e.message : String(e);\n throw new Error(\n _formatConfigErrorMessage(\n filename,\n errorMessage,\n 'You may need to add the plugin manually.',\n ),\n );\n }\n}\n\nexport async function configureReactRouterConfig(isTS: boolean): Promise<void> {\n const configFilename = `react-router.config.${isTS ? 'ts' : 'js'}`;\n const configPath = path.join(process.cwd(), configFilename);\n const filename = chalk.cyan(configFilename);\n\n try {\n const fileExistedBefore = fs.existsSync(configPath);\n\n const { ssrWasChanged } = await instrumentReactRouterConfig(isTS);\n\n if (fileExistedBefore) {\n clack.log.success(`Updated ${filename} with Sentry buildEnd hook.`);\n } else {\n clack.log.success(`Created ${filename} with Sentry buildEnd hook.`);\n }\n\n if (ssrWasChanged) {\n clack.log.warn(\n `${chalk.yellow(\n 'Note:',\n )} SSR has been enabled in your React Router config (${chalk.cyan(\n 'ssr: true',\n )}). This is required for Sentry sourcemap uploads to work correctly.`,\n );\n }\n } catch (e) {\n debug('Failed to modify react-router.config:', e);\n const errorMessage = e instanceof Error ? e.message : String(e);\n throw new Error(\n _formatConfigErrorMessage(\n filename,\n errorMessage,\n 'You may need to add the buildEnd hook manually.',\n ),\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/react-router/sdk-setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,4DAA8C;AAE9C,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,mCAAiD;AAGjD,wDAA0D;AAC1D,0CAAuC;AACvC,2CAAoE;AACpE,0DAAgE;AAChE,0CAAmD;AACnD,0DAAgE;AAChE,0CAAuD;AACvD,wEAA6E;AAE7E,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAC9D,M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AI,iBAAiB,EAAE;YACrB,iBAAK,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,QAAQ,6BAA6B,CAAC,CAAC;SACrE;aAAM;YACL,iBAAK,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,QAAQ,6BAA6B,CAAC,CAAC;SACrE;QAED,IAAI,aAAa,EAAE;YACjB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,GAAG,eAAK,CAAC,MAAM,CACb,OAAO,CACR,sDAAsD,eAAK,CAAC,IAAI,CAC/D,WAAW,CACZ,qEAAqE,CACvE,CAAC;SACH;KACF;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,aAAK,EAAC,uCAAuC,EAAE,CAAC,CAAC,CAAC;QAClD,MAAM,YAAY,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,yBAAyB,CACvB,QAAQ,EACR,YAAY,EACZ,iDAAiD,CAClD,CACF,CAAC;KACH;AACH,CAAC;AApCD,gEAoCC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\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, coerce } from 'semver';\n\nimport type { PackageDotJson } from '../utils/package-json';\nimport { getPackageVersion } from '../utils/package-json';\nimport { debug } from '../utils/debug';\nimport { getSentryInstrumentationServerContent } from './templates';\nimport { instrumentServerEntry } from './codemods/server-entry';\nimport { getPackageDotJson } from '../utils/clack';\nimport { instrumentClientEntry } from './codemods/client.entry';\nimport { instrumentViteConfig } from './codemods/vite';\nimport { instrumentReactRouterConfig } from './codemods/react-router-config';\n\nconst REACT_ROUTER_REVEAL_COMMAND = 'npx react-router reveal';\nconst INSTRUMENTATION_FILE = 'instrument.server.mjs';\nconst APP_DIRECTORY = 'app';\nconst ROUTES_DIRECTORY = 'routes';\n\nfunction _formatConfigErrorMessage(\n filename: string,\n errorMessage: string,\n fallbackHint: string,\n): string {\n return (\n `Could not automatically configure ${filename}. ${errorMessage}\\n` +\n `This may happen if your config has an unusual format. ` +\n `${fallbackHint}`\n );\n}\n\nfunction getAppFilePath(\n filename: string,\n isTS: boolean,\n isPage = true,\n): string {\n const ext = isPage ? (isTS ? 'tsx' : 'jsx') : isTS ? 'ts' : 'js';\n return path.join(process.cwd(), APP_DIRECTORY, `${filename}.${ext}`);\n}\n\nexport function getRouteFilePath(filename: string, isTS: boolean): string {\n const ext = isTS ? 'tsx' : 'jsx';\n return path.join(\n process.cwd(),\n APP_DIRECTORY,\n ROUTES_DIRECTORY,\n `${filename}.${ext}`,\n );\n}\n\nexport async function tryRevealAndGetManualInstructions(\n missingFilename: string,\n filePath: string,\n): Promise<boolean> {\n const shouldTryReveal = await clack.confirm({\n message: `Would you like to try running ${chalk.cyan(\n REACT_ROUTER_REVEAL_COMMAND,\n )} to generate entry files?`,\n initialValue: true,\n });\n\n if (shouldTryReveal) {\n try {\n clack.log.info(`Running ${chalk.cyan(REACT_ROUTER_REVEAL_COMMAND)}...`);\n const output = childProcess.execSync(REACT_ROUTER_REVEAL_COMMAND, {\n encoding: 'utf8',\n stdio: 'pipe',\n });\n clack.log.info(output);\n\n if (fs.existsSync(filePath)) {\n clack.log.success(\n `Found ${chalk.cyan(missingFilename)} after running reveal.`,\n );\n return true;\n } else {\n clack.log.warn(\n `${chalk.cyan(\n missingFilename,\n )} still not found after running reveal.`,\n );\n }\n } catch (e) {\n debug('Failed to run React Router reveal command:', e);\n clack.log.warn(\n `Failed to run ${chalk.cyan(\n REACT_ROUTER_REVEAL_COMMAND,\n )}. This command generates entry files for React Router v7.`,\n );\n }\n }\n\n return false; // File still doesn't exist, manual intervention needed\n}\n\nasync function ensureEntryFileExists(\n filename: string,\n filePath: string,\n): Promise<void> {\n if (fs.existsSync(filePath)) {\n return; // File exists, nothing to do\n }\n\n clack.log.warn(`Could not find ${chalk.cyan(filename)}.`);\n\n const fileExists = await tryRevealAndGetManualInstructions(\n filename,\n filePath,\n );\n\n if (!fileExists) {\n throw new Error(\n `Failed to create or find ${filename}. Please create this file manually or ensure your React Router v7 project structure is correct.`,\n );\n }\n}\n\nexport function runReactRouterReveal(): void {\n if (\n !fs.existsSync(path.join(process.cwd(), 'app', 'entry.client.tsx')) &&\n !fs.existsSync(path.join(process.cwd(), 'app', 'entry.client.jsx'))\n ) {\n try {\n childProcess.execSync(REACT_ROUTER_REVEAL_COMMAND, {\n encoding: 'utf8',\n stdio: 'pipe',\n });\n } catch (e) {\n debug('Failed to run React Router reveal command:', e);\n throw e;\n }\n }\n}\n\nexport function isReactRouterV7(packageJson: PackageDotJson): boolean {\n const reactRouterVersion = getPackageVersion(\n '@react-router/dev',\n packageJson,\n );\n if (!reactRouterVersion) {\n return false;\n }\n\n const minVer = minVersion(reactRouterVersion);\n\n if (!minVer) {\n return false;\n }\n\n return gte(minVer, '7.0.0');\n}\n\nexport function getReactRouterVersion(\n packageJson: PackageDotJson,\n): string | undefined {\n const rangeVersion = getPackageVersion('@react-router/dev', packageJson);\n if (!rangeVersion) {\n return undefined;\n }\n\n const coerced = coerce(rangeVersion);\n return coerced ? coerced.version : rangeVersion;\n}\n\nexport function supportsOnError(packageJson: PackageDotJson): boolean {\n const reactRouterVersion = getPackageVersion(\n '@react-router/dev',\n packageJson,\n );\n if (!reactRouterVersion) {\n return false;\n }\n\n const minVer = minVersion(reactRouterVersion);\n\n if (!minVer) {\n return false;\n }\n\n return gte(minVer, '7.11.0');\n}\n\nexport function supportsInstrumentationAPI(\n packageJson: PackageDotJson,\n): boolean {\n const reactRouterVersion = getPackageVersion(\n '@react-router/dev',\n packageJson,\n );\n if (!reactRouterVersion) {\n return false;\n }\n\n const minVer = minVersion(reactRouterVersion);\n\n if (!minVer) {\n return false;\n }\n\n return gte(minVer, '7.15.0');\n}\n\nexport async function initializeSentryOnEntryClient(\n dsn: string,\n enableTracing: boolean,\n enableReplay: boolean,\n enableLogs: boolean,\n isTS: boolean,\n useInstrumentationAPI = false,\n useOnError = false,\n): Promise<void> {\n const clientEntryPath = getAppFilePath('entry.client', isTS);\n const clientEntryFilename = path.basename(clientEntryPath);\n\n await ensureEntryFileExists(clientEntryFilename, clientEntryPath);\n\n await instrumentClientEntry(\n clientEntryPath,\n dsn,\n enableTracing,\n enableReplay,\n enableLogs,\n useInstrumentationAPI,\n useOnError,\n );\n\n clack.log.success(\n `Updated ${chalk.cyan(clientEntryFilename)} with Sentry initialization.`,\n );\n}\n\nexport function createServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n profiling: boolean;\n },\n): string {\n const instrumentationPath = path.join(process.cwd(), INSTRUMENTATION_FILE);\n\n const content = getSentryInstrumentationServerContent(\n dsn,\n selectedFeatures.performance,\n selectedFeatures.profiling,\n selectedFeatures.logs,\n );\n\n fs.writeFileSync(instrumentationPath, content);\n clack.log.success(`Created ${chalk.cyan(INSTRUMENTATION_FILE)}.`);\n return instrumentationPath;\n}\n\nexport async function updatePackageJsonScripts(): Promise<void> {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson?.scripts) {\n throw new Error(\n 'Could not find a `scripts` section in your package.json file. Please add scripts manually or ensure your package.json is valid.',\n );\n }\n\n if (!packageJson.scripts.start) {\n throw new Error(\n 'Could not find a `start` script in your package.json. Please add: \"start\": \"react-router-serve ./build/server/index.js\" and re-run the wizard.',\n );\n }\n\n function mergeNodeOptions(\n scriptCommand: string,\n instrumentPath = './instrument.server.mjs',\n ): string {\n if (scriptCommand.includes(instrumentPath)) {\n return scriptCommand;\n }\n\n const quotedMatch = scriptCommand.match(/NODE_OPTIONS=(['\"])([^'\"]*)\\1/);\n if (quotedMatch) {\n const existingOptions = quotedMatch[2];\n const mergedOptions =\n `${existingOptions} --import ${instrumentPath}`.trim();\n return scriptCommand.replace(\n /NODE_OPTIONS=(['\"])([^'\"]*)\\1/,\n `NODE_OPTIONS='${mergedOptions}'`,\n );\n }\n\n const unquotedMatch = scriptCommand.match(\n /NODE_OPTIONS=([^\\s]+(?:\\s+[^\\s]+)*?)(\\s+(?:react-router-serve|react-router|node|npx|tsx))/,\n );\n if (unquotedMatch) {\n const existingOptions = unquotedMatch[1];\n const commandPart = unquotedMatch[2];\n const mergedOptions =\n `${existingOptions} --import ${instrumentPath}`.trim();\n return scriptCommand.replace(\n /NODE_OPTIONS=([^\\s]+(?:\\s+[^\\s]+)*?)(\\s+(?:react-router-serve|react-router|node|npx|tsx))/,\n `NODE_OPTIONS='${mergedOptions}'${commandPart}`,\n );\n }\n\n return `NODE_OPTIONS='--import ${instrumentPath}' ${scriptCommand}`;\n }\n\n if (packageJson.scripts.dev) {\n packageJson.scripts.dev = mergeNodeOptions(packageJson.scripts.dev);\n }\n\n const startScript = packageJson.scripts.start;\n if (\n !startScript.includes(INSTRUMENTATION_FILE) &&\n !startScript.includes('NODE_OPTIONS')\n ) {\n packageJson.scripts.start = `NODE_OPTIONS='--import ./${INSTRUMENTATION_FILE}' react-router-serve ./build/server/index.js`;\n } else {\n packageJson.scripts.start = mergeNodeOptions(startScript);\n }\n\n // Prevent React CJS dev/prod bundle mismatch when --import loads react\n // before react-router-serve sets NODE_ENV\n if (\n packageJson.scripts.start.includes('--import') &&\n !packageJson.scripts.start.includes('NODE_ENV=')\n ) {\n packageJson.scripts.start = `NODE_ENV=production ${packageJson.scripts.start}`;\n }\n\n await fs.promises.writeFile(\n 'package.json',\n JSON.stringify(packageJson, null, 2),\n );\n}\n\nexport async function instrumentSentryOnEntryServer(\n isTS: boolean,\n useInstrumentationAPI = false,\n): Promise<void> {\n const serverEntryPath = getAppFilePath('entry.server', isTS);\n const serverEntryFilename = path.basename(serverEntryPath);\n\n await ensureEntryFileExists(serverEntryFilename, serverEntryPath);\n\n await instrumentServerEntry(serverEntryPath, useInstrumentationAPI);\n\n clack.log.success(\n `Updated ${chalk.cyan(serverEntryFilename)} with Sentry error handling.`,\n );\n}\n\nexport async function configureReactRouterVitePlugin(\n orgSlug: string,\n projectSlug: string,\n): Promise<void> {\n const configPath = fs.existsSync(path.join(process.cwd(), 'vite.config.ts'))\n ? path.join(process.cwd(), 'vite.config.ts')\n : path.join(process.cwd(), 'vite.config.js');\n const filename = chalk.cyan(path.basename(configPath));\n\n try {\n const { wasConverted } = await instrumentViteConfig(orgSlug, projectSlug);\n\n clack.log.success(`Updated ${filename} with sentryReactRouter plugin.`);\n\n if (wasConverted) {\n clack.log.info(\n `Converted your Vite config to function form ${chalk.dim(\n '(defineConfig(config => ({ ... })))',\n )} to support the Sentry React Router plugin.`,\n );\n }\n } catch (e) {\n debug('Failed to modify vite config:', e);\n const errorMessage = e instanceof Error ? e.message : String(e);\n throw new Error(\n _formatConfigErrorMessage(\n filename,\n errorMessage,\n 'You may need to add the plugin manually.',\n ),\n );\n }\n}\n\nexport async function configureReactRouterConfig(isTS: boolean): Promise<void> {\n const configFilename = `react-router.config.${isTS ? 'ts' : 'js'}`;\n const configPath = path.join(process.cwd(), configFilename);\n const filename = chalk.cyan(configFilename);\n\n try {\n const fileExistedBefore = fs.existsSync(configPath);\n\n const { ssrWasChanged } = await instrumentReactRouterConfig(isTS);\n\n if (fileExistedBefore) {\n clack.log.success(`Updated ${filename} with Sentry buildEnd hook.`);\n } else {\n clack.log.success(`Created ${filename} with Sentry buildEnd hook.`);\n }\n\n if (ssrWasChanged) {\n clack.log.warn(\n `${chalk.yellow(\n 'Note:',\n )} SSR has been enabled in your React Router config (${chalk.cyan(\n 'ssr: true',\n )}). This is required for Sentry sourcemap uploads to work correctly.`,\n );\n }\n } catch (e) {\n debug('Failed to modify react-router.config:', e);\n const errorMessage = e instanceof Error ? e.message : String(e);\n throw new Error(\n _formatConfigErrorMessage(\n filename,\n errorMessage,\n 'You may need to add the buildEnd hook manually.',\n ),\n );\n }\n}\n"]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
export declare const ERROR_BOUNDARY_TEMPLATE: string;
|
|
2
1
|
export declare const EXAMPLE_PAGE_TEMPLATE_TSX = "import type { Route } from \"./+types/sentry-example-page\";\n\nexport async function loader() {\n throw new Error(\"some error thrown in a loader\");\n}\n\nexport default function SentryExamplePage() {\n return <div>Loading this page will throw an error</div>;\n}";
|
|
3
2
|
export declare const EXAMPLE_PAGE_TEMPLATE_JSX = "export async function loader() {\n throw new Error(\"some error thrown in a loader\");\n}\n\nexport default function SentryExamplePage() {\n return <div>Loading this page will throw an error</div>;\n}";
|
|
4
3
|
export declare const getSentryInstrumentationServerContent: (dsn: string, enableTracing: boolean, enableProfiling?: boolean, enableLogs?: boolean) => string;
|
|
5
|
-
export declare const getManualClientEntryContent: (dsn: string, enableTracing: boolean, enableReplay: boolean, enableLogs: boolean, useInstrumentationAPI?: boolean) => string;
|
|
4
|
+
export declare const getManualClientEntryContent: (dsn: string, enableTracing: boolean, enableReplay: boolean, enableLogs: boolean, useInstrumentationAPI?: boolean, useOnError?: boolean) => string;
|
|
6
5
|
export declare const getManualServerEntryContent: (useInstrumentationAPI?: boolean) => string;
|
|
7
6
|
export declare const getManualHandleRequestContent: () => string;
|
|
8
|
-
export declare const getManualRootContent: (isTs: boolean) => string;
|
|
9
7
|
export declare const getManualServerInstrumentContent: (dsn: string, enableTracing: boolean, enableProfiling: boolean, enableLogs?: boolean) => string;
|
|
10
8
|
export declare const getManualReactRouterConfigContent: (isTS?: boolean) => string;
|
|
11
9
|
export declare const getManualViteConfigContent: (orgSlug: string, projectSlug: string) => string;
|