@sentry/wizard 6.9.0 → 6.11.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 (170) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/dist/ci-ensure-runtime-loaded.sh +82 -0
  3. package/dist/e2e-tests/tests/angular-17.test.js +72 -82
  4. package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
  5. package/dist/e2e-tests/tests/angular-19.test.js +71 -80
  6. package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
  7. package/dist/e2e-tests/tests/cloudflare-worker.test.d.ts +1 -0
  8. package/dist/e2e-tests/tests/cloudflare-worker.test.js +64 -0
  9. package/dist/e2e-tests/tests/cloudflare-worker.test.js.map +1 -0
  10. package/dist/e2e-tests/tests/cloudflare-wrangler-sourcemaps.test.js +2 -5
  11. package/dist/e2e-tests/tests/cloudflare-wrangler-sourcemaps.test.js.map +1 -1
  12. package/dist/e2e-tests/tests/expo.test.js +36 -61
  13. package/dist/e2e-tests/tests/expo.test.js.map +1 -1
  14. package/dist/e2e-tests/tests/flutter.test.js +63 -70
  15. package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
  16. package/dist/e2e-tests/tests/help-message.test.js +2 -2
  17. package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
  18. package/dist/e2e-tests/tests/nextjs-14.test.js +54 -82
  19. package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
  20. package/dist/e2e-tests/tests/nextjs-15.test.js +95 -105
  21. package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
  22. package/dist/e2e-tests/tests/nextjs-16.test.d.ts +1 -0
  23. package/dist/e2e-tests/tests/nextjs-16.test.js +123 -0
  24. package/dist/e2e-tests/tests/nextjs-16.test.js.map +1 -0
  25. package/dist/e2e-tests/tests/nuxt-3.test.js +45 -58
  26. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
  27. package/dist/e2e-tests/tests/nuxt-4.test.js +59 -73
  28. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
  29. package/dist/e2e-tests/tests/pnpm-workspace.test.js +4 -7
  30. package/dist/e2e-tests/tests/pnpm-workspace.test.js.map +1 -1
  31. package/dist/e2e-tests/tests/react-native.test.js +44 -80
  32. package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
  33. package/dist/e2e-tests/tests/react-router.test.js +163 -145
  34. package/dist/e2e-tests/tests/react-router.test.js.map +1 -1
  35. package/dist/e2e-tests/tests/remix.test.js +162 -132
  36. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  37. package/dist/e2e-tests/tests/sveltekit-hooks.test.js +48 -36
  38. package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
  39. package/dist/e2e-tests/tests/sveltekit-tracing.test.js +3 -6
  40. package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
  41. package/dist/e2e-tests/utils/index.d.ts +21 -43
  42. package/dist/e2e-tests/utils/index.js +108 -183
  43. package/dist/e2e-tests/utils/index.js.map +1 -1
  44. package/dist/get-e2e-test-matrix.mjs +11 -0
  45. package/dist/lib/Constants.d.ts +1 -0
  46. package/dist/lib/Constants.js +5 -0
  47. package/dist/lib/Constants.js.map +1 -1
  48. package/dist/src/android/android-wizard.js +2 -4
  49. package/dist/src/android/android-wizard.js.map +1 -1
  50. package/dist/src/angular/angular-wizard.js +4 -6
  51. package/dist/src/angular/angular-wizard.js.map +1 -1
  52. package/dist/src/angular/sdk-setup.js +1 -1
  53. package/dist/src/angular/sdk-setup.js.map +1 -1
  54. package/dist/src/apple/apple-wizard.js +2 -4
  55. package/dist/src/apple/apple-wizard.js.map +1 -1
  56. package/dist/src/cloudflare/cloudflare-wizard.d.ts +3 -0
  57. package/dist/src/cloudflare/cloudflare-wizard.js +99 -0
  58. package/dist/src/cloudflare/cloudflare-wizard.js.map +1 -0
  59. package/dist/src/cloudflare/sdk-setup.d.ts +7 -0
  60. package/dist/src/cloudflare/sdk-setup.js +47 -0
  61. package/dist/src/cloudflare/sdk-setup.js.map +1 -0
  62. package/dist/src/cloudflare/templates.d.ts +4 -0
  63. package/dist/src/cloudflare/templates.js +44 -0
  64. package/dist/src/cloudflare/templates.js.map +1 -0
  65. package/dist/src/cloudflare/wrangler/create-wrangler-config.d.ts +4 -0
  66. package/dist/src/cloudflare/wrangler/create-wrangler-config.js +27 -0
  67. package/dist/src/cloudflare/wrangler/create-wrangler-config.js.map +1 -0
  68. package/dist/src/cloudflare/wrangler/ensure-wrangler-config.d.ts +4 -0
  69. package/dist/src/cloudflare/wrangler/ensure-wrangler-config.js +25 -0
  70. package/dist/src/cloudflare/wrangler/ensure-wrangler-config.js.map +1 -0
  71. package/dist/src/cloudflare/wrangler/find-wrangler-config.d.ts +4 -0
  72. package/dist/src/cloudflare/wrangler/find-wrangler-config.js +23 -0
  73. package/dist/src/cloudflare/wrangler/find-wrangler-config.js.map +1 -0
  74. package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.d.ts +6 -0
  75. package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.js +52 -0
  76. package/dist/src/cloudflare/wrangler/get-entry-point-from-wrangler-config.js.map +1 -0
  77. package/dist/src/cloudflare/wrangler/update-wrangler-config.d.ts +17 -0
  78. package/dist/src/cloudflare/wrangler/update-wrangler-config.js +173 -0
  79. package/dist/src/cloudflare/wrangler/update-wrangler-config.js.map +1 -0
  80. package/dist/src/cloudflare/wrap-worker.d.ts +32 -0
  81. package/dist/src/cloudflare/wrap-worker.js +109 -0
  82. package/dist/src/cloudflare/wrap-worker.js.map +1 -0
  83. package/dist/src/flutter/flutter-wizard.js +3 -6
  84. package/dist/src/flutter/flutter-wizard.js.map +1 -1
  85. package/dist/src/nextjs/nextjs-wizard.js +46 -10
  86. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  87. package/dist/src/nextjs/templates.d.ts +6 -3
  88. package/dist/src/nextjs/templates.js +144 -93
  89. package/dist/src/nextjs/templates.js.map +1 -1
  90. package/dist/src/nuxt/nuxt-wizard.js +3 -5
  91. package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
  92. package/dist/src/react-native/react-native-wizard.js +2 -4
  93. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  94. package/dist/src/react-router/codemods/client.entry.js +4 -1
  95. package/dist/src/react-router/codemods/client.entry.js.map +1 -1
  96. package/dist/src/react-router/react-router-wizard.js +3 -5
  97. package/dist/src/react-router/react-router-wizard.js.map +1 -1
  98. package/dist/src/react-router/sdk-example.js +5 -2
  99. package/dist/src/react-router/sdk-example.js.map +1 -1
  100. package/dist/src/react-router/sdk-setup.d.ts +1 -1
  101. package/dist/src/react-router/sdk-setup.js +3 -4
  102. package/dist/src/react-router/sdk-setup.js.map +1 -1
  103. package/dist/src/remix/remix-wizard.js +2 -4
  104. package/dist/src/remix/remix-wizard.js.map +1 -1
  105. package/dist/src/run.d.ts +1 -1
  106. package/dist/src/run.js +5 -0
  107. package/dist/src/run.js.map +1 -1
  108. package/dist/src/sourcemaps/tools/sentry-cli.js +1 -1
  109. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  110. package/dist/src/sourcemaps/tools/wrangler.js +1 -1
  111. package/dist/src/sourcemaps/tools/wrangler.js.map +1 -1
  112. package/dist/src/sveltekit/sveltekit-wizard.js +4 -6
  113. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  114. package/dist/src/telemetry.d.ts +1 -1
  115. package/dist/src/telemetry.js +52 -31
  116. package/dist/src/telemetry.js.map +1 -1
  117. package/dist/src/utils/abort-if-sportlight-not-supported.d.ts +5 -0
  118. package/dist/src/utils/abort-if-sportlight-not-supported.js +40 -0
  119. package/dist/src/utils/abort-if-sportlight-not-supported.js.map +1 -0
  120. package/dist/src/utils/ast-utils.d.ts +1 -1
  121. package/dist/src/utils/ast-utils.js.map +1 -1
  122. package/dist/src/utils/clack/index.d.ts +19 -2
  123. package/dist/src/utils/clack/index.js +174 -12
  124. package/dist/src/utils/clack/index.js.map +1 -1
  125. package/dist/src/utils/clack/mcp-config.js +117 -59
  126. package/dist/src/utils/clack/mcp-config.js.map +1 -1
  127. package/dist/src/version.d.ts +1 -1
  128. package/dist/src/version.js +1 -1
  129. package/dist/src/version.js.map +1 -1
  130. package/dist/test/angular/angular-wizard.test.js +2 -4
  131. package/dist/test/angular/angular-wizard.test.js.map +1 -1
  132. package/dist/test/apple/cocoapod.test.js +7 -3
  133. package/dist/test/apple/cocoapod.test.js.map +1 -1
  134. package/dist/test/apple/code-tools.test.js +8 -2
  135. package/dist/test/apple/code-tools.test.js.map +1 -1
  136. package/dist/test/cloudflare/create-wrangler-config.test.d.ts +1 -0
  137. package/dist/test/cloudflare/create-wrangler-config.test.js +48 -0
  138. package/dist/test/cloudflare/create-wrangler-config.test.js.map +1 -0
  139. package/dist/test/cloudflare/ensure-wrangler-config.test.d.ts +1 -0
  140. package/dist/test/cloudflare/ensure-wrangler-config.test.js +61 -0
  141. package/dist/test/cloudflare/ensure-wrangler-config.test.js.map +1 -0
  142. package/dist/test/cloudflare/find-wrangler-config.test.d.ts +1 -0
  143. package/dist/test/cloudflare/find-wrangler-config.test.js +77 -0
  144. package/dist/test/cloudflare/find-wrangler-config.test.js.map +1 -0
  145. package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.d.ts +1 -0
  146. package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.js +81 -0
  147. package/dist/test/cloudflare/get-entry-point-from-wrangler-config.test.js.map +1 -0
  148. package/dist/test/cloudflare/sdk-setup.test.d.ts +1 -0
  149. package/dist/test/cloudflare/sdk-setup.test.js +152 -0
  150. package/dist/test/cloudflare/sdk-setup.test.js.map +1 -0
  151. package/dist/test/cloudflare/templates.test.d.ts +1 -0
  152. package/dist/test/cloudflare/templates.test.js +68 -0
  153. package/dist/test/cloudflare/templates.test.js.map +1 -0
  154. package/dist/test/cloudflare/update-wrangler-config.test.d.ts +1 -0
  155. package/dist/test/cloudflare/update-wrangler-config.test.js +216 -0
  156. package/dist/test/cloudflare/update-wrangler-config.test.js.map +1 -0
  157. package/dist/test/cloudflare/wrap-worker.test.d.ts +1 -0
  158. package/dist/test/cloudflare/wrap-worker.test.js +143 -0
  159. package/dist/test/cloudflare/wrap-worker.test.js.map +1 -0
  160. package/dist/test/nextjs/templates.test.js +156 -87
  161. package/dist/test/nextjs/templates.test.js.map +1 -1
  162. package/dist/test/nextjs/wizard-double-wrap-prevention.test.js +12 -7
  163. package/dist/test/nextjs/wizard-double-wrap-prevention.test.js.map +1 -1
  164. package/dist/test/react-router/sdk-setup.test.js +2 -2
  165. package/dist/test/react-router/sdk-setup.test.js.map +1 -1
  166. package/dist/test/utils/clack/index.test.js +37 -29
  167. package/dist/test/utils/clack/index.test.js.map +1 -1
  168. package/dist/test/utils/clack/mcp-config.test.js +176 -51
  169. package/dist/test/utils/clack/mcp-config.test.js.map +1 -1
  170. package/package.json +6 -5
