@sentry/wizard 3.23.2 → 3.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/dist/package.json +2 -2
  3. package/dist/src/nextjs/nextjs-wizard.js +1 -1
  4. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  5. package/dist/src/nextjs/templates.d.ts +1 -1
  6. package/dist/src/nextjs/templates.js +4 -2
  7. package/dist/src/nextjs/templates.js.map +1 -1
  8. package/dist/src/react-native/glob.js +24 -4
  9. package/dist/src/react-native/glob.js.map +1 -1
  10. package/dist/src/remix/codemods/express-server.d.ts +0 -4
  11. package/dist/src/remix/codemods/express-server.js +1 -80
  12. package/dist/src/remix/codemods/express-server.js.map +1 -1
  13. package/dist/src/remix/codemods/handle-error.js +2 -2
  14. package/dist/src/remix/codemods/handle-error.js.map +1 -1
  15. package/dist/src/remix/remix-wizard.js +62 -19
  16. package/dist/src/remix/remix-wizard.js.map +1 -1
  17. package/dist/src/remix/sdk-example.js +1 -1
  18. package/dist/src/remix/sdk-example.js.map +1 -1
  19. package/dist/src/remix/sdk-setup.d.ts +5 -3
  20. package/dist/src/remix/sdk-setup.js +98 -38
  21. package/dist/src/remix/sdk-setup.js.map +1 -1
  22. package/dist/src/remix/templates.d.ts +1 -1
  23. package/dist/src/remix/templates.js +1 -1
  24. package/dist/src/remix/templates.js.map +1 -1
  25. package/dist/src/remix/utils.d.ts +9 -3
  26. package/dist/src/remix/utils.js +39 -10
  27. package/dist/src/remix/utils.js.map +1 -1
  28. package/package.json +2 -2
  29. package/src/nextjs/nextjs-wizard.ts +1 -1
  30. package/src/nextjs/templates.ts +32 -4
  31. package/src/react-native/glob.ts +1 -1
  32. package/src/remix/codemods/express-server.ts +0 -121
  33. package/src/remix/codemods/handle-error.ts +3 -2
  34. package/src/remix/remix-wizard.ts +45 -17
  35. package/src/remix/sdk-example.ts +0 -2
  36. package/src/remix/sdk-setup.ts +125 -33
  37. package/src/remix/templates.ts +1 -1
  38. package/src/remix/utils.ts +57 -7
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/remix/sdk-setup.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO5D,qCAAyB;AACzB,yCAA6B;AAC7B,uCAA2B;AAC3B,0DAA8C;AAE9C,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAC1B,iCAAyC;AAEzC,kFAAkF;AAClF,qCAAuE;AACvE,sDAA0E;AAC1E,iCAAsE;AACtE,8CAA2D;AAC3D,8CAA2D;AAC3D,wDAAgE;AAChE,4DAGmC;AACnC,oDAAyD;AAczD,IAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAC5C,IAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEhD,SAAgB,cAAc,CAAC,IAAa;IAC1C,qCAAqC;IACrC,IAAM,mBAAmB,GAAG,uBAAgB,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAE,CAAC;IACnE,IAAM,mBAAmB,GAAG,uBAAgB,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAE,CAAC;IAEnE,IAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC;IAC7E,IAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC;IAE7E,IAAI,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;QACpE,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,4BAAqB,eAAK,CAAC,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,CACL,CAAC;;;;;CACH;AApDD,sEAoDC;AAED,SAAsB,uBAAuB;;;;;wBACjB,qBAAM,IAAA,sDAAqC,GAAE,EAAA;;oBAAjE,iBAAiB,GAAG,SAA6C;oBAEvE,IAAI,CAAC,iBAAiB,EAAE;wBACtB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,qFAAqF,CACtF,CAAC;wBACF,sBAAO;qBACR;oBAED,qBAAM,IAAA,sDAAqC,EAAC,iBAAiB,CAAC,EAAA;;oBAA9D,SAA8D,CAAC;;;;;CAChE;AAXD,0DAWC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport type { Program } from '@babel/types';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport * as childProcess from 'child_process';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { gte, minVersion } from 'semver';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { builders, generateCode, loadFile, writeFile } from 'magicast';\nimport { PackageDotJson, getPackageVersion } from '../utils/package-json';\nimport { getInitCallInsertionIndex, hasSentryContent } from './utils';\nimport { instrumentRootRouteV1 } from './codemods/root-v1';\nimport { instrumentRootRouteV2 } from './codemods/root-v2';\nimport { instrumentHandleError } from './codemods/handle-error';\nimport {\n findCustomExpressServerImplementation,\n instrumentExpressCreateRequestHandler,\n} from './codemods/express-server';\nimport { getPackageDotJson } from '../utils/clack-utils';\n\nexport type PartialRemixConfig = {\n unstable_dev?: boolean;\n future?: {\n v2_dev?: boolean;\n v2_errorBoundary?: boolean;\n v2_headers?: boolean;\n v2_meta?: boolean;\n v2_normalizeFormMethod?: boolean;\n v2_routeConvention?: boolean;\n };\n};\n\nconst REMIX_CONFIG_FILE = 'remix.config.js';\nconst REMIX_REVEAL_COMMAND = 'npx remix reveal';\n\nexport function runRemixReveal(isTS: boolean): void {\n // Check if entry files already exist\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const clientEntryPath = path.join(process.cwd(), 'app', clientEntryFilename);\n const serverEntryPath = path.join(process.cwd(), 'app', serverEntryFilename);\n\n if (fs.existsSync(clientEntryPath) && fs.existsSync(serverEntryPath)) {\n clack.log.info(\n `Found entry files ${chalk.cyan(clientEntryFilename)} and ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n } else {\n clack.log.info(\n `Couldn't find entry files in your project. Trying to run ${chalk.cyan(\n REMIX_REVEAL_COMMAND,\n )}...`,\n );\n\n clack.log.info(childProcess.execSync(REMIX_REVEAL_COMMAND).toString());\n }\n}\n\nfunction insertClientInitCall(\n dsn: string,\n originalHooksMod: ProxifiedModule<any>,\n): void {\n const initCall = builders.functionCall('Sentry.init', {\n dsn,\n tracesSampleRate: 1.0,\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1.0,\n integrations: [\n builders.functionCall(\n 'Sentry.browserTracingIntegration',\n builders.raw('{ useEffect, useLocation, useMatches }'),\n ),\n builders.functionCall('Sentry.replayIntegration'),\n ],\n });\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n const initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n}\n\nfunction insertServerInitCall(\n dsn: string,\n originalHooksMod: ProxifiedModule<any>,\n) {\n const initCall = builders.functionCall('Sentry.init', {\n dsn,\n tracesSampleRate: 1.0,\n });\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n\n const initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n}\n\nexport function isRemixV2(\n remixConfig: PartialRemixConfig,\n packageJson: PackageDotJson,\n): boolean {\n const remixVersion = getPackageVersion('@remix-run/react', packageJson);\n if (!remixVersion) {\n return false;\n }\n\n const minVer = minVersion(remixVersion);\n\n if (!minVer) {\n return false;\n }\n\n const isV2Remix = gte(minVer, '2.0.0');\n\n return isV2Remix || remixConfig?.future?.v2_errorBoundary || false;\n}\n\nexport async function loadRemixConfig(): Promise<PartialRemixConfig> {\n const configFilePath = path.join(process.cwd(), REMIX_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const remixConfigModule = (await import(configUrl)) as {\n default: PartialRemixConfig;\n };\n\n return remixConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${REMIX_CONFIG_FILE}.`);\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n\n return {};\n }\n}\n\nexport async function instrumentRootRoute(\n isV2?: boolean,\n isTS?: boolean,\n): Promise<void> {\n const rootFilename = `root.${isTS ? 'tsx' : 'jsx'}`;\n\n if (isV2) {\n await instrumentRootRouteV2(rootFilename);\n } else {\n await instrumentRootRouteV1(rootFilename);\n }\n\n clack.log.success(\n `Successfully instrumented root route ${chalk.cyan(rootFilename)}.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport async function updateBuildScript(args: {\n org: string;\n project: string;\n url?: string;\n isHydrogen: boolean;\n}): Promise<void> {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n const buildCommand = args.isHydrogen\n ? 'shopify hydrogen build'\n : 'remix build';\n\n const instrumentedBuildCommand =\n `${buildCommand} --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +\n (args.url ? ` --url ${args.url}` : '') +\n (args.isHydrogen ? ' --buildPath ./dist' : '');\n\n if (!packageJson.scripts.build) {\n packageJson.scripts.build = instrumentedBuildCommand;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n } else if (packageJson.scripts.build.includes(buildCommand)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n packageJson.scripts.build = packageJson.scripts.build.replace(\n buildCommand,\n instrumentedBuildCommand,\n );\n } else {\n throw new Error(\n \"`build` script doesn't contain a known build command. Please update it manually.\",\n );\n }\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('build')} script in ${chalk.cyan(\n 'package.json',\n )} to generate and upload sourcemaps.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport async function initializeSentryOnEntryClient(\n dsn: string,\n isTS: boolean,\n): Promise<void> {\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryClient = path.join(\n process.cwd(),\n 'app',\n clientEntryFilename,\n );\n\n const originalEntryClientMod = await loadFile(originalEntryClient);\n\n if (hasSentryContent(originalEntryClient, originalEntryClientMod.$code)) {\n return;\n }\n\n originalEntryClientMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n originalEntryClientMod.imports.$add({\n from: 'react',\n imported: 'useEffect',\n local: 'useEffect',\n });\n\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useLocation',\n local: 'useLocation',\n });\n\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useMatches',\n local: 'useMatches',\n });\n\n insertClientInitCall(dsn, originalEntryClientMod);\n\n await writeFile(\n originalEntryClientMod.$ast,\n path.join(process.cwd(), 'app', clientEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on client entry point ${chalk.cyan(\n clientEntryFilename,\n )}`,\n );\n}\n\nexport async function initializeSentryOnEntryServer(\n dsn: string,\n isV2: boolean,\n isTS: boolean,\n): Promise<void> {\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryServer = path.join(\n process.cwd(),\n 'app',\n serverEntryFilename,\n );\n\n const originalEntryServerMod = await loadFile(originalEntryServer);\n\n if (hasSentryContent(originalEntryServer, originalEntryServerMod.$code)) {\n return;\n }\n\n originalEntryServerMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n insertServerInitCall(dsn, originalEntryServerMod);\n\n if (isV2) {\n const handleErrorInstrumented = instrumentHandleError(\n originalEntryServerMod,\n serverEntryFilename,\n );\n\n if (handleErrorInstrumented) {\n clack.log.success(\n `Instrumented ${chalk.cyan('handleError')} in ${chalk.cyan(\n `${serverEntryFilename}`,\n )}`,\n );\n }\n }\n\n await writeFile(\n originalEntryServerMod.$ast,\n path.join(process.cwd(), 'app', serverEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on server entry point ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n}\n\nexport async function instrumentExpressServer() {\n const expressServerPath = await findCustomExpressServerImplementation();\n\n if (!expressServerPath) {\n clack.log.warn(\n `Could not find custom Express server implementation. Please instrument it manually.`,\n );\n return;\n }\n\n await instrumentExpressCreateRequestHandler(expressServerPath);\n}\n"]}
1
+ {"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/remix/sdk-setup.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO5D,qCAAyB;AACzB,yCAA6B;AAC7B,uCAA2B;AAC3B,0DAA8C;AAE9C,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAC1B,iCAAyC;AAEzC,qC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I,CACnC,OAAO,CAAC,GAAG,EAAE,EACb,KAAK,EACL,mBAAmB,CACpB,CAAC;oBAE6B,qBAAM,IAAA,mBAAQ,EAAC,mBAAmB,CAAC,EAAA;;oBAA5D,sBAAsB,GAAG,SAAmC;oBAElE,IAAI,IAAA,wBAAgB,EAAC,mBAAmB,EAAE,sBAAsB,CAAC,KAAK,CAAC,EAAE;wBACvE,sBAAO;qBACR;oBAED,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC;wBAClC,IAAI,EAAE,eAAe;wBACrB,QAAQ,EAAE,GAAG;wBACb,KAAK,EAAE,QAAQ;qBAChB,CAAC,CAAC;oBAEH,IAAI,IAAI,EAAE;wBACF,uBAAuB,GAAG,IAAA,oCAAqB,EACnD,sBAAsB,EACtB,mBAAmB,CACpB,CAAC;wBAEF,IAAI,uBAAuB,EAAE;4BAC3B,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,uBAAgB,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC,iBAAO,eAAK,CAAC,IAAI,CACxD,UAAG,mBAAmB,CAAE,CACzB,CAAE,CACJ,CAAC;yBACH;qBACF;oBAED,qBAAM,IAAA,oBAAS,EACb,sBAAsB,CAAC,IAAI,EAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CACrD,EAAA;;oBAHD,SAGC,CAAC;oBAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,gEAAyD,eAAK,CAAC,IAAI,CACjE,mBAAmB,CACpB,MAAG,CACL,CAAC;;;;;CACH;AAjDD,sEAiDC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport type { Program } from '@babel/types';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport * as childProcess from 'child_process';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { gte, minVersion } from 'semver';\n\nimport {\n builders,\n generateCode,\n loadFile,\n parseModule,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\nimport type { PackageDotJson } from '../utils/package-json';\nimport { getPackageVersion } from '../utils/package-json';\nimport {\n getAfterImportsInsertionIndex,\n hasSentryContent,\n serverHasInstrumentationImport,\n} from './utils';\nimport { instrumentRootRouteV1 } from './codemods/root-v1';\nimport { instrumentRootRouteV2 } from './codemods/root-v2';\nimport { instrumentHandleError } from './codemods/handle-error';\nimport { getPackageDotJson } from '../utils/clack-utils';\nimport { findCustomExpressServerImplementation } from './codemods/express-server';\n\nexport type PartialRemixConfig = {\n unstable_dev?: boolean;\n future?: {\n v2_dev?: boolean;\n v2_errorBoundary?: boolean;\n v2_headers?: boolean;\n v2_meta?: boolean;\n v2_normalizeFormMethod?: boolean;\n v2_routeConvention?: boolean;\n };\n};\n\nconst REMIX_CONFIG_FILE = 'remix.config.js';\nconst REMIX_REVEAL_COMMAND = 'npx remix reveal';\n\nexport function runRemixReveal(isTS: boolean): void {\n // Check if entry files already exist\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const clientEntryPath = path.join(process.cwd(), 'app', clientEntryFilename);\n const serverEntryPath = path.join(process.cwd(), 'app', serverEntryFilename);\n\n if (fs.existsSync(clientEntryPath) && fs.existsSync(serverEntryPath)) {\n clack.log.info(\n `Found entry files ${chalk.cyan(clientEntryFilename)} and ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n } else {\n clack.log.info(\n `Couldn't find entry files in your project. Trying to run ${chalk.cyan(\n REMIX_REVEAL_COMMAND,\n )}...`,\n );\n\n clack.log.info(childProcess.execSync(REMIX_REVEAL_COMMAND).toString());\n }\n}\n\nfunction insertClientInitCall(\n dsn: string,\n originalHooksMod: ProxifiedModule<any>,\n): void {\n const initCall = builders.functionCall('Sentry.init', {\n dsn,\n tracesSampleRate: 1.0,\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1.0,\n integrations: [\n builders.functionCall(\n 'Sentry.browserTracingIntegration',\n builders.raw('{ useEffect, useLocation, useMatches }'),\n ),\n builders.functionCall('Sentry.replayIntegration'),\n ],\n });\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n const initCallInsertionIndex =\n getAfterImportsInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n}\n\nexport async function createServerInstrumentationFile(dsn: string) {\n // create an empty file named `instrument.server.mjs`\n const instrumentationFile = 'instrumentation.server.mjs';\n const instrumentationFileMod = parseModule('');\n\n instrumentationFileMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n const initCall = builders.functionCall('Sentry.init', {\n dsn,\n tracesSampleRate: 1.0,\n autoInstrumentRemix: true,\n });\n\n const instrumentationFileModAST = instrumentationFileMod.$ast as Program;\n\n const initCallInsertionIndex = getAfterImportsInsertionIndex(\n instrumentationFileModAST,\n );\n\n instrumentationFileModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n\n await writeFile(instrumentationFileModAST, instrumentationFile);\n\n return instrumentationFile;\n}\n\nexport async function insertServerInstrumentationFile(dsn: string) {\n const instrumentationFile = await createServerInstrumentationFile(dsn);\n\n const expressServerPath = await findCustomExpressServerImplementation();\n\n if (!expressServerPath) {\n return false;\n }\n\n const originalExpressServerMod = await loadFile(expressServerPath);\n\n if (\n serverHasInstrumentationImport(\n expressServerPath,\n originalExpressServerMod.$code,\n )\n ) {\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(expressServerPath),\n )} already contains instrumentation import.\nSkipping adding instrumentation functionality to ${chalk.cyan(\n path.basename(expressServerPath),\n )}.`,\n );\n\n return true;\n }\n\n originalExpressServerMod.$code = `import './${instrumentationFile}';\\n${originalExpressServerMod.$code}`;\n\n fs.writeFileSync(expressServerPath, originalExpressServerMod.$code);\n\n return true;\n}\n\nexport function isRemixV2(\n remixConfig: PartialRemixConfig,\n packageJson: PackageDotJson,\n): boolean {\n const remixVersion = getPackageVersion('@remix-run/react', packageJson);\n if (!remixVersion) {\n return false;\n }\n\n const minVer = minVersion(remixVersion);\n\n if (!minVer) {\n return false;\n }\n\n const isV2Remix = gte(minVer, '2.0.0');\n\n return isV2Remix || remixConfig?.future?.v2_errorBoundary || false;\n}\n\nexport async function loadRemixConfig(): Promise<PartialRemixConfig> {\n const configFilePath = path.join(process.cwd(), REMIX_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const remixConfigModule = (await import(configUrl)) as {\n default: PartialRemixConfig;\n };\n\n return remixConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${REMIX_CONFIG_FILE}.`);\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n\n return {};\n }\n}\n\nexport async function instrumentRootRoute(\n isV2?: boolean,\n isTS?: boolean,\n): Promise<void> {\n const rootFilename = `root.${isTS ? 'tsx' : 'jsx'}`;\n\n if (isV2) {\n await instrumentRootRouteV2(rootFilename);\n } else {\n await instrumentRootRouteV1(rootFilename);\n }\n\n clack.log.success(\n `Successfully instrumented root route ${chalk.cyan(rootFilename)}.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport async function updateBuildScript(args: {\n org: string;\n project: string;\n url?: string;\n isHydrogen: boolean;\n}): Promise<void> {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n const buildCommand = args.isHydrogen\n ? 'shopify hydrogen build'\n : 'remix build';\n\n const instrumentedBuildCommand =\n `${buildCommand} --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +\n (args.url ? ` --url ${args.url}` : '') +\n (args.isHydrogen ? ' --buildPath ./dist' : '');\n\n if (!packageJson.scripts.build) {\n packageJson.scripts.build = instrumentedBuildCommand;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n } else if (packageJson.scripts.build.includes(buildCommand)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n packageJson.scripts.build = packageJson.scripts.build.replace(\n buildCommand,\n instrumentedBuildCommand,\n );\n } else {\n throw new Error(\n \"`build` script doesn't contain a known build command. Please update it manually.\",\n );\n }\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('build')} script in ${chalk.cyan(\n 'package.json',\n )} to generate and upload sourcemaps.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport async function initializeSentryOnEntryClient(\n dsn: string,\n isTS: boolean,\n): Promise<void> {\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryClient = path.join(\n process.cwd(),\n 'app',\n clientEntryFilename,\n );\n\n const originalEntryClientMod = await loadFile(originalEntryClient);\n\n if (hasSentryContent(originalEntryClient, originalEntryClientMod.$code)) {\n return;\n }\n\n originalEntryClientMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n originalEntryClientMod.imports.$add({\n from: 'react',\n imported: 'useEffect',\n local: 'useEffect',\n });\n\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useLocation',\n local: 'useLocation',\n });\n\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useMatches',\n local: 'useMatches',\n });\n\n insertClientInitCall(dsn, originalEntryClientMod);\n\n await writeFile(\n originalEntryClientMod.$ast,\n path.join(process.cwd(), 'app', clientEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on client entry point ${chalk.cyan(\n clientEntryFilename,\n )}`,\n );\n}\n\nexport async function updateStartScript(instrumentationFile: string) {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts || !packageJson.scripts.start) {\n throw new Error(\n \"Couldn't find a `start` script in your package.json. Please add one manually.\",\n );\n }\n\n if (packageJson.scripts.start.includes('NODE_OPTIONS')) {\n clack.log.warn(\n `Found existing NODE_OPTIONS in ${chalk.cyan(\n 'start',\n )} script. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n if (\n !packageJson.scripts.start.includes('remix-serve') &&\n // Adding a following empty space not to match a path that includes `node`\n !packageJson.scripts.start.includes('node ')\n ) {\n clack.log.warn(\n `Found a ${chalk.cyan('start')} script that doesn't use ${chalk.cyan(\n 'remix-serve',\n )} or ${chalk.cyan('node')}. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n const startCommand = packageJson.scripts.start;\n\n packageJson.scripts.start = `NODE_OPTIONS='--import ./${instrumentationFile}' ${startCommand}`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('start')} script in ${chalk.cyan(\n 'package.json',\n )} to include Sentry initialization on start.`,\n );\n}\n\nexport async function instrumentSentryOnEntryServer(\n isV2: boolean,\n isTS: boolean,\n): Promise<void> {\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryServer = path.join(\n process.cwd(),\n 'app',\n serverEntryFilename,\n );\n\n const originalEntryServerMod = await loadFile(originalEntryServer);\n\n if (hasSentryContent(originalEntryServer, originalEntryServerMod.$code)) {\n return;\n }\n\n originalEntryServerMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n if (isV2) {\n const handleErrorInstrumented = instrumentHandleError(\n originalEntryServerMod,\n serverEntryFilename,\n );\n\n if (handleErrorInstrumented) {\n clack.log.success(\n `Instrumented ${chalk.cyan('handleError')} in ${chalk.cyan(\n `${serverEntryFilename}`,\n )}`,\n );\n }\n }\n\n await writeFile(\n originalEntryServerMod.$ast,\n path.join(process.cwd(), 'app', serverEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on server entry point ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
1
  export declare const ERROR_BOUNDARY_TEMPLATE_V2 = "const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};\n";
2
- export declare const HANDLE_ERROR_TEMPLATE_V2 = "function handleError(error, { request }) {\n Sentry.captureRemixServerException(error, 'remix.server', request);\n}\n";
2
+ export declare const HANDLE_ERROR_TEMPLATE_V2 = "function handleError(error, { request }) {\n Sentry.captureRemixServerException(error, 'remix.server', request, true);\n}\n";
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HANDLE_ERROR_TEMPLATE_V2 = exports.ERROR_BOUNDARY_TEMPLATE_V2 = void 0;
4
4
  exports.ERROR_BOUNDARY_TEMPLATE_V2 = "const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};\n";
5
- exports.HANDLE_ERROR_TEMPLATE_V2 = "function handleError(error, { request }) {\n Sentry.captureRemixServerException(error, 'remix.server', request);\n}\n";
5
+ exports.HANDLE_ERROR_TEMPLATE_V2 = "function handleError(error, { request }) {\n Sentry.captureRemixServerException(error, 'remix.server', request, true);\n}\n";
6
6
  //# sourceMappingURL=templates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/remix/templates.ts"],"names":[],"mappings":";;;AAAa,QAAA,0BAA0B,GAAG,4JAKzC,CAAC;AAEW,QAAA,wBAAwB,GAAG,wHAGvC,CAAC","sourcesContent":["export const ERROR_BOUNDARY_TEMPLATE_V2 = `const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};\n`;\n\nexport const HANDLE_ERROR_TEMPLATE_V2 = `function handleError(error, { request }) {\n Sentry.captureRemixServerException(error, 'remix.server', request);\n}\n`;\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/remix/templates.ts"],"names":[],"mappings":";;;AAAa,QAAA,0BAA0B,GAAG,4JAKzC,CAAC;AAEW,QAAA,wBAAwB,GAAG,8HAGvC,CAAC","sourcesContent":["export const ERROR_BOUNDARY_TEMPLATE_V2 = `const ErrorBoundary = () => {\n const error = useRouteError();\n captureRemixErrorBoundaryError(error);\n return <div>Something went wrong</div>;\n};\n`;\n\nexport const HANDLE_ERROR_TEMPLATE_V2 = `function handleError(error, { request }) {\n Sentry.captureRemixServerException(error, 'remix.server', request, true);\n}\n`;\n"]}
@@ -1,8 +1,14 @@
1
1
  import type { Program } from '@babel/types';
2
2
  import { PackageDotJson } from '../utils/package-json';
3
- export declare function hasSentryContent(fileName: string, fileContent: string): boolean;
3
+ export declare const POSSIBLE_SERVER_INSTRUMENTATION_PATHS: string[];
4
+ export declare function hasSentryContent(fileName: string, fileContent: string, expectedContent?: string): boolean;
5
+ export declare function serverHasInstrumentationImport(serverFileName: string, serverFileContent: string): boolean;
4
6
  /**
5
- * We want to insert the init call on top of the file but after all import statements
7
+ * We want to insert the init call on top of the file, before any other imports.
6
8
  */
7
- export declare function getInitCallInsertionIndex(originalHooksModAST: Program): number;
9
+ export declare function getBeforeImportsInsertionIndex(originalHooksModAST: Program): number;
10
+ /**
11
+ * We want to insert the handleError function just after all imports
12
+ */
13
+ export declare function getAfterImportsInsertionIndex(originalEntryServerModAST: Program): number;
8
14
  export declare function isHydrogenApp(packageJson: PackageDotJson): boolean;
@@ -26,33 +26,62 @@ 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.isHydrogenApp = exports.getInitCallInsertionIndex = exports.hasSentryContent = void 0;
29
+ exports.isHydrogenApp = exports.getAfterImportsInsertionIndex = exports.getBeforeImportsInsertionIndex = exports.serverHasInstrumentationImport = exports.hasSentryContent = exports.POSSIBLE_SERVER_INSTRUMENTATION_PATHS = void 0;
30
30
  var path = __importStar(require("path"));
31
31
  // @ts-expect-error - clack is ESM and TS complains about that. It works though
32
32
  var prompts_1 = __importDefault(require("@clack/prompts"));
33
33
  var chalk_1 = __importDefault(require("chalk"));
34
34
  var package_json_1 = require("../utils/package-json");
35
- // Copied from sveltekit wizard
36
- function hasSentryContent(fileName, fileContent) {
37
- var includesContent = fileContent.includes('@sentry/remix');
35
+ exports.POSSIBLE_SERVER_INSTRUMENTATION_PATHS = [
36
+ './instrumentation',
37
+ './instrumentation.server',
38
+ ];
39
+ function hasSentryContent(fileName, fileContent, expectedContent) {
40
+ if (expectedContent === void 0) { expectedContent = '@sentry/remix'; }
41
+ var includesContent = fileContent.includes(expectedContent);
38
42
  if (includesContent) {
39
- prompts_1.default.log.warn("File ".concat(chalk_1.default.cyan(path.basename(fileName)), " already contains Sentry code.\nSkipping adding Sentry functionality to ").concat(chalk_1.default.cyan(path.basename(fileName)), "."));
43
+ prompts_1.default.log.warn("File ".concat(chalk_1.default.cyan(path.basename(fileName)), " already contains ").concat(expectedContent, ".\nSkipping adding Sentry functionality to ").concat(chalk_1.default.cyan(path.basename(fileName)), "."));
40
44
  }
41
45
  return includesContent;
42
46
  }
43
47
  exports.hasSentryContent = hasSentryContent;
48
+ function serverHasInstrumentationImport(serverFileName, serverFileContent) {
49
+ var includesServerInstrumentationImport = exports.POSSIBLE_SERVER_INSTRUMENTATION_PATHS.some(function (path) {
50
+ return serverFileContent.includes(path);
51
+ });
52
+ if (includesServerInstrumentationImport) {
53
+ prompts_1.default.log.warn("File ".concat(chalk_1.default.cyan(path.basename(serverFileName)), " already contains instrumentation import.\nSkipping adding instrumentation functionality to ").concat(chalk_1.default.cyan(path.basename(serverFileName)), "."));
54
+ }
55
+ return includesServerInstrumentationImport;
56
+ }
57
+ exports.serverHasInstrumentationImport = serverHasInstrumentationImport;
58
+ /**
59
+ * We want to insert the init call on top of the file, before any other imports.
60
+ */
61
+ function getBeforeImportsInsertionIndex(originalHooksModAST) {
62
+ for (var x = 0; x < originalHooksModAST.body.length - 1; x++) {
63
+ if (originalHooksModAST.body[x].type === 'ImportDeclaration' &&
64
+ // @ts-expect-error - source is available in body
65
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
66
+ originalHooksModAST.body[x].source.value === '@sentry/remix') {
67
+ return x + 1;
68
+ }
69
+ }
70
+ return 0;
71
+ }
72
+ exports.getBeforeImportsInsertionIndex = getBeforeImportsInsertionIndex;
44
73
  /**
45
- * We want to insert the init call on top of the file but after all import statements
74
+ * We want to insert the handleError function just after all imports
46
75
  */
47
- function getInitCallInsertionIndex(originalHooksModAST) {
48
- for (var x = originalHooksModAST.body.length - 1; x >= 0; x--) {
49
- if (originalHooksModAST.body[x].type === 'ImportDeclaration') {
76
+ function getAfterImportsInsertionIndex(originalEntryServerModAST) {
77
+ for (var x = originalEntryServerModAST.body.length - 1; x >= 0; x--) {
78
+ if (originalEntryServerModAST.body[x].type === 'ImportDeclaration') {
50
79
  return x + 1;
51
80
  }
52
81
  }
53
82
  return 0;
54
83
  }
55
- exports.getInitCallInsertionIndex = getInitCallInsertionIndex;
84
+ exports.getAfterImportsInsertionIndex = getAfterImportsInsertionIndex;
56
85
  function isHydrogenApp(packageJson) {
57
86
  return (0, package_json_1.hasPackageInstalled)('@shopify/hydrogen', packageJson);
58
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/remix/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAA6B;AAE7B,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAC1B,sDAA4E;AAE5E,+BAA+B;AAC/B,SAAgB,gBAAgB,CAC9B,QAAgB,EAChB,WAAmB;IAEnB,IAAM,eAAe,GAAG,WAAW,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAE9D,IAAI,eAAe,EAAE;QACnB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,eAAQ,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,qFACP,eAAK,CAAC,IAAI,CAC5C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACxB,MAAG,CACL,CAAC;KACH;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAhBD,4CAgBC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CACvC,mBAA4B;IAE5B,KAAK,IAAI,CAAC,GAAG,mBAAmB,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7D,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,mBAAmB,EAAE;YAC5D,OAAO,CAAC,GAAG,CAAC,CAAC;SACd;KACF;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAVD,8DAUC;AAED,SAAgB,aAAa,CAAC,WAA2B;IACvD,OAAO,IAAA,kCAAmB,EAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;AAC/D,CAAC;AAFD,sCAEC","sourcesContent":["import type { Program } from '@babel/types';\n\nimport * as path from 'path';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { PackageDotJson, hasPackageInstalled } from '../utils/package-json';\n\n// Copied from sveltekit wizard\nexport function hasSentryContent(\n fileName: string,\n fileContent: string,\n): boolean {\n const includesContent = fileContent.includes('@sentry/remix');\n\n if (includesContent) {\n clack.log.warn(\n `File ${chalk.cyan(path.basename(fileName))} already contains Sentry code.\nSkipping adding Sentry functionality to ${chalk.cyan(\n path.basename(fileName),\n )}.`,\n );\n }\n\n return includesContent;\n}\n\n/**\n * We want to insert the init call on top of the file but after all import statements\n */\nexport function getInitCallInsertionIndex(\n originalHooksModAST: Program,\n): number {\n for (let x = originalHooksModAST.body.length - 1; x >= 0; x--) {\n if (originalHooksModAST.body[x].type === 'ImportDeclaration') {\n return x + 1;\n }\n }\n\n return 0;\n}\n\nexport function isHydrogenApp(packageJson: PackageDotJson): boolean {\n return hasPackageInstalled('@shopify/hydrogen', packageJson);\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/remix/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAA6B;AAE7B,+EAA+E;AAC/E,2DAAmC;AACnC,gDAA0B;AAC1B,sDAA4E;AAE/D,QAAA,qCAAqC,GAAG;IACnD,mBAAmB;IACnB,0BAA0B;CAC3B,CAAC;AAEF,SAAgB,gBAAgB,CAC9B,QAAgB,EAChB,WAAmB,EACnB,eAAiC;IAAjC,gCAAA,EAAA,iCAAiC;IAEjC,IAAM,eAAe,GAAG,WAAW,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAE9D,IAAI,eAAe,EAAE;QACnB,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,eAAQ,eAAK,CAAC,IAAI,CAChB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACxB,+BAAqB,eAAe,wDACD,eAAK,CAAC,IAAI,CAC5C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACxB,MAAG,CACL,CAAC;KACH;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAnBD,4CAmBC;AAED,SAAgB,8BAA8B,CAC5C,cAAsB,EAC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AC;AACX,CAAC;AAVD,sEAUC;AAED,SAAgB,aAAa,CAAC,WAA2B;IACvD,OAAO,IAAA,kCAAmB,EAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;AAC/D,CAAC;AAFD,sCAEC","sourcesContent":["import type { Program } from '@babel/types';\n\nimport * as path from 'path';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { PackageDotJson, hasPackageInstalled } from '../utils/package-json';\n\nexport const POSSIBLE_SERVER_INSTRUMENTATION_PATHS = [\n './instrumentation',\n './instrumentation.server',\n];\n\nexport function hasSentryContent(\n fileName: string,\n fileContent: string,\n expectedContent = '@sentry/remix',\n): boolean {\n const includesContent = fileContent.includes(expectedContent);\n\n if (includesContent) {\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(fileName),\n )} already contains ${expectedContent}.\nSkipping adding Sentry functionality to ${chalk.cyan(\n path.basename(fileName),\n )}.`,\n );\n }\n\n return includesContent;\n}\n\nexport function serverHasInstrumentationImport(\n serverFileName: string,\n serverFileContent: string,\n): boolean {\n const includesServerInstrumentationImport =\n POSSIBLE_SERVER_INSTRUMENTATION_PATHS.some((path) =>\n serverFileContent.includes(path),\n );\n\n if (includesServerInstrumentationImport) {\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(serverFileName),\n )} already contains instrumentation import.\nSkipping adding instrumentation functionality to ${chalk.cyan(\n path.basename(serverFileName),\n )}.`,\n );\n }\n\n return includesServerInstrumentationImport;\n}\n\n/**\n * We want to insert the init call on top of the file, before any other imports.\n */\nexport function getBeforeImportsInsertionIndex(\n originalHooksModAST: Program,\n): number {\n for (let x = 0; x < originalHooksModAST.body.length - 1; x++) {\n if (\n originalHooksModAST.body[x].type === 'ImportDeclaration' &&\n // @ts-expect-error - source is available in body\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n originalHooksModAST.body[x].source.value === '@sentry/remix'\n ) {\n return x + 1;\n }\n }\n\n return 0;\n}\n\n/**\n * We want to insert the handleError function just after all imports\n */\nexport function getAfterImportsInsertionIndex(\n originalEntryServerModAST: Program,\n): number {\n for (let x = originalEntryServerModAST.body.length - 1; x >= 0; x--) {\n if (originalEntryServerModAST.body[x].type === 'ImportDeclaration') {\n return x + 1;\n }\n }\n\n return 0;\n}\n\nexport function isHydrogenApp(packageJson: PackageDotJson): boolean {\n return hasPackageInstalled('@shopify/hydrogen', packageJson);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/wizard",
3
- "version": "3.23.2",
3
+ "version": "3.24.0",
4
4
  "homepage": "https://github.com/getsentry/sentry-wizard",
5
5
  "repository": "https://github.com/getsentry/sentry-wizard",
6
6
  "description": "Sentry wizard helping you to configure your project",
@@ -29,7 +29,7 @@
29
29
  "@sentry/node": "^7.69.0",
30
30
  "axios": "1.6.0",
31
31
  "chalk": "^2.4.1",
32
- "glob": "^7.1.3",
32
+ "glob": "^8.1.0",
33
33
  "inquirer": "^6.2.0",
34
34
  "lodash": "^4.17.15",
35
35
  "magicast": "^0.2.10",
@@ -244,7 +244,7 @@ export async function runNextjsWizardWithTelemetry(
244
244
 
245
245
  await fs.promises.writeFile(
246
246
  path.join(process.cwd(), ...appDirLocation, newGlobalErrorFileName),
247
- getSentryDefaultGlobalErrorPage(),
247
+ getSentryDefaultGlobalErrorPage(typeScriptDetected),
248
248
  { encoding: 'utf8', flag: 'w' },
249
249
  );
250
250
 
@@ -377,11 +377,35 @@ export function getInstrumentationHookCopyPasteSnippet(
377
377
  });
378
378
  }
379
379
 
380
- export function getSentryDefaultGlobalErrorPage() {
381
- return `"use client";
380
+ export function getSentryDefaultGlobalErrorPage(isTs: boolean) {
381
+ return isTs
382
+ ? `"use client";
382
383
 
383
384
  import * as Sentry from "@sentry/nextjs";
384
- import Error from "next/error";
385
+ import NextError from "next/error";
386
+ import { useEffect } from "react";
387
+
388
+ export default function GlobalError({ error }: { error: Error & { digest?: string } }) {
389
+ useEffect(() => {
390
+ Sentry.captureException(error);
391
+ }, [error]);
392
+
393
+ return (
394
+ <html>
395
+ <body>
396
+ {/* \`NextError\` is the default Next.js error page component. Its type
397
+ definition requires a \`statusCode\` prop. However, since the App Router
398
+ does not expose status codes for errors, we simply pass 0 to render a
399
+ generic error message. */}
400
+ <NextError statusCode={0} />
401
+ </body>
402
+ </html>
403
+ );
404
+ }`
405
+ : `"use client";
406
+
407
+ import * as Sentry from "@sentry/nextjs";
408
+ import NextError from "next/error";
385
409
  import { useEffect } from "react";
386
410
 
387
411
  export default function GlobalError({ error }) {
@@ -392,7 +416,11 @@ export default function GlobalError({ error }) {
392
416
  return (
393
417
  <html>
394
418
  <body>
395
- <Error />
419
+ {/* \`NextError\` is the default Next.js error page component. Its type
420
+ definition requires a \`statusCode\` prop. However, since the App Router
421
+ does not expose status codes for errors, we simply pass 0 to render a
422
+ generic error message. */}
423
+ <NextError statusCode={0} />
396
424
  </body>
397
425
  </html>
398
426
  );
@@ -1,4 +1,4 @@
1
- import glob from 'glob';
1
+ import * as glob from 'glob';
2
2
 
3
3
  export const XCODE_PROJECT = 'ios/*.xcodeproj/project.pbxproj';
4
4
  export const APP_BUILD_GRADLE = '**/app/build.gradle';
@@ -1,19 +1,9 @@
1
- // @ts-expect-error - clack is ESM and TS complains about that. It works though
2
- import clack from '@clack/prompts';
3
- import chalk from 'chalk';
4
- import * as recast from 'recast';
5
- import { visit } from 'ast-types';
6
1
  import {
7
- ProxifiedImportItem,
8
- generateCode,
9
2
  loadFile,
10
- writeFile,
11
3
  // @ts-expect-error - magicast is ESM and TS complains about that. It works though
12
4
  } from 'magicast';
13
- import type { Program } from '@babel/types';
14
5
  import * as fs from 'fs';
15
6
 
16
- import { getInitCallInsertionIndex, hasSentryContent } from '../utils';
17
7
  import { findFile } from '../../utils/ast-utils';
18
8
 
19
9
  // Try to find the Express server implementation that contains `createRequestHandler` from `@remix-run/express`
@@ -52,114 +42,3 @@ export async function findCustomExpressServerImplementation() {
52
42
 
53
43
  return null;
54
44
  }
55
-
56
- // Wrap createRequestHandler with `wrapExpressCreateRequestHandler` from `@sentry/remix`
57
- export async function instrumentExpressCreateRequestHandler(
58
- expressServerPath: string,
59
- ): Promise<boolean> {
60
- const originalExpressServerMod = await loadFile(expressServerPath);
61
-
62
- if (
63
- hasSentryContent(
64
- generateCode(originalExpressServerMod.$ast).code,
65
- originalExpressServerMod.$code,
66
- )
67
- ) {
68
- clack.log.warn(
69
- `Express server in ${chalk.cyan(
70
- expressServerPath,
71
- )} already has Sentry instrumentation. Skipping.`,
72
- );
73
-
74
- return false;
75
- }
76
-
77
- originalExpressServerMod.imports.$add({
78
- from: '@sentry/remix',
79
- imported: 'wrapExpressCreateRequestHandler',
80
- local: 'wrapExpressCreateRequestHandler',
81
- });
82
-
83
- const createRequestHandlerImport =
84
- originalExpressServerMod.imports.$items.find(
85
- (imp) =>
86
- imp.from === '@remix-run/express' &&
87
- imp.imported === 'createRequestHandler',
88
- );
89
-
90
- visit(originalExpressServerMod.$ast, {
91
- visitIdentifier(path) {
92
- if (
93
- path.value.name === 'createRequestHandler' &&
94
- path.parentPath.value.type === 'CallExpression'
95
- ) {
96
- path.value.name = 'sentryCreateRequestHandler';
97
- }
98
-
99
- this.traverse(path);
100
- },
101
- });
102
-
103
- // Insert the const declaration right after the imports
104
- // Where we want to insert the const declaration is the same as where we would want to insert the init call.
105
- const insertionIndex = getInitCallInsertionIndex(
106
- originalExpressServerMod.$ast as Program,
107
- );
108
-
109
- const createRequestHandlerConst = wrapCreateRequestHandlerWithSentry(
110
- createRequestHandlerImport,
111
- );
112
-
113
- if (!createRequestHandlerConst) {
114
- // Todo: throw error
115
- }
116
-
117
- (originalExpressServerMod.$ast as Program).body.splice(
118
- insertionIndex,
119
- 0,
120
- // @ts-expect-error - string works here because the AST is proxified by magicast
121
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
122
- createRequestHandlerConst,
123
- );
124
-
125
- try {
126
- await writeFile(originalExpressServerMod.$ast, expressServerPath);
127
-
128
- clack.log.info(
129
- `Successfully instrumented Express server in ${chalk.cyan(
130
- expressServerPath,
131
- )}.`,
132
- );
133
- } catch (e) {
134
- clack.log.warn(
135
- `Could not write to Express server in ${chalk.cyan(expressServerPath)}.`,
136
- );
137
-
138
- throw e;
139
- }
140
-
141
- return true;
142
- }
143
-
144
- // Wrap `createRequestHandler` with `wrapExpressCreateRequestHandler` and set const name to `sentryCreateRequestHandler`
145
- export function wrapCreateRequestHandlerWithSentry(
146
- createRequestHandlerImport: ProxifiedImportItem | undefined,
147
- ) {
148
- if (!createRequestHandlerImport) {
149
- return;
150
- }
151
-
152
- const createRequestHandler = createRequestHandlerImport.local;
153
-
154
- const wrapCreateRequestHandler = recast.types.builders.callExpression(
155
- recast.types.builders.identifier('wrapExpressCreateRequestHandler'),
156
- [recast.types.builders.identifier(createRequestHandler)],
157
- );
158
-
159
- return recast.types.builders.variableDeclaration('const', [
160
- recast.types.builders.variableDeclarator(
161
- recast.types.builders.identifier('sentryCreateRequestHandler'),
162
- wrapCreateRequestHandler,
163
- ),
164
- ]);
165
- }
@@ -7,7 +7,7 @@ import type { Program } from '@babel/types';
7
7
  import * as recast from 'recast';
8
8
 
9
9
  import { HANDLE_ERROR_TEMPLATE_V2 } from '../templates';
10
- import { getInitCallInsertionIndex, hasSentryContent } from '../utils';
10
+ import { getAfterImportsInsertionIndex, hasSentryContent } from '../utils';
11
11
 
12
12
  // @ts-expect-error - clack is ESM and TS complains about that. It works though
13
13
  import clack from '@clack/prompts';
@@ -41,7 +41,7 @@ export function instrumentHandleError(
41
41
  .body[0];
42
42
 
43
43
  originalEntryServerModAST.body.splice(
44
- getInitCallInsertionIndex(originalEntryServerModAST),
44
+ getAfterImportsInsertionIndex(originalEntryServerModAST),
45
45
  0,
46
46
  // @ts-expect-error - string works here because the AST is proxified by magicast
47
47
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@@ -51,6 +51,7 @@ export function instrumentHandleError(
51
51
  hasSentryContent(
52
52
  generateCode(handleErrorFunction).code,
53
53
  originalEntryServerMod.$code,
54
+ 'captureRemixServerException',
54
55
  )
55
56
  ) {
56
57
  return false;
@@ -18,13 +18,15 @@ import { hasPackageInstalled } from '../utils/package-json';
18
18
  import { WizardOptions } from '../utils/types';
19
19
  import {
20
20
  initializeSentryOnEntryClient,
21
- initializeSentryOnEntryServer,
21
+ instrumentSentryOnEntryServer,
22
22
  updateBuildScript,
23
23
  instrumentRootRoute,
24
24
  isRemixV2,
25
25
  loadRemixConfig,
26
26
  runRemixReveal,
27
- instrumentExpressServer,
27
+ insertServerInstrumentationFile,
28
+ createServerInstrumentationFile,
29
+ updateStartScript,
28
30
  } from './sdk-setup';
29
31
  import { debug } from '../utils/debug';
30
32
  import { traceStep, withTelemetry } from '../telemetry';
@@ -145,31 +147,57 @@ async function runRemixWizardWithTelemetry(
145
147
  }
146
148
  });
147
149
 
148
- await traceStep('Initialize Sentry on server entry', async () => {
150
+ let instrumentationFile = '';
151
+
152
+ await traceStep('Create server instrumentation file', async () => {
149
153
  try {
150
- await initializeSentryOnEntryServer(dsn, isV2, isTS);
154
+ instrumentationFile = await createServerInstrumentationFile(dsn);
151
155
  } catch (e) {
152
- clack.log.warn(`Could not initialize Sentry on server entry.
153
- Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);
156
+ clack.log.warn(
157
+ 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',
158
+ );
154
159
  debug(e);
155
160
  }
156
161
  });
157
162
 
158
- await traceStep('Instrument custom Express server', async () => {
159
- try {
160
- const hasExpressAdapter = hasPackageInstalled(
161
- '@remix-run/express',
162
- packageJson,
163
- );
163
+ let serverFileInstrumented = false;
164
164
 
165
- if (!hasExpressAdapter) {
166
- return;
165
+ await traceStep(
166
+ 'Create server instrumentation file and import it',
167
+ async () => {
168
+ try {
169
+ serverFileInstrumented = await insertServerInstrumentationFile(dsn);
170
+ } catch (e) {
171
+ clack.log.warn(
172
+ 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',
173
+ );
174
+ debug(e);
167
175
  }
176
+ },
177
+ );
168
178
 
169
- await instrumentExpressServer();
179
+ if (!serverFileInstrumented && instrumentationFile) {
180
+ await traceStep(
181
+ 'Update `start` script to import instrumentation file.',
182
+ async () => {
183
+ try {
184
+ await updateStartScript(instrumentationFile);
185
+ } catch (e) {
186
+ clack.log
187
+ .warn(`Could not automatically add Sentry initialization to server entry.
188
+ Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);
189
+ debug(e);
190
+ }
191
+ },
192
+ );
193
+ }
194
+
195
+ await traceStep('Instrument server `handleError`', async () => {
196
+ try {
197
+ await instrumentSentryOnEntryServer(isV2, isTS);
170
198
  } catch (e) {
171
- clack.log.warn(`Could not instrument custom Express server.
172
- Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/#custom-express-server`);
199
+ clack.log.warn(`Could not initialize Sentry on server entry.
200
+ Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);
173
201
  debug(e);
174
202
  }
175
203
  });
@@ -46,8 +46,6 @@ export function getSentryExamplePageContents(options: {
46
46
  : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;
47
47
 
48
48
  return `
49
- import * as Sentry from '@sentry/remix';
50
-
51
49
  export default function SentryExamplePage() {
52
50
  return (
53
51
  <div>