@sentry/wizard 6.0.0 → 6.1.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 +8 -0
- package/dist/e2e-tests/tests/angular-17.test.js +6 -0
- package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
- package/dist/e2e-tests/tests/angular-19.test.js +7 -1
- package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-14.test.js +5 -1
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +5 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +9 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +9 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +8 -2
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +15 -3
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/src/angular/angular-wizard.js +5 -0
- package/dist/src/angular/angular-wizard.js.map +1 -1
- package/dist/src/angular/codemods/main.d.ts +4 -1
- package/dist/src/angular/codemods/main.js +3 -0
- package/dist/src/angular/codemods/main.js.map +1 -1
- package/dist/src/angular/sdk-setup.d.ts +1 -0
- package/dist/src/angular/sdk-setup.js.map +1 -1
- package/dist/src/apple/xcode-manager.d.ts +5 -0
- package/dist/src/apple/xcode-manager.js +44 -40
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +5 -0
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +3 -0
- package/dist/src/nextjs/templates.js +15 -2
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.js +5 -0
- package/dist/src/nuxt/sdk-setup.js.map +1 -1
- package/dist/src/nuxt/templates.d.ts +1 -0
- package/dist/src/nuxt/templates.js +3 -2
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +5 -0
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/remix/sdk-setup.d.ts +5 -0
- package/dist/src/remix/sdk-setup.js +4 -0
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +11 -0
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/templates.d.ts +2 -0
- package/dist/src/sveltekit/templates.js +10 -0
- package/dist/src/sveltekit/templates.js.map +1 -1
- 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/nextjs/templates.test.js +119 -0
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/nuxt/templates.test.js +119 -0
- package/dist/test/nuxt/templates.test.js.map +1 -1
- package/dist/test/remix/client-entry.test.js +56 -0
- package/dist/test/remix/client-entry.test.js.map +1 -1
- package/dist/test/remix/server-instrumentation.test.js +37 -1
- package/dist/test/remix/server-instrumentation.test.js.map +1 -1
- package/dist/test/sveltekit/templates.test.js +67 -0
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/nuxt/sdk-setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,+EAA+E;AAC/E,sDAAwC;AACxC,qDAAuC;AACvC,kDAA0B;AAC1B,kFAAkF;AAClF,uCAAkD;AAClD,kFAAkF;AAClF,8CAAiD;AACjD,8CAAsB;AACtB,mCAAyC;AACzC,4CAAyC;AACzC,0CAOwB;AACxB,wDA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;KACF;AACH,CAAC;AAjED,4CAiEC;AAEM,KAAK,UAAU,qBAAqB,CACzC,kBAA+C;IAE/C,MAAM,+BAA+B,GACnC,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,SAAS,CAAC;IAEtE,IAAI,CAAC,+BAA+B,EAAE;QACpC,gFAAgF;QAChF,OAAO;KACR;IAED,MAAM,OAAO,GACX,+GAA+G,CAAC;IAElH,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,6CAA6C,eAAK,CAAC,IAAI,CACrD,UAAU,CACX,mFAAmF,eAAK,CAAC,SAAS,CACjG,OAAO,CACR,EAAE,CACJ,CAAC;IAEF,MAAM,cAAc,GAAG,MAAM,IAAA,wBAAgB,EAC3C,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC,CAC5D,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,8BAA8B,EAAE,cAAc,CAAC,CAAC;IAE9D,IAAI,cAAc,EAAE;QAClB,iGAAiG;QACjG,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,2DAA2D;QAClF,IAAA,aAAG,EAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;KACxE;AACH,CAAC;AAjCD,sDAiCC","sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, loadFile } from 'magicast';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { addNuxtModule } from 'magicast/helpers';\nimport opn from 'opn';\nimport { type SemVer, lt } from 'semver';\nimport { traceStep } from '../telemetry';\nimport {\n abortIfCancelled,\n askShouldAddPackageOverride,\n askShouldInstallPackage,\n featureSelectionPrompt,\n installPackage,\n isUsingTypeScript,\n} from '../utils/clack';\nimport {\n type PackageDotJson,\n hasPackageInstalled,\n} from '../utils/package-json';\nimport { PNPM, type PackageManager } from '../utils/package-manager';\nimport {\n getConfigBody,\n getDefaultNuxtConfig,\n getNuxtModuleFallbackTemplate,\n getSentryConfigContents,\n} from './templates';\nimport { type DeploymentPlatform, deploymentPlatforms } from './types';\n\nconst possibleNuxtConfig = [\n 'nuxt.config.js',\n 'nuxt.config.mjs',\n 'nuxt.config.cjs',\n 'nuxt.config.ts',\n 'nuxt.config.mts',\n 'nuxt.config.cts',\n];\n\nexport async function getNuxtConfig(): Promise<string> {\n let configFile = possibleNuxtConfig.find((fileName) =>\n fs.existsSync(path.join(process.cwd(), fileName)),\n );\n\n if (!configFile) {\n clack.log.info('No Nuxt config file found, creating a new one.');\n Sentry.setTag('nuxt-config-strategy', 'create');\n // nuxt recommends its config to be .ts by default\n configFile = 'nuxt.config.ts';\n\n await fs.promises.writeFile(\n path.join(process.cwd(), configFile),\n getDefaultNuxtConfig(),\n { encoding: 'utf-8', flag: 'w' },\n );\n\n clack.log.success(`Created ${chalk.cyan('nuxt.config.ts')}.`);\n }\n\n return path.join(process.cwd(), configFile);\n}\n\nexport async function askDeploymentPlatform(): Promise<\n DeploymentPlatform | symbol\n> {\n return await abortIfCancelled(\n clack.select({\n message: 'Please select your deployment platform.',\n options: deploymentPlatforms.map((platform) => ({\n value: platform,\n label: `${platform.charAt(0).toUpperCase()}${platform.slice(1)}`,\n })),\n }),\n );\n}\n\nexport async function addSDKModule(\n config: string,\n options: { org: string; project: string; url: string; selfHosted: boolean },\n deploymentPlatform: DeploymentPlatform | symbol,\n): Promise<void> {\n const failureTagKey = 'modify-nuxt-config-error';\n\n const shouldTopLevelImport =\n deploymentPlatform === 'vercel' || deploymentPlatform === 'netlify';\n\n if (shouldTopLevelImport) {\n clack.log.warn(\n `Sentry needs to be initialized before the application starts. ${chalk.cyan(\n `${deploymentPlatform\n .charAt(0)\n .toUpperCase()}${deploymentPlatform.slice(1)}`,\n )} does not support this yet.\\n\\nWe will inject the Sentry server-side config at the top of your Nuxt server entry file instead.\\n\\nThis comes with some restrictions, for more info see:\\n\\n${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/install/top-level-import/',\n )} `,\n );\n }\n\n let module;\n\n try {\n module = await loadFile(config);\n } catch (e) {\n if (e instanceof Error) {\n if (e instanceof SyntaxError || e.message.includes('Unexpected token')) {\n Sentry.setTag(failureTagKey, 'loadFile-failed-syntax-error');\n } else if (\n e.message.includes('ENOENT') ||\n e.message.includes('no such file')\n ) {\n Sentry.setTag(failureTagKey, 'loadFile-failed-file-not-found');\n }\n } else {\n Sentry.setTag(failureTagKey, 'loadFile-failed');\n }\n\n clack.log.error(\n `Error while loading Nuxt config file: ${\n e instanceof Error ? e.message : 'Unknown'\n }`,\n );\n\n showFallbackInstructions(config, options, shouldTopLevelImport);\n throw e;\n }\n\n try {\n addNuxtModule(module, '@sentry/nuxt/module', 'sentry', {\n sourceMapsUploadOptions: {\n org: options.org,\n project: options.project,\n ...(options.selfHosted && { url: options.url }),\n },\n ...(shouldTopLevelImport && {\n autoInjectServerSentry: 'top-level-import',\n }),\n });\n } catch (e) {\n Sentry.setTag(failureTagKey, 'adding-sentry-options-failed');\n\n clack.log.error(\n `Error while modifying 'sentry' in Nuxt config: ${\n e instanceof Error ? e.message : 'Unknown'\n }`,\n );\n\n showFallbackInstructions(config, options, shouldTopLevelImport);\n throw e;\n }\n\n try {\n addNuxtModule(module, '@sentry/nuxt/module', 'sourcemap', {\n client: 'hidden',\n });\n } catch (e) {\n Sentry.setTag(failureTagKey, 'adding-sourcemap-options-failed');\n\n clack.log.error(\n `Error while modifying 'sourcemap' in Nuxt config: ${\n e instanceof Error ? e.message : 'Unknown'\n }`,\n );\n\n showFallbackInstructions(config, options, shouldTopLevelImport);\n throw e;\n }\n\n let code;\n\n try {\n ({ code } = generateCode(module));\n } catch (e) {\n Sentry.setTag(failureTagKey, 'generateCode-failed');\n\n clack.log.error(\n `Error while generating module code: ${\n e instanceof Error ? e.message : 'Unknown'\n }`,\n );\n\n showFallbackInstructions(config, options, shouldTopLevelImport);\n throw e;\n }\n\n try {\n await fs.promises.writeFile(config, code, { encoding: 'utf-8', flag: 'w' });\n\n clack.log.success(\n `Added Sentry Nuxt Module to ${chalk.cyan(path.basename(config))}.`,\n );\n } catch (e: unknown) {\n Sentry.setTag(failureTagKey, 'writeFile-failed');\n\n clack.log.error(\n `Error while writing Nuxt config: ${\n e instanceof Error ? e.message : 'Unknown'\n }`,\n );\n\n showFallbackInstructions(config, options, shouldTopLevelImport);\n throw e;\n }\n}\n\nfunction showFallbackInstructions(\n config: string,\n options: { org: string; project: string; url: string; selfHosted: boolean },\n shouldTopLevelImport: boolean,\n) {\n clack.log.warn(\n `Please add the following settings to ${chalk.cyan(\n path.basename(config),\n )}:`,\n );\n // eslint-disable-next-line no-console\n console.log(\n `\\n\\n${getNuxtModuleFallbackTemplate(options, shouldTopLevelImport)}\\n\\n`,\n );\n}\n\nexport async function createConfigFiles(dsn: string) {\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', 'client'] as const;\n\n for (const configVariant of configVariants) {\n await traceStep(`create-sentry-${configVariant}-config`, async () => {\n const jsConfig = `sentry.${configVariant}.config.js`;\n const tsConfig = `sentry.${configVariant}.config.ts`;\n\n const jsConfigExists = fs.existsSync(path.join(process.cwd(), jsConfig));\n const tsConfigExists = fs.existsSync(path.join(process.cwd(), tsConfig));\n\n let shouldWriteFile = true;\n\n if (jsConfigExists || tsConfigExists) {\n const existingConfigs = [];\n\n if (jsConfigExists) {\n existingConfigs.push(jsConfig);\n }\n\n if (tsConfigExists) {\n existingConfigs.push(tsConfig);\n }\n\n const overwriteExistingConfigs = await abortIfCancelled(\n clack.confirm({\n message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(\n ', ',\n )}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,\n }),\n );\n Sentry.setTag(\n `overwrite-${configVariant}-config`,\n overwriteExistingConfigs,\n );\n\n shouldWriteFile = overwriteExistingConfigs;\n\n if (overwriteExistingConfigs) {\n if (jsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), jsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(jsConfig)}.`);\n }\n if (tsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), tsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(tsConfig)}.`);\n }\n }\n }\n\n if (shouldWriteFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig),\n getSentryConfigContents(dsn, configVariant, selectedFeatures),\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created new ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )}.`,\n );\n Sentry.setTag(`created-${configVariant}-config`, true);\n } else {\n clack.log.info(\n `Okay, here are the changes your ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )} should contain:`,\n );\n // eslint-disable-next-line no-console\n console.log(\n '\\n\\n ' +\n getConfigBody(dsn, configVariant, selectedFeatures) +\n '\\n\\n',\n );\n }\n });\n }\n}\n\nexport async function addNuxtOverrides(\n packageJson: PackageDotJson,\n packageManager: PackageManager,\n nuxtMinVer: SemVer | null,\n forceInstall?: boolean,\n) {\n const isPNPM = PNPM.detect();\n\n const overrides = [\n {\n pkgName: '@vercel/nft',\n pkgVersion: '^0.27.4',\n },\n ...(nuxtMinVer && lt(nuxtMinVer, '3.14.0')\n ? [{ pkgName: 'ofetch', pkgVersion: '^1.4.0' }]\n : []),\n ];\n\n clack.log.warn(\n `To ensure Sentry can properly instrument your code it needs to add version overrides for some Nuxt dependencies${\n isPNPM ? ` and install ${chalk.cyan('import-in-the-middle')}.` : '.'\n }\\n\\nFor more info see: ${chalk.underline(\n 'https://github.com/getsentry/sentry-javascript/issues/14514',\n )}${\n isPNPM\n ? `\\n\\nand ${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#pnpm-dev-cannot-find-package-import-in-the-middle',\n )}`\n : ''\n }`,\n );\n\n for (const { pkgName, pkgVersion } of overrides) {\n const shouldAddOverride = await askShouldAddPackageOverride(\n pkgName,\n pkgVersion,\n );\n\n if (shouldAddOverride) {\n await packageManager.addOverride(pkgName, pkgVersion);\n }\n }\n\n if (PNPM.detect()) {\n // For pnpm, we want to install iitm\n // See: https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#pnpm-dev-cannot-find-package-import-in-the-middle\n const iitmAlreadyInstalled = hasPackageInstalled(\n 'import-in-the-middle',\n packageJson,\n );\n Sentry.setTag('iitm-already-installed', iitmAlreadyInstalled);\n\n const shouldInstallIitm = await askShouldInstallPackage(\n 'import-in-the-middle',\n );\n\n if (shouldInstallIitm) {\n await installPackage({\n packageName: 'import-in-the-middle',\n alreadyInstalled: iitmAlreadyInstalled,\n packageManager,\n forceInstall,\n });\n }\n }\n}\n\nexport async function confirmReadImportDocs(\n deploymentPlatform: DeploymentPlatform | symbol,\n) {\n const canImportSentryServerConfigFile =\n deploymentPlatform !== 'vercel' && deploymentPlatform !== 'netlify';\n\n if (!canImportSentryServerConfigFile) {\n // Nothing to do, users have been set up with automatic top-level-import instead\n return;\n }\n\n const docsUrl =\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/install/cli-import/#initializing-sentry-with---import';\n\n clack.log.info(\n `After building your Nuxt app, you need to ${chalk.bold(\n '--import',\n )} the Sentry server config file when running your app.\\n\\nFor more info, see:\\n\\n${chalk.underline(\n docsUrl,\n )}`,\n );\n\n const shouldOpenDocs = await abortIfCancelled(\n clack.confirm({ message: 'Do you want to open the docs?' }),\n );\n\n Sentry.setTag('init-with-import-docs-opened', shouldOpenDocs);\n\n if (shouldOpenDocs) {\n // opn throws in environments that don't have a browser (e.g. remote shells) so we just noop here\n const noop = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function\n opn(docsUrl, { wait: false }).then((cp) => cp.on('error', noop), noop);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/nuxt/sdk-setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,+EAA+E;AAC/E,sDAAwC;AACxC,qDAAuC;AACvC,kDAA0B;AAC1B,kFAAkF;AAClF,uCAAkD;AAClD,kFAAkF;AAClF,8CAAiD;AACjD,8CAAsB;AACtB,mCAAyC;AACzC,4CAAyC;AACzC,0CAOwB;AACxB,wDAG+B;AAC/B,8DAAqE;AACrE,2CAKqB;AACrB,mCAAuE;AAEvE,MAAM,kBAAkB,GAAG;IACzB,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;CAClB,CAAC;AAEK,KAAK,UAAU,aAAa;IACjC,IAAI,UAAU,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACpD,iBAAE,CAAC,UAAU,CAAC,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC,CAClD,CAAC;IAEF,IAAI,CAAC,UAAU,EAAE;QACf,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QACjE,MAAM,CAAC,MAAM,CAAC,sBAAsB,EAAE,QAAQ,C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AAM,cAAc,GAAG,MAAM,IAAA,wBAAgB,EAC3C,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC,CAC5D,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC,8BAA8B,EAAE,cAAc,CAAC,CAAC;IAE9D,IAAI,cAAc,EAAE;QAClB,iGAAiG;QACjG,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,2DAA2D;QAClF,IAAA,aAAG,EAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;KACxE;AACH,CAAC;AAjCD,sDAiCC","sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, loadFile } from 'magicast';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { addNuxtModule } from 'magicast/helpers';\nimport opn from 'opn';\nimport { type SemVer, lt } from 'semver';\nimport { traceStep } from '../telemetry';\nimport {\n abortIfCancelled,\n askShouldAddPackageOverride,\n askShouldInstallPackage,\n featureSelectionPrompt,\n installPackage,\n isUsingTypeScript,\n} from '../utils/clack';\nimport {\n type PackageDotJson,\n hasPackageInstalled,\n} from '../utils/package-json';\nimport { PNPM, type PackageManager } from '../utils/package-manager';\nimport {\n getConfigBody,\n getDefaultNuxtConfig,\n getNuxtModuleFallbackTemplate,\n getSentryConfigContents,\n} from './templates';\nimport { type DeploymentPlatform, deploymentPlatforms } from './types';\n\nconst possibleNuxtConfig = [\n 'nuxt.config.js',\n 'nuxt.config.mjs',\n 'nuxt.config.cjs',\n 'nuxt.config.ts',\n 'nuxt.config.mts',\n 'nuxt.config.cts',\n];\n\nexport async function getNuxtConfig(): Promise<string> {\n let configFile = possibleNuxtConfig.find((fileName) =>\n fs.existsSync(path.join(process.cwd(), fileName)),\n );\n\n if (!configFile) {\n clack.log.info('No Nuxt config file found, creating a new one.');\n Sentry.setTag('nuxt-config-strategy', 'create');\n // nuxt recommends its config to be .ts by default\n configFile = 'nuxt.config.ts';\n\n await fs.promises.writeFile(\n path.join(process.cwd(), configFile),\n getDefaultNuxtConfig(),\n { encoding: 'utf-8', flag: 'w' },\n );\n\n clack.log.success(`Created ${chalk.cyan('nuxt.config.ts')}.`);\n }\n\n return path.join(process.cwd(), configFile);\n}\n\nexport async function askDeploymentPlatform(): Promise<\n DeploymentPlatform | symbol\n> {\n return await abortIfCancelled(\n clack.select({\n message: 'Please select your deployment platform.',\n options: deploymentPlatforms.map((platform) => ({\n value: platform,\n label: `${platform.charAt(0).toUpperCase()}${platform.slice(1)}`,\n })),\n }),\n );\n}\n\nexport async function addSDKModule(\n config: string,\n options: { org: string; project: string; url: string; selfHosted: boolean },\n deploymentPlatform: DeploymentPlatform | symbol,\n): Promise<void> {\n const failureTagKey = 'modify-nuxt-config-error';\n\n const shouldTopLevelImport =\n deploymentPlatform === 'vercel' || deploymentPlatform === 'netlify';\n\n if (shouldTopLevelImport) {\n clack.log.warn(\n `Sentry needs to be initialized before the application starts. ${chalk.cyan(\n `${deploymentPlatform\n .charAt(0)\n .toUpperCase()}${deploymentPlatform.slice(1)}`,\n )} does not support this yet.\\n\\nWe will inject the Sentry server-side config at the top of your Nuxt server entry file instead.\\n\\nThis comes with some restrictions, for more info see:\\n\\n${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/install/top-level-import/',\n )} `,\n );\n }\n\n let module;\n\n try {\n module = await loadFile(config);\n } catch (e) {\n if (e instanceof Error) {\n if (e instanceof SyntaxError || e.message.includes('Unexpected token')) {\n Sentry.setTag(failureTagKey, 'loadFile-failed-syntax-error');\n } else if (\n e.message.includes('ENOENT') ||\n e.message.includes('no such file')\n ) {\n Sentry.setTag(failureTagKey, 'loadFile-failed-file-not-found');\n }\n } else {\n Sentry.setTag(failureTagKey, 'loadFile-failed');\n }\n\n clack.log.error(\n `Error while loading Nuxt config file: ${\n e instanceof Error ? e.message : 'Unknown'\n }`,\n );\n\n showFallbackInstructions(config, options, shouldTopLevelImport);\n throw e;\n }\n\n try {\n addNuxtModule(module, '@sentry/nuxt/module', 'sentry', {\n sourceMapsUploadOptions: {\n org: options.org,\n project: options.project,\n ...(options.selfHosted && { url: options.url }),\n },\n ...(shouldTopLevelImport && {\n autoInjectServerSentry: 'top-level-import',\n }),\n });\n } catch (e) {\n Sentry.setTag(failureTagKey, 'adding-sentry-options-failed');\n\n clack.log.error(\n `Error while modifying 'sentry' in Nuxt config: ${\n e instanceof Error ? e.message : 'Unknown'\n }`,\n );\n\n showFallbackInstructions(config, options, shouldTopLevelImport);\n throw e;\n }\n\n try {\n addNuxtModule(module, '@sentry/nuxt/module', 'sourcemap', {\n client: 'hidden',\n });\n } catch (e) {\n Sentry.setTag(failureTagKey, 'adding-sourcemap-options-failed');\n\n clack.log.error(\n `Error while modifying 'sourcemap' in Nuxt config: ${\n e instanceof Error ? e.message : 'Unknown'\n }`,\n );\n\n showFallbackInstructions(config, options, shouldTopLevelImport);\n throw e;\n }\n\n let code;\n\n try {\n ({ code } = generateCode(module));\n } catch (e) {\n Sentry.setTag(failureTagKey, 'generateCode-failed');\n\n clack.log.error(\n `Error while generating module code: ${\n e instanceof Error ? e.message : 'Unknown'\n }`,\n );\n\n showFallbackInstructions(config, options, shouldTopLevelImport);\n throw e;\n }\n\n try {\n await fs.promises.writeFile(config, code, { encoding: 'utf-8', flag: 'w' });\n\n clack.log.success(\n `Added Sentry Nuxt Module to ${chalk.cyan(path.basename(config))}.`,\n );\n } catch (e: unknown) {\n Sentry.setTag(failureTagKey, 'writeFile-failed');\n\n clack.log.error(\n `Error while writing Nuxt config: ${\n e instanceof Error ? e.message : 'Unknown'\n }`,\n );\n\n showFallbackInstructions(config, options, shouldTopLevelImport);\n throw e;\n }\n}\n\nfunction showFallbackInstructions(\n config: string,\n options: { org: string; project: string; url: string; selfHosted: boolean },\n shouldTopLevelImport: boolean,\n) {\n clack.log.warn(\n `Please add the following settings to ${chalk.cyan(\n path.basename(config),\n )}:`,\n );\n // eslint-disable-next-line no-console\n console.log(\n `\\n\\n${getNuxtModuleFallbackTemplate(options, shouldTopLevelImport)}\\n\\n`,\n );\n}\n\nexport async function createConfigFiles(dsn: string) {\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n '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 ] as const);\n\n const typeScriptDetected = isUsingTypeScript();\n\n const configVariants = ['server', 'client'] as const;\n\n for (const configVariant of configVariants) {\n await traceStep(`create-sentry-${configVariant}-config`, async () => {\n const jsConfig = `sentry.${configVariant}.config.js`;\n const tsConfig = `sentry.${configVariant}.config.ts`;\n\n const jsConfigExists = fs.existsSync(path.join(process.cwd(), jsConfig));\n const tsConfigExists = fs.existsSync(path.join(process.cwd(), tsConfig));\n\n let shouldWriteFile = true;\n\n if (jsConfigExists || tsConfigExists) {\n const existingConfigs = [];\n\n if (jsConfigExists) {\n existingConfigs.push(jsConfig);\n }\n\n if (tsConfigExists) {\n existingConfigs.push(tsConfig);\n }\n\n const overwriteExistingConfigs = await abortIfCancelled(\n clack.confirm({\n message: `Found existing Sentry ${configVariant} config (${existingConfigs.join(\n ', ',\n )}). Overwrite ${existingConfigs.length > 1 ? 'them' : 'it'}?`,\n }),\n );\n Sentry.setTag(\n `overwrite-${configVariant}-config`,\n overwriteExistingConfigs,\n );\n\n shouldWriteFile = overwriteExistingConfigs;\n\n if (overwriteExistingConfigs) {\n if (jsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), jsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(jsConfig)}.`);\n }\n if (tsConfigExists) {\n fs.unlinkSync(path.join(process.cwd(), tsConfig));\n clack.log.warn(`Removed existing ${chalk.cyan(tsConfig)}.`);\n }\n }\n }\n\n if (shouldWriteFile) {\n await fs.promises.writeFile(\n path.join(process.cwd(), typeScriptDetected ? tsConfig : jsConfig),\n getSentryConfigContents(dsn, configVariant, selectedFeatures),\n { encoding: 'utf8', flag: 'w' },\n );\n clack.log.success(\n `Created new ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )}.`,\n );\n Sentry.setTag(`created-${configVariant}-config`, true);\n } else {\n clack.log.info(\n `Okay, here are the changes your ${chalk.cyan(\n typeScriptDetected ? tsConfig : jsConfig,\n )} should contain:`,\n );\n // eslint-disable-next-line no-console\n console.log(\n '\\n\\n ' +\n getConfigBody(dsn, configVariant, selectedFeatures) +\n '\\n\\n',\n );\n }\n });\n }\n}\n\nexport async function addNuxtOverrides(\n packageJson: PackageDotJson,\n packageManager: PackageManager,\n nuxtMinVer: SemVer | null,\n forceInstall?: boolean,\n) {\n const isPNPM = PNPM.detect();\n\n const overrides = [\n {\n pkgName: '@vercel/nft',\n pkgVersion: '^0.27.4',\n },\n ...(nuxtMinVer && lt(nuxtMinVer, '3.14.0')\n ? [{ pkgName: 'ofetch', pkgVersion: '^1.4.0' }]\n : []),\n ];\n\n clack.log.warn(\n `To ensure Sentry can properly instrument your code it needs to add version overrides for some Nuxt dependencies${\n isPNPM ? ` and install ${chalk.cyan('import-in-the-middle')}.` : '.'\n }\\n\\nFor more info see: ${chalk.underline(\n 'https://github.com/getsentry/sentry-javascript/issues/14514',\n )}${\n isPNPM\n ? `\\n\\nand ${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#pnpm-dev-cannot-find-package-import-in-the-middle',\n )}`\n : ''\n }`,\n );\n\n for (const { pkgName, pkgVersion } of overrides) {\n const shouldAddOverride = await askShouldAddPackageOverride(\n pkgName,\n pkgVersion,\n );\n\n if (shouldAddOverride) {\n await packageManager.addOverride(pkgName, pkgVersion);\n }\n }\n\n if (PNPM.detect()) {\n // For pnpm, we want to install iitm\n // See: https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#pnpm-dev-cannot-find-package-import-in-the-middle\n const iitmAlreadyInstalled = hasPackageInstalled(\n 'import-in-the-middle',\n packageJson,\n );\n Sentry.setTag('iitm-already-installed', iitmAlreadyInstalled);\n\n const shouldInstallIitm = await askShouldInstallPackage(\n 'import-in-the-middle',\n );\n\n if (shouldInstallIitm) {\n await installPackage({\n packageName: 'import-in-the-middle',\n alreadyInstalled: iitmAlreadyInstalled,\n packageManager,\n forceInstall,\n });\n }\n }\n}\n\nexport async function confirmReadImportDocs(\n deploymentPlatform: DeploymentPlatform | symbol,\n) {\n const canImportSentryServerConfigFile =\n deploymentPlatform !== 'vercel' && deploymentPlatform !== 'netlify';\n\n if (!canImportSentryServerConfigFile) {\n // Nothing to do, users have been set up with automatic top-level-import instead\n return;\n }\n\n const docsUrl =\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/install/cli-import/#initializing-sentry-with---import';\n\n clack.log.info(\n `After building your Nuxt app, you need to ${chalk.bold(\n '--import',\n )} the Sentry server config file when running your app.\\n\\nFor more info, see:\\n\\n${chalk.underline(\n docsUrl,\n )}`,\n );\n\n const shouldOpenDocs = await abortIfCancelled(\n clack.confirm({ message: 'Do you want to open the docs?' }),\n );\n\n Sentry.setTag('init-with-import-docs-opened', shouldOpenDocs);\n\n if (shouldOpenDocs) {\n // opn throws in environments that don't have a browser (e.g. remote shells) so we just noop here\n const noop = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function\n opn(docsUrl, { wait: false }).then((cp) => cp.on('error', noop), noop);\n }\n}\n"]}
|
|
@@ -49,10 +49,11 @@ const featuresConfigMap = {
|
|
|
49
49
|
" // If you don't want to use Session Replay, just remove the line below:",
|
|
50
50
|
' integrations: [Sentry.replayIntegration()],',
|
|
51
51
|
].join('\n'),
|
|
52
|
+
logs: [' // Enable logs to be sent to Sentry', ' enableLogs: true,'].join('\n'),
|
|
52
53
|
};
|
|
53
54
|
const featuresMap = {
|
|
54
|
-
client: ['performance', 'replay'],
|
|
55
|
-
server: ['performance'],
|
|
55
|
+
client: ['performance', 'replay', 'logs'],
|
|
56
|
+
server: ['performance', 'logs'],
|
|
56
57
|
};
|
|
57
58
|
function getConfigBody(dsn, variant, selectedFeatures) {
|
|
58
59
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nuxt/templates.ts"],"names":[],"mappings":";;;AAAA,sCAAiD;AAOjD,SAAgB,oBAAoB;IAClC,OAAO;;;;;CAKR,CAAC;AACF,CAAC;AAPD,oDAOC;AAED,SAAgB,6BAA6B,CAC3C,OAKC,EACD,oBAA6B;IAE7B,OAAO;;;cAGK,OAAO,CAAC,GAAG;kBACP,OAAO,CAAC,OAAO,KAC7B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAC1D;QAEI,oBAAoB;QAClB,CAAC,CAAC,mDAAmD;QACrD,CAAC,CAAC,EACN;;mCAE+B,CAAC;AACpC,CAAC;AAvBD,sEAuBC;AAED,SAAgB,uBAAuB,CACrC,GAAW,EACX,MAA2B,EAC3B,gBAAwC;IAExC,IAAI,MAAM,KAAK,QAAQ,EAAE;QACvB,OAAO,6BAA6B,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;KAC7D;IAED,OAAO,6BAA6B,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;AAC9D,CAAC;AAVD,0DAUC;AAED,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AE,gBAAgB,CAAC;;;;;CAKjD,CAAC;AACF,CAAC;AAED,SAAgB,qBAAqB;IACnC,OAAO;;;;;sBAKa,CAAC;AACvB,CAAC;AAPD,sDAOC;AAED,SAAgB,4BAA4B,CAAC,OAI5C;IACC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,cAAc,GAAG,IAAA,uBAAiB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAE3E,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mGA4D0F,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiKhH,CAAC;AACF,CAAC;AAtOD,oEAsOC;AAED,SAAgB,2BAA2B;IACzC,OAAO;;;;;;;CAOR,CAAC;AACF,CAAC;AATD,kEASC;AAED,SAAgB,4BAA4B;IAC1C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ER,CAAC;AACF,CAAC;AA/ED,oEA+EC","sourcesContent":["import { getIssueStreamUrl } from '../utils/url';\n\ntype SelectedSentryFeatures = {\n performance: boolean;\n replay: boolean;\n};\n\nexport function getDefaultNuxtConfig(): string {\n return `// https://nuxt.com/docs/api/configuration/nuxt-config\nexport default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n})\n`;\n}\n\nexport function getNuxtModuleFallbackTemplate(\n options: {\n org: string;\n project: string;\n url: string;\n selfHosted: boolean;\n },\n shouldTopLevelImport: boolean,\n): string {\n return ` modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"${options.org}\",\n project: \"${options.project}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n },${\n shouldTopLevelImport\n ? `\\n autoInjectServerSentry: \"top-level-import\",`\n : ''\n }\n },\n sourcemap: { client: \"hidden\" },`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n): string {\n if (config === 'client') {\n return getSentryClientConfigContents(dsn, selectedFeatures);\n }\n\n return getSentryServerConfigContents(dsn, selectedFeatures);\n}\n\nconst featuresConfigMap: Record<keyof SelectedSentryFeatures, string> = {\n performance: [\n ' // We recommend adjusting this value in production, or using tracesSampler',\n ' // for finer control',\n ' tracesSampleRate: 1.0,',\n ].join('\\n'),\n replay: [\n ' // This sets the sample rate to be 10%. You may want this to be 100% while',\n ' // in development and sample at a lower rate in production',\n ' replaysSessionSampleRate: 0.1,',\n ' ',\n ' // If the entire session is not sampled, use the below sample rate to sample',\n ' // sessions when an error occurs.',\n ' replaysOnErrorSampleRate: 1.0,',\n ' ',\n \" // If you don't want to use Session Replay, just remove the line below:\",\n ' integrations: [Sentry.replayIntegration()],',\n ].join('\\n'),\n};\n\nconst featuresMap: Record<\n 'client' | 'server',\n Array<keyof SelectedSentryFeatures>\n> = {\n client: ['performance', 'replay'],\n server: ['performance'],\n};\n\nexport function getConfigBody(\n dsn: string,\n variant: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n) {\n return [\n `dsn: \"${dsn}\",`,\n Object.entries(selectedFeatures)\n .map(([feature, activated]: [keyof SelectedSentryFeatures, boolean]) => {\n return featuresMap[variant].includes(feature) && activated\n ? featuresConfigMap[feature]\n : null;\n })\n .filter(Boolean)\n .join('\\n\\n'),\n ]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\nfunction getSentryClientConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n\nSentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n ${getConfigBody(dsn, 'client', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nfunction getSentryServerConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n \nSentry.init({\n ${getConfigBody(dsn, 'server', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getIndexRouteTemplate(): string {\n return `<!--\nThis is just to verify the sentry-example-page.\nFeel free to delete this file.\n-->\n\n<template></template>`;\n}\n\nexport function getSentryExamplePageTemplate(options: {\n url: string;\n org: string;\n projectId: string;\n}): string {\n const { url, org, projectId } = options;\n const issuesPageLink = getIssueStreamUrl({ url, orgSlug: org, projectId });\n\n return `<!--\nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n\n class SentryExampleFrontendError extends Error {\n constructor(message) {\n super(message);\n this.name = \"SentryExampleFrontendError\";\n }\n }\n\n const hasSentError = ref(false);\n const isConnected = ref(true);\n \n onMounted(async () => {\n try {\n const result = await Sentry.diagnoseSdkConnectivity();\n isConnected.value = result !== 'sentry-unreachable';\n } catch (error) {\n isConnected.value = false;\n }\n });\n \n async function getSentryData() {\n await Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const res = await $fetch('/api/sentry-example-api', { \n method: 'GET',\n ignoreResponseError: true \n }).catch(() => null);\n if (!res) {\n hasSentError.value = true;\n }\n }\n );\n throw new SentryExampleFrontendError(\"This error is raised on the frontend of the example page.\");\n }\n</script>\n\n<template>\n <title>Sentry Onboarding</title>\n <div>\n <main>\n <div class=\"flex-spacer\" />\n <svg height=\"40\" width=\"40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z\" fill=\"currentcolor\"/>\n </svg>\n <h1>\n sentry-example-page\n </h1>\n\n <p class=\"description\">\n Click the button below, and view the sample error on the Sentry <a target=\"_blank\" href=\"${issuesPageLink}\">Issues Page</a>.\n For more details about setting up Sentry, <a target=\"_blank\" href=\"https://docs.sentry.io/platforms/javascript/guides/nuxt/\">read our docs</a>.\n </p>\n\n <button\n type=\"button\"\n @click=\"getSentryData\"\n :disabled=\"!isConnected\"\n >\n <span>\n Throw Sample Error\n </span>\n </button>\n\n <p v-if=\"hasSentError\" class=\"success\">\n Sample error was sent to Sentry.\n </p>\n <div v-else-if=\"!isConnected\" class=\"connectivity-error\">\n <p>It looks like network requests to Sentry are being blocked, which will prevent errors from being captured. Try disabling your ad-blocker to complete the test.</p>\n </div>\n <div v-else class=\"success_placeholder\" />\n\n <div class=\"flex-spacer\" />\n </main>\n </div>\n</template>\n\n<style scoped>\n :global(body) {\n margin: 0;\n\n @media (prefers-color-scheme: dark) {\n color: #ededed;\n background-color: #0a0a0a;\n }\n }\n\n main {\n display: flex;\n min-height: 100vh;\n box-sizing: border-box;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 16px;\n padding: 16px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n\n h1 {\n padding: 0px 4px;\n margin: 0;\n border-radius: 4px;\n background-color: rgba(24, 20, 35, 0.03);\n font-family: monospace;\n font-size: 20px;\n line-height: 1.2;\n }\n\n p {\n margin: 0;\n font-size: 20px;\n }\n\n a {\n color: #6341F0;\n text-decoration: underline;\n cursor: pointer;\n\n @media (prefers-color-scheme: dark) {\n color: #B3A1FF;\n }\n }\n\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0); \n }\n\n &:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n\n & > span {\n transform: translateY(0);\n border: none;\n }\n }\n }\n\n .description {\n text-align: center;\n color: #6E6C75;\n max-width: 500px;\n line-height: 1.5;\n font-size: 20px;\n\n @media (prefers-color-scheme: dark) {\n color: #A49FB5;\n }\n }\n\n .flex-spacer {\n flex: 1;\n }\n\n .success {\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n }\n\n .success_placeholder {\n height: 46px;\n }\n \n .connectivity-error {\n padding: 12px 16px;\n background-color: #E50045;\n border-radius: 8px;\n width: 500px;\n color: #FFFFFF;\n border: 1px solid #A80033;\n text-align: center;\n margin: 0;\n }\n \n .connectivity-error a {\n color: #FFFFFF;\n text-decoration: underline;\n }\n</style>\n\n`;\n}\n\nexport function getSentryExampleApiTemplate() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(() => {\n throw new Error(\"Sentry Example API Route Error\");\n});\n`;\n}\n\nexport function getSentryErrorButtonTemplate() {\n return `<!--\nThis is just a very simple component that throws an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n\n const hasSentError = ref(false);\n \n const throwError = () => {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n () => {\n hasSentError.value = true;\n throw new Error('Sentry Example Error');\n }\n )\n };\n</script>\n\n<template>\n <div v-if=\"hasSentError\" class=\"success\">\n Sample error was sent to Sentry.\n </div>\n <button v-else @click=\"throwError\">\n <span>Throw Sample Error</span>\n </button>\n</template>\n\n<style scoped>\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0);\n }\n }\n\n .success {\n width: max-content;\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n</style>\n`;\n}\n"]}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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mGA4D0F,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiKhH,CAAC;AACF,CAAC;AAtOD,oEAsOC;AAED,SAAgB,2BAA2B;IACzC,OAAO;;;;;;;CAOR,CAAC;AACF,CAAC;AATD,kEASC;AAED,SAAgB,4BAA4B;IAC1C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ER,CAAC;AACF,CAAC;AA/ED,oEA+EC","sourcesContent":["import { getIssueStreamUrl } from '../utils/url';\n\ntype SelectedSentryFeatures = {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n};\n\nexport function getDefaultNuxtConfig(): string {\n return `// https://nuxt.com/docs/api/configuration/nuxt-config\nexport default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n})\n`;\n}\n\nexport function getNuxtModuleFallbackTemplate(\n options: {\n org: string;\n project: string;\n url: string;\n selfHosted: boolean;\n },\n shouldTopLevelImport: boolean,\n): string {\n return ` modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"${options.org}\",\n project: \"${options.project}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n },${\n shouldTopLevelImport\n ? `\\n autoInjectServerSentry: \"top-level-import\",`\n : ''\n }\n },\n sourcemap: { client: \"hidden\" },`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n): string {\n if (config === 'client') {\n return getSentryClientConfigContents(dsn, selectedFeatures);\n }\n\n return getSentryServerConfigContents(dsn, selectedFeatures);\n}\n\nconst featuresConfigMap: Record<keyof SelectedSentryFeatures, string> = {\n performance: [\n ' // We recommend adjusting this value in production, or using tracesSampler',\n ' // for finer control',\n ' tracesSampleRate: 1.0,',\n ].join('\\n'),\n replay: [\n ' // This sets the sample rate to be 10%. You may want this to be 100% while',\n ' // in development and sample at a lower rate in production',\n ' replaysSessionSampleRate: 0.1,',\n ' ',\n ' // If the entire session is not sampled, use the below sample rate to sample',\n ' // sessions when an error occurs.',\n ' replaysOnErrorSampleRate: 1.0,',\n ' ',\n \" // If you don't want to use Session Replay, just remove the line below:\",\n ' integrations: [Sentry.replayIntegration()],',\n ].join('\\n'),\n logs: [' // Enable logs to be sent to Sentry', ' enableLogs: true,'].join(\n '\\n',\n ),\n};\n\nconst featuresMap: Record<\n 'client' | 'server',\n Array<keyof SelectedSentryFeatures>\n> = {\n client: ['performance', 'replay', 'logs'],\n server: ['performance', 'logs'],\n};\n\nexport function getConfigBody(\n dsn: string,\n variant: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n) {\n return [\n `dsn: \"${dsn}\",`,\n Object.entries(selectedFeatures)\n .map(([feature, activated]: [keyof SelectedSentryFeatures, boolean]) => {\n return featuresMap[variant].includes(feature) && activated\n ? featuresConfigMap[feature]\n : null;\n })\n .filter(Boolean)\n .join('\\n\\n'),\n ]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\nfunction getSentryClientConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n\nSentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n ${getConfigBody(dsn, 'client', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nfunction getSentryServerConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n \nSentry.init({\n ${getConfigBody(dsn, 'server', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getIndexRouteTemplate(): string {\n return `<!--\nThis is just to verify the sentry-example-page.\nFeel free to delete this file.\n-->\n\n<template></template>`;\n}\n\nexport function getSentryExamplePageTemplate(options: {\n url: string;\n org: string;\n projectId: string;\n}): string {\n const { url, org, projectId } = options;\n const issuesPageLink = getIssueStreamUrl({ url, orgSlug: org, projectId });\n\n return `<!--\nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n\n class SentryExampleFrontendError extends Error {\n constructor(message) {\n super(message);\n this.name = \"SentryExampleFrontendError\";\n }\n }\n\n const hasSentError = ref(false);\n const isConnected = ref(true);\n \n onMounted(async () => {\n try {\n const result = await Sentry.diagnoseSdkConnectivity();\n isConnected.value = result !== 'sentry-unreachable';\n } catch (error) {\n isConnected.value = false;\n }\n });\n \n async function getSentryData() {\n await Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const res = await $fetch('/api/sentry-example-api', { \n method: 'GET',\n ignoreResponseError: true \n }).catch(() => null);\n if (!res) {\n hasSentError.value = true;\n }\n }\n );\n throw new SentryExampleFrontendError(\"This error is raised on the frontend of the example page.\");\n }\n</script>\n\n<template>\n <title>Sentry Onboarding</title>\n <div>\n <main>\n <div class=\"flex-spacer\" />\n <svg height=\"40\" width=\"40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z\" fill=\"currentcolor\"/>\n </svg>\n <h1>\n sentry-example-page\n </h1>\n\n <p class=\"description\">\n Click the button below, and view the sample error on the Sentry <a target=\"_blank\" href=\"${issuesPageLink}\">Issues Page</a>.\n For more details about setting up Sentry, <a target=\"_blank\" href=\"https://docs.sentry.io/platforms/javascript/guides/nuxt/\">read our docs</a>.\n </p>\n\n <button\n type=\"button\"\n @click=\"getSentryData\"\n :disabled=\"!isConnected\"\n >\n <span>\n Throw Sample Error\n </span>\n </button>\n\n <p v-if=\"hasSentError\" class=\"success\">\n Sample error was sent to Sentry.\n </p>\n <div v-else-if=\"!isConnected\" class=\"connectivity-error\">\n <p>It looks like network requests to Sentry are being blocked, which will prevent errors from being captured. Try disabling your ad-blocker to complete the test.</p>\n </div>\n <div v-else class=\"success_placeholder\" />\n\n <div class=\"flex-spacer\" />\n </main>\n </div>\n</template>\n\n<style scoped>\n :global(body) {\n margin: 0;\n\n @media (prefers-color-scheme: dark) {\n color: #ededed;\n background-color: #0a0a0a;\n }\n }\n\n main {\n display: flex;\n min-height: 100vh;\n box-sizing: border-box;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 16px;\n padding: 16px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n\n h1 {\n padding: 0px 4px;\n margin: 0;\n border-radius: 4px;\n background-color: rgba(24, 20, 35, 0.03);\n font-family: monospace;\n font-size: 20px;\n line-height: 1.2;\n }\n\n p {\n margin: 0;\n font-size: 20px;\n }\n\n a {\n color: #6341F0;\n text-decoration: underline;\n cursor: pointer;\n\n @media (prefers-color-scheme: dark) {\n color: #B3A1FF;\n }\n }\n\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0); \n }\n\n &:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n\n & > span {\n transform: translateY(0);\n border: none;\n }\n }\n }\n\n .description {\n text-align: center;\n color: #6E6C75;\n max-width: 500px;\n line-height: 1.5;\n font-size: 20px;\n\n @media (prefers-color-scheme: dark) {\n color: #A49FB5;\n }\n }\n\n .flex-spacer {\n flex: 1;\n }\n\n .success {\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n }\n\n .success_placeholder {\n height: 46px;\n }\n \n .connectivity-error {\n padding: 12px 16px;\n background-color: #E50045;\n border-radius: 8px;\n width: 500px;\n color: #FFFFFF;\n border: 1px solid #A80033;\n text-align: center;\n margin: 0;\n }\n \n .connectivity-error a {\n color: #FFFFFF;\n text-decoration: underline;\n }\n</style>\n\n`;\n}\n\nexport function getSentryExampleApiTemplate() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(() => {\n throw new Error(\"Sentry Example API Route Error\");\n});\n`;\n}\n\nexport function getSentryErrorButtonTemplate() {\n return `<!--\nThis is just a very simple component that throws an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n\n const hasSentError = ref(false);\n \n const throwError = () => {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n () => {\n hasSentError.value = true;\n throw new Error('Sentry Example Error');\n }\n )\n };\n</script>\n\n<template>\n <div v-if=\"hasSentError\" class=\"success\">\n Sample error was sent to Sentry.\n </div>\n <button v-else @click=\"throwError\">\n <span>Throw Sample Error</span>\n </button>\n</template>\n\n<style scoped>\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0);\n }\n }\n\n .success {\n width: max-content;\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n</style>\n`;\n}\n"]}
|
|
@@ -64,6 +64,11 @@ async function runRemixWizardWithTelemetry(options) {
|
|
|
64
64
|
prompt: `Do you want to enable ${chalk_1.default.bold('Session Replay')} to get a video-like reproduction of errors during a user session?`,
|
|
65
65
|
enabledHint: 'recommended, but increases bundle size',
|
|
66
66
|
},
|
|
67
|
+
{
|
|
68
|
+
id: 'logs',
|
|
69
|
+
prompt: `Do you want to enable ${chalk_1.default.bold('Logs')} to send your application logs to Sentry?`,
|
|
70
|
+
enabledHint: 'recommended',
|
|
71
|
+
},
|
|
67
72
|
]);
|
|
68
73
|
if (viteConfig) {
|
|
69
74
|
await (0, telemetry_1.traceStep)('Update vite configuration for sourcemap uploads', async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remix-wizard.js","sourceRoot":"","sources":["../../../src/remix/remix-wizard.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,mDAAkD;AAClD,mDAA+D;AAC/D,4CAAwD;AACxD,kDAA8C;AAC9C,0CAawB;AACxB,0CAAuC;AACvC,wDAA4D;AAE5D,+CAAkD;AAClD,2CAUqB;AACrB,mCAAwC;AAEjC,KAAK,UAAU,cAAc,CAAC,OAAsB;IACzD,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,OAAO;QACpB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAC3C,CAAC;AACJ,CAAC;AATD,wCASC;AAED,KAAK,UAAU,2BAA2B,CACxC,OAAsB;IAEtB,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE9D,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,qBAAqB;QACjC,SAAS;QACT,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAE9C,IAAI,CAAC,IAAA,qBAAS,EAAC,WAAW,CAAC,EAAE;QAC3B,iBAAK,CAAC,GAAG,CAAC,KAAK,CACb,2FAA2F,CAC5F,CAAC;QACF,OAAO;KACR;IAED,MAAM,IAAA,yCAAiC,EAAC;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,qEAAqE;IACrE,MAAM,IAAA,gCAAw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B,CAAC,CAAC;aAC9C;YAAC,OAAO,CAAC,EAAE;gBACV,iBAAK,CAAC,GAAG;qBACN,IAAI,CAAC;yHACuG,CAAC,CAAC;gBACjH,IAAA,aAAK,EAAC,CAAC,CAAC,CAAC;aACV;QACH,CAAC,CACF,CAAC;KACH;IAED,MAAM,IAAA,qBAAS,EAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC5D,IAAI;YACF,MAAM,IAAA,yCAA6B,EAAC,IAAI,CAAC,CAAC;SAC3C;QAAC,OAAO,CAAC,EAAE;YACV,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC;uHACkG,CAAC,CAAC;YACnH,IAAA,aAAK,EAAC,CAAC,CAAC,CAAC;SACV;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,uBAAuB,GAAG,MAAM,IAAA,kCAA0B,GAAE,CAAC;IAEnE,IAAI,uBAAuB,EAAE;QAC3B,MAAM,IAAA,qBAAS,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,IAAA,+BAAiB,EAAC;gBACtB,IAAI;gBACJ,UAAU;gBACV,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;gBAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;gBAC7B,GAAG,EAAE,SAAS;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;KACJ;IAED,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAEjD,iBAAK,CAAC,KAAK,CAAC;EACZ,eAAK,CAAC,KAAK,CACX,iEAAiE,CAClE;;EAEC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC;;EAEtE,eAAK,CAAC,IAAI,CACV;0DACwD,CACzD,EAAE,CAAC,CAAC;AACL,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport { DEFAULT_URL } from '../../lib/Constants';\nimport { configureVitePlugin } from '../sourcemaps/tools/vite';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { findFile } from '../utils/ast-utils';\nimport {\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n rcCliSetupConfig,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { debug } from '../utils/debug';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { createExamplePage } from './sdk-example';\nimport {\n createServerInstrumentationFile,\n initializeSentryOnEntryClient,\n insertServerInstrumentationFile,\n instrumentRootRoute,\n instrumentSentryOnEntryServer,\n isRemixV2,\n runRemixReveal,\n updateBuildScript,\n updateStartScript,\n} from './sdk-setup';\nimport { isHydrogenApp } from './utils';\n\nexport async function runRemixWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'remix',\n wizardOptions: options,\n },\n () => runRemixWizardWithTelemetry(options),\n );\n}\n\nasync function runRemixWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Remix Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n const packageJson = await getPackageDotJson();\n\n if (!isRemixV2(packageJson)) {\n clack.log.error(\n `Sentry only supports Remix v2 and above. Please upgrade your Remix version to use Sentry.`,\n );\n return;\n }\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n // We expect `@remix-run/dev` to be installed for every Remix project\n await ensurePackageIsInstalled(packageJson, '@remix-run/dev', 'Remix');\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-remix');\n\n await installPackage({\n packageName: '@sentry/remix@^9',\n packageNameDisplayLabel: '@sentry/remix',\n alreadyInstalled: hasPackageInstalled('@sentry/remix', packageJson),\n forceInstall,\n });\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const isTS = isUsingTypeScript();\n const viteConfig = findFile('vite.config');\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n if (viteConfig) {\n await traceStep(\n 'Update vite configuration for sourcemap uploads',\n async () => {\n try {\n await configureVitePlugin({\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n url: sentryUrl,\n selfHosted,\n authToken,\n });\n } catch (e) {\n clack.log\n .warn(`Could not update vite configuration to generate and upload sourcemaps.\n Please update your vite configuration manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n },\n );\n } else {\n await traceStep('Update build script for sourcemap uploads', async () => {\n try {\n await updateBuildScript({\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n url: sentryUrl === DEFAULT_URL ? undefined : sentryUrl,\n isHydrogen: isHydrogenApp(packageJson),\n });\n\n await addSentryCliConfig({ authToken }, rcCliSetupConfig);\n } catch (e) {\n clack.log\n .warn(`Could not update build script to generate and upload sourcemaps.\n Please update your build script manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n });\n }\n\n await traceStep('Instrument root route', async () => {\n try {\n await instrumentRootRoute(isTS);\n } catch (e) {\n clack.log.warn(`Could not instrument root route.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n traceStep('Reveal missing entry files', () => {\n try {\n runRemixReveal(isTS);\n } catch (e) {\n clack.log.warn(`Could not run 'npx remix reveal'.\n Please create your entry files manually`);\n debug(e);\n }\n });\n\n await traceStep('Initialize Sentry on client entry', async () => {\n try {\n await initializeSentryOnEntryClient(dsn, isTS, selectedFeatures);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on client entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n let instrumentationFile = '';\n\n await traceStep('Create server instrumentation file', async () => {\n try {\n instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n });\n\n let serverFileInstrumented = false;\n\n await traceStep(\n 'Create server instrumentation file and import it',\n async () => {\n try {\n serverFileInstrumented = await insertServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n },\n );\n\n if (!serverFileInstrumented && instrumentationFile) {\n await traceStep(\n 'Update `start` script to import instrumentation file.',\n async () => {\n try {\n await updateStartScript(instrumentationFile);\n } catch (e) {\n clack.log\n .warn(`Could not automatically add Sentry initialization to server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n },\n );\n }\n\n await traceStep('Instrument server `handleError`', async () => {\n try {\n await instrumentSentryOnEntryServer(isTS);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage();\n\n if (shouldCreateExamplePage) {\n await traceStep('Create example page', async () => {\n await createExamplePage({\n isTS,\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n });\n });\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n clack.outro(`\n${chalk.green(\n 'Sentry has been successfully configured for your Remix project.',\n)}\n\n${chalk.cyan('You can now deploy your project to see Sentry in action.')}\n\n${chalk.cyan(\n `To learn more about how to use Sentry with Remix, visit our documentation:\nhttps://docs.sentry.io/platforms/javascript/guides/remix/`,\n)}`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"remix-wizard.js","sourceRoot":"","sources":["../../../src/remix/remix-wizard.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,mDAAkD;AAClD,mDAA+D;AAC/D,4CAAwD;AACxD,kDAA8C;AAC9C,0CAawB;AACxB,0CAAuC;AACvC,wDAA4D;AAE5D,+CAAkD;AAClD,2CAUqB;AACrB,mCAAwC;AAEjC,KAAK,UAAU,cAAc,CAAC,OAAsB;IACzD,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,OAAO;QACpB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAC3C,CAAC;AACJ,CAAC;AATD,wCASC;AAED,KAAK,UAAU,2BAA2B,CACxC,OAAsB;IAEtB,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE9D,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,qBAAqB;QACjC,SAAS;QACT,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAE9C,IAAI,CAAC,IAAA,qBAAS,EAAC,WAAW,CAAC,EAAE;QAC3B,iBAAK,CAAC,GAAG,CAAC,KAAK,CACb,2FAA2F,CAC5F,CAAC;QACF,OAAO;KACR;IAED,MAAM,IAAA,yCAAiC,EA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AiE,CAClE;;EAEC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC;;EAEtE,eAAK,CAAC,IAAI,CACV;0DACwD,CACzD,EAAE,CAAC,CAAC;AACL,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport { DEFAULT_URL } from '../../lib/Constants';\nimport { configureVitePlugin } from '../sourcemaps/tools/vite';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { findFile } from '../utils/ast-utils';\nimport {\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n rcCliSetupConfig,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { debug } from '../utils/debug';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { createExamplePage } from './sdk-example';\nimport {\n createServerInstrumentationFile,\n initializeSentryOnEntryClient,\n insertServerInstrumentationFile,\n instrumentRootRoute,\n instrumentSentryOnEntryServer,\n isRemixV2,\n runRemixReveal,\n updateBuildScript,\n updateStartScript,\n} from './sdk-setup';\nimport { isHydrogenApp } from './utils';\n\nexport async function runRemixWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'remix',\n wizardOptions: options,\n },\n () => runRemixWizardWithTelemetry(options),\n );\n}\n\nasync function runRemixWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Remix Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n const packageJson = await getPackageDotJson();\n\n if (!isRemixV2(packageJson)) {\n clack.log.error(\n `Sentry only supports Remix v2 and above. Please upgrade your Remix version to use Sentry.`,\n );\n return;\n }\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n // We expect `@remix-run/dev` to be installed for every Remix project\n await ensurePackageIsInstalled(packageJson, '@remix-run/dev', 'Remix');\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-remix');\n\n await installPackage({\n packageName: '@sentry/remix@^9',\n packageNameDisplayLabel: '@sentry/remix',\n alreadyInstalled: hasPackageInstalled('@sentry/remix', packageJson),\n forceInstall,\n });\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const isTS = isUsingTypeScript();\n const viteConfig = findFile('vite.config');\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n {\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 ] as const);\n\n if (viteConfig) {\n await traceStep(\n 'Update vite configuration for sourcemap uploads',\n async () => {\n try {\n await configureVitePlugin({\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n url: sentryUrl,\n selfHosted,\n authToken,\n });\n } catch (e) {\n clack.log\n .warn(`Could not update vite configuration to generate and upload sourcemaps.\n Please update your vite configuration manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n },\n );\n } else {\n await traceStep('Update build script for sourcemap uploads', async () => {\n try {\n await updateBuildScript({\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n url: sentryUrl === DEFAULT_URL ? undefined : sentryUrl,\n isHydrogen: isHydrogenApp(packageJson),\n });\n\n await addSentryCliConfig({ authToken }, rcCliSetupConfig);\n } catch (e) {\n clack.log\n .warn(`Could not update build script to generate and upload sourcemaps.\n Please update your build script manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n });\n }\n\n await traceStep('Instrument root route', async () => {\n try {\n await instrumentRootRoute(isTS);\n } catch (e) {\n clack.log.warn(`Could not instrument root route.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n traceStep('Reveal missing entry files', () => {\n try {\n runRemixReveal(isTS);\n } catch (e) {\n clack.log.warn(`Could not run 'npx remix reveal'.\n Please create your entry files manually`);\n debug(e);\n }\n });\n\n await traceStep('Initialize Sentry on client entry', async () => {\n try {\n await initializeSentryOnEntryClient(dsn, isTS, selectedFeatures);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on client entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n let instrumentationFile = '';\n\n await traceStep('Create server instrumentation file', async () => {\n try {\n instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n });\n\n let serverFileInstrumented = false;\n\n await traceStep(\n 'Create server instrumentation file and import it',\n async () => {\n try {\n serverFileInstrumented = await insertServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n },\n );\n\n if (!serverFileInstrumented && instrumentationFile) {\n await traceStep(\n 'Update `start` script to import instrumentation file.',\n async () => {\n try {\n await updateStartScript(instrumentationFile);\n } catch (e) {\n clack.log\n .warn(`Could not automatically add Sentry initialization to server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n },\n );\n }\n\n await traceStep('Instrument server `handleError`', async () => {\n try {\n await instrumentSentryOnEntryServer(isTS);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage();\n\n if (shouldCreateExamplePage) {\n await traceStep('Create example page', async () => {\n await createExamplePage({\n isTS,\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n });\n });\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n clack.outro(`\n${chalk.green(\n 'Sentry has been successfully configured for your Remix project.',\n)}\n\n${chalk.cyan('You can now deploy your project to see Sentry in action.')}\n\n${chalk.cyan(\n `To learn more about how to use Sentry with Remix, visit our documentation:\nhttps://docs.sentry.io/platforms/javascript/guides/remix/`,\n)}`);\n}\n"]}
|
|
@@ -7,6 +7,7 @@ export declare function runRemixReveal(isTS: boolean): void;
|
|
|
7
7
|
export declare function generateServerInstrumentationFile(dsn: string, selectedFeatures: {
|
|
8
8
|
performance: boolean;
|
|
9
9
|
replay: boolean;
|
|
10
|
+
logs: boolean;
|
|
10
11
|
}): {
|
|
11
12
|
instrumentationFile: string;
|
|
12
13
|
instrumentationFileMod: ProxifiedModule<any>;
|
|
@@ -14,10 +15,12 @@ export declare function generateServerInstrumentationFile(dsn: string, selectedF
|
|
|
14
15
|
export declare function createServerInstrumentationFile(dsn: string, selectedFeatures: {
|
|
15
16
|
performance: boolean;
|
|
16
17
|
replay: boolean;
|
|
18
|
+
logs: boolean;
|
|
17
19
|
}): Promise<string>;
|
|
18
20
|
export declare function insertServerInstrumentationFile(dsn: string, selectedFeatures: {
|
|
19
21
|
performance: boolean;
|
|
20
22
|
replay: boolean;
|
|
23
|
+
logs: boolean;
|
|
21
24
|
}): Promise<boolean>;
|
|
22
25
|
export declare function isRemixV2(packageJson: PackageDotJson): boolean;
|
|
23
26
|
export declare function loadRemixConfig(): Promise<PartialRemixConfig>;
|
|
@@ -31,10 +34,12 @@ export declare function updateBuildScript(args: {
|
|
|
31
34
|
export declare function updateEntryClientMod(originalEntryClientMod: ProxifiedModule<any>, dsn: string, selectedFeatures: {
|
|
32
35
|
performance: boolean;
|
|
33
36
|
replay: boolean;
|
|
37
|
+
logs: boolean;
|
|
34
38
|
}): ProxifiedModule<any>;
|
|
35
39
|
export declare function initializeSentryOnEntryClient(dsn: string, isTS: boolean, selectedFeatures: {
|
|
36
40
|
performance: boolean;
|
|
37
41
|
replay: boolean;
|
|
42
|
+
logs: boolean;
|
|
38
43
|
}): Promise<void>;
|
|
39
44
|
export declare function updateStartScript(instrumentationFile: string): Promise<void>;
|
|
40
45
|
export declare function instrumentSentryOnEntryServer(isTS: boolean): Promise<void>;
|
|
@@ -68,6 +68,10 @@ function getInitCallArgs(dsn, type, selectedFeatures) {
|
|
|
68
68
|
if (selectedFeatures.performance) {
|
|
69
69
|
initCallArgs.tracesSampleRate = 1.0;
|
|
70
70
|
}
|
|
71
|
+
// Adding logs for both client and server
|
|
72
|
+
if (selectedFeatures.logs) {
|
|
73
|
+
initCallArgs.enableLogs = true;
|
|
74
|
+
}
|
|
71
75
|
// Adding integrations and replay options only for client
|
|
72
76
|
if (type === 'client' &&
|
|
73
77
|
(selectedFeatures.performance || selectedFeatures.replay)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/remix/sdk-setup.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO5D,uCAAyB;AACzB,2CAA6B;AAC7B,yCAA2B;AAC3B,4DAA8C;AAE9C,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,mCAAyC;AAEzC,uCAOkB;AAElB,wDAA0D;AAC1D,mCAIiB;AACjB,0CAAiD;AACjD,0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E,OAAO;KACR;IAED,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC;QAClC,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,GAAG;QACb,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IAEH,MAAM,uBAAuB,GAAG,IAAA,oCAAqB,EACnD,sBAAsB,EACtB,mBAAmB,CACpB,CAAC;IAEF,IAAI,uBAAuB,EAAE;QAC3B,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,gBAAgB,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,eAAK,CAAC,IAAI,CACxD,GAAG,mBAAmB,EAAE,CACzB,EAAE,CACJ,CAAC;KACH;IAED,MAAM,IAAA,oBAAS,EACb,sBAAsB,CAAC,IAAI,EAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CACrD,CAAC;IAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,yDAAyD,eAAK,CAAC,IAAI,CACjE,mBAAmB,CACpB,GAAG,CACL,CAAC;AACJ,CAAC;AA9CD,sEA8CC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport type { Program } from '@babel/types';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { Proxified, ProxifiedModule } from 'magicast';\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport * as childProcess from 'child_process';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { gte, minVersion } from 'semver';\n\nimport {\n builders,\n generateCode,\n loadFile,\n parseModule,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\nimport type { PackageDotJson } from '../utils/package-json';\nimport { getPackageVersion } from '../utils/package-json';\nimport {\n getAfterImportsInsertionIndex,\n hasSentryContent,\n serverHasInstrumentationImport,\n} from './utils';\nimport { instrumentRoot } from './codemods/root';\nimport { instrumentHandleError } from './codemods/handle-error';\nimport { getPackageDotJson } from '../utils/clack';\nimport { findCustomExpressServerImplementation } from './codemods/express-server';\n\nexport type PartialRemixConfig = {\n unstable_dev?: boolean;\n};\n\nconst REMIX_CONFIG_FILE = 'remix.config.js';\nconst REMIX_REVEAL_COMMAND = 'npx remix reveal';\n\nexport function runRemixReveal(isTS: boolean): void {\n // Check if entry files already exist\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const clientEntryPath = path.join(process.cwd(), 'app', clientEntryFilename);\n const serverEntryPath = path.join(process.cwd(), 'app', serverEntryFilename);\n\n if (fs.existsSync(clientEntryPath) && fs.existsSync(serverEntryPath)) {\n clack.log.info(\n `Found entry files ${chalk.cyan(clientEntryFilename)} and ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n } else {\n clack.log.info(\n `Couldn't find entry files in your project. Trying to run ${chalk.cyan(\n REMIX_REVEAL_COMMAND,\n )}...`,\n );\n\n clack.log.info(childProcess.execSync(REMIX_REVEAL_COMMAND).toString());\n }\n}\n\ninterface SdkAstOptions {\n dsn: string;\n tracesSampleRate?: number;\n replaysSessionSampleRate?: number;\n replaysOnErrorSampleRate?: number;\n integrations?: Array<Proxified>;\n}\n\nfunction getInitCallArgs(\n dsn: string,\n type: 'client' | 'server',\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const initCallArgs: SdkAstOptions = {\n dsn,\n };\n\n // Adding tracing sample rate for both client and server\n if (selectedFeatures.performance) {\n initCallArgs.tracesSampleRate = 1.0;\n }\n\n // Adding integrations and replay options only for client\n if (\n type === 'client' &&\n (selectedFeatures.performance || selectedFeatures.replay)\n ) {\n initCallArgs.integrations = [] as Array<Proxified>;\n\n if (selectedFeatures.performance) {\n initCallArgs.integrations.push(\n builders.functionCall(\n 'browserTracingIntegration',\n builders.raw('{ useEffect, useLocation, useMatches }'),\n ),\n );\n }\n\n if (selectedFeatures.replay) {\n initCallArgs.integrations.push(\n builders.functionCall('replayIntegration', {\n maskAllText: true,\n blockAllMedia: true,\n }),\n );\n\n initCallArgs.replaysSessionSampleRate = 0.1;\n initCallArgs.replaysOnErrorSampleRate = 1.0;\n }\n }\n\n return initCallArgs;\n}\n\nfunction insertClientInitCall(\n dsn: string,\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalHooksMod: ProxifiedModule<any>,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): void {\n const initCallArgs = getInitCallArgs(dsn, 'client', selectedFeatures);\n const initCall = builders.functionCall('init', initCallArgs);\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n const initCallInsertionIndex =\n getAfterImportsInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n}\n\nexport function generateServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n // create an empty file named `instrument.server.mjs`\n const instrumentationFile = 'instrumentation.server.mjs';\n const instrumentationFileMod = parseModule('');\n\n instrumentationFileMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n const initCallArgs = getInitCallArgs(dsn, 'server', selectedFeatures);\n const initCall = builders.functionCall('Sentry.init', initCallArgs);\n\n const instrumentationFileModAST = instrumentationFileMod.$ast as Program;\n\n const initCallInsertionIndex = getAfterImportsInsertionIndex(\n instrumentationFileModAST,\n );\n\n instrumentationFileModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n\n return { instrumentationFile, instrumentationFileMod };\n}\n\nexport async function createServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const { instrumentationFile, instrumentationFileMod } =\n generateServerInstrumentationFile(dsn, selectedFeatures);\n\n await writeFile(instrumentationFileMod.$ast, instrumentationFile);\n\n return instrumentationFile;\n}\n\nexport async function insertServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n const instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n\n const expressServerPath = await findCustomExpressServerImplementation();\n\n if (!expressServerPath) {\n return false;\n }\n\n const originalExpressServerMod = await loadFile(expressServerPath);\n\n if (\n serverHasInstrumentationImport(\n expressServerPath,\n originalExpressServerMod.$code,\n )\n ) {\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(expressServerPath),\n )} already contains instrumentation import.\nSkipping adding instrumentation functionality to ${chalk.cyan(\n path.basename(expressServerPath),\n )}.`,\n );\n\n return true;\n }\n\n originalExpressServerMod.$code = `import './${instrumentationFile}';\\n${originalExpressServerMod.$code}`;\n\n fs.writeFileSync(expressServerPath, originalExpressServerMod.$code);\n\n return true;\n}\n\nexport function isRemixV2(packageJson: PackageDotJson): boolean {\n const remixVersion = getPackageVersion('@remix-run/react', packageJson);\n if (!remixVersion) {\n return false;\n }\n\n const minVer = minVersion(remixVersion);\n\n if (!minVer) {\n return false;\n }\n\n return gte(minVer, '2.0.0');\n}\n\nexport async function loadRemixConfig(): Promise<PartialRemixConfig> {\n const configFilePath = path.join(process.cwd(), REMIX_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const remixConfigModule = (await import(configUrl)) as {\n default: PartialRemixConfig;\n };\n\n return remixConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${REMIX_CONFIG_FILE}.`);\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n\n return {};\n }\n}\n\nexport async function instrumentRootRoute(isTS?: boolean): Promise<void> {\n const rootFilename = `root.${isTS ? 'tsx' : 'jsx'}`;\n\n await instrumentRoot(rootFilename);\n\n clack.log.success(\n `Successfully instrumented root route ${chalk.cyan(rootFilename)}.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport async function updateBuildScript(args: {\n org: string;\n project: string;\n url?: string;\n isHydrogen: boolean;\n}): Promise<void> {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n const buildCommand = args.isHydrogen\n ? 'shopify hydrogen build'\n : 'remix build';\n\n const instrumentedBuildCommand =\n `${buildCommand} --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +\n (args.url ? ` --url ${args.url}` : '') +\n (args.isHydrogen ? ' --buildPath ./dist' : '');\n\n if (!packageJson.scripts.build) {\n packageJson.scripts.build = instrumentedBuildCommand;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n } else if (packageJson.scripts.build.includes(buildCommand)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n packageJson.scripts.build = packageJson.scripts.build.replace(\n buildCommand,\n instrumentedBuildCommand,\n );\n } else {\n throw new Error(\n \"`build` script doesn't contain a known build command. Please update it manually.\",\n );\n }\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('build')} script in ${chalk.cyan(\n 'package.json',\n )} to generate and upload sourcemaps.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport function updateEntryClientMod(\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalEntryClientMod: ProxifiedModule<any>,\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): ProxifiedModule<any> {\n const imports = ['init'];\n if (selectedFeatures.replay) {\n imports.push('replayIntegration');\n }\n if (selectedFeatures.performance) {\n imports.push('browserTracingIntegration');\n }\n originalEntryClientMod.imports.$add({\n from: '@sentry/remix',\n imported: `${imports.join(', ')}`,\n });\n\n if (selectedFeatures.performance) {\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useLocation',\n local: 'useLocation',\n });\n\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useMatches',\n local: 'useMatches',\n });\n\n originalEntryClientMod.imports.$add({\n from: 'react',\n imported: 'useEffect',\n local: 'useEffect',\n });\n }\n\n insertClientInitCall(dsn, originalEntryClientMod, selectedFeatures);\n\n return originalEntryClientMod;\n}\n\nexport async function initializeSentryOnEntryClient(\n dsn: string,\n isTS: boolean,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): Promise<void> {\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryClient = path.join(\n process.cwd(),\n 'app',\n clientEntryFilename,\n );\n\n const originalEntryClientMod = await loadFile(originalEntryClient);\n\n if (hasSentryContent(originalEntryClient, originalEntryClientMod.$code)) {\n return;\n }\n\n const updatedEntryClientMod = updateEntryClientMod(\n originalEntryClientMod,\n dsn,\n selectedFeatures,\n );\n\n await writeFile(\n updatedEntryClientMod.$ast,\n path.join(process.cwd(), 'app', clientEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on client entry point ${chalk.cyan(\n clientEntryFilename,\n )}`,\n );\n}\n\nexport async function updateStartScript(instrumentationFile: string) {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts || !packageJson.scripts.start) {\n throw new Error(\n \"Couldn't find a `start` script in your package.json. Please add one manually.\",\n );\n }\n\n if (packageJson.scripts.start.includes('NODE_OPTIONS')) {\n clack.log.warn(\n `Found existing NODE_OPTIONS in ${chalk.cyan(\n 'start',\n )} script. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n if (\n !packageJson.scripts.start.includes('remix-serve') &&\n // Adding a following empty space not to match a path that includes `node`\n !packageJson.scripts.start.includes('node ')\n ) {\n clack.log.warn(\n `Found a ${chalk.cyan('start')} script that doesn't use ${chalk.cyan(\n 'remix-serve',\n )} or ${chalk.cyan('node')}. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n const startCommand = packageJson.scripts.start;\n\n packageJson.scripts.start = `NODE_OPTIONS='--import ./${instrumentationFile}' ${startCommand}`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('start')} script in ${chalk.cyan(\n 'package.json',\n )} to include Sentry initialization on start.`,\n );\n}\n\nexport async function instrumentSentryOnEntryServer(\n isTS: boolean,\n): Promise<void> {\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryServer = path.join(\n process.cwd(),\n 'app',\n serverEntryFilename,\n );\n\n const originalEntryServerMod = await loadFile(originalEntryServer);\n\n if (hasSentryContent(originalEntryServer, originalEntryServerMod.$code)) {\n return;\n }\n\n originalEntryServerMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n const handleErrorInstrumented = instrumentHandleError(\n originalEntryServerMod,\n serverEntryFilename,\n );\n\n if (handleErrorInstrumented) {\n clack.log.success(\n `Instrumented ${chalk.cyan('handleError')} in ${chalk.cyan(\n `${serverEntryFilename}`,\n )}`,\n );\n }\n\n await writeFile(\n originalEntryServerMod.$ast,\n path.join(process.cwd(), 'app', serverEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on server entry point ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-setup.js","sourceRoot":"","s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IAAa;IAEb,MAAM,mBAAmB,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IAEnE,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CACnC,OAAO,CAAC,GAAG,EAAE,EACb,KAAK,EACL,mBAAmB,CACpB,CAAC;IAEF,MAAM,sBAAsB,GAAG,MAAM,IAAA,mBAAQ,EAAC,mBAAmB,CAAC,CAAC;IAEnE,IAAI,IAAA,wBAAgB,EAAC,mBAAmB,EAAE,sBAAsB,CAAC,KAAK,CAAC,EAAE;QACvE,OAAO;KACR;IAED,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC;QAClC,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,GAAG;QACb,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IAEH,MAAM,uBAAuB,GAAG,IAAA,oCAAqB,EACnD,sBAAsB,EACtB,mBAAmB,CACpB,CAAC;IAEF,IAAI,uBAAuB,EAAE;QAC3B,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,gBAAgB,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,eAAK,CAAC,IAAI,CACxD,GAAG,mBAAmB,EAAE,CACzB,EAAE,CACJ,CAAC;KACH;IAED,MAAM,IAAA,oBAAS,EACb,sBAAsB,CAAC,IAAI,EAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAAC,CACrD,CAAC;IAEF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,yDAAyD,eAAK,CAAC,IAAI,CACjE,mBAAmB,CACpB,GAAG,CACL,CAAC;AACJ,CAAC;AA9CD,sEA8CC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\nimport type { Program } from '@babel/types';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { Proxified, ProxifiedModule } from 'magicast';\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport * as childProcess from 'child_process';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { gte, minVersion } from 'semver';\n\nimport {\n builders,\n generateCode,\n loadFile,\n parseModule,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\nimport type { PackageDotJson } from '../utils/package-json';\nimport { getPackageVersion } from '../utils/package-json';\nimport {\n getAfterImportsInsertionIndex,\n hasSentryContent,\n serverHasInstrumentationImport,\n} from './utils';\nimport { instrumentRoot } from './codemods/root';\nimport { instrumentHandleError } from './codemods/handle-error';\nimport { getPackageDotJson } from '../utils/clack';\nimport { findCustomExpressServerImplementation } from './codemods/express-server';\n\nexport type PartialRemixConfig = {\n unstable_dev?: boolean;\n};\n\nconst REMIX_CONFIG_FILE = 'remix.config.js';\nconst REMIX_REVEAL_COMMAND = 'npx remix reveal';\n\nexport function runRemixReveal(isTS: boolean): void {\n // Check if entry files already exist\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const clientEntryPath = path.join(process.cwd(), 'app', clientEntryFilename);\n const serverEntryPath = path.join(process.cwd(), 'app', serverEntryFilename);\n\n if (fs.existsSync(clientEntryPath) && fs.existsSync(serverEntryPath)) {\n clack.log.info(\n `Found entry files ${chalk.cyan(clientEntryFilename)} and ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n } else {\n clack.log.info(\n `Couldn't find entry files in your project. Trying to run ${chalk.cyan(\n REMIX_REVEAL_COMMAND,\n )}...`,\n );\n\n clack.log.info(childProcess.execSync(REMIX_REVEAL_COMMAND).toString());\n }\n}\n\ninterface SdkAstOptions {\n dsn: string;\n tracesSampleRate?: number;\n replaysSessionSampleRate?: number;\n replaysOnErrorSampleRate?: number;\n integrations?: Array<Proxified>;\n enableLogs?: boolean;\n}\n\nfunction getInitCallArgs(\n dsn: string,\n type: 'client' | 'server',\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n) {\n const initCallArgs: SdkAstOptions = {\n dsn,\n };\n\n // Adding tracing sample rate for both client and server\n if (selectedFeatures.performance) {\n initCallArgs.tracesSampleRate = 1.0;\n }\n\n // Adding logs for both client and server\n if (selectedFeatures.logs) {\n initCallArgs.enableLogs = true;\n }\n\n // Adding integrations and replay options only for client\n if (\n type === 'client' &&\n (selectedFeatures.performance || selectedFeatures.replay)\n ) {\n initCallArgs.integrations = [] as Array<Proxified>;\n\n if (selectedFeatures.performance) {\n initCallArgs.integrations.push(\n builders.functionCall(\n 'browserTracingIntegration',\n builders.raw('{ useEffect, useLocation, useMatches }'),\n ),\n );\n }\n\n if (selectedFeatures.replay) {\n initCallArgs.integrations.push(\n builders.functionCall('replayIntegration', {\n maskAllText: true,\n blockAllMedia: true,\n }),\n );\n\n initCallArgs.replaysSessionSampleRate = 0.1;\n initCallArgs.replaysOnErrorSampleRate = 1.0;\n }\n }\n\n return initCallArgs;\n}\n\nfunction insertClientInitCall(\n dsn: string,\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalHooksMod: ProxifiedModule<any>,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n): void {\n const initCallArgs = getInitCallArgs(dsn, 'client', selectedFeatures);\n const initCall = builders.functionCall('init', initCallArgs);\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n const initCallInsertionIndex =\n getAfterImportsInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n}\n\nexport function generateServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n) {\n // create an empty file named `instrument.server.mjs`\n const instrumentationFile = 'instrumentation.server.mjs';\n const instrumentationFileMod = parseModule('');\n\n instrumentationFileMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n const initCallArgs = getInitCallArgs(dsn, 'server', selectedFeatures);\n const initCall = builders.functionCall('Sentry.init', initCallArgs);\n\n const instrumentationFileModAST = instrumentationFileMod.$ast as Program;\n\n const initCallInsertionIndex = getAfterImportsInsertionIndex(\n instrumentationFileModAST,\n );\n\n instrumentationFileModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCall).code,\n );\n\n return { instrumentationFile, instrumentationFileMod };\n}\n\nexport async function createServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n) {\n const { instrumentationFile, instrumentationFileMod } =\n generateServerInstrumentationFile(dsn, selectedFeatures);\n\n await writeFile(instrumentationFileMod.$ast, instrumentationFile);\n\n return instrumentationFile;\n}\n\nexport async function insertServerInstrumentationFile(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n) {\n const instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n\n const expressServerPath = await findCustomExpressServerImplementation();\n\n if (!expressServerPath) {\n return false;\n }\n\n const originalExpressServerMod = await loadFile(expressServerPath);\n\n if (\n serverHasInstrumentationImport(\n expressServerPath,\n originalExpressServerMod.$code,\n )\n ) {\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(expressServerPath),\n )} already contains instrumentation import.\nSkipping adding instrumentation functionality to ${chalk.cyan(\n path.basename(expressServerPath),\n )}.`,\n );\n\n return true;\n }\n\n originalExpressServerMod.$code = `import './${instrumentationFile}';\\n${originalExpressServerMod.$code}`;\n\n fs.writeFileSync(expressServerPath, originalExpressServerMod.$code);\n\n return true;\n}\n\nexport function isRemixV2(packageJson: PackageDotJson): boolean {\n const remixVersion = getPackageVersion('@remix-run/react', packageJson);\n if (!remixVersion) {\n return false;\n }\n\n const minVer = minVersion(remixVersion);\n\n if (!minVer) {\n return false;\n }\n\n return gte(minVer, '2.0.0');\n}\n\nexport async function loadRemixConfig(): Promise<PartialRemixConfig> {\n const configFilePath = path.join(process.cwd(), REMIX_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const remixConfigModule = (await import(configUrl)) as {\n default: PartialRemixConfig;\n };\n\n return remixConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${REMIX_CONFIG_FILE}.`);\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n\n return {};\n }\n}\n\nexport async function instrumentRootRoute(isTS?: boolean): Promise<void> {\n const rootFilename = `root.${isTS ? 'tsx' : 'jsx'}`;\n\n await instrumentRoot(rootFilename);\n\n clack.log.success(\n `Successfully instrumented root route ${chalk.cyan(rootFilename)}.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport async function updateBuildScript(args: {\n org: string;\n project: string;\n url?: string;\n isHydrogen: boolean;\n}): Promise<void> {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n const buildCommand = args.isHydrogen\n ? 'shopify hydrogen build'\n : 'remix build';\n\n const instrumentedBuildCommand =\n `${buildCommand} --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +\n (args.url ? ` --url ${args.url}` : '') +\n (args.isHydrogen ? ' --buildPath ./dist' : '');\n\n if (!packageJson.scripts.build) {\n packageJson.scripts.build = instrumentedBuildCommand;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n } else if (packageJson.scripts.build.includes(buildCommand)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n packageJson.scripts.build = packageJson.scripts.build.replace(\n buildCommand,\n instrumentedBuildCommand,\n );\n } else {\n throw new Error(\n \"`build` script doesn't contain a known build command. Please update it manually.\",\n );\n }\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('build')} script in ${chalk.cyan(\n 'package.json',\n )} to generate and upload sourcemaps.`,\n );\n /* eslint-enable @typescript-eslint/no-unsafe-member-access */\n}\n\nexport function updateEntryClientMod(\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalEntryClientMod: ProxifiedModule<any>,\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): ProxifiedModule<any> {\n const imports = ['init'];\n if (selectedFeatures.replay) {\n imports.push('replayIntegration');\n }\n if (selectedFeatures.performance) {\n imports.push('browserTracingIntegration');\n }\n originalEntryClientMod.imports.$add({\n from: '@sentry/remix',\n imported: `${imports.join(', ')}`,\n });\n\n if (selectedFeatures.performance) {\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useLocation',\n local: 'useLocation',\n });\n\n originalEntryClientMod.imports.$add({\n from: '@remix-run/react',\n imported: 'useMatches',\n local: 'useMatches',\n });\n\n originalEntryClientMod.imports.$add({\n from: 'react',\n imported: 'useEffect',\n local: 'useEffect',\n });\n }\n\n insertClientInitCall(dsn, originalEntryClientMod, selectedFeatures);\n\n return originalEntryClientMod;\n}\n\nexport async function initializeSentryOnEntryClient(\n dsn: string,\n isTS: boolean,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n): Promise<void> {\n const clientEntryFilename = `entry.client.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryClient = path.join(\n process.cwd(),\n 'app',\n clientEntryFilename,\n );\n\n const originalEntryClientMod = await loadFile(originalEntryClient);\n\n if (hasSentryContent(originalEntryClient, originalEntryClientMod.$code)) {\n return;\n }\n\n const updatedEntryClientMod = updateEntryClientMod(\n originalEntryClientMod,\n dsn,\n selectedFeatures,\n );\n\n await writeFile(\n updatedEntryClientMod.$ast,\n path.join(process.cwd(), 'app', clientEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on client entry point ${chalk.cyan(\n clientEntryFilename,\n )}`,\n );\n}\n\nexport async function updateStartScript(instrumentationFile: string) {\n const packageJson = await getPackageDotJson();\n\n if (!packageJson.scripts || !packageJson.scripts.start) {\n throw new Error(\n \"Couldn't find a `start` script in your package.json. Please add one manually.\",\n );\n }\n\n if (packageJson.scripts.start.includes('NODE_OPTIONS')) {\n clack.log.warn(\n `Found existing NODE_OPTIONS in ${chalk.cyan(\n 'start',\n )} script. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n if (\n !packageJson.scripts.start.includes('remix-serve') &&\n // Adding a following empty space not to match a path that includes `node`\n !packageJson.scripts.start.includes('node ')\n ) {\n clack.log.warn(\n `Found a ${chalk.cyan('start')} script that doesn't use ${chalk.cyan(\n 'remix-serve',\n )} or ${chalk.cyan('node')}. Skipping adding Sentry initialization.`,\n );\n\n return;\n }\n\n const startCommand = packageJson.scripts.start;\n\n packageJson.scripts.start = `NODE_OPTIONS='--import ./${instrumentationFile}' ${startCommand}`;\n\n await fs.promises.writeFile(\n path.join(process.cwd(), 'package.json'),\n JSON.stringify(packageJson, null, 2),\n );\n\n clack.log.success(\n `Successfully updated ${chalk.cyan('start')} script in ${chalk.cyan(\n 'package.json',\n )} to include Sentry initialization on start.`,\n );\n}\n\nexport async function instrumentSentryOnEntryServer(\n isTS: boolean,\n): Promise<void> {\n const serverEntryFilename = `entry.server.${isTS ? 'tsx' : 'jsx'}`;\n\n const originalEntryServer = path.join(\n process.cwd(),\n 'app',\n serverEntryFilename,\n );\n\n const originalEntryServerMod = await loadFile(originalEntryServer);\n\n if (hasSentryContent(originalEntryServer, originalEntryServerMod.$code)) {\n return;\n }\n\n originalEntryServerMod.imports.$add({\n from: '@sentry/remix',\n imported: '*',\n local: 'Sentry',\n });\n\n const handleErrorInstrumented = instrumentHandleError(\n originalEntryServerMod,\n serverEntryFilename,\n );\n\n if (handleErrorInstrumented) {\n clack.log.success(\n `Instrumented ${chalk.cyan('handleError')} in ${chalk.cyan(\n `${serverEntryFilename}`,\n )}`,\n );\n }\n\n await writeFile(\n originalEntryServerMod.$ast,\n path.join(process.cwd(), 'app', serverEntryFilename),\n );\n\n clack.log.success(\n `Successfully initialized Sentry on server entry point ${chalk.cyan(\n serverEntryFilename,\n )}.`,\n );\n}\n"]}
|
|
@@ -56,6 +56,11 @@ async function createOrMergeSvelteKitFiles(projectInfo, svelteConfig) {
|
|
|
56
56
|
prompt: `Do you want to enable ${chalk_1.default.bold('Session Replay')} to get a video-like reproduction of errors during a user session?`,
|
|
57
57
|
enabledHint: 'recommended, but increases bundle size',
|
|
58
58
|
},
|
|
59
|
+
{
|
|
60
|
+
id: 'logs',
|
|
61
|
+
prompt: `Do you want to enable ${chalk_1.default.bold('Logs')} to send your application logs to Sentry?`,
|
|
62
|
+
enabledHint: 'recommended',
|
|
63
|
+
},
|
|
59
64
|
]);
|
|
60
65
|
const { clientHooksPath, serverHooksPath } = getHooksConfigDirs(svelteConfig);
|
|
61
66
|
// full file paths with correct file ending (or undefined if not found)
|
|
@@ -180,6 +185,9 @@ originalHooksMod, selectedFeatures) {
|
|
|
180
185
|
initArgs.replaysOnErrorSampleRate = 1.0;
|
|
181
186
|
initArgs.integrations = [magicast_1.builders.functionCall('Sentry.replayIntegration')];
|
|
182
187
|
}
|
|
188
|
+
if (selectedFeatures.logs) {
|
|
189
|
+
initArgs.enableLogs = true;
|
|
190
|
+
}
|
|
183
191
|
// This assignment of any values is fine because we're just creating a function call in magicast
|
|
184
192
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
185
193
|
const initCall = magicast_1.builders.functionCall('Sentry.init', initArgs);
|
|
@@ -203,6 +211,9 @@ originalHooksMod, selectedFeatures) {
|
|
|
203
211
|
if (selectedFeatures.performance) {
|
|
204
212
|
initArgs.tracesSampleRate = 1.0;
|
|
205
213
|
}
|
|
214
|
+
if (selectedFeatures.logs) {
|
|
215
|
+
initArgs.enableLogs = true;
|
|
216
|
+
}
|
|
206
217
|
// This assignment of any values is fine because we're just creating a function call in magicast
|
|
207
218
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
208
219
|
const initCall = magicast_1.builders.functionCall('Sentry.init', initArgs);
|