@sentry/wizard 3.27.0 → 3.28.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 +5 -0
- package/dist/package.json +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +52 -9
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +64 -43
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.d.ts +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.d.ts +8 -2
- package/dist/src/sveltekit/templates.js +11 -5
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/test/sveltekit/templates.test.d.ts +1 -0
- package/dist/test/sveltekit/templates.test.js +43 -0
- package/dist/test/sveltekit/templates.test.js.map +1 -0
- package/package.json +1 -1
- package/src/nextjs/nextjs-wizard.ts +45 -4
- package/src/sveltekit/sdk-setup.ts +100 -22
- package/src/sveltekit/sveltekit-wizard.ts +1 -1
- package/src/sveltekit/templates.ts +36 -10
- package/test/sveltekit/templates.test.ts +152 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/sveltekit/sdk-setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAyB;AACzB,yCAA6B;AAC7B,uCAA2B;AAC3B,gDAA0B;AAE1B,mDAAuC;AAEvC,yEAAyE;AACzE,2DAAmC;AAGnC,4EAA4E;AAC5E,qCAAyE;AACzE,4EAA4E;AAC5E,4CAAiD;AACjD,yCAA6E;AAC7E,oDAA2E;AAC3E,wCAAuC;AACvC,gDAAgE;AAKhE,0CAAyC;AAEzC,IAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAs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AAM,CAAC,CAAC;oBAC9C,MAAM,CAAC,MAAM,CAAC,UAAG,QAAQ,qBAAkB,EAAE,MAAM,CAAC,CAAC;oBACrD,MAAM,GAAC,CAAC;;;;;CAEX","sourcesContent":["import type { ExportNamedDeclaration, Program } from '@babel/types';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport chalk from 'chalk';\n\nimport * as Sentry from '@sentry/node';\n\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { builders, generateCode, loadFile, parseModule } from 'magicast';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { addVitePlugin } from 'magicast/helpers';\nimport { getClientHooksTemplate, getServerHooksTemplate } from './templates';\nimport { abortIfCancelled, isUsingTypeScript } from '../utils/clack-utils';\nimport { debug } from '../utils/debug';\nimport { findFile, hasSentryContent } from '../utils/ast-utils';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\nimport { traceStep } from '../telemetry';\n\nconst SVELTE_CONFIG_FILE = 'svelte.config.js';\n\nexport type PartialSvelteConfig = {\n kit?: {\n files?: {\n hooks?: {\n client?: string;\n server?: string;\n };\n routes?: string;\n };\n };\n};\n\ntype ProjectInfo = {\n dsn: string;\n org: string;\n project: string;\n selfHosted: boolean;\n url: string;\n};\n\nexport async function createOrMergeSvelteKitFiles(\n projectInfo: ProjectInfo,\n svelteConfig: PartialSvelteConfig,\n): Promise<void> {\n const { clientHooksPath, serverHooksPath } = getHooksConfigDirs(svelteConfig);\n\n // full file paths with correct file ending (or undefined if not found)\n const originalClientHooksFile = findFile(clientHooksPath);\n const originalServerHooksFile = findFile(serverHooksPath);\n\n const viteConfig = findFile(path.resolve(process.cwd(), 'vite.config'));\n\n const fileEnding = isUsingTypeScript() ? 'ts' : 'js';\n\n const { dsn } = projectInfo;\n\n Sentry.setTag(\n 'client-hooks-file-strategy',\n originalClientHooksFile ? 'merge' : 'create',\n );\n if (!originalClientHooksFile) {\n clack.log.info('No client hooks file found, creating a new one.');\n await createNewHooksFile(`${clientHooksPath}.${fileEnding}`, 'client', dsn);\n } else {\n await mergeHooksFile(originalClientHooksFile, 'client', dsn);\n }\n\n Sentry.setTag(\n 'server-hooks-file-strategy',\n originalServerHooksFile ? 'merge' : 'create',\n );\n if (!originalServerHooksFile) {\n clack.log.info('No server hooks file found, creating a new one.');\n await createNewHooksFile(`${serverHooksPath}.${fileEnding}`, 'server', dsn);\n } else {\n await mergeHooksFile(originalServerHooksFile, 'server', dsn);\n }\n\n if (viteConfig) {\n await modifyViteConfig(viteConfig, projectInfo);\n }\n}\n\n/**\n * Attempts to read the svelte.config.js file to find the location of the hooks files.\n * If users specified a custom location, we'll use that. Otherwise, we'll use the default.\n */\nfunction getHooksConfigDirs(svelteConfig: PartialSvelteConfig): {\n clientHooksPath: string;\n serverHooksPath: string;\n} {\n const relativeUserClientHooksPath = svelteConfig?.kit?.files?.hooks?.client;\n const relativeUserServerHooksPath = svelteConfig?.kit?.files?.hooks?.server;\n const userClientHooksPath =\n relativeUserClientHooksPath &&\n path.resolve(process.cwd(), relativeUserClientHooksPath);\n const userServerHooksPath =\n relativeUserServerHooksPath &&\n path.resolve(process.cwd(), relativeUserServerHooksPath);\n\n const defaulHooksDir = path.resolve(process.cwd(), 'src');\n const defaultClientHooksPath = path.resolve(defaulHooksDir, 'hooks.client'); // file ending missing on purpose\n const defaultServerHooksPath = path.resolve(defaulHooksDir, 'hooks.server'); // same here\n\n return {\n clientHooksPath: userClientHooksPath || defaultClientHooksPath,\n serverHooksPath: userServerHooksPath || defaultServerHooksPath,\n };\n}\n\n/**\n * Reads the template, replaces the dsn placeholder with the actual dsn and writes the file to @param hooksFileDest\n */\nasync function createNewHooksFile(\n hooksFileDest: string,\n hooktype: 'client' | 'server',\n dsn: string,\n): Promise<void> {\n const filledTemplate =\n hooktype === 'client'\n ? getClientHooksTemplate(dsn)\n : getServerHooksTemplate(dsn);\n\n await fs.promises.mkdir(path.dirname(hooksFileDest), { recursive: true });\n await fs.promises.writeFile(hooksFileDest, filledTemplate);\n\n clack.log.success(`Created ${hooksFileDest}`);\n Sentry.setTag(`created-${hooktype}-hooks`, 'success');\n}\n\n/**\n * Merges the users' hooks file with Sentry-related code.\n *\n * Both hooks:\n * - add import * as Sentry\n * - add Sentry.init\n * - add handleError hook wrapper\n *\n * Additionally in Server hook:\n * - add handle hook handler\n */\nasync function mergeHooksFile(\n hooksFile: string,\n hookType: 'client' | 'server',\n dsn: string,\n): Promise<void> {\n const originalHooksMod = await loadFile(hooksFile);\n\n const file: 'server-hooks' | 'client-hooks' = `${hookType}-hooks`;\n\n if (hasSentryContent(originalHooksMod.$ast as t.Program)) {\n // We don't want to mess with files that already have Sentry content.\n // Let's just bail out at this point.\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(hooksFile),\n )} already contains Sentry code.\nSkipping adding Sentry functionality to.`,\n );\n Sentry.setTag(`modified-${file}`, 'fail');\n Sentry.setTag(`${file}-fail-reason`, 'has-sentry-content');\n return;\n }\n\n await modifyAndRecordFail(\n () =>\n originalHooksMod.imports.$add({\n from: '@sentry/sveltekit',\n imported: '*',\n local: 'Sentry',\n }),\n 'import-injection',\n file,\n );\n\n await modifyAndRecordFail(\n () => {\n if (hookType === 'client') {\n insertClientInitCall(dsn, originalHooksMod);\n } else {\n insertServerInitCall(dsn, originalHooksMod);\n }\n },\n 'init-call-injection',\n file,\n );\n\n await modifyAndRecordFail(\n () => wrapHandleError(originalHooksMod),\n 'wrap-handle-error',\n file,\n );\n\n if (hookType === 'server') {\n await modifyAndRecordFail(\n () => wrapHandle(originalHooksMod),\n 'wrap-handle',\n 'server-hooks',\n );\n }\n\n await modifyAndRecordFail(\n async () => {\n const modifiedCode = originalHooksMod.generate().code;\n await fs.promises.writeFile(hooksFile, modifiedCode);\n },\n 'write-file',\n file,\n );\n\n clack.log.success(`Added Sentry code to ${hooksFile}`);\n Sentry.setTag(`modified-${hookType}-hooks`, 'success');\n}\n\nfunction insertClientInitCall(\n dsn: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalHooksMod: ProxifiedModule<any>,\n): void {\n const initCallComment = `\n // If you don't want to use Session Replay, remove the \\`Replay\\` integration, \n // \\`replaysSessionSampleRate\\` and \\`replaysOnErrorSampleRate\\` options.`;\n\n // This assignment of any values is fine because we're just creating a function call in magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const initCall = builders.functionCall('Sentry.init', {\n dsn,\n tracesSampleRate: 1.0,\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1.0,\n integrations: [builders.functionCall('Sentry.replayIntegration')],\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const initCallWithComment = builders.raw(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n `${initCallComment}\\n${generateCode(initCall).code}`,\n );\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n\n const initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-ignore - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCallWithComment).code,\n );\n}\n\nfunction insertServerInitCall(\n dsn: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalHooksMod: ProxifiedModule<any>,\n): void {\n // This assignment of any values is fine because we're just creating a function call in magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const initCall = builders.functionCall('Sentry.init', {\n dsn,\n tracesSampleRate: 1.0,\n });\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n\n const initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-ignore - 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\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction wrapHandleError(mod: ProxifiedModule<any>): void {\n const modAst = mod.exports.$ast as Program;\n const namedExports = modAst.body.filter(\n (node) => node.type === 'ExportNamedDeclaration',\n ) as ExportNamedDeclaration[];\n\n let foundHandleError = false;\n\n namedExports.forEach((modExport) => {\n const declaration = modExport.declaration;\n if (!declaration) {\n return;\n }\n if (declaration.type === 'FunctionDeclaration') {\n if (!declaration.id || declaration.id.name !== 'handleError') {\n return;\n }\n foundHandleError = true;\n const userCode = generateCode(declaration).code;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.handleError = builders.raw(\n `Sentry.handleErrorWithSentry(${userCode.replace(\n 'handleError',\n '_handleError',\n )})`,\n );\n // because magicast doesn't overwrite the original function export, we need to remove it manually\n modAst.body = modAst.body.filter((node) => node !== modExport);\n } else if (declaration.type === 'VariableDeclaration') {\n const declarations = declaration.declarations;\n declarations.forEach((declaration) => {\n // @ts-ignore - id should always have a name in this case\n if (!declaration.id || declaration.id.name !== 'handleError') {\n return;\n }\n foundHandleError = true;\n const userCode = declaration.init;\n const stringifiedUserCode = userCode ? generateCode(userCode).code : '';\n // @ts-ignore - we can just place a string here, magicast will convert it to a node\n declaration.init = `Sentry.handleErrorWithSentry(${stringifiedUserCode})`;\n });\n }\n });\n\n if (!foundHandleError) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.handleError = builders.functionCall(\n 'Sentry.handleErrorWithSentry',\n );\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction wrapHandle(mod: ProxifiedModule<any>): void {\n const modAst = mod.exports.$ast as Program;\n const namedExports = modAst.body.filter(\n (node) => node.type === 'ExportNamedDeclaration',\n ) as ExportNamedDeclaration[];\n\n let foundHandle = false;\n\n namedExports.forEach((modExport) => {\n const declaration = modExport.declaration;\n if (!declaration) {\n return;\n }\n if (declaration.type === 'FunctionDeclaration') {\n if (!declaration.id || declaration.id.name !== 'handle') {\n return;\n }\n foundHandle = true;\n const userCode = generateCode(declaration).code;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.handle = builders.raw(\n `sequence(Sentry.sentryHandle(), ${userCode.replace(\n 'handle',\n '_handle',\n )})`,\n );\n // because of an issue with magicast, we need to remove the original export\n modAst.body = modAst.body.filter((node) => node !== modExport);\n } else if (declaration.type === 'VariableDeclaration') {\n const declarations = declaration.declarations;\n declarations.forEach((declaration) => {\n // @ts-ignore - id should always have a name in this case\n if (!declaration.id || declaration.id.name !== 'handle') {\n return;\n }\n const userCode = declaration.init;\n const stringifiedUserCode = userCode ? generateCode(userCode).code : '';\n // @ts-ignore - we can just place a string here, magicast will convert it to a node\n declaration.init = `sequence(Sentry.sentryHandle(), ${stringifiedUserCode})`;\n foundHandle = true;\n });\n }\n });\n\n if (!foundHandle) {\n // can't use builders.functionCall here because it doesn't yet\n // support member expressions (Sentry.sentryHandle()) in args\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.handle = builders.raw('sequence(Sentry.sentryHandle())');\n }\n\n try {\n mod.imports.$add({\n from: '@sveltejs/kit/hooks',\n imported: 'sequence',\n local: 'sequence',\n });\n } catch (_) {\n // It's possible sequence is already imported. in this case, magicast throws but that's fine.\n }\n}\n\nexport async function loadSvelteConfig(): Promise<PartialSvelteConfig> {\n const configFilePath = path.join(process.cwd(), SVELTE_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const svelteConfigModule = (await import(configUrl)) as {\n default: PartialSvelteConfig;\n };\n\n return svelteConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${SVELTE_CONFIG_FILE}.\nPlease make sure, you're running this wizard with Node 16 or newer`);\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\nasync function modifyViteConfig(\n viteConfigPath: string,\n projectInfo: ProjectInfo,\n): Promise<void> {\n const viteConfigContent = (\n await fs.promises.readFile(viteConfigPath, 'utf-8')\n ).toString();\n\n const { org, project, url, selfHosted } = projectInfo;\n\n const prettyViteConfigFilename = chalk.cyan(path.basename(viteConfigPath));\n\n try {\n const viteModule = parseModule(viteConfigContent);\n\n if (hasSentryContent(viteModule.$ast as t.Program)) {\n clack.log.warn(\n `File ${prettyViteConfigFilename} already contains Sentry code.\nSkipping adding Sentry functionality to.`,\n );\n Sentry.setTag(`modified-vite-cfg`, 'fail');\n Sentry.setTag(`vite-cfg-fail-reason`, 'has-sentry-content');\n return;\n }\n\n await modifyAndRecordFail(\n () =>\n addVitePlugin(viteModule, {\n imported: 'sentrySvelteKit',\n from: '@sentry/sveltekit',\n constructor: 'sentrySvelteKit',\n options: {\n sourceMapsUploadOptions: {\n org,\n project,\n ...(selfHosted && { url }),\n },\n },\n index: 0,\n }),\n 'add-vite-plugin',\n 'vite-cfg',\n );\n\n await modifyAndRecordFail(\n async () => {\n const code = generateCode(viteModule.$ast).code;\n await fs.promises.writeFile(viteConfigPath, code);\n },\n 'write-file',\n 'vite-cfg',\n );\n } catch (e) {\n debug(e);\n await showFallbackViteCopyPasteSnippet(\n viteConfigPath,\n getViteConfigCodeSnippet(org, project, selfHosted, url),\n );\n Sentry.captureException('Sveltekit Vite Config Modification Fail');\n }\n\n clack.log.success(`Added Sentry code to ${prettyViteConfigFilename}`);\n Sentry.setTag(`modified-vite-cfg`, 'success');\n}\n\nasync function showFallbackViteCopyPasteSnippet(\n viteConfigPath: string,\n codeSnippet: string,\n) {\n const viteConfigFilename = path.basename(viteConfigPath);\n\n clack.log.warning(\n `Couldn't automatically modify your ${chalk.cyan(viteConfigFilename)}\n${chalk.dim(`This sometimes happens when we encounter more complex vite configs.\nIt may not seem like it but sometimes our magical powers are limited ;)`)}`,\n );\n\n clack.log.info(\"But don't worry - it's super easy to do this yourself!\");\n\n clack.log.step(\n `Add the following code to your ${chalk.cyan(viteConfigFilename)}:`,\n );\n\n // Intentionally logging to console here for easier copy/pasting\n // eslint-disable-next-line no-console\n console.log(codeSnippet);\n\n await abortIfCancelled(\n clack.select({\n message: 'Did you copy the snippet above?',\n options: [\n { label: 'Yes!', value: true, hint: \"Great, that's already it!\" },\n ],\n initialValue: true,\n }),\n );\n}\n\nconst getViteConfigCodeSnippet = (\n org: string,\n project: string,\n selfHosted: boolean,\n url: string,\n) =>\n chalk.gray(`\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { defineConfig } from 'vite';\n${chalk.greenBright(\"import { sentrySvelteKit } from '@sentry/sveltekit'\")}\n\nexport default defineConfig({\n plugins: [\n // Make sure \\`sentrySvelteKit\\` is registered before \\`sveltekit\\`\n ${chalk.greenBright(`sentrySvelteKit({\n sourceMapsUploadOptions: {\n org: '${org}',\n project: '${project}',${selfHosted ? `\\n url: '${url}',` : ''}\n } \n }),`)}\n sveltekit(),\n ]\n});\n`);\n\n/**\n * We want to insert the init call on top of the file but after all import statements\n */\nfunction getInitCallInsertionIndex(originalHooksModAST: Program): number {\n // We need to deep-copy here because reverse mutates in place\n const copiedBodyNodes = [...originalHooksModAST.body];\n const lastImportDeclaration = copiedBodyNodes\n .reverse()\n .find((node) => node.type === 'ImportDeclaration');\n\n const initCallInsertionIndex = lastImportDeclaration\n ? originalHooksModAST.body.indexOf(lastImportDeclaration) + 1\n : 0;\n return initCallInsertionIndex;\n}\n\n/**\n * Applies the @param modifyCallback and records Sentry tags if the call failed.\n * In case of a failure, a tag is set with @param reason as a fail reason\n * and the error is rethrown.\n */\nasync function modifyAndRecordFail<T>(\n modifyCallback: () => T | Promise<T>,\n reason: string,\n fileType: 'server-hooks' | 'client-hooks' | 'vite-cfg',\n): Promise<void> {\n try {\n await traceStep(`${fileType}-${reason}`, modifyCallback);\n } catch (e) {\n Sentry.setTag(`modified-${fileType}`, 'fail');\n Sentry.setTag(`${fileType}-mod-fail-reason`, reason);\n throw e;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-setup.js","sourceRoot":"","sources":["../../../src/sveltekit/sdk-setup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qCAAyB;AACzB,yCAA6B;AAC7B,uCAA2B;AAC3B,gDAA0B;AAE1B,mDAAuC;AAEvC,yEAAyE;AACzE,2DAAmC;AAGnC,4EAA4E;AAC5E,qCAAyE;AACzE,4EAA4E;AAC5E,4CAAiD;AACjD,yCAA6E;AAC7E,oDAI8B;AAC9B,wCAAuC;AACvC,gDAAgE;AAKhE,0CAAyC;AAEzC,IAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAsB9C,SAAsB,2BAA2B,CAC/C,WAAwB,EACxB,YAAiC;;;;;wBAER,qBAAM,IAAA,oCAAsB,EAAC;wBACpD;4BACE,EAAE,EAAE,aAAa;4BACjB,MAAM,EAAE,gCAAyB,eAAK,CAAC,IAAI,CACzC,SAAS,CACV,mDAAgD;4BACjD,WAAW,EAAE,aAAa;yBAC3B;wBACD;4BACE,EAAE,EAAE,QAAQ;4BACZ,MAAM,EAAE,gCAAyB,eAAK,CAAC,IAAI,CACzC,uBAAuB,CACxB,uEAAoE;4BACrE,WAAW,EAAE,wCAAwC;yBACtD;qBACO,CAAC,EAAA;;oBAfL,gBAAgB,GAAG,SAed;oBAEL,KAAuC,kBAAkB,CAAC,YAAY,CAAC,EAArE,eAAe,qBAAA,EAAE,eAAe,qBAAA,CAAsC;oBAGxE,uBAAuB,GAAG,IAAA,oBAAQ,EAAC,eAAe,CAAC,CAAC;oBACpD,uBAAuB,GAAG,IAAA,oBAAQ,EAAC,eAAe,CAAC,CAAC;oBAEpD,UAAU,GAAG,IAAA,oBAAQ,EAAC,IAAI,CAAC,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I,MAAM,CAAE,EAAE,cAAc,CAAC,EAAA;;oBAAxD,SAAwD,CAAC;;;;oBAEzD,MAAM,CAAC,MAAM,CAAC,mBAAY,QAAQ,CAAE,EAAE,MAAM,CAAC,CAAC;oBAC9C,MAAM,CAAC,MAAM,CAAC,UAAG,QAAQ,qBAAkB,EAAE,MAAM,CAAC,CAAC;oBACrD,MAAM,GAAC,CAAC;;;;;CAEX","sourcesContent":["import type { ExportNamedDeclaration, Program } from '@babel/types';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport chalk from 'chalk';\n\nimport * as Sentry from '@sentry/node';\n\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { builders, generateCode, loadFile, parseModule } from 'magicast';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { addVitePlugin } from 'magicast/helpers';\nimport { getClientHooksTemplate, getServerHooksTemplate } from './templates';\nimport {\n abortIfCancelled,\n featureSelectionPrompt,\n isUsingTypeScript,\n} from '../utils/clack-utils';\nimport { debug } from '../utils/debug';\nimport { findFile, hasSentryContent } from '../utils/ast-utils';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\nimport { traceStep } from '../telemetry';\n\nconst SVELTE_CONFIG_FILE = 'svelte.config.js';\n\nexport type PartialSvelteConfig = {\n kit?: {\n files?: {\n hooks?: {\n client?: string;\n server?: string;\n };\n routes?: string;\n };\n };\n};\n\ntype ProjectInfo = {\n dsn: string;\n org: string;\n project: string;\n selfHosted: boolean;\n url: string;\n};\n\nexport async function createOrMergeSvelteKitFiles(\n projectInfo: ProjectInfo,\n svelteConfig: PartialSvelteConfig,\n): Promise<void> {\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 'Sentry 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 { clientHooksPath, serverHooksPath } = getHooksConfigDirs(svelteConfig);\n\n // full file paths with correct file ending (or undefined if not found)\n const originalClientHooksFile = findFile(clientHooksPath);\n const originalServerHooksFile = findFile(serverHooksPath);\n\n const viteConfig = findFile(path.resolve(process.cwd(), 'vite.config'));\n\n const fileEnding = isUsingTypeScript() ? 'ts' : 'js';\n\n const { dsn } = projectInfo;\n\n Sentry.setTag(\n 'client-hooks-file-strategy',\n originalClientHooksFile ? 'merge' : 'create',\n );\n if (!originalClientHooksFile) {\n clack.log.info('No client hooks file found, creating a new one.');\n await createNewHooksFile(\n `${clientHooksPath}.${fileEnding}`,\n 'client',\n dsn,\n selectedFeatures,\n );\n } else {\n await mergeHooksFile(\n originalClientHooksFile,\n 'client',\n dsn,\n selectedFeatures,\n );\n }\n\n Sentry.setTag(\n 'server-hooks-file-strategy',\n originalServerHooksFile ? 'merge' : 'create',\n );\n if (!originalServerHooksFile) {\n clack.log.info('No server hooks file found, creating a new one.');\n await createNewHooksFile(\n `${serverHooksPath}.${fileEnding}`,\n 'server',\n dsn,\n selectedFeatures,\n );\n } else {\n await mergeHooksFile(\n originalServerHooksFile,\n 'server',\n dsn,\n selectedFeatures,\n );\n }\n\n if (viteConfig) {\n await modifyViteConfig(viteConfig, projectInfo);\n }\n}\n\n/**\n * Attempts to read the svelte.config.js file to find the location of the hooks files.\n * If users specified a custom location, we'll use that. Otherwise, we'll use the default.\n */\nfunction getHooksConfigDirs(svelteConfig: PartialSvelteConfig): {\n clientHooksPath: string;\n serverHooksPath: string;\n} {\n const relativeUserClientHooksPath = svelteConfig?.kit?.files?.hooks?.client;\n const relativeUserServerHooksPath = svelteConfig?.kit?.files?.hooks?.server;\n const userClientHooksPath =\n relativeUserClientHooksPath &&\n path.resolve(process.cwd(), relativeUserClientHooksPath);\n const userServerHooksPath =\n relativeUserServerHooksPath &&\n path.resolve(process.cwd(), relativeUserServerHooksPath);\n\n const defaulHooksDir = path.resolve(process.cwd(), 'src');\n const defaultClientHooksPath = path.resolve(defaulHooksDir, 'hooks.client'); // file ending missing on purpose\n const defaultServerHooksPath = path.resolve(defaulHooksDir, 'hooks.server'); // same here\n\n return {\n clientHooksPath: userClientHooksPath || defaultClientHooksPath,\n serverHooksPath: userServerHooksPath || defaultServerHooksPath,\n };\n}\n\n/**\n * Reads the template, replaces the dsn placeholder with the actual dsn and writes the file to @param hooksFileDest\n */\nasync function createNewHooksFile(\n hooksFileDest: string,\n hooktype: 'client' | 'server',\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): Promise<void> {\n const filledTemplate =\n hooktype === 'client'\n ? getClientHooksTemplate(dsn, selectedFeatures)\n : getServerHooksTemplate(dsn, selectedFeatures);\n\n await fs.promises.mkdir(path.dirname(hooksFileDest), { recursive: true });\n await fs.promises.writeFile(hooksFileDest, filledTemplate);\n\n clack.log.success(`Created ${hooksFileDest}`);\n Sentry.setTag(`created-${hooktype}-hooks`, 'success');\n}\n\n/**\n * Merges the users' hooks file with Sentry-related code.\n *\n * Both hooks:\n * - add import * as Sentry\n * - add Sentry.init\n * - add handleError hook wrapper\n *\n * Additionally in Server hook:\n * - add handle hook handler\n */\nasync function mergeHooksFile(\n hooksFile: string,\n hookType: 'client' | 'server',\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n): Promise<void> {\n const originalHooksMod = await loadFile(hooksFile);\n\n const file: 'server-hooks' | 'client-hooks' = `${hookType}-hooks`;\n\n if (hasSentryContent(originalHooksMod.$ast as t.Program)) {\n // We don't want to mess with files that already have Sentry content.\n // Let's just bail out at this point.\n clack.log.warn(\n `File ${chalk.cyan(\n path.basename(hooksFile),\n )} already contains Sentry code.\nSkipping adding Sentry functionality to.`,\n );\n Sentry.setTag(`modified-${file}`, 'fail');\n Sentry.setTag(`${file}-fail-reason`, 'has-sentry-content');\n return;\n }\n\n await modifyAndRecordFail(\n () =>\n originalHooksMod.imports.$add({\n from: '@sentry/sveltekit',\n imported: '*',\n local: 'Sentry',\n }),\n 'import-injection',\n file,\n );\n\n await modifyAndRecordFail(\n () => {\n if (hookType === 'client') {\n insertClientInitCall(dsn, originalHooksMod, selectedFeatures);\n } else {\n insertServerInitCall(dsn, originalHooksMod, selectedFeatures);\n }\n },\n 'init-call-injection',\n file,\n );\n\n await modifyAndRecordFail(\n () => wrapHandleError(originalHooksMod),\n 'wrap-handle-error',\n file,\n );\n\n if (hookType === 'server') {\n await modifyAndRecordFail(\n () => wrapHandle(originalHooksMod),\n 'wrap-handle',\n 'server-hooks',\n );\n }\n\n await modifyAndRecordFail(\n async () => {\n const modifiedCode = originalHooksMod.generate().code;\n await fs.promises.writeFile(hooksFile, modifiedCode);\n },\n 'write-file',\n file,\n );\n\n clack.log.success(`Added Sentry code to ${hooksFile}`);\n Sentry.setTag(`modified-${hookType}-hooks`, 'success');\n}\n\nfunction insertClientInitCall(\n dsn: string,\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 initCallComment = `\n // If you don't want to use Session Replay, remove the \\`Replay\\` integration,\n // \\`replaysSessionSampleRate\\` and \\`replaysOnErrorSampleRate\\` options.`;\n\n const initArgs: {\n dsn: string;\n tracesSampleRate?: number;\n replaysSessionSampleRate?: number;\n replaysOnErrorSampleRate?: number;\n integrations?: string[];\n } = {\n dsn,\n };\n\n if (selectedFeatures.performance) {\n initArgs.tracesSampleRate = 1.0;\n }\n\n if (selectedFeatures.replay) {\n initArgs.replaysSessionSampleRate = 0.1;\n initArgs.replaysOnErrorSampleRate = 1.0;\n initArgs.integrations = [builders.functionCall('Sentry.replayIntegration')];\n }\n\n // This assignment of any values is fine because we're just creating a function call in magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const initCall = builders.functionCall('Sentry.init', initArgs);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const initCallWithComment = builders.raw(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n `${initCallComment}\\n${generateCode(initCall).code}`,\n );\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n\n const initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-ignore - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n generateCode(initCallWithComment).code,\n );\n}\n\nfunction insertServerInitCall(\n dsn: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalHooksMod: ProxifiedModule<any>,\n selectedFeatures: {\n performance: boolean;\n },\n): void {\n const initArgs: {\n dsn: string;\n tracesSampleRate?: number;\n } = {\n dsn,\n };\n\n if (selectedFeatures.performance) {\n initArgs.tracesSampleRate = 1.0;\n }\n\n // This assignment of any values is fine because we're just creating a function call in magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const initCall = builders.functionCall('Sentry.init', initArgs);\n\n const originalHooksModAST = originalHooksMod.$ast as Program;\n\n const initCallInsertionIndex = getInitCallInsertionIndex(originalHooksModAST);\n\n originalHooksModAST.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-ignore - 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\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction wrapHandleError(mod: ProxifiedModule<any>): void {\n const modAst = mod.exports.$ast as Program;\n const namedExports = modAst.body.filter(\n (node) => node.type === 'ExportNamedDeclaration',\n ) as ExportNamedDeclaration[];\n\n let foundHandleError = false;\n\n namedExports.forEach((modExport) => {\n const declaration = modExport.declaration;\n if (!declaration) {\n return;\n }\n if (declaration.type === 'FunctionDeclaration') {\n if (!declaration.id || declaration.id.name !== 'handleError') {\n return;\n }\n foundHandleError = true;\n const userCode = generateCode(declaration).code;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.handleError = builders.raw(\n `Sentry.handleErrorWithSentry(${userCode.replace(\n 'handleError',\n '_handleError',\n )})`,\n );\n // because magicast doesn't overwrite the original function export, we need to remove it manually\n modAst.body = modAst.body.filter((node) => node !== modExport);\n } else if (declaration.type === 'VariableDeclaration') {\n const declarations = declaration.declarations;\n declarations.forEach((declaration) => {\n // @ts-ignore - id should always have a name in this case\n if (!declaration.id || declaration.id.name !== 'handleError') {\n return;\n }\n foundHandleError = true;\n const userCode = declaration.init;\n const stringifiedUserCode = userCode ? generateCode(userCode).code : '';\n // @ts-ignore - we can just place a string here, magicast will convert it to a node\n declaration.init = `Sentry.handleErrorWithSentry(${stringifiedUserCode})`;\n });\n }\n });\n\n if (!foundHandleError) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.handleError = builders.functionCall(\n 'Sentry.handleErrorWithSentry',\n );\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction wrapHandle(mod: ProxifiedModule<any>): void {\n const modAst = mod.exports.$ast as Program;\n const namedExports = modAst.body.filter(\n (node) => node.type === 'ExportNamedDeclaration',\n ) as ExportNamedDeclaration[];\n\n let foundHandle = false;\n\n namedExports.forEach((modExport) => {\n const declaration = modExport.declaration;\n if (!declaration) {\n return;\n }\n if (declaration.type === 'FunctionDeclaration') {\n if (!declaration.id || declaration.id.name !== 'handle') {\n return;\n }\n foundHandle = true;\n const userCode = generateCode(declaration).code;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.handle = builders.raw(\n `sequence(Sentry.sentryHandle(), ${userCode.replace(\n 'handle',\n '_handle',\n )})`,\n );\n // because of an issue with magicast, we need to remove the original export\n modAst.body = modAst.body.filter((node) => node !== modExport);\n } else if (declaration.type === 'VariableDeclaration') {\n const declarations = declaration.declarations;\n declarations.forEach((declaration) => {\n // @ts-ignore - id should always have a name in this case\n if (!declaration.id || declaration.id.name !== 'handle') {\n return;\n }\n const userCode = declaration.init;\n const stringifiedUserCode = userCode ? generateCode(userCode).code : '';\n // @ts-ignore - we can just place a string here, magicast will convert it to a node\n declaration.init = `sequence(Sentry.sentryHandle(), ${stringifiedUserCode})`;\n foundHandle = true;\n });\n }\n });\n\n if (!foundHandle) {\n // can't use builders.functionCall here because it doesn't yet\n // support member expressions (Sentry.sentryHandle()) in args\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.handle = builders.raw('sequence(Sentry.sentryHandle())');\n }\n\n try {\n mod.imports.$add({\n from: '@sveltejs/kit/hooks',\n imported: 'sequence',\n local: 'sequence',\n });\n } catch (_) {\n // It's possible sequence is already imported. in this case, magicast throws but that's fine.\n }\n}\n\nexport async function loadSvelteConfig(): Promise<PartialSvelteConfig> {\n const configFilePath = path.join(process.cwd(), SVELTE_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const svelteConfigModule = (await import(configUrl)) as {\n default: PartialSvelteConfig;\n };\n\n return svelteConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${SVELTE_CONFIG_FILE}.\nPlease make sure, you're running this wizard with Node 16 or newer`);\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\nasync function modifyViteConfig(\n viteConfigPath: string,\n projectInfo: ProjectInfo,\n): Promise<void> {\n const viteConfigContent = (\n await fs.promises.readFile(viteConfigPath, 'utf-8')\n ).toString();\n\n const { org, project, url, selfHosted } = projectInfo;\n\n const prettyViteConfigFilename = chalk.cyan(path.basename(viteConfigPath));\n\n try {\n const viteModule = parseModule(viteConfigContent);\n\n if (hasSentryContent(viteModule.$ast as t.Program)) {\n clack.log.warn(\n `File ${prettyViteConfigFilename} already contains Sentry code.\nSkipping adding Sentry functionality to.`,\n );\n Sentry.setTag(`modified-vite-cfg`, 'fail');\n Sentry.setTag(`vite-cfg-fail-reason`, 'has-sentry-content');\n return;\n }\n\n await modifyAndRecordFail(\n () =>\n addVitePlugin(viteModule, {\n imported: 'sentrySvelteKit',\n from: '@sentry/sveltekit',\n constructor: 'sentrySvelteKit',\n options: {\n sourceMapsUploadOptions: {\n org,\n project,\n ...(selfHosted && { url }),\n },\n },\n index: 0,\n }),\n 'add-vite-plugin',\n 'vite-cfg',\n );\n\n await modifyAndRecordFail(\n async () => {\n const code = generateCode(viteModule.$ast).code;\n await fs.promises.writeFile(viteConfigPath, code);\n },\n 'write-file',\n 'vite-cfg',\n );\n } catch (e) {\n debug(e);\n await showFallbackViteCopyPasteSnippet(\n viteConfigPath,\n getViteConfigCodeSnippet(org, project, selfHosted, url),\n );\n Sentry.captureException('Sveltekit Vite Config Modification Fail');\n }\n\n clack.log.success(`Added Sentry code to ${prettyViteConfigFilename}`);\n Sentry.setTag(`modified-vite-cfg`, 'success');\n}\n\nasync function showFallbackViteCopyPasteSnippet(\n viteConfigPath: string,\n codeSnippet: string,\n) {\n const viteConfigFilename = path.basename(viteConfigPath);\n\n clack.log.warning(\n `Couldn't automatically modify your ${chalk.cyan(viteConfigFilename)}\n${chalk.dim(`This sometimes happens when we encounter more complex vite configs.\nIt may not seem like it but sometimes our magical powers are limited ;)`)}`,\n );\n\n clack.log.info(\"But don't worry - it's super easy to do this yourself!\");\n\n clack.log.step(\n `Add the following code to your ${chalk.cyan(viteConfigFilename)}:`,\n );\n\n // Intentionally logging to console here for easier copy/pasting\n // eslint-disable-next-line no-console\n console.log(codeSnippet);\n\n await abortIfCancelled(\n clack.select({\n message: 'Did you copy the snippet above?',\n options: [\n { label: 'Yes!', value: true, hint: \"Great, that's already it!\" },\n ],\n initialValue: true,\n }),\n );\n}\n\nconst getViteConfigCodeSnippet = (\n org: string,\n project: string,\n selfHosted: boolean,\n url: string,\n) =>\n chalk.gray(`\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { defineConfig } from 'vite';\n${chalk.greenBright(\"import { sentrySvelteKit } from '@sentry/sveltekit'\")}\n\nexport default defineConfig({\n plugins: [\n // Make sure \\`sentrySvelteKit\\` is registered before \\`sveltekit\\`\n ${chalk.greenBright(`sentrySvelteKit({\n sourceMapsUploadOptions: {\n org: '${org}',\n project: '${project}',${selfHosted ? `\\n url: '${url}',` : ''}\n }\n }),`)}\n sveltekit(),\n ]\n});\n`);\n\n/**\n * We want to insert the init call on top of the file but after all import statements\n */\nfunction getInitCallInsertionIndex(originalHooksModAST: Program): number {\n // We need to deep-copy here because reverse mutates in place\n const copiedBodyNodes = [...originalHooksModAST.body];\n const lastImportDeclaration = copiedBodyNodes\n .reverse()\n .find((node) => node.type === 'ImportDeclaration');\n\n const initCallInsertionIndex = lastImportDeclaration\n ? originalHooksModAST.body.indexOf(lastImportDeclaration) + 1\n : 0;\n return initCallInsertionIndex;\n}\n\n/**\n * Applies the @param modifyCallback and records Sentry tags if the call failed.\n * In case of a failure, a tag is set with @param reason as a fail reason\n * and the error is rethrown.\n */\nasync function modifyAndRecordFail<T>(\n modifyCallback: () => T | Promise<T>,\n reason: string,\n fileType: 'server-hooks' | 'client-hooks' | 'vite-cfg',\n): Promise<void> {\n try {\n await traceStep(`${fileType}-${reason}`, modifyCallback);\n } catch (e) {\n Sentry.setTag(`modified-${fileType}`, 'fail');\n Sentry.setTag(`${fileType}-mod-fail-reason`, reason);\n throw e;\n }\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { WizardOptions } from '../utils/types';
|
|
1
|
+
import type { WizardOptions } from '../utils/types';
|
|
2
2
|
export declare function runSvelteKitWizard(options: WizardOptions): Promise<void>;
|
|
3
3
|
export declare function runSvelteKitWizardWithTelemetry(options: WizardOptions): Promise<void>;
|
|
@@ -1 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AAe,CAAC,YAAY,CAAC,IAAI;gCAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;6BAC9B,CAAC;wBALF,CAKE,CACH,EAAA;;oBAPD,SAOC,CAAC;;;;oBAEF,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;oBACxE,KAAK,CAAC,GAAG,CAAC,IAAI,CACZ,eAAK,CAAC,GAAG,CACP,OAAO,GAAC,KAAK,QAAQ,IAAI,GAAC,IAAI,IAAI,IAAI,UAAU,IAAI,GAAC;wBACnD,CAAC,CAAC,GAAC,CAAC,QAAQ,EAAE;wBACd,CAAC,CAAC,OAAO,GAAC,KAAK,QAAQ;4BACvB,CAAC,CAAC,GAAC;4BACH,CAAC,CAAC,eAAe,CACpB,CACF,CAAC;oBACF,MAAM,CAAC,gBAAgB,CACrB,4DAA4D,CAC7D,CAAC;oBACF,qBAAM,IAAA,mBAAK,EAAC,gBAAgB,CAAC,EAAA;;oBAA7B,SAA6B,CAAC;oBAC9B,sBAAO;;oBAIX,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,CAAC,CAAC;;;;;CACzD;AAhID,0EAgIC;AAED,SAAS,iBAAiB,CAAC,uBAAgC;IACzD,IAAM,cAAc,GAAG,IAAA,qCAAmB,GAAE,IAAI,qBAAG,CAAC;IAEpD,IAAI,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAE5E,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,4EAAqE,eAAK,CAAC,IAAI,CACpF,WAAK,cAAc,CAAC,gBAAgB,UAAQ,CAC7C,4BAAkB,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAG,CAAC;KACvD;IAED,GAAG,IAAI,+HACqD,CAAC;IAE7D,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport * as Sentry from '@sentry/node';\n\nimport {\n abort,\n abortIfCancelled,\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n} from '../utils/clack-utils';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { WizardOptions } from '../utils/types';\nimport { createExamplePage } from './sdk-example';\nimport { createOrMergeSvelteKitFiles, loadSvelteConfig } from './sdk-setup';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { getKitVersionBucket, getSvelteVersionBucket } from './utils';\nimport { NPM, detectPackageManger } from '../utils/package-manager';\n\nexport async function runSvelteKitWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sveltekit',\n },\n () => runSvelteKitWizardWithTelemetry(options),\n );\n}\n\nexport async function runSvelteKitWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry SvelteKit Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, '@sveltejs/kit', 'Sveltekit');\n\n const kitVersion = getPackageVersion('@sveltejs/kit', packageJson);\n const kitVersionBucket = getKitVersionBucket(kitVersion);\n Sentry.setTag('sveltekit-version', kitVersionBucket);\n\n if (kitVersionBucket === '0.x') {\n clack.log.warn(\n \"It seems you're using a SvelteKit version <1.0.0 which is not supported by Sentry.\\nWe recommend upgrading to the latest 1.x version before you continue.\",\n );\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: 'Yes, continue',\n hint: 'The SDK might not work correctly',\n value: true,\n },\n { label: \"No, I'll upgrade first\", value: false },\n ],\n }),\n );\n if (!shouldContinue) {\n await abort('Exiting Wizard', 0);\n return;\n }\n }\n\n Sentry.setTag(\n 'svelte-version',\n getSvelteVersionBucket(getPackageVersion('svelte', packageJson)),\n );\n\n const { selectedProject, selfHosted, sentryUrl, authToken } =\n await getOrAskForProjectData(options, 'javascript-sveltekit');\n\n const sdkAlreadyInstalled = hasPackageInstalled(\n '@sentry/sveltekit',\n packageJson,\n );\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/sveltekit',\n alreadyInstalled: sdkAlreadyInstalled,\n });\n\n await addSentryCliConfig({ authToken });\n\n const svelteConfig = await traceStep('load-svelte-config', loadSvelteConfig);\n\n try {\n await traceStep('configure-sdk', () =>\n createOrMergeSvelteKitFiles(\n {\n dsn: selectedProject.keys[0].dsn.public,\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n selfHosted,\n url: sentryUrl,\n },\n svelteConfig,\n ),\n );\n } catch (e: unknown) {\n clack.log.error('Error while setting up the SvelteKit SDK:');\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 Sentry.captureException('Error while setting up the SvelteKit SDK');\n await abort('Exiting Wizard');\n return;\n }\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage(\n '/sentry-example',\n );\n\n if (shouldCreateExamplePage) {\n try {\n await traceStep('create-example-page', () =>\n createExamplePage(svelteConfig, {\n selfHosted,\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n }),\n );\n } catch (e: unknown) {\n clack.log.error('Error while creating an example page to test Sentry:');\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 Sentry.captureException(\n 'Error while creating an example Svelte page to test Sentry',\n );\n await abort('Exiting Wizard');\n return;\n }\n }\n\n clack.outro(buildOutroMessage(shouldCreateExamplePage));\n}\n\nfunction buildOutroMessage(shouldCreateExamplePage: boolean): string {\n const packageManager = detectPackageManger() || NPM;\n\n let msg = chalk.green('\\nSuccessfully installed the Sentry SvelteKit SDK!');\n\n if (shouldCreateExamplePage) {\n msg += `\\n\\nYou can validate your setup by starting your dev environment (${chalk.cyan(\n `\\`${packageManager.runScriptCommand} dev\\``,\n )}) and visiting ${chalk.cyan('\"/sentry-example\"')}.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/sveltekit/`;\n\n return msg;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sveltekit-wizard.js","sourceRoot":"","sources":["../../../src/sveltekit/sveltekit-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAAyE;AACzE,oDAAwC;AACxC,gDAA0B;AAE1B,mDAAuC;AAEvC,oDAW8B;AAC9B,sDAA+E;AAE/E,6CAAkD;AAClD,yCAA4E;AAC5E,0CAAwD;AACxD,iCAAsE;AACtE,4DAAoE;AAEpE,SAAsB,kBAAkB,CACtC,OAAsB;;;YAEtB,sBAAO,IAAA,yBAAa,EAClB;oBACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;oBACjC,WAAW,EAAE,WAAW;iBACzB,EACD,cAAM,OAAA,+BAA+B,CAAC,OAAO,CAAC,EAAxC,CAAwC,CAC/C,EAAC;;;CACH;AAVD,gDAUC;AAED,SAAsB,+BAA+B,CACnD,OAAsB;;;;;;oBAEtB,IAAA,0BAAY,EAAC;wBACX,UAAU,EAAE,yBAAyB;wBACrC,SAAS,EAAE,OAAO,CAAC,SAAS;wBAC5B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;qBAC3C,CAAC,CAAC;oBAEH,qBAAM,IAAA,+CAAiC,GAAE,EAAA;;oBAAzC,SAAyC,CAAC;oBAEtB,qBAAM,IAAA,+BAAiB,GAAE,EAAA;;oBAAv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CAAC;IAE5E,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,4EAAqE,eAAK,CAAC,IAAI,CACpF,WAAK,cAAc,CAAC,gBAAgB,UAAQ,CAC7C,4BAAkB,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAG,CAAC;KACvD;IAED,GAAG,IAAI,+HACqD,CAAC;IAE7D,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport * as Sentry from '@sentry/node';\n\nimport {\n abort,\n abortIfCancelled,\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n} from '../utils/clack-utils';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { createExamplePage } from './sdk-example';\nimport { createOrMergeSvelteKitFiles, loadSvelteConfig } from './sdk-setup';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { getKitVersionBucket, getSvelteVersionBucket } from './utils';\nimport { NPM, detectPackageManger } from '../utils/package-manager';\n\nexport async function runSvelteKitWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sveltekit',\n },\n () => runSvelteKitWizardWithTelemetry(options),\n );\n}\n\nexport async function runSvelteKitWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry SvelteKit Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, '@sveltejs/kit', 'Sveltekit');\n\n const kitVersion = getPackageVersion('@sveltejs/kit', packageJson);\n const kitVersionBucket = getKitVersionBucket(kitVersion);\n Sentry.setTag('sveltekit-version', kitVersionBucket);\n\n if (kitVersionBucket === '0.x') {\n clack.log.warn(\n \"It seems you're using a SvelteKit version <1.0.0 which is not supported by Sentry.\\nWe recommend upgrading to the latest 1.x version before you continue.\",\n );\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: 'Yes, continue',\n hint: 'The SDK might not work correctly',\n value: true,\n },\n { label: \"No, I'll upgrade first\", value: false },\n ],\n }),\n );\n if (!shouldContinue) {\n await abort('Exiting Wizard', 0);\n return;\n }\n }\n\n Sentry.setTag(\n 'svelte-version',\n getSvelteVersionBucket(getPackageVersion('svelte', packageJson)),\n );\n\n const { selectedProject, selfHosted, sentryUrl, authToken } =\n await getOrAskForProjectData(options, 'javascript-sveltekit');\n\n const sdkAlreadyInstalled = hasPackageInstalled(\n '@sentry/sveltekit',\n packageJson,\n );\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/sveltekit',\n alreadyInstalled: sdkAlreadyInstalled,\n });\n\n await addSentryCliConfig({ authToken });\n\n const svelteConfig = await traceStep('load-svelte-config', loadSvelteConfig);\n\n try {\n await traceStep('configure-sdk', () =>\n createOrMergeSvelteKitFiles(\n {\n dsn: selectedProject.keys[0].dsn.public,\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n selfHosted,\n url: sentryUrl,\n },\n svelteConfig,\n ),\n );\n } catch (e: unknown) {\n clack.log.error('Error while setting up the SvelteKit SDK:');\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 Sentry.captureException('Error while setting up the SvelteKit SDK');\n await abort('Exiting Wizard');\n return;\n }\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage(\n '/sentry-example',\n );\n\n if (shouldCreateExamplePage) {\n try {\n await traceStep('create-example-page', () =>\n createExamplePage(svelteConfig, {\n selfHosted,\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n }),\n );\n } catch (e: unknown) {\n clack.log.error('Error while creating an example page to test Sentry:');\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 Sentry.captureException(\n 'Error while creating an example Svelte page to test Sentry',\n );\n await abort('Exiting Wizard');\n return;\n }\n }\n\n clack.outro(buildOutroMessage(shouldCreateExamplePage));\n}\n\nfunction buildOutroMessage(shouldCreateExamplePage: boolean): string {\n const packageManager = detectPackageManger() || NPM;\n\n let msg = chalk.green('\\nSuccessfully installed the Sentry SvelteKit SDK!');\n\n if (shouldCreateExamplePage) {\n msg += `\\n\\nYou can validate your setup by starting your dev environment (${chalk.cyan(\n `\\`${packageManager.runScriptCommand} dev\\``,\n )}) and visiting ${chalk.cyan('\"/sentry-example\"')}.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/sveltekit/`;\n\n return msg;\n}\n"]}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
export declare function getClientHooksTemplate(dsn: string
|
|
2
|
-
|
|
1
|
+
export declare function getClientHooksTemplate(dsn: string, selectedFeatures: {
|
|
2
|
+
performance: boolean;
|
|
3
|
+
replay: boolean;
|
|
4
|
+
}): string;
|
|
5
|
+
export declare function getServerHooksTemplate(dsn: string, selectedFeatures: {
|
|
6
|
+
performance: boolean;
|
|
7
|
+
replay: boolean;
|
|
8
|
+
}): string;
|
|
3
9
|
/**
|
|
4
10
|
* +page.svelte with Sentry example
|
|
5
11
|
*/
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSentryExampleApiRoute = exports.getSentryExampleSveltePage = exports.getServerHooksTemplate = exports.getClientHooksTemplate = void 0;
|
|
4
|
-
function getClientHooksTemplate(dsn) {
|
|
5
|
-
return "import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n
|
|
4
|
+
function getClientHooksTemplate(dsn, selectedFeatures) {
|
|
5
|
+
return "import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n").concat(selectedFeatures.performance
|
|
6
|
+
? "\n tracesSampleRate: 1.0,\n"
|
|
7
|
+
: '', "\n").concat(selectedFeatures.replay
|
|
8
|
+
? " // 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: [replayIntegration()],"
|
|
9
|
+
: '', "\n});\n\n// If you have a custom error handler, pass it to `handleErrorWithSentry`\nexport const handleError = handleErrorWithSentry();\n");
|
|
6
10
|
}
|
|
7
11
|
exports.getClientHooksTemplate = getClientHooksTemplate;
|
|
8
|
-
function getServerHooksTemplate(dsn) {
|
|
9
|
-
return "import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n
|
|
12
|
+
function getServerHooksTemplate(dsn, selectedFeatures) {
|
|
13
|
+
return "import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '".concat(dsn, "',\n").concat(selectedFeatures.performance
|
|
14
|
+
? "\n tracesSampleRate: 1.0,\n"
|
|
15
|
+
: '', "\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});\n\n// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to `handleErrorWithSentry`\nexport const handleError = handleErrorWithSentry();\n");
|
|
10
16
|
}
|
|
11
17
|
exports.getServerHooksTemplate = getServerHooksTemplate;
|
|
12
18
|
/**
|
|
@@ -16,7 +22,7 @@ function getSentryExampleSveltePage(options) {
|
|
|
16
22
|
var issuesPageLink = options.selfHosted
|
|
17
23
|
? "".concat(options.url, "organizations/").concat(options.orgSlug, "/issues/?project=").concat(options.projectId)
|
|
18
24
|
: "https://".concat(options.orgSlug, ".sentry.io/issues/?project=").concat(options.projectId);
|
|
19
|
-
return "
|
|
25
|
+
return "<!--\nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file and the entire sentry route.\n-->\n\n<script>\n import * as Sentry from '@sentry/sveltekit';\n\n function getSentryData() {\n Sentry.startSpan({\n name: 'Example Frontend Span',\n op: 'test',\n }, async () => {\n const res = await fetch('/sentry-example');\n if (!res.ok) {\n throw new Error('Sentry Example Frontend Error');\n }\n });\n }\n</script>\n\n<div>\n <head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your SvelteKit app!\" />\n </head>\n\n <main>\n <h1>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n />\n </svg>\n </h1>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button\n type=\"button\"\n on:click={getSentryData}>\n Throw error!\n </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"".concat(issuesPageLink, "\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/sveltekit/\">\n Sentry SvelteKit Documentation\n </a>\n </p>\n </main>\n</div>\n\n<style>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n h1 {\n font-size: 4rem;\n margin: 14px 0;\n }\n\n svg {\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n");
|
|
20
26
|
}
|
|
21
27
|
exports.getSentryExampleSveltePage = getSentryExampleSveltePage;
|
|
22
28
|
function getSentryExampleApiRoute() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/sveltekit/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/sveltekit/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,sBAAsB,CACpC,GAAW,EACX,gBAGC;IAED,OAAO,kKAIC,GAAG,iBAEX,gBAAgB,CAAC,WAAW;QAC1B,CAAC,CAAC,8BAEL;QACG,CAAC,CAAC,EAAE,eAGN,gBAAgB,CAAC,MAAM;QACrB,CAAC,CAAC,4bASiC;QACnC,CAAC,CAAC,EAAE,8IAMP,CAAC;AACF,CAAC;AAtCD,wDAsCC;AAED,SAAgB,sBAAsB,CACpC,GAAW,EACX,gBAGC;IAED,OAAO,gNAKC,GAAG,iBAEX,gBAAgB,CAAC,WAAW;QAC1B,CAAC,CAAC,8BAEL;QACG,CAAC,CAAC,EAAE,gaAWP,CAAC;AACF,CAAC;AA9BD,wDA8BC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CAAC,OAK1C;IACC,IAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,UAAG,OAAO,CAAC,GAAG,2BAAiB,OAAO,CAAC,OAAO,8BAAoB,OAAO,CAAC,SAAS,CAAE;QACvF,CAAC,CAAC,kBAAW,OAAO,CAAC,OAAO,wCAA8B,OAAO,CAAC,SAAS,CAAE,CAAC;IAEhF,OAAO,s6EAiDQ,cAAc,w7BAgD9B,CAAC;AACF,CAAC;AA5GD,gEA4GC;AAED,SAAgB,wBAAwB;IACtC,OAAO,wOAMR,CAAC;AACF,CAAC;AARD,4DAQC","sourcesContent":["export function getClientHooksTemplate(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n return `import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n${\n selectedFeatures.performance\n ? `\n tracesSampleRate: 1.0,\n`\n : ''\n}\n${\n selectedFeatures.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: [replayIntegration()],`\n : ''\n}\n});\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\nexport function getServerHooksTemplate(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n return `import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n${\n selectedFeatures.performance\n ? `\n tracesSampleRate: 1.0,\n`\n : ''\n}\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});\n\n// If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\n/**\n * +page.svelte with Sentry example\n */\nexport function getSentryExampleSveltePage(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n}) {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;\n\n return `<!--\nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file and the entire sentry route.\n-->\n\n<script>\n import * as Sentry from '@sentry/sveltekit';\n\n function getSentryData() {\n Sentry.startSpan({\n name: 'Example Frontend Span',\n op: 'test',\n }, async () => {\n const res = await fetch('/sentry-example');\n if (!res.ok) {\n throw new Error('Sentry Example Frontend Error');\n }\n });\n }\n</script>\n\n<div>\n <head>\n <title>Sentry Onboarding</title>\n <meta name=\"description\" content=\"Test Sentry for your SvelteKit app!\" />\n </head>\n\n <main>\n <h1>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n />\n </svg>\n </h1>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button\n type=\"button\"\n on:click={getSentryData}>\n Throw error!\n </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/sveltekit/\">\n Sentry SvelteKit Documentation\n </a>\n </p>\n </main>\n</div>\n\n<style>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n h1 {\n font-size: 4rem;\n margin: 14px 0;\n }\n\n svg {\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n\nexport function getSentryExampleApiRoute() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file and the entire sentry route.\n\nexport const GET = async () => {\n throw new Error(\"Sentry Example API Route Error\");\n};\n`;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var templates_1 = require("../../src/sveltekit/templates");
|
|
4
|
+
describe('getClientHooksTemplate', function () {
|
|
5
|
+
it('should generate client hooks template with all features enabled', function () {
|
|
6
|
+
var result = (0, templates_1.getClientHooksTemplate)('https://sentry.io/123', {
|
|
7
|
+
performance: true,
|
|
8
|
+
replay: true,
|
|
9
|
+
});
|
|
10
|
+
expect(result).toMatchInlineSnapshot("\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\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: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to `handleErrorWithSentry`\n export const handleError = handleErrorWithSentry();\n \"\n ");
|
|
11
|
+
});
|
|
12
|
+
it('should generate client hooks template when performance disabled', function () {
|
|
13
|
+
var result = (0, templates_1.getClientHooksTemplate)('https://sentry.io/123', {
|
|
14
|
+
performance: false,
|
|
15
|
+
replay: true,
|
|
16
|
+
});
|
|
17
|
+
expect(result).toMatchInlineSnapshot("\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\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: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to `handleErrorWithSentry`\n export const handleError = handleErrorWithSentry();\n \"\n ");
|
|
18
|
+
});
|
|
19
|
+
it('should generate client hooks template when replay disabled', function () {
|
|
20
|
+
var result = (0, templates_1.getClientHooksTemplate)('https://sentry.io/123', {
|
|
21
|
+
performance: true,
|
|
22
|
+
replay: false,
|
|
23
|
+
});
|
|
24
|
+
expect(result).toMatchInlineSnapshot("\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n\n });\n\n // If you have a custom error handler, pass it to `handleErrorWithSentry`\n export const handleError = handleErrorWithSentry();\n \"\n ");
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('getServerHooksTemplate', function () {
|
|
28
|
+
it('should generate server hooks template with all features enabled', function () {
|
|
29
|
+
var result = (0, templates_1.getServerHooksTemplate)('https://sentry.io/123', {
|
|
30
|
+
performance: true,
|
|
31
|
+
replay: true,
|
|
32
|
+
});
|
|
33
|
+
expect(result).toMatchInlineSnapshot("\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to `handleErrorWithSentry`\n export const handleError = handleErrorWithSentry();\n \"\n ");
|
|
34
|
+
});
|
|
35
|
+
it('should generate server hooks template when performance disabled', function () {
|
|
36
|
+
var result = (0, templates_1.getServerHooksTemplate)('https://sentry.io/123', {
|
|
37
|
+
performance: false,
|
|
38
|
+
replay: true,
|
|
39
|
+
});
|
|
40
|
+
expect(result).toMatchInlineSnapshot("\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to `handleErrorWithSentry`\n export const handleError = handleErrorWithSentry();\n \"\n ");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=templates.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/sveltekit/templates.test.ts"],"names":[],"mappings":";;AAAA,2DAGuC;AAEvC,QAAQ,CAAC,wBAAwB,EAAE;IACjC,EAAE,CAAC,iEAAiE,EAAE;QACpE,IAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,s4BAwBpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE;QACpE,IAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,o2BAsBpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE;QAC/D,IAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,4ZAepC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,wBAAwB,EAAE;IACjC,EAAE,CAAC,iEAAiE,EAAE;QACpE,IAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,wvBAoBpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE;QACpE,IAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,stBAkBpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n getClientHooksTemplate,\n getServerHooksTemplate,\n} from '../../src/sveltekit/templates';\n\ndescribe('getClientHooksTemplate', () => {\n it('should generate client hooks template with all features enabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\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: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate client hooks template when performance disabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\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: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate client hooks template when replay disabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: false,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n});\n\ndescribe('getServerHooksTemplate', () => {\n it('should generate server hooks template with all features enabled', () => {\n const result = getServerHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate server hooks template when performance disabled', () => {\n const result = getServerHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/wizard",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.28.0",
|
|
4
4
|
"homepage": "https://github.com/getsentry/sentry-wizard",
|
|
5
5
|
"repository": "https://github.com/getsentry/sentry-wizard",
|
|
6
6
|
"description": "Sentry wizard helping you to configure your project",
|
|
@@ -297,6 +297,25 @@ export async function runNextjsWizardWithTelemetry(
|
|
|
297
297
|
|
|
298
298
|
await addDotEnvSentryBuildPluginFile(authToken);
|
|
299
299
|
|
|
300
|
+
const isLikelyUsingTurbopack = await checkIfLikelyIsUsingTurbopack();
|
|
301
|
+
if (isLikelyUsingTurbopack || isLikelyUsingTurbopack === null) {
|
|
302
|
+
await abortIfCancelled(
|
|
303
|
+
clack.select({
|
|
304
|
+
message: `Warning: The Sentry SDK doesn't yet fully support Turbopack in dev mode. The SDK will not be loaded in the browser, and serverside instrumentation will be inaccurate or incomplete. Production builds will still fully work. ${chalk.bold(
|
|
305
|
+
`To continue this setup, if you are using Turbopack, temporarily remove \`--turbo\` from your dev command until you have verified the SDK is working as expected.`,
|
|
306
|
+
)}`,
|
|
307
|
+
options: [
|
|
308
|
+
{
|
|
309
|
+
label: 'I understand.',
|
|
310
|
+
hint: 'press enter',
|
|
311
|
+
value: true,
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
initialValue: true,
|
|
315
|
+
}),
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
300
319
|
const mightBeUsingVercel = fs.existsSync(
|
|
301
320
|
path.join(process.cwd(), 'vercel.json'),
|
|
302
321
|
);
|
|
@@ -309,13 +328,18 @@ export async function runNextjsWizardWithTelemetry(
|
|
|
309
328
|
await traceStep('configure-ci', () => configureCI('nextjs', authToken));
|
|
310
329
|
}
|
|
311
330
|
|
|
312
|
-
clack.outro(
|
|
313
|
-
|
|
331
|
+
clack.outro(`${chalk.green(
|
|
332
|
+
'Successfully installed the Sentry Next.js SDK!',
|
|
333
|
+
)}${
|
|
314
334
|
shouldCreateExamplePage
|
|
315
|
-
? `\n\nYou can validate your setup by
|
|
335
|
+
? `\n\nYou can validate your setup by (re)starting your dev environment (${chalk.cyan(
|
|
316
336
|
`next dev`,
|
|
317
337
|
)}) and visiting ${chalk.cyan('"/sentry-example-page"')}`
|
|
318
338
|
: ''
|
|
339
|
+
}${
|
|
340
|
+
shouldCreateExamplePage && isLikelyUsingTurbopack
|
|
341
|
+
? `\nDon't forget to remove \`--turbo\` from your dev command until you have verified the SDK is working. You can safely add it back afterwards.`
|
|
342
|
+
: ''
|
|
319
343
|
}
|
|
320
344
|
|
|
321
345
|
${chalk.dim(
|
|
@@ -346,7 +370,7 @@ async function createOrMergeNextJsFiles(
|
|
|
346
370
|
id: 'replay',
|
|
347
371
|
prompt: `Do you want to enable ${chalk.bold(
|
|
348
372
|
'Sentry Session Replay',
|
|
349
|
-
)} to get reproduction of
|
|
373
|
+
)} to get a video-like reproduction of errors during a user session?`,
|
|
350
374
|
enabledHint: 'recommended, but increases bundle size',
|
|
351
375
|
},
|
|
352
376
|
] as const);
|
|
@@ -925,3 +949,20 @@ async function askShouldEnableReactComponentAnnotation() {
|
|
|
925
949
|
return shouldEnableReactComponentAnnotation;
|
|
926
950
|
});
|
|
927
951
|
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* Returns true or false depending on whether we think the user is using Turbopack. May return null in case we aren't sure.
|
|
955
|
+
*/
|
|
956
|
+
async function checkIfLikelyIsUsingTurbopack(): Promise<boolean | null> {
|
|
957
|
+
let packageJsonContent: string;
|
|
958
|
+
try {
|
|
959
|
+
packageJsonContent = await fs.promises.readFile(
|
|
960
|
+
path.join(process.cwd(), 'package.json'),
|
|
961
|
+
'utf8',
|
|
962
|
+
);
|
|
963
|
+
} catch {
|
|
964
|
+
return null;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
return packageJsonContent.includes('--turbo');
|
|
968
|
+
}
|