@@ -55,17 +55,35 @@ export async function handleError({ error, event }) {
55
55
  vitest_1.describe.sequential('Sveltekit', () => {
56
56
  (0, vitest_1.describe)('without existing hooks', () => {
57
57
  const integration = Constants_1.Integration.sveltekit;
58
- const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-hooks-test-app');
58
+ const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('sveltekit-hooks-test-app');
59
59
  (0, vitest_1.beforeAll)(async () => {
60
- (0, utils_1.initGit)(projectDir);
61
- (0, utils_1.revertLocalChanges)(projectDir);
62
60
  await runWizardOnSvelteKitProject(projectDir, integration);
63
61
  });
64
62
  (0, vitest_1.afterAll)(() => {
65
- (0, utils_1.revertLocalChanges)(projectDir);
66
- (0, utils_1.cleanupGit)(projectDir);
63
+ cleanup();
64
+ });
65
+ (0, vitest_1.test)('has the correct package.json', () => {
66
+ (0, utils_1.checkPackageJson)(projectDir, '@sentry/sveltekit');
67
+ });
68
+ (0, vitest_1.test)('has the correct .env.sentry-build-plugin', () => {
69
+ (0, utils_1.checkEnvBuildPlugin)(projectDir);
70
+ });
71
+ (0, vitest_1.test)('vite.config contains sentry plugin', () => {
72
+ (0, utils_1.checkFileContents)(path.resolve(projectDir, 'vite.config.ts'), `plugins: [sentrySvelteKit({`);
73
+ });
74
+ (0, vitest_1.test)('hook files created', () => {
75
+ (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.server.ts'));
76
+ (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.client.ts'));
77
+ });
78
+ (0, vitest_1.test)('builds successfully', async () => {
79
+ await (0, utils_1.checkIfBuilds)(projectDir);
80
+ });
81
+ (0, vitest_1.test)('runs on dev mode correctly', async () => {
82
+ await (0, utils_1.checkIfRunsOnDevMode)(projectDir, 'ready in');
83
+ });
84
+ (0, vitest_1.test)('runs on prod mode correctly', async () => {
85
+ await (0, utils_1.checkIfRunsOnProdMode)(projectDir, 'to expose', 'preview');
67
86
  });
68
- checkSvelteKitProject(projectDir, integration);
69
87
  (0, vitest_1.test)('hooks.client.ts contains sentry', () => {
70
88
  (0, utils_1.checkFileContents)(path.resolve(projectDir, 'src/hooks.client.ts'), [
71
89
  `import * as Sentry from '@sentry/sveltekit';`,
@@ -127,20 +145,38 @@ vitest_1.describe.sequential('Sveltekit', () => {
127
145
  });
128
146
  (0, vitest_1.describe)('with existing hooks', () => {
129
147
  const integration = Constants_1.Integration.sveltekit;
130
- const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-hooks-test-app');
148
+ const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('sveltekit-hooks-test-app');
131
149
  (0, vitest_1.beforeAll)(async () => {
132
- (0, utils_1.initGit)(projectDir);
133
- (0, utils_1.revertLocalChanges)(projectDir);
134
150
  await runWizardOnSvelteKitProject(projectDir, integration, (projectDir) => {
135
151
  (0, utils_1.createFile)(path.resolve(projectDir, 'src/hooks.server.ts'), SERVER_HOOK_TEMPLATE);
136
152
  (0, utils_1.createFile)(path.resolve(projectDir, 'src/hooks.client.ts'), CLIENT_HOOK_TEMPLATE);
137
153
  });
138
154
  });
139
155
  (0, vitest_1.afterAll)(() => {
140
- (0, utils_1.revertLocalChanges)(projectDir);
141
- (0, utils_1.cleanupGit)(projectDir);
156
+ cleanup();
157
+ });
158
+ (0, vitest_1.test)('has the correct package.json', () => {
159
+ (0, utils_1.checkPackageJson)(projectDir, '@sentry/sveltekit');
160
+ });
161
+ (0, vitest_1.test)('has the correct .env.sentry-build-plugin', () => {
162
+ (0, utils_1.checkEnvBuildPlugin)(projectDir);
163
+ });
164
+ (0, vitest_1.test)('vite.config contains sentry plugin', () => {
165
+ (0, utils_1.checkFileContents)(path.resolve(projectDir, 'vite.config.ts'), `plugins: [sentrySvelteKit({`);
166
+ });
167
+ (0, vitest_1.test)('hook files created', () => {
168
+ (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.server.ts'));
169
+ (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.client.ts'));
170
+ });
171
+ (0, vitest_1.test)('builds successfully', async () => {
172
+ await (0, utils_1.checkIfBuilds)(projectDir);
173
+ });
174
+ (0, vitest_1.test)('runs on dev mode correctly', async () => {
175
+ await (0, utils_1.checkIfRunsOnDevMode)(projectDir, 'ready in');
176
+ });
177
+ (0, vitest_1.test)('runs on prod mode correctly', async () => {
178
+ await (0, utils_1.checkIfRunsOnProdMode)(projectDir, 'to expose', 'preview');
142
179
  });
143
- checkSvelteKitProject(projectDir, integration);
144
180
  // These are removed from the common tests as the content is different
145
181
  // when the hooks are merged instead of created from the template
146
182
  (0, vitest_1.test)('hooks.client.ts contains sentry instrumentation', () => {
@@ -202,28 +238,4 @@ async function runWizardOnSvelteKitProject(projectDir, integration, fileModifica
202
238
  .expectOutput('Successfully installed the Sentry SvelteKit SDK!');
203
239
  await wizardInteraction.run((0, utils_1.getWizardCommand)(Constants_1.Integration.sveltekit));
204
240
  }
205
- function checkSvelteKitProject(projectDir, integration, options) {
206
- (0, vitest_1.test)('should have the correct package.json', () => {
207
- (0, utils_1.checkPackageJson)(projectDir, integration);
208
- });
209
- (0, vitest_1.test)('should have the correct .env.sentry-build-plugin', () => {
210
- (0, utils_1.checkEnvBuildPlugin)(projectDir);
211
- });
212
- (0, vitest_1.test)('vite.config contains sentry plugin', () => {
213
- (0, utils_1.checkFileContents)(path.resolve(projectDir, 'vite.config.ts'), `plugins: [sentrySvelteKit({`);
214
- });
215
- (0, vitest_1.test)('hook files created', () => {
216
- (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.server.ts'));
217
- (0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.client.ts'));
218
- });
219
- (0, vitest_1.test)('builds successfully', async () => {
220
- await (0, utils_1.checkIfBuilds)(projectDir);
221
- });
222
- (0, vitest_1.test)('runs on dev mode correctly', async () => {
223
- await (0, utils_1.checkIfRunsOnDevMode)(projectDir, options?.devModeExpectedOutput || 'ready in');
224
- });
225
- (0, vitest_1.test)('runs on prod mode correctly', async () => {
226
- await (0, utils_1.checkIfRunsOnProdMode)(projectDir, options?.prodModeExpectedOutput || 'to expose', 'preview');
227
- });
228
- }
229
241
  //# sourceMappingURL=sveltekit-hooks.test.js.map
@@ -1 +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;AAC7D,uCAAuC;AACvC,mCAAuC;AAEvC,MAAM,oBAAoB,GAAG;;;;;;;;;;CAU5B,CAAC;AACF,MAAM,oBAAoB,GAAG;;;;;;;;;;;CAW5B,CAAC;AAEF,iBAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,GAAG,EAAE;IACpC,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,WAAW,GAAG,uBAAW,CAAC,SAAS,CAAC;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B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AAE;QAC5C,MAAM,IAAA,4BAAoB,EACxB,UAAU,EACV,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAC7C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,IAAA,6BAAqB,EACzB,UAAU,EACV,OAAO,EAAE,sBAAsB,IAAI,WAAW,EAC9C,SAAS,CACV,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { Integration } from '../../lib/Constants';\nimport {\n TEST_ARGS,\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n createFile,\n getWizardCommand,\n initGit,\n revertLocalChanges,\n} from '../utils';\nimport { afterAll, beforeAll, describe, test } from 'vitest';\n//@ts-expect-error - clifty is ESM only\nimport { KEYS, withEnv } from 'clifty';\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\ndescribe.sequential('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 initGit(projectDir);\n revertLocalChanges(projectDir);\n\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 // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\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\n // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: 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 test('creates an example route and page', () => {\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n );\n checkFileContents(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n // Svelte <5 specific syntax\n ['let hasSentError = false;', 'on:click={getSentryData}'],\n );\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'),\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 initGit(projectDir);\n revertLocalChanges(projectDir);\n\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 sendDefaultPii: 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 sendDefaultPii: true\n})`,\n 'export const handleError = Sentry.handleErrorWithSentry();',\n ]);\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 wizardInteraction = withEnv({\n cwd: projectDir,\n }).defineInteraction();\n\n if (fileModificationFn) {\n fileModificationFn(projectDir, integration);\n\n wizardInteraction\n .whenAsked('Do you want to continue anyway?')\n .respondWith(KEYS.ENTER);\n }\n\n wizardInteraction\n .whenAsked(\"It seems you're using a SvelteKit version\")\n .respondWith(KEYS.DOWN, KEYS.DOWN, KEYS.ENTER)\n .whenAsked('Please select your package manager.')\n .respondWith(KEYS.DOWN, KEYS.ENTER)\n .whenAsked('Do you want to enable Tracing', {\n timeout: 90_000, // package installation can take a while in CI\n })\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to enable Session Replay')\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to enable Logs')\n .respondWith(KEYS.ENTER)\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\n await wizardInteraction.run(getWizardCommand(Integration.sveltekit));\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('vite.config contains sentry plugin', () => {\n checkFileContents(\n path.resolve(projectDir, 'vite.config.ts'),\n `plugins: [sentrySvelteKit({`,\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"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SACA,WAAW,CAAC,aAAI,CAAC,IAAI,EAAE,aAAI,CAAC,KAAK,CAAC;SAClC,YAAY,CAAC,kDAAkD,CAAC,CAAC;IAEpE,MAAM,iBAAiB,CAAC,GAAG,CAAC,IAAA,wBAAgB,EAAC,uBAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { Integration } from '../../lib/Constants';\nimport {\n TEST_ARGS,\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n createFile,\n createIsolatedTestEnv,\n getWizardCommand,\n} from '../utils';\nimport { afterAll, beforeAll, describe, test } from 'vitest';\n//@ts-expect-error - clifty is ESM only\nimport { KEYS, withEnv } from 'clifty';\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\ndescribe.sequential('Sveltekit', () => {\n describe('without existing hooks', () => {\n const integration = Integration.sveltekit;\n\n const { projectDir, cleanup } = createIsolatedTestEnv(\n 'sveltekit-hooks-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnSvelteKitProject(projectDir, integration);\n });\n\n afterAll(() => {\n cleanup();\n });\n\n test('has the correct package.json', () => {\n checkPackageJson(projectDir, '@sentry/sveltekit');\n });\n\n test('has the correct .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('vite.config contains sentry plugin', () => {\n checkFileContents(\n path.resolve(projectDir, 'vite.config.ts'),\n `plugins: [sentrySvelteKit({`,\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(projectDir, 'ready in');\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, 'to expose', 'preview');\n });\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 // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\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\n // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: 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 test('creates an example route and page', () => {\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n );\n checkFileContents(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n // Svelte <5 specific syntax\n ['let hasSentError = false;', 'on:click={getSentryData}'],\n );\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'),\n );\n });\n });\n\n describe('with existing hooks', () => {\n const integration = Integration.sveltekit;\n\n const { projectDir, cleanup } = createIsolatedTestEnv(\n '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 cleanup();\n });\n\n test('has the correct package.json', () => {\n checkPackageJson(projectDir, '@sentry/sveltekit');\n });\n\n test('has the correct .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('vite.config contains sentry plugin', () => {\n checkFileContents(\n path.resolve(projectDir, 'vite.config.ts'),\n `plugins: [sentrySvelteKit({`,\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(projectDir, 'ready in');\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, 'to expose', 'preview');\n });\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 sendDefaultPii: 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 sendDefaultPii: true\n})`,\n 'export const handleError = Sentry.handleErrorWithSentry();',\n ]);\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 wizardInteraction = withEnv({\n cwd: projectDir,\n }).defineInteraction();\n\n if (fileModificationFn) {\n fileModificationFn(projectDir, integration);\n\n wizardInteraction\n .whenAsked('Do you want to continue anyway?')\n .respondWith(KEYS.ENTER);\n }\n\n wizardInteraction\n .whenAsked(\"It seems you're using a SvelteKit version\")\n .respondWith(KEYS.DOWN, KEYS.DOWN, KEYS.ENTER)\n .whenAsked('Please select your package manager.')\n .respondWith(KEYS.DOWN, KEYS.ENTER)\n .whenAsked('Do you want to enable Tracing', {\n timeout: 90_000, // package installation can take a while in CI\n })\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to enable Session Replay')\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to enable Logs')\n .respondWith(KEYS.ENTER)\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\n await wizardInteraction.run(getWizardCommand(Integration.sveltekit));\n}\n"]}
@@ -32,12 +32,10 @@ const vitest_1 = require("vitest");
32
32
  const clifty_1 = require("clifty");
33
33
  (0, vitest_1.describe)('Sveltekit with instrumentation and tracing', () => {
34
34
  (0, vitest_1.describe)('without existing files', () => {
35
- const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-tracing-test-app');
36
35
  const integration = Constants_1.Integration.sveltekit;
37
36
  let wizardExitCode;
37
+ const { projectDir, cleanup } = (0, utils_1.createIsolatedTestEnv)('sveltekit-tracing-test-app');
38
38
  (0, vitest_1.beforeAll)(async () => {
39
- (0, utils_1.initGit)(projectDir);
40
- (0, utils_1.revertLocalChanges)(projectDir);
41
39
  wizardExitCode = await (0, clifty_1.withEnv)({
42
40
  cwd: projectDir,
43
41
  })
@@ -62,14 +60,13 @@ const clifty_1 = require("clifty");
62
60
  .run((0, utils_1.getWizardCommand)(integration));
63
61
  });
64
62
  (0, vitest_1.afterAll)(() => {
65
- (0, utils_1.revertLocalChanges)(projectDir);
66
- (0, utils_1.cleanupGit)(projectDir);
63
+ cleanup();
67
64
  });
68
65
  (0, vitest_1.it)('exits with exit code 0', () => {
69
66
  (0, vitest_1.expect)(wizardExitCode).toBe(0);
70
67
  });
71
68
  (0, vitest_1.it)('adds the SDK dependency to package.json', () => {
72
- (0, utils_1.checkPackageJson)(projectDir, integration);
69
+ (0, utils_1.checkPackageJson)(projectDir, '@sentry/sveltekit');
73
70
  });
74
71
  (0, vitest_1.it)('adds the .env.sentry-build-plugin', () => {
75
72
  (0, utils_1.checkEnvBuildPlugin)(projectDir);
@@ -1 +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,oCAakB;AAClB,mCAAmE;AAEnE,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E;YACjE,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAClC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAC7C,CAAC;YACF,IAAA,eAAM,EAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BrD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,kDAAkD;QAClD,IAAA,WAAE,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YACnC,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 checkFileContents,\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 checkFileContents(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n // svelte 5 specific syntax\n ['let hasSentError = $state(false);', 'onclick={getSentryData}'],\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 org: \"${TEST_ARGS.ORG_SLUG}\",\n project: \"${TEST_ARGS.PROJECT_SLUG}\"\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 // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\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
+ {"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,oCAWkB;AAClB,mCAAmE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AC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BrD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,kDAAkD;QAClD,IAAA,WAAE,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YACnC,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 checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n createIsolatedTestEnv,\n getWizardCommand,\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 integration = Integration.sveltekit;\n let wizardExitCode: number;\n\n const { projectDir, cleanup } = createIsolatedTestEnv(\n 'sveltekit-tracing-test-app',\n );\n\n beforeAll(async () => {\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 cleanup();\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, '@sentry/sveltekit');\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 checkFileContents(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n // svelte 5 specific syntax\n ['let hasSentError = $state(false);', 'onclick={getSentryData}'],\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 org: \"${TEST_ARGS.ORG_SLUG}\",\n project: \"${TEST_ARGS.PROJECT_SLUG}\"\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 // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\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"]}
@@ -20,22 +20,24 @@ export declare const log: {
20
20
  info: (message: string) => void;
21
21
  error: (message: unknown) => void;
22
22
  };
23
- export declare class WizardTestEnv {
23
+ /**
24
+ * Creates an isolated test environment by copying a test application to a temporary directory.
25
+ * Each call creates a NEW unique temporary directory, allowing multiple isolated environments
26
+ * per test file (useful for tests that run the wizard multiple times with different configs).
27
+ *
28
+ * @param testAppName - Name of the test application folder (e.g., 'nextjs-16-test-app')
29
+ * @returns Object with projectDir path and cleanup function
30
+ */
31
+ export declare function createIsolatedTestEnv(testAppName: string): {
32
+ projectDir: string;
33
+ cleanup: () => void;
34
+ };
35
+ export declare class ProcessRunner {
24
36
  taskHandle: ChildProcess;
25
37
  constructor(cmd: string, args: string[], opts?: {
26
38
  cwd?: string;
27
39
  debug?: boolean;
28
40
  });
29
- sendStdin(input: string): void;
30
- /**
31
- * Sends the input and waits for the output.
32
- * @returns a promise that resolves when the output was found
33
- * @throws an error when the output was not found within the timeout
34
- */
35
- sendStdinAndWaitForOutput(input: string | string[], output: string, options?: {
36
- timeout?: number;
37
- optional?: boolean;
38
- }): Promise<boolean>;
39
41
  /**
40
42
  * Waits for the task to exit with a given `statusCode`.
41
43
  *
@@ -60,37 +62,7 @@ export declare class WizardTestEnv {
60
62
  }): Promise<boolean>;
61
63
  kill(): void;
62
64
  }
63
- /**
64
- * Initialize a git repository in the given directory
65
- * @param projectDir
66
- */
67
- export declare function initGit(projectDir: string): void;
68
- /**
69
- * Cleanup the git repository in the given directory
70
- *
71
- * Caution! Make sure `projectDir` is a test project directory,
72
- * if in doubt, please commit your local non-test changes first!
73
- * @param projectDir
74
- */
75
- export declare function cleanupGit(projectDir: string): void;
76
- /**
77
- * Revert local changes in the given directory
78
- *
79
- * Caution! Make sure `projectDir` is a test project directory,
80
- * if in doubt, please commit your local non-test changes first!
81
- *
82
- * @param projectDir
83
- */
84
- export declare function revertLocalChanges(projectDir: string): void;
85
65
  export declare function getWizardCommand(integration: Integration): string;
86
- /**
87
- * Start the wizard instance with the given integration and project directory
88
- * @param integration
89
- * @param projectDir
90
- *
91
- * @returns WizardTestEnv
92
- */
93
- export declare function startWizardInstance(integration: Integration, projectDir: string, debug?: boolean, spotlight?: boolean): WizardTestEnv;
94
66
  /**
95
67
  * Create a file with the given content
96
68
  *
@@ -133,12 +105,12 @@ export declare function checkFileExists(filePath: string): void;
133
105
  */
134
106
  export declare function checkFileDoesNotExist(filePath: string): void;
135
107
  /**
136
- * Check if the package.json contains the given integration
108
+ * Check if the package.json lists the given package as a dependency or dev dependency
137
109
  *
138
110
  * @param projectDir
139
111
  * @param integration
140
112
  */
141
- export declare function checkPackageJson(projectDir: string, integration: Integration): void;
113
+ export declare function checkPackageJson(projectDir: string, packageName: string, devDependency?: boolean): void;
142
114
  /**
143
115
  * Check if the .sentryclirc contains the auth token
144
116
  *
@@ -161,6 +133,12 @@ export declare function checkSentryProperties(projectDir: string): void;
161
133
  * @param projectDir
162
134
  */
163
135
  export declare function checkIfBuilds(projectDir: string): Promise<void>;
136
+ /**
137
+ * Check if the project lints successfully
138
+ * Runs `npm run lint` and expects status code 0.
139
+ * @param projectDir
140
+ */
141
+ export declare function checkIfLints(projectDir: string): Promise<void>;
164
142
  /**
165
143
  * Check if the flutter project builds
166
144
  * @param projectDir