@sentry/wizard 6.8.0 → 6.9.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 +18 -0
- package/dist/e2e-tests/tests/nuxt-3.test.js +2 -4
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +2 -4
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/pnpm-workspace.test.js +2 -4
- package/dist/e2e-tests/tests/pnpm-workspace.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js +68 -84
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js +5 -4
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
- package/dist/src/apple/fastlane.js +3 -1
- package/dist/src/apple/fastlane.js.map +1 -1
- package/dist/src/apple/templates.js +1 -1
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.js +3 -5
- package/dist/src/nuxt/sdk-setup.js.map +1 -1
- package/dist/src/nuxt/templates.js +6 -3
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.d.ts +1 -0
- package/dist/src/sveltekit/sdk-example.js +3 -1
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup/vite.js +5 -9
- package/dist/src/sveltekit/sdk-setup/vite.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +4 -2
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.d.ts +1 -0
- package/dist/src/sveltekit/templates.js +2 -4
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/sveltekit/utils.d.ts +1 -1
- package/dist/src/sveltekit/utils.js +45 -32
- package/dist/src/sveltekit/utils.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/apple/fastfile.test.js +8 -8
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/templates.test.js +1 -1
- package/dist/test/apple/templates.test.js.map +1 -1
- package/dist/test/nuxt/templates.test.js +35 -6
- package/dist/test/nuxt/templates.test.js.map +1 -1
- package/dist/test/sveltekit/templates.test.js +478 -0
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/dist/test/sveltekit/utils.test.d.ts +1 -0
- package/dist/test/sveltekit/utils.test.js +68 -0
- package/dist/test/sveltekit/utils.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -86,10 +86,12 @@ function findLanes(content) {
|
|
|
86
86
|
}
|
|
87
87
|
function addSentryToLane(content, lane, org, project) {
|
|
88
88
|
const laneContent = content.slice(lane.index, lane.index + lane.length);
|
|
89
|
-
const sentryCLIMatch = /
|
|
89
|
+
const sentryCLIMatch = /(\n\s+)sentry_debug_files_upload\s*\([^)]+\)/gim.exec(laneContent);
|
|
90
90
|
if (sentryCLIMatch) {
|
|
91
91
|
// Sentry already added to lane. Update it.
|
|
92
|
+
// sentryCLIMatch[1] contains the leading newline and whitespace
|
|
92
93
|
return (content.slice(0, sentryCLIMatch.index + lane.index) +
|
|
94
|
+
sentryCLIMatch[1] +
|
|
93
95
|
templates.getFastlaneSnippet(org, project).trim() +
|
|
94
96
|
content.slice(sentryCLIMatch.index + sentryCLIMatch[0].length + lane.index));
|
|
95
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastlane.js","sourceRoot":"","sources":["../../../src/apple/fastlane.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,0CAAqD;AACrD,uDAAyC;AACzC,+EAA+E;AAC/E,sDAAwC;AAExC,SAAgB,QAAQ,CAAC,WAAmB;IAC1C,MAAM,YAAY,GAAG,I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AAe,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;KACvE;SAAM;QACL,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,YAAY,GAAG,MAAM,IAAA,2BAAmB,EAC5C,SAAS,EACT,+BAA+B,CAChC,CAAC;QACF,IAAI,YAAY,KAAK,SAAS,EAAE;YAC9B,OAAO,KAAK,CAAC;SACd;QACD,cAAc,GAAG,eAAe,CAC9B,WAAW,EACX,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EACzB,GAAG,EACH,OAAO,CACR,CAAC;KACH;IAED,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC;AACd,CAAC;AAlDD,kDAkDC;AAUD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;IACnC,wBAAgB,GAAG;QACjB,eAAe;QACf,SAAS;QACT,eAAe;KAChB,CAAC;CACH","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { askForItemSelection } from '../utils/clack';\nimport * as templates from './templates';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n\nexport function fastFile(projectPath: string): string | null {\n const fastlanePath = path.join(projectPath, 'fastlane', 'Fastfile');\n return fs.existsSync(fastlanePath) ? fastlanePath : null;\n}\n\nfunction findIOSPlatform(\n content: string,\n): { index: number; length: number } | null {\n const platformRegex = /^ *platform\\s+:([^ ]+)[^\\n]*\\n/gim;\n let match = platformRegex.exec(content);\n if (!match) {\n // No platform found, treat whole file as one platform.\n return { index: 0, length: content.length };\n }\n\n let index = -1;\n while (match) {\n if (match[1] === 'ios') {\n index = match.index + match[0].length;\n break;\n }\n match = platformRegex.exec(content);\n }\n\n if (index === -1) {\n return null;\n }\n\n //After finding the platform, we need to find the end of the platform block.\n //This solution has the assumption that the file is well formed,\n //which is not a perfect solution, but it's good enough assumption.\n const platformEndRegex = /^end[^\\n]*/gim;\n match = platformEndRegex.exec(content.slice(index));\n if (!match) {\n return null;\n }\n\n return { index, length: match.index };\n}\n\nfunction findLanes(\n content: string,\n): { index: number; length: number; name: string }[] | null {\n const laneRegex = /^ {2}lane\\s+:([^ ]+)[^\\n]*\\n/gim;\n let match = laneRegex.exec(content);\n if (!match) {\n return null;\n }\n\n const lanes: { index: number; length: number; name: string }[] = [];\n while (match) {\n const laneEnd = /^ {2}end/m.exec(\n content.slice(match.index + match[0].length),\n );\n if (laneEnd === null) {\n return null;\n }\n lanes.push({\n index: match.index + match[0].length,\n length: laneEnd.index,\n name: match[1],\n });\n match = laneRegex.exec(content);\n }\n return lanes;\n}\n\nfunction addSentryToLane(\n content: string,\n lane: { index: number; length: number; name: string },\n org: string,\n project: string,\n): string {\n const laneContent = content.slice(lane.index, lane.index + lane.length);\n const sentryCLIMatch = /(\\n\\s+)sentry_debug_files_upload\\s*\\([^)]+\\)/gim.exec(\n laneContent,\n );\n if (sentryCLIMatch) {\n // Sentry already added to lane. Update it.\n // sentryCLIMatch[1] contains the leading newline and whitespace\n return (\n content.slice(0, sentryCLIMatch.index + lane.index) +\n sentryCLIMatch[1] +\n templates.getFastlaneSnippet(org, project).trim() +\n content.slice(\n sentryCLIMatch.index + sentryCLIMatch[0].length + lane.index,\n )\n );\n }\n\n // Sentry not added to lane. Add it.\n return (\n content.slice(0, lane.index + lane.length) +\n '\\n' +\n templates.getFastlaneSnippet(org, project) +\n '\\n' +\n content.slice(lane.index + lane.length)\n );\n}\n\nexport async function addSentryToFastlane(\n projectDir: string,\n org: string,\n project: string,\n): Promise<boolean> {\n const fastFilePath = fastFile(projectDir);\n if (!fastFilePath) {\n return false;\n }\n\n const fileContent = fs.readFileSync(fastFilePath, 'utf8');\n const platform = findIOSPlatform(fileContent);\n if (!platform) {\n return false;\n }\n\n const platformContent = fileContent.slice(\n platform.index,\n platform.index + platform.length,\n );\n const lanes = findLanes(platformContent);\n lanes?.forEach((l) => (l.index += platform.index));\n\n if (!lanes || lanes.length === 0) {\n clack.log.warn('No suitable lanes in your Fastfile.');\n return false;\n }\n\n let newFileContent: string | undefined;\n if (lanes.length === 1) {\n newFileContent = addSentryToLane(fileContent, lanes[0], org, project);\n } else {\n const laneNames = lanes.map((l) => l.name);\n const selectedLane = await askForItemSelection(\n laneNames,\n 'Select lane to add Sentry to:',\n );\n if (selectedLane === undefined) {\n return false;\n }\n newFileContent = addSentryToLane(\n fileContent,\n lanes[selectedLane.index],\n org,\n project,\n );\n }\n\n fs.writeFileSync(fastFilePath, newFileContent, 'utf8');\n return true;\n}\n\n/**\n * Exported for testing purposes, but should not be used in other modules.\n */\nexport let exportForTesting: {\n findIOSPlatform: typeof findIOSPlatform;\n findLanes: typeof findLanes;\n addSentryToLane: typeof addSentryToLane;\n};\nif (process.env.NODE_ENV === 'test') {\n exportForTesting = {\n findIOSPlatform,\n findLanes,\n addSentryToLane,\n };\n}\n"]}
|
|
@@ -94,7 +94,7 @@ function getObjcSnippet(dsn, enableLogs) {
|
|
|
94
94
|
}
|
|
95
95
|
exports.getObjcSnippet = getObjcSnippet;
|
|
96
96
|
function getFastlaneSnippet(org, project) {
|
|
97
|
-
return `
|
|
97
|
+
return ` sentry_debug_files_upload(
|
|
98
98
|
org_slug: '${org}',
|
|
99
99
|
project_slug: '${project}',
|
|
100
100
|
include_sources: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC;;;;CAIL;QACG,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe;;sBAE5F,OAAO;0BACH,WAAW;0CAEjC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC;;;;;;;CAOD,CAAC;AACF,CAAC;AA5BD,oDA4BC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW,EAAE,UAAmB;IAC9D,IAAI,OAAO,GAAG;6BACa,GAAG;;;;;;;;;;;;;;;;;;sGAkBsE,CAAC;IAErG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;mDAGoC,CAAC;KACjD;IAED,OAAO,IAAI;;;iEAGoD,CAAC;IAEhE,OAAO,OAAO,CAAC;AACjB,CAAC;AAnCD,0CAmCC;AAED,SAAgB,cAAc,CAAC,GAAW,EAAE,UAAmB;IAC7D,IAAI,OAAO,GAAG;0BACU,GAAG;;;;;;;;;;;;;;;;;;oGAkBuE,CAAC;IAEnG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;+CAGgC,CAAC;KAC7C;IAED,OAAO,IAAI;;;2DAG8C,CAAC;IAE1D,OAAO,OAAO,CAAC;AACjB,CAAC;AAnCD,wCAmCC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? `\nif [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n`\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\nif which sentry-cli >/dev/null; then\n export SENTRY_ORG=${orgSlug}\n export SENTRY_PROJECT=${projectSlug}\n ERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\n if [ ! $? -eq 0 ]; then\n echo \"warning: sentry-cli - $ERROR\"\n fi\nelse\n echo \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = true`;\n }\n\n snippet += `\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n\n return snippet;\n}\n\nexport function getObjcSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = YES;`;\n }\n\n snippet += `\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n\n return snippet;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return `
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC;;;;CAIL;QACG,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe;;sBAE5F,OAAO;0BACH,WAAW;0CAEjC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC;;;;;;;CAOD,CAAC;AACF,CAAC;AA5BD,oDA4BC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW,EAAE,UAAmB;IAC9D,IAAI,OAAO,GAAG;6BACa,GAAG;;;;;;;;;;;;;;;;;;sGAkBsE,CAAC;IAErG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;mDAGoC,CAAC;KACjD;IAED,OAAO,IAAI;;;iEAGoD,CAAC;IAEhE,OAAO,OAAO,CAAC;AACjB,CAAC;AAnCD,0CAmCC;AAED,SAAgB,cAAc,CAAC,GAAW,EAAE,UAAmB;IAC7D,IAAI,OAAO,GAAG;0BACU,GAAG;;;;;;;;;;;;;;;;;;oGAkBuE,CAAC;IAEnG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;+CAGgC,CAAC;KAC7C;IAED,OAAO,IAAI;;;2DAG8C,CAAC;IAE1D,OAAO,OAAO,CAAC;AACjB,CAAC;AAnCD,wCAmCC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? `\nif [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n`\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\nif which sentry-cli >/dev/null; then\n export SENTRY_ORG=${orgSlug}\n export SENTRY_PROJECT=${projectSlug}\n ERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\n if [ ! $? -eq 0 ]; then\n echo \"warning: sentry-cli - $ERROR\"\n fi\nelse\n echo \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = true`;\n }\n\n snippet += `\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n\n return snippet;\n}\n\nexport function getObjcSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = YES;`;\n }\n\n snippet += `\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n\n return snippet;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_debug_files_upload(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
|
|
@@ -107,11 +107,9 @@ async function addSDKModule(config, options, deploymentPlatform) {
|
|
|
107
107
|
}
|
|
108
108
|
try {
|
|
109
109
|
(0, helpers_1.addNuxtModule)(module, '@sentry/nuxt/module', 'sentry', {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
...(options.selfHosted && { url: options.url }),
|
|
114
|
-
},
|
|
110
|
+
org: options.org,
|
|
111
|
+
project: options.project,
|
|
112
|
+
...(options.selfHosted && { url: options.url }),
|
|
115
113
|
...(shouldTopLevelImport && {
|
|
116
114
|
autoInjectServerSentry: 'top-level-import',
|
|
117
115
|
}),
|
|
@@ -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,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;Q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AC,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 {\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"]}
|
|
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,CAAC,CAAC;QAChD,kDAAkD;QAClD,UAAU,GAAG,gBAAgB,CAAC;QAE9B,MAAM,iBAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,EACpC,IAAA,gCAAoB,GAAE,EACtB,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE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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 org: options.org,\n project: options.project,\n ...(options.selfHosted && { url: options.url }),\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"]}
|
|
@@ -14,9 +14,12 @@ exports.getDefaultNuxtConfig = getDefaultNuxtConfig;
|
|
|
14
14
|
function getNuxtModuleFallbackTemplate(options, shouldTopLevelImport) {
|
|
15
15
|
return ` modules: ["@sentry/nuxt/module"],
|
|
16
16
|
sentry: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
org: "${options.org}",
|
|
18
|
+
project: "${options.project}",${options.selfHosted ? `\n url: "${options.url}",` : ''}
|
|
19
|
+
sourcemaps: {
|
|
20
|
+
// This will delete all .map files in the build output after uploading them to Sentry. Modify as needed.
|
|
21
|
+
// For more information, see: https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps/
|
|
22
|
+
filesToDeleteAfterUpload: ['.*/**/*.map']
|
|
20
23
|
},${shouldTopLevelImport
|
|
21
24
|
? `\n autoInjectServerSentry: "top-level-import",`
|
|
22
25
|
: ''}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nuxt/templates.ts"],"names":[],"mappings":";;;AAAA,sCAAiD;AAQjD,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,MAAM,iBAAiB,GAAiD;IACtE,WAAW,EAAE;QACX,8EAA8E;QAC9E,wBAAwB;QACxB,0BAA0B;KAC3B,CAAC,IAAI,CAAC,IAAI,CAAC;IACZ,MAAM,EAAE;QACN,8EAA8E;QAC9E,8DAA8D;QAC9D,kCAAkC;QA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,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 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 // Enable sending of user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\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 // Enable sending of user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\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"]}
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nuxt/templates.ts"],"names":[],"mappings":";;;AAAA,sCAAiD;AAQjD,SAAgB,oBAAoB;IAClC,OAAO;;;;;CAKR,CAAC;AACF,CAAC;AAPD,oDAOC;AAED,SAAgB,6BAA6B,CAC3C,OAKC,EACD,oBAA6B;IAE7B,OAAO;;YAEG,OAAO,CAAC,GAAG;gBACP,OAAO,CAAC,OAAO,KAC3B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EACxD;;;;;QAMI,oBAAoB;QAClB,CAAC,CAAC,mDAAmD;QACrD,CAAC,CAAC,EACN;;mCAE+B,CAAC;AACpC,CAAC;AA1BD,sEA0BC;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,MAAM,iBAAiB,GAAiD;IACtE,WAAW,EAAE;QACX,8EAA8E;QAC9E,wBAAwB;QACxB,0BAA0B;KAC3B,CAAC,IAAI,CAAC,IAAI,CAAC;IACZ,MAAM,EAAE;QACN,8EAA8E;QAC9E,8DAA8D;QAC9D,kCAAkC;QAClC,IAAI;QACJ,gFAAgF;QAChF,qCAAqC;QACrC,kCAAkC;QAClC,IAAI;QACJ,2EAA2E;QAC3E,+CAA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AM,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 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 org: \"${options.org}\",\n project: \"${options.project}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n sourcemaps: { \n // This will delete all .map files in the build output after uploading them to Sentry. Modify as needed.\n // For more information, see: https://docs.sentry.io/platforms/javascript/guides/nuxt/sourcemaps/\n filesToDeleteAfterUpload: ['.*/**/*.map'] \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 // Enable sending of user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\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 // Enable sending of user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\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"]}
|
|
@@ -49,7 +49,9 @@ async function createExamplePage(svelteConfig, projectProps) {
|
|
|
49
49
|
prompts_1.default.log.warn(`It seems like a sentry example page already exists (${path.basename(exampleRoutePath)}). Skipping creation of example route.`);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
await fs.promises.writeFile(path.join(exampleRoutePath, '+page.svelte'), (0, templates_1.getSentryExampleSveltePage)(
|
|
52
|
+
await fs.promises.writeFile(path.join(exampleRoutePath, '+page.svelte'), (0, templates_1.getSentryExampleSveltePage)({
|
|
53
|
+
...projectProps,
|
|
54
|
+
}));
|
|
53
55
|
await fs.promises.writeFile(path.join(exampleRoutePath, '+server.js'), (0, templates_1.getSentryExampleApiRoute)());
|
|
54
56
|
}
|
|
55
57
|
exports.createExamplePage = createExamplePage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-example.js","sourceRoot":"","sources":["../../../src/sveltekit/sdk-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,+EAA+E;AAC/E,6DAAmC;AAGnC,2CAGqB;AAErB;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,YAA4D,EAC5D,
|
|
1
|
+
{"version":3,"file":"sdk-example.js","sourceRoot":"","sources":["../../../src/sveltekit/sdk-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,+EAA+E;AAC/E,6DAAmC;AAGnC,2CAGqB;AAErB;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,YAA4D,EAC5D,YAMC;IAED,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,IAAI,YAAY,CAAC;IACxE,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CACnC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAClD,CAAC;IAEF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;QACnC,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,yDAAyD,eAAe,EAAE,CAC3E,CAAC;QACF,EAAE,CAAC,SAAS,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KACpD;IAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACpC,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;KAChC;SAAM;QACL,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,uDAAuD,IAAI,CAAC,QAAQ,CAClE,gBAAgB,CACjB,wCAAwC,CAC1C,CAAC;QACF,OAAO;KACR;IAED,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,EAC3C,IAAA,sCAA0B,EAAC;QACzB,GAAG,YAAY;KAChB,CAAC,CACH,CAAC;IAEF,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,EACzC,IAAA,oCAAwB,GAAE,CAC3B,CAAC;AACJ,CAAC;AA5CD,8CA4CC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n\nimport { PartialBackwardsForwardsCompatibleSvelteConfig } from './sdk-setup/svelte-config';\nimport {\n getSentryExampleApiRoute,\n getSentryExampleSveltePage,\n} from './templates';\n\n/**\n * Creates example page and API route to test Sentry\n */\nexport async function createExamplePage(\n svelteConfig: PartialBackwardsForwardsCompatibleSvelteConfig,\n projectProps: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n isUsingSvelte5: boolean;\n },\n): Promise<void> {\n const routesDirectory = svelteConfig.kit?.files?.routes || 'src/routes';\n const exampleRoutePath = path.resolve(\n path.join(routesDirectory, 'sentry-example-page'),\n );\n\n if (!fs.existsSync(routesDirectory)) {\n clack.log.warn(\n `Couldn't find your routes directory. Creating it now: ${routesDirectory}`,\n );\n fs.mkdirSync(routesDirectory, { recursive: true });\n }\n\n if (!fs.existsSync(exampleRoutePath)) {\n fs.mkdirSync(exampleRoutePath);\n } else {\n clack.log.warn(\n `It seems like a sentry example page already exists (${path.basename(\n exampleRoutePath,\n )}). Skipping creation of example route.`,\n );\n return;\n }\n\n await fs.promises.writeFile(\n path.join(exampleRoutePath, '+page.svelte'),\n getSentryExampleSveltePage({\n ...projectProps,\n }),\n );\n\n await fs.promises.writeFile(\n path.join(exampleRoutePath, '+server.js'),\n getSentryExampleApiRoute(),\n );\n}\n"]}
|
|
@@ -59,11 +59,9 @@ Skipping adding Sentry functionality to.`);
|
|
|
59
59
|
from: '@sentry/sveltekit',
|
|
60
60
|
constructor: 'sentrySvelteKit',
|
|
61
61
|
options: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
...(selfHosted && { url }),
|
|
66
|
-
},
|
|
62
|
+
org,
|
|
63
|
+
project,
|
|
64
|
+
...(selfHosted && { url }),
|
|
67
65
|
},
|
|
68
66
|
index: 0,
|
|
69
67
|
}), 'add-vite-plugin', 'vite-cfg');
|
|
@@ -108,10 +106,8 @@ export default defineConfig({
|
|
|
108
106
|
plugins: [
|
|
109
107
|
// Make sure \`sentrySvelteKit\` is registered before \`sveltekit\`
|
|
110
108
|
${chalk_1.default.greenBright(`sentrySvelteKit({
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
project: '${project}',${selfHosted ? `\n url: '${url}',` : ''}
|
|
114
|
-
}
|
|
109
|
+
org: '${org}',
|
|
110
|
+
project: '${project}',${selfHosted ? `\n url: '${url}',` : ''}
|
|
115
111
|
}),`)}
|
|
116
112
|
sveltekit(),
|
|
117
113
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","sourceRoot":"","sources":["../../../../src/sveltekit/sdk-setup/vite.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,uCAAyB;AACzB,2CAA6B;AAC7B,kDAA0B;AAE1B,8EAA8E;AAC9E,6DAAmC;AACnC,kFAAkF;AAClF,uCAAqD;AACrD,kFAAkF;AAClF,8CAAiD;AAMjD,qDAAyD;AACzD,6CAA0C;AAC1C,6CAAqD;AAErD,mCAA8C;AAEvC,KAAK,UAAU,gBAAgB,CACpC,cAAsB,EACtB,WAAwB;IAExB,MAAM,iBAAiB,GAAG,CACxB,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CACpD,CAAC,QAAQ,EAAE,CAAC;IAEb,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;IAEtD,MAAM,wBAAwB,GAAG,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;IAE3E,IAAI;QACF,MAAM,UAAU,GAAG,IAAA,sBAAW,EAAC,iBAAiB,CAAC,CAAC;QAElD,IAAI,IAAA,4BAAgB,EAAC,UAAU,CAAC,IAAiB,CAAC,EAAE;YAClD,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,QAAQ,wBAAwB;yCACC,CAClC,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;YAC3C,MAAM,CAAC,MAAM,CAAC,sBAAsB,EAA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sCAAsC,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC;EACtE,eAAK,CAAC,GAAG,CAAC;wEAC4D,CAAC,EAAE,CACxE,CAAC;IAEF,iBAAK,CAAC,GAAG,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;IAEzE,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,kCAAkC,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CACpE,CAAC;IAEF,gEAAgE;IAChE,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEzB,MAAM,IAAA,wBAAgB,EACpB,iBAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,iCAAiC;QAC1C,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,2BAA2B,EAAE;SAClE;QACD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,wBAAwB,GAAG,CAC/B,GAAW,EACX,OAAe,EACf,UAAmB,EACnB,GAAW,EACX,EAAE,CACF,eAAK,CAAC,IAAI,CAAC;;;EAGX,eAAK,CAAC,WAAW,CAAC,qDAAqD,CAAC;;;;;MAKpE,eAAK,CAAC,WAAW,CAAC;cACV,GAAG;kBACC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE;QAClE,CAAC;;;;CAIR,CAAC,CAAC","sourcesContent":["import * as Sentry from '@sentry/node';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport chalk from 'chalk';\n\n//@ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule } from 'magicast';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { addVitePlugin } from 'magicast/helpers';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nimport { hasSentryContent } from '../../utils/ast-utils';\nimport { debug } from '../../utils/debug';\nimport { abortIfCancelled } from '../../utils/clack';\nimport type { ProjectInfo } from './types';\nimport { modifyAndRecordFail } from './utils';\n\nexport async 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 org,\n project,\n ...(selfHosted && { url }),\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 org: '${org}',\n project: '${project}',${selfHosted ? `\\n url: '${url}',` : ''}\n }),`)}\n sveltekit(),\n ]\n});\n`);\n"]}
|
|
@@ -121,7 +121,8 @@ without SvelteKit's builtin observability.`);
|
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
const svelteVersionBucket = (0, utils_1.getSvelteVersionBucket)((0, package_json_1.getPackageVersion)('svelte', packageJson));
|
|
125
|
+
Sentry.setTag('svelte-version', svelteVersionBucket);
|
|
125
126
|
const projectData = await (0, clack_1.getOrAskForProjectData)(options, 'javascript-sveltekit');
|
|
126
127
|
if (projectData.spotlight) {
|
|
127
128
|
clack.log.warn('Spotlight mode is not yet supported for SvelteKit.');
|
|
@@ -163,11 +164,12 @@ without SvelteKit's builtin observability.`);
|
|
|
163
164
|
const shouldCreateExamplePage = await (0, clack_1.askShouldCreateExamplePage)('/sentry-example-page');
|
|
164
165
|
if (shouldCreateExamplePage) {
|
|
165
166
|
try {
|
|
166
|
-
await (0, telemetry_1.traceStep)('create-example-page', () => (0, sdk_example_1.createExamplePage)(svelteConfig, {
|
|
167
|
+
await (0, telemetry_1.traceStep)('create-example-page', async () => (0, sdk_example_1.createExamplePage)(svelteConfig, {
|
|
167
168
|
selfHosted,
|
|
168
169
|
url: sentryUrl,
|
|
169
170
|
orgSlug: selectedProject.organization.slug,
|
|
170
171
|
projectId: selectedProject.id,
|
|
172
|
+
isUsingSvelte5: ['5.x', '>5.x'].includes(svelteVersionBucket),
|
|
171
173
|
}));
|
|
172
174
|
}
|
|
173
175
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit-wizard.js","sourceRoot":"","sources":["../../../src/sveltekit/sveltekit-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAE1B,qDAAuC;AAEvC,4CAAwD;AACxD,0CAawB;AACxB,wDAA+E;AAC/E,8DAA+C;AAE/C,0DAAwE;AACxE,+CAAkD;AAClD,6CAAgE;AAChE,6DAA6D;AAC7D,mCAAsE;AAE/D,KAAK,UAAU,kBAAkB,CACtC,OAAsB;IAEtB,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,WAAW;QACxB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAC/C,CAAC;AACJ,CAAC;AAXD,gDAWC;AAEM,KAAK,UAAU,+BAA+B,CACnD,OAAsB;IAEtB,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE9D,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,yBAAyB;QACrC,SAAS;QACT,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,IAAA,yCAAiC,EAAC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AU,iBAAiB,CAC9B,uBAAgC;IAEhC,MAAM,cAAc,GAAG,MAAM,IAAA,yBAAiB,EAAC,qBAAG,CAAC,CAAC;IAEpD,IAAI,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAE1E,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,qEAAqE,eAAK,CAAC,IAAI,CACpF,KAAK,cAAc,CAAC,gBAAgB,QAAQ,CAC7C,kBAAkB,eAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC;KAC5D;IAED,GAAG,IAAI;8DACqD,CAAC;IAE7D,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// @ts-expect-error - 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 { traceStep, withTelemetry } from '../telemetry';\nimport {\n abort,\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n getPackageManager,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { NPM } from '../utils/package-manager';\nimport type { WizardOptions } from '../utils/types';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport { createExamplePage } from './sdk-example';\nimport { createOrMergeSvelteKitFiles } from './sdk-setup/setup';\nimport { loadSvelteConfig } from './sdk-setup/svelte-config';\nimport { getKitVersionBucket, getSvelteVersionBucket } from './utils';\n\nexport async function runSvelteKitWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sveltekit',\n wizardOptions: options,\n },\n () => runSvelteKitWizardWithTelemetry(options),\n );\n}\n\nexport async function runSvelteKitWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry SvelteKit Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\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 let setupForSvelteKitTracing = kitVersionBucket === '>=2.31.0';\n\n if (kitVersionBucket !== '>=2.31.0') {\n clack.log.warn(\n `It seems you're using a SvelteKit version ${chalk.cyan(\n '<2.31.0',\n )} (detected ${chalk.cyan(kitVersion ?? 'unknown')}). \n\nWe recommend upgrading SvelteKit to version ${chalk.cyan(\n '>=2.31.0',\n )} to use SvelteKit's builtin observability:\n${chalk.cyan('https://svelte.dev/docs/kit/observability')}\n\nSentry works best with SvelteKit versions ${chalk.cyan('>=2.31.0')}.\n\nIf you prefer, you can stay on your current version and use the Sentry SDK \nwithout SvelteKit's builtin observability.`,\n );\n\n const decision = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: \"No, I'll upgrade SvelteKit first\",\n hint: 'Recommended',\n value: 'exit-to-upgrade',\n },\n {\n label: \"I'm already on SvelteKit >=2.31.0\",\n hint: 'Sorry, my bad!',\n value: 'install-with-kit-tracing',\n },\n {\n label: 'Yes, continue',\n hint: 'No Problem!',\n value: 'install-without-kit-tracing',\n },\n ],\n }),\n );\n\n if (decision === 'install-with-kit-tracing') {\n setupForSvelteKitTracing = true;\n }\n\n if (decision === 'exit-to-upgrade') {\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 projectData = await getOrAskForProjectData(\n options,\n 'javascript-sveltekit',\n );\n\n if (projectData.spotlight) {\n clack.log.warn('Spotlight mode is not yet supported for SvelteKit.');\n clack.log.info('Spotlight is currently only available for Next.js.');\n await abort('Exiting wizard', 0);\n return;\n }\n\n const { selectedProject, selfHosted, sentryUrl, authToken } = projectData;\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@^10',\n packageNameDisplayLabel: '@sentry/sveltekit',\n alreadyInstalled: sdkAlreadyInstalled,\n forceInstall,\n });\n\n await addDotEnvSentryBuildPluginFile(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 setupForSvelteKitTracing,\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-page',\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 await runPrettierIfInstalled({ cwd: undefined });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n clack.outro(await buildOutroMessage(shouldCreateExamplePage));\n}\n\nasync function buildOutroMessage(\n shouldCreateExamplePage: boolean,\n): Promise<string> {\n const packageManager = await getPackageManager(NPM);\n\n let msg = chalk.green('Successfully 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-page\"')}.`;\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,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAE1B,qDAAuC;AAEvC,4CAAwD;AACxD,0CAawB;AACxB,wDAA+E;AAC/E,8DAA+C;AAE/C,0DAAwE;AACxE,+CAAkD;AAClD,6CAAgE;AAChE,6DAA6D;AAC7D,mC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I,CAAC,IAAI,IAAI,IAAI,UAAU,IAAI,CAAC;gBACnD,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;gBACd,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ;oBACvB,CAAC,CAAC,CAAC;oBACH,CAAC,CAAC,eAAe,CACpB,CACF,CAAC;YACF,MAAM,CAAC,gBAAgB,CACrB,4DAA4D,CAC7D,CAAC;YACF,MAAM,IAAA,aAAK,EAAC,gBAAgB,CAAC,CAAC;YAC9B,OAAO;SACR;KACF;IAED,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAEjD,iFAAiF;IACjF,MAAM,IAAA,wCAA2B,EAC/B,eAAe,CAAC,YAAY,CAAC,IAAI,EACjC,eAAe,CAAC,IAAI,CACrB,CAAC;IAEF,KAAK,CAAC,KAAK,CAAC,MAAM,iBAAiB,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAChE,CAAC;AAhND,0EAgNC;AAED,KAAK,UAAU,iBAAiB,CAC9B,uBAAgC;IAEhC,MAAM,cAAc,GAAG,MAAM,IAAA,yBAAiB,EAAC,qBAAG,CAAC,CAAC;IAEpD,IAAI,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAE1E,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,qEAAqE,eAAK,CAAC,IAAI,CACpF,KAAK,cAAc,CAAC,gBAAgB,QAAQ,CAC7C,kBAAkB,eAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC;KAC5D;IAED,GAAG,IAAI;8DACqD,CAAC;IAE7D,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// @ts-expect-error - 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 { traceStep, withTelemetry } from '../telemetry';\nimport {\n abort,\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n getPackageManager,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { NPM } from '../utils/package-manager';\nimport type { WizardOptions } from '../utils/types';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport { createExamplePage } from './sdk-example';\nimport { createOrMergeSvelteKitFiles } from './sdk-setup/setup';\nimport { loadSvelteConfig } from './sdk-setup/svelte-config';\nimport { getKitVersionBucket, getSvelteVersionBucket } from './utils';\n\nexport async function runSvelteKitWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sveltekit',\n wizardOptions: options,\n },\n () => runSvelteKitWizardWithTelemetry(options),\n );\n}\n\nexport async function runSvelteKitWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry SvelteKit Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\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 let setupForSvelteKitTracing = kitVersionBucket === '>=2.31.0';\n\n if (kitVersionBucket !== '>=2.31.0') {\n clack.log.warn(\n `It seems you're using a SvelteKit version ${chalk.cyan(\n '<2.31.0',\n )} (detected ${chalk.cyan(kitVersion ?? 'unknown')}). \n\nWe recommend upgrading SvelteKit to version ${chalk.cyan(\n '>=2.31.0',\n )} to use SvelteKit's builtin observability:\n${chalk.cyan('https://svelte.dev/docs/kit/observability')}\n\nSentry works best with SvelteKit versions ${chalk.cyan('>=2.31.0')}.\n\nIf you prefer, you can stay on your current version and use the Sentry SDK \nwithout SvelteKit's builtin observability.`,\n );\n\n const decision = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: \"No, I'll upgrade SvelteKit first\",\n hint: 'Recommended',\n value: 'exit-to-upgrade',\n },\n {\n label: \"I'm already on SvelteKit >=2.31.0\",\n hint: 'Sorry, my bad!',\n value: 'install-with-kit-tracing',\n },\n {\n label: 'Yes, continue',\n hint: 'No Problem!',\n value: 'install-without-kit-tracing',\n },\n ],\n }),\n );\n\n if (decision === 'install-with-kit-tracing') {\n setupForSvelteKitTracing = true;\n }\n\n if (decision === 'exit-to-upgrade') {\n await abort('Exiting Wizard', 0);\n return;\n }\n }\n\n const svelteVersionBucket = getSvelteVersionBucket(\n getPackageVersion('svelte', packageJson),\n );\n Sentry.setTag('svelte-version', svelteVersionBucket);\n\n const projectData = await getOrAskForProjectData(\n options,\n 'javascript-sveltekit',\n );\n\n if (projectData.spotlight) {\n clack.log.warn('Spotlight mode is not yet supported for SvelteKit.');\n clack.log.info('Spotlight is currently only available for Next.js.');\n await abort('Exiting wizard', 0);\n return;\n }\n\n const { selectedProject, selfHosted, sentryUrl, authToken } = projectData;\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@^10',\n packageNameDisplayLabel: '@sentry/sveltekit',\n alreadyInstalled: sdkAlreadyInstalled,\n forceInstall,\n });\n\n await addDotEnvSentryBuildPluginFile(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 setupForSvelteKitTracing,\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-page',\n );\n\n if (shouldCreateExamplePage) {\n try {\n await traceStep('create-example-page', async () =>\n createExamplePage(svelteConfig, {\n selfHosted,\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n isUsingSvelte5: ['5.x', '>5.x'].includes(svelteVersionBucket),\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 await runPrettierIfInstalled({ cwd: undefined });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n clack.outro(await buildOutroMessage(shouldCreateExamplePage));\n}\n\nasync function buildOutroMessage(\n shouldCreateExamplePage: boolean,\n): Promise<string> {\n const packageManager = await getPackageManager(NPM);\n\n let msg = chalk.green('Successfully 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-page\"')}.`;\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"]}
|
|
@@ -113,9 +113,7 @@ Feel free to delete this file and the entire sentry route.
|
|
|
113
113
|
import * as Sentry from '@sentry/sveltekit';
|
|
114
114
|
import { onMount } from 'svelte';
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
// let hasSentError = $state(false);
|
|
118
|
-
let hasSentError = false;
|
|
116
|
+
let hasSentError = ${options.isUsingSvelte5 ? '$state(false)' : 'false'};
|
|
119
117
|
let isConnected = true;
|
|
120
118
|
|
|
121
119
|
onMount(async () => {
|
|
@@ -159,7 +157,7 @@ Feel free to delete this file and the entire sentry route.
|
|
|
159
157
|
|
|
160
158
|
<button
|
|
161
159
|
type="button"
|
|
162
|
-
|
|
160
|
+
on${options.isUsingSvelte5 ? '' : ':'}click={getSentryData}
|
|
163
161
|
disabled={!isConnected}
|
|
164
162
|
>
|
|
165
163
|
<span>
|