@sentry/wizard 6.3.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/e2e-tests/tests/{sveltekit.test.js → sveltekit-hooks.test.js} +10 -6
  3. package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -0
  4. package/dist/e2e-tests/tests/sveltekit-tracing.test.d.ts +1 -0
  5. package/dist/e2e-tests/tests/sveltekit-tracing.test.js +203 -0
  6. package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -0
  7. package/dist/src/sveltekit/sdk-example.d.ts +2 -2
  8. package/dist/src/sveltekit/sdk-example.js.map +1 -1
  9. package/dist/src/sveltekit/sdk-setup/setup.d.ts +3 -0
  10. package/dist/src/sveltekit/{sdk-setup.js → sdk-setup/setup.js} +113 -157
  11. package/dist/src/sveltekit/sdk-setup/setup.js.map +1 -0
  12. package/dist/src/sveltekit/sdk-setup/svelte-config.d.ts +25 -0
  13. package/dist/src/sveltekit/sdk-setup/svelte-config.js +291 -0
  14. package/dist/src/sveltekit/sdk-setup/svelte-config.js.map +1 -0
  15. package/dist/src/sveltekit/sdk-setup/types.d.ts +7 -0
  16. package/dist/src/sveltekit/sdk-setup/types.js +3 -0
  17. package/dist/src/sveltekit/sdk-setup/types.js.map +1 -0
  18. package/dist/src/sveltekit/sdk-setup/utils.d.ts +6 -0
  19. package/dist/src/sveltekit/sdk-setup/utils.js +45 -0
  20. package/dist/src/sveltekit/sdk-setup/utils.js.map +1 -0
  21. package/dist/src/sveltekit/sdk-setup/vite.d.ts +2 -0
  22. package/dist/src/sveltekit/sdk-setup/vite.js +120 -0
  23. package/dist/src/sveltekit/sdk-setup/vite.js.map +1 -0
  24. package/dist/src/sveltekit/sveltekit-wizard.js +45 -5
  25. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  26. package/dist/src/sveltekit/templates.d.ts +4 -0
  27. package/dist/src/sveltekit/templates.js +33 -10
  28. package/dist/src/sveltekit/templates.js.map +1 -1
  29. package/dist/src/sveltekit/utils.d.ts +2 -1
  30. package/dist/src/sveltekit/utils.js +7 -2
  31. package/dist/src/sveltekit/utils.js.map +1 -1
  32. package/dist/src/version.d.ts +1 -1
  33. package/dist/src/version.js +1 -1
  34. package/dist/src/version.js.map +1 -1
  35. package/dist/test/sveltekit/sdk-setup/svelte-config.test.d.ts +1 -0
  36. package/dist/test/sveltekit/sdk-setup/svelte-config.test.js +529 -0
  37. package/dist/test/sveltekit/sdk-setup/svelte-config.test.js.map +1 -0
  38. package/dist/test/sveltekit/templates.test.js +103 -10
  39. package/dist/test/sveltekit/templates.test.js.map +1 -1
  40. package/package.json +1 -1
  41. package/dist/e2e-tests/tests/sveltekit.test.js.map +0 -1
  42. package/dist/src/sveltekit/sdk-setup.d.ts +0 -21
  43. package/dist/src/sveltekit/sdk-setup.js.map +0 -1
  44. /package/dist/e2e-tests/tests/{sveltekit.test.d.ts → sveltekit-hooks.test.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.4.0
4
+
5
+ - feat(sveltekit): Add support for SDK setup with `instrumentation.server.ts` ([#1077](https://github.com/getsentry/sentry-wizard/pull/1077))
6
+
7
+ This release adds support for setting up the SvelteKit SDK in SvelteKit versions 2.31.0 or higher.
8
+
3
9
  ## 6.3.0
4
10
 
5
11
  - feat(nextjs,remix,sveltekit,react-native,flutter,ios,angular,android,nuxt): add support to add MCP server during wizard based installlations ([#1063](https://github.com/getsentry/sentry-wizard/pull/1063))
@@ -52,16 +52,20 @@ export async function handleError({ error, event }) {
52
52
  `;
53
53
  async function runWizardOnSvelteKitProject(projectDir, integration, fileModificationFn) {
54
54
  const wizardInstance = (0, utils_1.startWizardInstance)(integration, projectDir);
55
- let packageManagerPrompted = false;
55
+ let kitVersionPrompted = false;
56
56
  if (fileModificationFn) {
57
57
  fileModificationFn(projectDir, integration);
58
58
  // As we modified project, we have a warning prompt before we get the package manager prompt
59
59
  await wizardInstance.waitForOutput('Do you want to continue anyway?');
60
- packageManagerPrompted = await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Please select your package manager.');
60
+ kitVersionPrompted = await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], "It seems you're using a SvelteKit version");
61
61
  }
62
62
  else {
63
- packageManagerPrompted = await wizardInstance.waitForOutput('Please select your package manager');
63
+ kitVersionPrompted = await wizardInstance.waitForOutput("It seems you're using a SvelteKit version");
64
64
  }
65
+ const packageManagerPrompted = kitVersionPrompted &&
66
+ (await wizardInstance.sendStdinAndWaitForOutput(
67
+ // Select "Yes, Continue" to perform hooks-based SDK setup
68
+ [utils_1.KEYS.DOWN, utils_1.KEYS.DOWN, utils_1.KEYS.ENTER], 'Please select your package manager.'));
65
69
  const tracingOptionPrompted = packageManagerPrompted &&
66
70
  (await wizardInstance.sendStdinAndWaitForOutput(
67
71
  // Selecting `yarn` as the package manager
@@ -132,7 +136,7 @@ function checkSvelteKitProject(projectDir, integration, options) {
132
136
  (0, vitest_1.describe)('Sveltekit', () => {
133
137
  (0, vitest_1.describe)('without existing hooks', () => {
134
138
  const integration = Constants_1.Integration.sveltekit;
135
- const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-test-app');
139
+ const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-hooks-test-app');
136
140
  (0, vitest_1.beforeAll)(async () => {
137
141
  await runWizardOnSvelteKitProject(projectDir, integration);
138
142
  });
@@ -186,7 +190,7 @@ function checkSvelteKitProject(projectDir, integration, options) {
186
190
  });
187
191
  (0, vitest_1.describe)('with existing hooks', () => {
188
192
  const integration = Constants_1.Integration.sveltekit;
189
- const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-test-app');
193
+ const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-hooks-test-app');
190
194
  (0, vitest_1.beforeAll)(async () => {
191
195
  await runWizardOnSvelteKitProject(projectDir, integration, (projectDir) => {
192
196
  (0, utils_1.createFile)(path.resolve(projectDir, 'src/hooks.server.ts'), SERVER_HOOK_TEMPLATE);
@@ -227,4 +231,4 @@ function checkSvelteKitProject(projectDir, integration, options) {
227
231
  });
228
232
  });
229
233
  });
230
- //# sourceMappingURL=sveltekit.test.js.map
234
+ //# sourceMappingURL=sveltekit-hooks.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sveltekit-hooks.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/sveltekit-hooks.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,mDAAkD;AAClD,oCAckB;AAClB,mCAA6D;AAE7D,MAAM,oBAAoB,GAAG;;;;;;;;;;CAU5B,CAAC;AACF,MAAM,oBAAoB,GAAG;;;;;;;;;;;CAW5B,CAAC;AAEF,KAAK,UAAU,2BAA2B,CACxC,UAAkB,EAClB,WAAwB,EACxB,kBAGY;IAEZ,MAAM,cAAc,GAAG,IAAA,2BAAmB,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpE,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAE/B,IAAI,kBAAkB,EAAE;QACtB,kBAAkB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAE5C,4FAA4F;QAC5F,MAAM,cAAc,CAAC,aAAa,CAAC,iCAAiC,CAAC,CAAC;QAEtE,kBAAkB,GAAG,MAAM,cAAc,CAAC,yBAAyB,CACjE,CAAC,YAAI,CAAC,KAAK,CAAC,EACZ,2CAA2C,CAC5C,CAAC;KACH;SAAM;QACL,kBAAkB,GAAG,MAAM,cAAc,CAAC,aAAa,CACrD,2CAA2C,CAC5C,CAAC;KACH;IAED,MAAM,sBAAsB,GAC1B,kBAAkB;QAClB,CAAC,MAAM,cAAc,CAAC,yBAAyB;QAC7C,0DAA0D;QAC1D,CAAC,YAAI,CAAC,IAAI,EAAE,YAAI,CAAC,IAAI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;QAEH,IAAA,aAAI,EAAC,sCAAsC,EAAE,GAAG,EAAE;YAChD,IAAA,yBAAiB,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE;gBACjE,8CAA8C;gBAC9C;YACI,iBAAS,CAAC,WAAW;;;GAG9B;gBACK,4DAA4D;aAC7D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { Integration } from '../../lib/Constants';\nimport {\n KEYS,\n TEST_ARGS,\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n createFile,\n revertLocalChanges,\n startWizardInstance,\n} from '../utils';\nimport { afterAll, beforeAll, describe, test } from 'vitest';\n\nconst SERVER_HOOK_TEMPLATE = `import type { Handle } from '@sveltejs/kit';\n\nexport const handle: Handle = async ({ event, resolve }) => {\n\tif (event.url.pathname.startsWith('/custom')) {\n\t\treturn new Response('custom response');\n\t}\n\n\tconst response = await resolve(event);\n\treturn response;\n};\n`;\nconst CLIENT_HOOK_TEMPLATE = `\nexport async function handleError({ error, event }) {\n // you can capture the \\`error\\` and \\`event\\` from the client\n // but it only runs if the unexpected error comes from \\`+ page.ts\\`\n console.log(error)\n\n return {\n // don't show sensitive data to the user\n message: 'Yikes! 💩',\n }\n}\n`;\n\nasync function runWizardOnSvelteKitProject(\n projectDir: string,\n integration: Integration,\n fileModificationFn?: (\n projectDir: string,\n integration: Integration,\n ) => unknown,\n) {\n const wizardInstance = startWizardInstance(integration, projectDir);\n let kitVersionPrompted = false;\n\n if (fileModificationFn) {\n fileModificationFn(projectDir, integration);\n\n // As we modified project, we have a warning prompt before we get the package manager prompt\n await wizardInstance.waitForOutput('Do you want to continue anyway?');\n\n kitVersionPrompted = await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n \"It seems you're using a SvelteKit version\",\n );\n } else {\n kitVersionPrompted = await wizardInstance.waitForOutput(\n \"It seems you're using a SvelteKit version\",\n );\n }\n\n const packageManagerPrompted =\n kitVersionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Select \"Yes, Continue\" to perform hooks-based SDK setup\n [KEYS.DOWN, KEYS.DOWN, KEYS.ENTER],\n 'Please select your package manager.',\n ));\n\n const tracingOptionPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000,\n },\n ));\n\n const replayOptionPrompted =\n tracingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n ));\n\n const logsOptionPrompted =\n replayOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Logs\", sometimes doesn't work as `Logs` can be printed in bold.\n 'to send your application logs to Sentry?',\n ));\n\n const examplePagePrompted =\n logsOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Do you want to create an example page',\n {\n optional: true,\n },\n ));\n\n // After the example page prompt, we send ENTER to accept it\n // Then handle the MCP prompt that comes after\n const mcpPrompted =\n examplePagePrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // This ENTER is for accepting the example page\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n {\n optional: true,\n },\n ));\n\n // Decline MCP config (default is Yes, so press DOWN then ENTER to select No)\n if (mcpPrompted) {\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER],\n 'Successfully installed the Sentry SvelteKit SDK!',\n );\n } else {\n // If MCP wasn't prompted, wait for success message directly\n await wizardInstance.waitForOutput(\n 'Successfully installed the Sentry SvelteKit SDK!',\n );\n }\n\n wizardInstance.kill();\n}\n\nfunction checkSvelteKitProject(\n projectDir: string,\n integration: Integration,\n options?: {\n devModeExpectedOutput: string;\n prodModeExpectedOutput: string;\n },\n) {\n test('should have the correct package.json', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('should have the correct .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('example page exists', () => {\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n );\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'),\n );\n });\n\n test('vite.config contains sentry plugin', () => {\n checkFileContents(\n path.resolve(projectDir, 'vite.config.ts'),\n `plugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n`,\n );\n });\n\n test('hook files created', () => {\n checkFileExists(path.resolve(projectDir, 'src/hooks.server.ts'));\n checkFileExists(path.resolve(projectDir, 'src/hooks.client.ts'));\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(\n projectDir,\n options?.devModeExpectedOutput || 'ready in',\n );\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(\n projectDir,\n options?.prodModeExpectedOutput || 'to expose',\n 'preview',\n );\n });\n}\n\ndescribe('Sveltekit', () => {\n describe('without existing hooks', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-hooks-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnSvelteKitProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkSvelteKitProject(projectDir, integration);\n\n test('hooks.client.ts contains sentry', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.client.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n\n // If you don't want to use Session Replay, just remove the line below:\n integrations: [replayIntegration()],\n});`,\n 'export const handleError = handleErrorWithSentry(',\n ]);\n });\n\n test('hooks.server.ts contains sentry', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.server.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});`,\n 'export const handleError = handleErrorWithSentry();',\n ]);\n });\n });\n\n describe('with existing hooks', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-hooks-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnSvelteKitProject(\n projectDir,\n integration,\n (projectDir) => {\n createFile(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n SERVER_HOOK_TEMPLATE,\n );\n\n createFile(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n CLIENT_HOOK_TEMPLATE,\n );\n },\n );\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkSvelteKitProject(projectDir, integration);\n\n // These are removed from the common tests as the content is different\n // when the hooks are merged instead of created from the template\n test('hooks.client.ts contains sentry instrumentation', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.client.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1,\n integrations: [Sentry.replayIntegration()],\n enableLogs: true\n})`,\n 'export const handleError = Sentry.handleErrorWithSentry(',\n ]);\n });\n\n test('hooks.server.ts contains sentry init', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.server.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n enableLogs: true\n})`,\n 'export const handleError = Sentry.handleErrorWithSentry();',\n ]);\n });\n });\n});\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const path = __importStar(require("node:path"));
27
+ const fs = __importStar(require("node:fs"));
28
+ const Constants_1 = require("../../lib/Constants");
29
+ const utils_1 = require("../utils");
30
+ const vitest_1 = require("vitest");
31
+ //@ts-expect-error - clifty is ESM only
32
+ const clifty_1 = require("clifty");
33
+ (0, vitest_1.describe)('Sveltekit with instrumentation and tracing', () => {
34
+ (0, vitest_1.describe)('without existing files', () => {
35
+ const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-tracing-test-app');
36
+ const integration = Constants_1.Integration.sveltekit;
37
+ let wizardExitCode;
38
+ (0, vitest_1.beforeAll)(async () => {
39
+ (0, utils_1.initGit)(projectDir);
40
+ (0, utils_1.revertLocalChanges)(projectDir);
41
+ wizardExitCode = await (0, clifty_1.withEnv)({
42
+ cwd: projectDir,
43
+ })
44
+ .defineInteraction()
45
+ .expectOutput('The Sentry SvelteKit Wizard will help you set up Sentry for your application')
46
+ .step('package installation', ({ expectOutput, whenAsked }) => {
47
+ whenAsked('Please select your package manager.').respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER);
48
+ expectOutput('Installing @sentry/sveltekit');
49
+ })
50
+ .step('SDK setup', ({ whenAsked }) => {
51
+ whenAsked('Do you want to enable Tracing', {
52
+ timeout: 90000, // package installation can take a while in CI
53
+ }).respondWith(clifty_1.KEYS.ENTER);
54
+ whenAsked('Do you want to enable Session Replay').respondWith(clifty_1.KEYS.ENTER);
55
+ whenAsked('Do you want to enable Logs').respondWith(clifty_1.KEYS.ENTER);
56
+ })
57
+ .whenAsked('Do you want to create an example page')
58
+ .respondWith(clifty_1.KEYS.ENTER)
59
+ .whenAsked('Optionally add a project-scoped MCP server configuration for the Sentry MCP?')
60
+ .respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
61
+ .expectOutput('Successfully installed the Sentry SvelteKit SDK!')
62
+ .run((0, utils_1.getWizardCommand)(integration));
63
+ });
64
+ (0, vitest_1.afterAll)(() => {
65
+ (0, utils_1.revertLocalChanges)(projectDir);
66
+ (0, utils_1.cleanupGit)(projectDir);
67
+ });
68
+ (0, vitest_1.it)('exits with exit code 0', () => {
69
+ (0, vitest_1.expect)(wizardExitCode).toBe(0);
70
+ });
71
+ (0, vitest_1.it)('adds the SDK dependency to package.json', () => {
72
+ (0, utils_1.checkPackageJson)(projectDir, integration);
73
+ });
74
+ (0, vitest_1.it)('adds the .env.sentry-build-plugin', () => {
75
+ (0, utils_1.checkEnvBuildPlugin)(projectDir);
76
+ });
77
+ (0, vitest_1.it)('adds the example page', () => {
78
+ (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'));
79
+ (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'));
80
+ });
81
+ (0, vitest_1.it)('adds the sentry plugin to vite.config.ts', () => {
82
+ const viteConfig = fs.readFileSync(path.resolve(projectDir, 'vite.config.ts'));
83
+ (0, vitest_1.expect)(viteConfig.toString()).toMatchInlineSnapshot(`
84
+ "import { sentrySvelteKit } from "@sentry/sveltekit";
85
+ import { sveltekit } from '@sveltejs/kit/vite';
86
+ import { defineConfig } from 'vite';
87
+
88
+ export default defineConfig({
89
+ plugins: [sentrySvelteKit({
90
+ sourceMapsUploadOptions: {
91
+ org: "${utils_1.TEST_ARGS.ORG_SLUG}",
92
+ project: "${utils_1.TEST_ARGS.PROJECT_SLUG}"
93
+ }
94
+ }), sveltekit()]
95
+ });"
96
+ `);
97
+ });
98
+ (0, vitest_1.it)('creates the hook files', () => {
99
+ const clientHooks = fs.readFileSync(path.resolve(projectDir, 'src/hooks.client.ts'));
100
+ const serverHooks = fs.readFileSync(path.resolve(projectDir, 'src/hooks.server.ts'));
101
+ (0, vitest_1.expect)(clientHooks.toString()).toMatchInlineSnapshot(`
102
+ "import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
103
+ import * as Sentry from '@sentry/sveltekit';
104
+
105
+ Sentry.init({
106
+ dsn: '${utils_1.TEST_ARGS.PROJECT_DSN}',
107
+
108
+ tracesSampleRate: 1.0,
109
+
110
+ // Enable logs to be sent to Sentry
111
+ enableLogs: true,
112
+
113
+ // This sets the sample rate to be 10%. You may want this to be 100% while
114
+ // in development and sample at a lower rate in production
115
+ replaysSessionSampleRate: 0.1,
116
+
117
+ // If the entire session is not sampled, use the below sample rate to sample
118
+ // sessions when an error occurs.
119
+ replaysOnErrorSampleRate: 1.0,
120
+
121
+ // If you don't want to use Session Replay, just remove the line below:
122
+ integrations: [replayIntegration()],
123
+ });
124
+
125
+ // If you have a custom error handler, pass it to \`handleErrorWithSentry\`
126
+ export const handleError = handleErrorWithSentry();
127
+ "
128
+ `);
129
+ (0, vitest_1.expect)(serverHooks.toString()).toMatchInlineSnapshot(`
130
+ "import {sequence} from "@sveltejs/kit/hooks";
131
+ import * as Sentry from "@sentry/sveltekit";
132
+ export const handle = sequence(Sentry.sentryHandle(), async ({ event, resolve }) => {
133
+ const response = await resolve(event);
134
+ return response;
135
+ });
136
+ export const handleError = Sentry.handleErrorWithSentry();"
137
+ `);
138
+ });
139
+ (0, vitest_1.it)('creates the insturmentation.server file', () => {
140
+ const instrumentationServer = fs.readFileSync(path.resolve(projectDir, 'src/instrumentation.server.ts'));
141
+ (0, vitest_1.expect)(instrumentationServer.toString()).toMatchInlineSnapshot(`
142
+ "import * as Sentry from '@sentry/sveltekit';
143
+
144
+ Sentry.init({
145
+ dsn: '${utils_1.TEST_ARGS.PROJECT_DSN}',
146
+
147
+ tracesSampleRate: 1.0,
148
+
149
+ // Enable logs to be sent to Sentry
150
+ enableLogs: true,
151
+
152
+ // uncomment the line below to enable Spotlight (https://spotlightjs.com)
153
+ // spotlight: import.meta.env.DEV,
154
+ });"
155
+ `);
156
+ });
157
+ (0, vitest_1.it)('enables tracing and instrumentation in svelte.config.js', () => {
158
+ const svelteConfig = fs.readFileSync(path.resolve(projectDir, 'svelte.config.js'));
159
+ (0, vitest_1.expect)(svelteConfig.toString()).toMatchInlineSnapshot(`
160
+ "import adapter from '@sveltejs/adapter-node';
161
+ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
162
+
163
+ /** @type {import('@sveltejs/kit').Config} */
164
+ const config = {
165
+ // Consult https://svelte.dev/docs/kit/integrations#preprocessors
166
+ // for more information about preprocessors
167
+ preprocess: vitePreprocess(),
168
+
169
+ kit: {
170
+ // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
171
+ // If your environment is not supported, or you settled on a specific environment, switch out the adapter.
172
+ // See https://svelte.dev/docs/kit/adapters for more information about adapters.
173
+ adapter: adapter(),
174
+ experimental: {
175
+ remoteFunctions: true,
176
+
177
+ tracing: {
178
+ server: true,
179
+ },
180
+
181
+ instrumentation: {
182
+ server: true,
183
+ },
184
+ },
185
+ },
186
+ };
187
+
188
+ export default config;"
189
+ `);
190
+ });
191
+ // checkSvelteKitProject(projectDir, integration);
192
+ (0, vitest_1.it)('builds successfully', async () => {
193
+ await (0, utils_1.checkIfBuilds)(projectDir);
194
+ });
195
+ (0, vitest_1.it)('runs on dev mode correctly', async () => {
196
+ await (0, utils_1.checkIfRunsOnDevMode)(projectDir, 'ready in');
197
+ });
198
+ (0, vitest_1.it)('runs on prod mode correctly', async () => {
199
+ await (0, utils_1.checkIfRunsOnProdMode)(projectDir, 'to expose', 'preview');
200
+ });
201
+ });
202
+ });
203
+ //# sourceMappingURL=sveltekit-tracing.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sveltekit-tracing.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/sveltekit-tracing.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,4CAA8B;AAC9B,mDAAkD;AAClD,oCAYkB;AAClB,mCAAmE;AAEnE,uCAAuC;AACvC,mCAAuC;AAEvC,IAAA,iBAAQ,EAAC,4CAA4C,EAAE,GAAG,EAAE;IAC1D,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B,SAAS,EACT,iDAAiD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,MAAM,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;YAC1C,MAAM,IAAA,4BAAoB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;YAC3C,MAAM,IAAA,6BAAqB,EAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport { Integration } from '../../lib/Constants';\nimport {\n checkEnvBuildPlugin,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n getWizardCommand,\n initGit,\n revertLocalChanges,\n TEST_ARGS,\n} from '../utils';\nimport { afterAll, beforeAll, describe, expect, it } from 'vitest';\n\n//@ts-expect-error - clifty is ESM only\nimport { KEYS, withEnv } from 'clifty';\n\ndescribe('Sveltekit with instrumentation and tracing', () => {\n describe('without existing files', () => {\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-tracing-test-app',\n );\n\n const integration = Integration.sveltekit;\n let wizardExitCode: number;\n\n beforeAll(async () => {\n initGit(projectDir);\n revertLocalChanges(projectDir);\n\n wizardExitCode = await withEnv({\n cwd: projectDir,\n })\n .defineInteraction()\n .expectOutput(\n 'The Sentry SvelteKit Wizard will help you set up Sentry for your application',\n )\n .step('package installation', ({ expectOutput, whenAsked }) => {\n whenAsked('Please select your package manager.').respondWith(\n KEYS.DOWN,\n KEYS.ENTER,\n );\n expectOutput('Installing @sentry/sveltekit');\n })\n .step('SDK setup', ({ whenAsked }) => {\n whenAsked('Do you want to enable Tracing', {\n timeout: 90_000, // package installation can take a while in CI\n }).respondWith(KEYS.ENTER);\n whenAsked('Do you want to enable Session Replay').respondWith(\n KEYS.ENTER,\n );\n whenAsked('Do you want to enable Logs').respondWith(KEYS.ENTER);\n })\n .whenAsked('Do you want to create an example page')\n .respondWith(KEYS.ENTER)\n .whenAsked(\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n )\n .respondWith(KEYS.DOWN, KEYS.ENTER)\n .expectOutput('Successfully installed the Sentry SvelteKit SDK!')\n .run(getWizardCommand(integration));\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n it('exits with exit code 0', () => {\n expect(wizardExitCode).toBe(0);\n });\n\n it('adds the SDK dependency to package.json', () => {\n checkPackageJson(projectDir, integration);\n });\n\n it('adds the .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n it('adds the example page', () => {\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n );\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'),\n );\n });\n\n it('adds the sentry plugin to vite.config.ts', () => {\n const viteConfig = fs.readFileSync(\n path.resolve(projectDir, 'vite.config.ts'),\n );\n expect(viteConfig.toString()).toMatchInlineSnapshot(`\n \"import { sentrySvelteKit } from \"@sentry/sveltekit\";\n import { sveltekit } from '@sveltejs/kit/vite';\n import { defineConfig } from 'vite';\n\n export default defineConfig({\n \tplugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n org: \"${TEST_ARGS.ORG_SLUG}\",\n project: \"${TEST_ARGS.PROJECT_SLUG}\"\n }\n }), sveltekit()]\n });\"\n `);\n });\n\n it('creates the hook files', () => {\n const clientHooks = fs.readFileSync(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n );\n const serverHooks = fs.readFileSync(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n );\n\n expect(clientHooks.toString()).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n\n // If you don't want to use Session Replay, just remove the line below:\n integrations: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n\n expect(serverHooks.toString()).toMatchInlineSnapshot(`\n \"import {sequence} from \"@sveltejs/kit/hooks\";\n import * as Sentry from \"@sentry/sveltekit\";\n export const handle = sequence(Sentry.sentryHandle(), async ({ event, resolve }) => {\n const response = await resolve(event);\n return response;\n });\n export const handleError = Sentry.handleErrorWithSentry();\"\n `);\n });\n\n it('creates the insturmentation.server file', () => {\n const instrumentationServer = fs.readFileSync(\n path.resolve(projectDir, 'src/instrumentation.server.ts'),\n );\n\n expect(instrumentationServer.toString()).toMatchInlineSnapshot(`\n \"import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\"\n `);\n });\n\n it('enables tracing and instrumentation in svelte.config.js', () => {\n const svelteConfig = fs.readFileSync(\n path.resolve(projectDir, 'svelte.config.js'),\n );\n expect(svelteConfig.toString()).toMatchInlineSnapshot(`\n \"import adapter from '@sveltejs/adapter-node';\n import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';\n\n /** @type {import('@sveltejs/kit').Config} */\n const config = {\n // Consult https://svelte.dev/docs/kit/integrations#preprocessors\n // for more information about preprocessors\n preprocess: vitePreprocess(),\n\n kit: {\n // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.\n // If your environment is not supported, or you settled on a specific environment, switch out the adapter.\n // See https://svelte.dev/docs/kit/adapters for more information about adapters.\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n\n tracing: {\n server: true,\n },\n\n instrumentation: {\n server: true,\n },\n },\n },\n };\n\n export default config;\"\n `);\n });\n\n // checkSvelteKitProject(projectDir, integration);\n it('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n it('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, 'ready in');\n });\n\n it('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, 'to expose', 'preview');\n });\n });\n});\n"]}
@@ -1,8 +1,8 @@
1
- import { PartialSvelteConfig } from './sdk-setup';
1
+ import { PartialBackwardsForwardsCompatibleSvelteConfig } from './sdk-setup/svelte-config';
2
2
  /**
3
3
  * Creates example page and API route to test Sentry
4
4
  */
5
- export declare function createExamplePage(svelteConfig: PartialSvelteConfig, projectProps: {
5
+ export declare function createExamplePage(svelteConfig: PartialBackwardsForwardsCompatibleSvelteConfig, projectProps: {
6
6
  selfHosted: boolean;
7
7
  url: string;
8
8
  orgSlug: string;
@@ -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,YAAiC,EACjC,YAKC;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,YAAY,CAAC,CACzC,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;AAzCD,8CAyCC","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 { PartialSvelteConfig } from './sdk-setup';\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: PartialSvelteConfig,\n projectProps: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\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(projectProps),\n );\n\n await fs.promises.writeFile(\n path.join(exampleRoutePath, '+server.js'),\n getSentryExampleApiRoute(),\n );\n}\n"]}
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,YAKC;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,YAAY,CAAC,CACzC,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;AAzCD,8CAyCC","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 },\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(projectProps),\n );\n\n await fs.promises.writeFile(\n path.join(exampleRoutePath, '+server.js'),\n getSentryExampleApiRoute(),\n );\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { type PartialBackwardsForwardsCompatibleSvelteConfig } from './svelte-config';
2
+ import { ProjectInfo } from './types';
3
+ export declare function createOrMergeSvelteKitFiles(projectInfo: ProjectInfo, svelteConfig: PartialBackwardsForwardsCompatibleSvelteConfig, setupForSvelteKitTracing: boolean): Promise<void>;