@sentry/wizard 6.5.0 → 6.6.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 (63) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/e2e-tests/tests/angular-17.test.js +1 -0
  3. package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
  4. package/dist/e2e-tests/tests/angular-19.test.js +1 -0
  5. package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
  6. package/dist/e2e-tests/tests/expo.test.js +4 -1
  7. package/dist/e2e-tests/tests/expo.test.js.map +1 -1
  8. package/dist/e2e-tests/tests/nuxt-3.test.js +6 -0
  9. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
  10. package/dist/e2e-tests/tests/nuxt-4.test.js +6 -0
  11. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
  12. package/dist/e2e-tests/tests/react-native.test.js +5 -2
  13. package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
  14. package/dist/e2e-tests/tests/remix.test.js +2 -1
  15. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  16. package/dist/e2e-tests/tests/sveltekit-hooks.test.js +13 -2
  17. package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
  18. package/dist/e2e-tests/tests/sveltekit-tracing.test.js +4 -0
  19. package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
  20. package/dist/src/angular/codemods/main.js +1 -0
  21. package/dist/src/angular/codemods/main.js.map +1 -1
  22. package/dist/src/apple/templates.js +0 -2
  23. package/dist/src/apple/templates.js.map +1 -1
  24. package/dist/src/nextjs/nextjs-wizard.js +1 -1
  25. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  26. package/dist/src/nextjs/templates.js +6 -4
  27. package/dist/src/nextjs/templates.js.map +1 -1
  28. package/dist/src/nuxt/templates.js +10 -2
  29. package/dist/src/nuxt/templates.js.map +1 -1
  30. package/dist/src/react-native/react-native-wizard.js +3 -3
  31. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  32. package/dist/src/react-native/xcode.d.ts +2 -2
  33. package/dist/src/react-native/xcode.js +8 -13
  34. package/dist/src/react-native/xcode.js.map +1 -1
  35. package/dist/src/remix/sdk-setup.js +1 -0
  36. package/dist/src/remix/sdk-setup.js.map +1 -1
  37. package/dist/src/sveltekit/sdk-setup/setup.d.ts +6 -0
  38. package/dist/src/sveltekit/sdk-setup/setup.js +4 -1
  39. package/dist/src/sveltekit/sdk-setup/setup.js.map +1 -1
  40. package/dist/src/sveltekit/templates.js +9 -0
  41. package/dist/src/sveltekit/templates.js.map +1 -1
  42. package/dist/src/utils/clack/index.js +4 -1
  43. package/dist/src/utils/clack/index.js.map +1 -1
  44. package/dist/src/version.d.ts +1 -1
  45. package/dist/src/version.js +1 -1
  46. package/dist/src/version.js.map +1 -1
  47. package/dist/test/angular/angular-wizard.test.js +113 -17
  48. package/dist/test/angular/angular-wizard.test.js.map +1 -1
  49. package/dist/test/apple/code-tools.test.js +0 -3
  50. package/dist/test/apple/code-tools.test.js.map +1 -1
  51. package/dist/test/apple/templates.test.js +0 -4
  52. package/dist/test/apple/templates.test.js.map +1 -1
  53. package/dist/test/nextjs/templates.test.js +33 -22
  54. package/dist/test/nextjs/templates.test.js.map +1 -1
  55. package/dist/test/nuxt/templates.test.js +50 -10
  56. package/dist/test/nuxt/templates.test.js.map +1 -1
  57. package/dist/test/react-native/xcode.test.js +14 -13
  58. package/dist/test/react-native/xcode.test.js.map +1 -1
  59. package/dist/test/remix/client-entry.test.js +10 -4
  60. package/dist/test/remix/client-entry.test.js.map +1 -1
  61. package/dist/test/sveltekit/templates.test.js +214 -0
  62. package/dist/test/sveltekit/templates.test.js.map +1 -1
  63. package/package.json +3 -3
@@ -166,6 +166,10 @@ function checkSvelteKitProject(projectDir, integration, options) {
166
166
 
167
167
  // If you don't want to use Session Replay, just remove the line below:
168
168
  integrations: [replayIntegration()],
169
+
170
+ // Enable sending user PII (Personally Identifiable Information)
171
+ // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii
172
+ sendDefaultPii: true,
169
173
  });`,
170
174
  'export const handleError = handleErrorWithSentry(',
171
175
  ]);
@@ -181,6 +185,11 @@ function checkSvelteKitProject(projectDir, integration, options) {
181
185
  // Enable logs to be sent to Sentry
182
186
  enableLogs: true,
183
187
 
188
+
189
+ // Enable sending user PII (Personally Identifiable Information)
190
+ // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii
191
+ sendDefaultPii: true,
192
+
184
193
  // uncomment the line below to enable Spotlight (https://spotlightjs.com)
185
194
  // spotlight: import.meta.env.DEV,
186
195
  });`,
@@ -213,7 +222,8 @@ function checkSvelteKitProject(projectDir, integration, options) {
213
222
  replaysSessionSampleRate: 0.1,
214
223
  replaysOnErrorSampleRate: 1,
215
224
  integrations: [Sentry.replayIntegration()],
216
- enableLogs: true
225
+ enableLogs: true,
226
+ sendDefaultPii: true
217
227
  })`,
218
228
  'export const handleError = Sentry.handleErrorWithSentry(',
219
229
  ]);
@@ -224,7 +234,8 @@ function checkSvelteKitProject(projectDir, integration, options) {
224
234
  `Sentry.init({
225
235
  dsn: "${utils_1.TEST_ARGS.PROJECT_DSN}",
226
236
  tracesSampleRate: 1,
227
- enableLogs: true
237
+ enableLogs: true,
238
+ sendDefaultPii: true
228
239
  })`,
229
240
  'export const handleError = Sentry.handleErrorWithSentry();',
230
241
  ]);
@@ -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;AAE7D,MAAM,oBAAoB,GAAG;;;;;;;;;;CAU5B,CAAC;AACF,MAAM,oBAAoB,GAAG;;;;;;;;;;;CAW5B,CAAC;AAEF,KAAK,UAAU,2BA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AAoB,CACrB,CAAC;gBAEF,IAAA,kBAAU,EACR,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAC/C,oBAAoB,CACrB,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAA,iBAAQ,EAAC,GAAG,EAAE;YACZ,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAC/B,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,qBAAqB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAE/C,sEAAsE;QACtE,iEAAiE;QACjE,IAAA,aAAI,EAAC,iDAAiD,EAAE,GAAG,EAAE;YAC3D,IAAA,yBAAiB,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE;gBACjE,8CAA8C;gBAC9C;YACI,iBAAS,CAAC,WAAW;;;;;;GAM9B;gBACK,0DAA0D;aAC3D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;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"]}
1
+ {"version":3,"file":"sveltekit-hooks.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/sveltekit-hooks.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,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AS,EAAC,KAAK,IAAI,EAAE;YACnB,MAAM,2BAA2B,CAC/B,UAAU,EACV,WAAW,EACX,CAAC,UAAU,EAAE,EAAE;gBACb,IAAA,kBAAU,EACR,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAC/C,oBAAoB,CACrB,CAAC;gBAEF,IAAA,kBAAU,EACR,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAC/C,oBAAoB,CACrB,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAA,iBAAQ,EAAC,GAAG,EAAE;YACZ,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAC/B,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,qBAAqB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAE/C,sEAAsE;QACtE,iEAAiE;QACjE,IAAA,aAAI,EAAC,iDAAiD,EAAE,GAAG,EAAE;YAC3D,IAAA,yBAAiB,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE;gBACjE,8CAA8C;gBAC9C;YACI,iBAAS,CAAC,WAAW;;;;;;;GAO9B;gBACK,0DAA0D;aAC3D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;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;;;;GAI9B;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 // 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\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 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"]}
@@ -120,6 +120,10 @@ const clifty_1 = require("clifty");
120
120
 
121
121
  // If you don't want to use Session Replay, just remove the line below:
122
122
  integrations: [replayIntegration()],
123
+
124
+ // Enable sending user PII (Personally Identifiable Information)
125
+ // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii
126
+ sendDefaultPii: true,
123
127
  });
124
128
 
125
129
  // If you have a custom error handler, pass it to \`handleErrorWithSentry\`
@@ -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,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,CAClD,CAAC;QAEF,MAAM,WAAW,GAAG,uBAAW,CAAC,SAAS,CAAC;QAC1C,IAAI,cAAsB,CAAC;QAE3B,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;YACnB,IAAA,eAAO,EAAC,UAAU,CAAC,CAAC;YACpB,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAE/B,cAAc,GAAG,MAAM,IAAA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,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
+ {"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,CAClD,CAAC;QAEF,MAAM,WAAW,GAAG,uBAAW,CAAC,SAAS,CAAC;QAC1C,IAAI,cAAsB,CAAC;QAE3B,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;YACnB,IAAA,eAAO,EAAC,UAAU,CAAC,CAAC;YACpB,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAE/B,cAAc,GAAG,MAAM,IAAA,gBAAO,EAAC;gBAC7B,GAAG,EAAE,UAAU;aAChB,CAAC;iBACC,iBAAiB,EAAE;iBACnB,YAAY,CACX,8EAA8E,CAC/E;iBACA,IAAI,CAAC,sBAAsB,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE;gBAC5D,SAAS,CAAC,qCAAqC,CAAC,CAAC,WAAW,CAC1D,aAAI,CAAC,IAAI,EACT,aAAI,CAAC,KAAK,CACX,CAAC;gBACF,YAAY,CAAC,8BAA8B,CAAC,CAAC;YAC/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B,GAAG,EAAE,CAAC,YAAY,CAC3C,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,+BAA+B,CAAC,CAC1D,CAAC;YAEF,IAAA,eAAM,EAAC,qBAAqB,CAAC,QAAQ,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;kBAInD,iBAAS,CAAC,WAAW;;;;;;;;;;OAUhC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,yDAAyD,EAAE,GAAG,EAAE;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 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 // 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"]}
@@ -47,6 +47,7 @@ function getInitCallArgs(dsn, selectedFeatures) {
47
47
  if (selectedFeatures.logs) {
48
48
  initCallArgs.enableLogs = true;
49
49
  }
50
+ initCallArgs.sendDefaultPii = true;
50
51
  return initCallArgs;
51
52
  }
52
53
  exports.getInitCallArgs = getInitCallArgs;
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../src/angular/codemods/main.ts"],"names":[],"mappings":";;;AAEA,uCAMkB;AAElB,SAAgB,iBAAiB;AAC/B,8DAA8D;AAC9D,oBAA0C,EAC1C,GAAW,EACX,gBAIC;IAGD,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC;QAChC,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,GAAG;QACb,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IAEH,cAAc,CAAC,oBAAoB,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAE5D,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AApBD,8CAoBC;AAED,SAAgB,cAAc;AAC5B,8DAA8D;AAC9D,oBAA0C,EAC1C,GAAW,EACX,gBAIC;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAC5D,sHAAsH;IACtH,MAAM,QAAQ,GAAG,mBAAQ,CAAC,YAAY,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IACpE,MAAM,uBAAuB,GAAG,oBAAoB,CAAC,IAAe,CAAC;IAErE,MAAM,sBAAsB,GAAG,6BAA6B,CAC1D,uBAAuB,CACxB,CAAC;IAEF,uBAAuB,CAAC,IAAI,CAAC,MAAM,CACjC,sBAAsB,EACtB,CAAC;IACD,gFAAgF;IAChF,qHAAqH;IACrH,IAAA,uBAAY,EAAC,QAAQ,CAAC,CAAC,IAAI,CAC5B,CAAC;AACJ,CAAC;AA1BD,wCA0BC;AAOD,SAAgB,eAAe,CAC7B,GAAW,EACX,gBAIC;IAED,MAAM,YAAY,GAAiB;QACjC,GAAG;KACJ,CAAC;IAEF,IAAI,gBAAgB,CAAC,MAAM,IAAI,gBAAgB,CAAC,WAAW,EAAE;QAC3D,YAAY,CAAC,YAAY,GAAG,EAAE,CAAC;QAE/B,IAAI,gBAAgB,CAAC,WAAW,EAAE;YAChC,YAAY,CAAC,YAAY,CAAC,IAAI,CAC5B,mBAAQ,CAAC,YAAY,CAAC,kCAAkC,CAAC,CAC1D,CAAC;YACF,YAAY,CAAC,gBAAgB,GAAG,GAAG,CAAC;SACrC;QAED,IAAI,gBAAgB,CAAC,MAAM,EAAE;YAC3B,YAAY,CAAC,YAAY,CAAC,IAAI,CAC5B,mBAAQ,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAClD,CAAC;YAEF,YAAY,CAAC,wBAAwB,GAAG,GAAG,CAAC;YAC5C,YAAY,CAAC,wBAAwB,GAAG,GAAG,CAAC;SAC7C;KACF;IAED,IAAI,gBAAgB,CAAC,IAAI,EAAE;QACzB,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC;KAChC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AArCD,0CAqCC;AAED;;GAEG;AACH,SAAgB,6BAA6B,CAC3C,yBAAkC;IAElC,KAAK,IAAI,CAAC,GAAG,yBAAyB,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACnE,IAAI,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,mBAAmB,EAAE;YAClE,OAAO,CAAC,GAAG,CAAC,CAAC;SACd;KACF;IAED,OAAO,CAAC,CAAC;AACX,CAAC;AAVD,sEAUC","sourcesContent":["import type { Program } from '@babel/types';\n\nimport {\n builders,\n generateCode,\n Proxified,\n type ProxifiedModule,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\n\nexport function updateAppEntryMod(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalAppModuleMod: ProxifiedModule<any>,\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): ProxifiedModule<any> {\n originalAppModuleMod.imports.$add({\n from: '@sentry/angular',\n imported: '*',\n local: 'Sentry',\n });\n\n insertInitCall(originalAppModuleMod, dsn, selectedFeatures);\n\n return originalAppModuleMod;\n}\n\nexport function insertInitCall(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalAppModuleMod: ProxifiedModule<any>,\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n): void {\n const initCallArgs = getInitCallArgs(dsn, selectedFeatures);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- builders return Proxified which defaults to any\n const initCall = builders.functionCall('Sentry.init', initCallArgs);\n const originalAppModuleModAst = originalAppModuleMod.$ast as Program;\n\n const initCallInsertionIndex = getAfterImportsInsertionIndex(\n originalAppModuleModAst,\n );\n\n originalAppModuleModAst.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- builders return Proxified which defaults to any.\n generateCode(initCall).code,\n );\n}\n\ntype InitCallArgs = Record<\n string,\n string | number | boolean | Array<Proxified>\n>;\n\nexport function getInitCallArgs(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n): InitCallArgs {\n const initCallArgs: InitCallArgs = {\n dsn,\n };\n\n if (selectedFeatures.replay || selectedFeatures.performance) {\n initCallArgs.integrations = [];\n\n if (selectedFeatures.performance) {\n initCallArgs.integrations.push(\n builders.functionCall('Sentry.browserTracingIntegration'),\n );\n initCallArgs.tracesSampleRate = 1.0;\n }\n\n if (selectedFeatures.replay) {\n initCallArgs.integrations.push(\n builders.functionCall('Sentry.replayIntegration'),\n );\n\n initCallArgs.replaysSessionSampleRate = 0.1;\n initCallArgs.replaysOnErrorSampleRate = 1.0;\n }\n }\n\n if (selectedFeatures.logs) {\n initCallArgs.enableLogs = true;\n }\n\n return initCallArgs;\n}\n\n/**\n * We want to insert the handleError function just after all imports\n */\nexport function getAfterImportsInsertionIndex(\n originalEntryServerModAST: Program,\n): number {\n for (let x = originalEntryServerModAST.body.length - 1; x >= 0; x--) {\n if (originalEntryServerModAST.body[x].type === 'ImportDeclaration') {\n return x + 1;\n }\n }\n\n return 0;\n}\n"]}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../src/angular/codemods/main.ts"],"names":[],"mappings":";;;AAEA,uCAMkB;AAElB,SAAgB,iBAAiB;AAC/B,8DAA8D;AAC9D,oBAA0C,EAC1C,GAAW,EACX,gBAIC;IAGD,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC;QAChC,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,GAAG;QACb,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IAEH,cAAc,CAAC,oBAAoB,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAE5D,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AApBD,8CAoBC;AAED,SAAgB,cAAc;AAC5B,8DAA8D;AAC9D,oBAA0C,EAC1C,GAAW,EACX,gBAIC;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAC5D,sHAAsH;IACtH,MAAM,QAAQ,GAAG,mBAAQ,CAAC,YAAY,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IACpE,MAAM,uBAAuB,GAAG,oBAAoB,CAAC,IAAe,CAAC;IAErE,MAAM,sBAAsB,GAAG,6BAA6B,CAC1D,uBAAuB,CACxB,CAAC;IAEF,uBAAuB,CAAC,IAAI,CAAC,MAAM,CACjC,sBAAsB,EACtB,CAAC;IACD,gFAAgF;IAChF,qHAAqH;IACrH,IAAA,uBAAY,EAAC,QAAQ,CAAC,CAAC,IAAI,CAC5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Code,\n Proxified,\n type ProxifiedModule,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\n\nexport function updateAppEntryMod(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalAppModuleMod: ProxifiedModule<any>,\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): ProxifiedModule<any> {\n originalAppModuleMod.imports.$add({\n from: '@sentry/angular',\n imported: '*',\n local: 'Sentry',\n });\n\n insertInitCall(originalAppModuleMod, dsn, selectedFeatures);\n\n return originalAppModuleMod;\n}\n\nexport function insertInitCall(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalAppModuleMod: ProxifiedModule<any>,\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n): void {\n const initCallArgs = getInitCallArgs(dsn, selectedFeatures);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- builders return Proxified which defaults to any\n const initCall = builders.functionCall('Sentry.init', initCallArgs);\n const originalAppModuleModAst = originalAppModuleMod.$ast as Program;\n\n const initCallInsertionIndex = getAfterImportsInsertionIndex(\n originalAppModuleModAst,\n );\n\n originalAppModuleModAst.body.splice(\n initCallInsertionIndex,\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- builders return Proxified which defaults to any.\n generateCode(initCall).code,\n );\n}\n\ntype InitCallArgs = Record<\n string,\n string | number | boolean | Array<Proxified>\n>;\n\nexport function getInitCallArgs(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n },\n): InitCallArgs {\n const initCallArgs: InitCallArgs = {\n dsn,\n };\n\n if (selectedFeatures.replay || selectedFeatures.performance) {\n initCallArgs.integrations = [];\n\n if (selectedFeatures.performance) {\n initCallArgs.integrations.push(\n builders.functionCall('Sentry.browserTracingIntegration'),\n );\n initCallArgs.tracesSampleRate = 1.0;\n }\n\n if (selectedFeatures.replay) {\n initCallArgs.integrations.push(\n builders.functionCall('Sentry.replayIntegration'),\n );\n\n initCallArgs.replaysSessionSampleRate = 0.1;\n initCallArgs.replaysOnErrorSampleRate = 1.0;\n }\n }\n\n if (selectedFeatures.logs) {\n initCallArgs.enableLogs = true;\n }\n\n initCallArgs.sendDefaultPii = true;\n\n return initCallArgs;\n}\n\n/**\n * We want to insert the handleError function just after all imports\n */\nexport function getAfterImportsInsertionIndex(\n originalEntryServerModAST: Program,\n): number {\n for (let x = originalEntryServerModAST.body.length - 1; x >= 0; x--) {\n if (originalEntryServerModAST.body[x].type === 'ImportDeclaration') {\n return x + 1;\n }\n }\n\n return 0;\n}\n"]}
@@ -28,7 +28,6 @@ exports.scriptInputPath = '"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Co
28
28
  function getSwiftSnippet(dsn, enableLogs) {
29
29
  let snippet = ` SentrySDK.start { options in
30
30
  options.dsn = "${dsn}"
31
- options.debug = true // Enabled debug when first installing is always helpful
32
31
 
33
32
  // Adds IP for users.
34
33
  // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/
@@ -63,7 +62,6 @@ exports.getSwiftSnippet = getSwiftSnippet;
63
62
  function getObjcSnippet(dsn, enableLogs) {
64
63
  let snippet = ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {
65
64
  options.dsn = @"${dsn}";
66
- options.debug = YES; // Enabled debug when first installing is always helpful
67
65
 
68
66
  // Adds IP for users.
69
67
  // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC;;;;CAIL;QACG,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe;;sBAE5F,OAAO;0BACH,WAAW;0CAEjC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC;;;;;;;CAOD,CAAC;AACF,CAAC;AA5BD,oDA4BC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW,EAAE,UAAmB;IAC9D,IAAI,OAAO,GAAG;6BACa,GAAG;;;;;;;;;;;;;;;;;;;sGAmBsE,CAAC;IAErG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;mDAGoC,CAAC;KACjD;IAED,OAAO,IAAI;;;iEAGoD,CAAC;IAEhE,OAAO,OAAO,CAAC;AACjB,CAAC;AApCD,0CAoCC;AAED,SAAgB,cAAc,CAAC,GAAW,EAAE,UAAmB;IAC7D,IAAI,OAAO,GAAG;0BACU,GAAG;;;;;;;;;;;;;;;;;;;oGAmBuE,CAAC;IAEnG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;+CAGgC,CAAC;KAC7C;IAED,OAAO,IAAI;;;2DAG8C,CAAC;IAE1D,OAAO,OAAO,CAAC;AACjB,CAAC;AApCD,wCAoCC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? `\nif [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n`\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\nif which sentry-cli >/dev/null; then\n export SENTRY_ORG=${orgSlug}\n export SENTRY_PROJECT=${projectSlug}\n ERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\n if [ ! $? -eq 0 ]; then\n echo \"warning: sentry-cli - $ERROR\"\n fi\nelse\n echo \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = true`;\n }\n\n snippet += `\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n\n return snippet;\n}\n\nexport function getObjcSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = YES;`;\n }\n\n snippet += `\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n\n return snippet;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC;;;;CAIL;QACG,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe;;sBAE5F,OAAO;0BACH,WAAW;0CAEjC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC;;;;;;;CAOD,CAAC;AACF,CAAC;AA5BD,oDA4BC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW,EAAE,UAAmB;IAC9D,IAAI,OAAO,GAAG;6BACa,GAAG;;;;;;;;;;;;;;;;;;sGAkBsE,CAAC;IAErG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;mDAGoC,CAAC;KACjD;IAED,OAAO,IAAI;;;iEAGoD,CAAC;IAEhE,OAAO,OAAO,CAAC;AACjB,CAAC;AAnCD,0CAmCC;AAED,SAAgB,cAAc,CAAC,GAAW,EAAE,UAAmB;IAC7D,IAAI,OAAO,GAAG;0BACU,GAAG;;;;;;;;;;;;;;;;;;oGAkBuE,CAAC;IAEnG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;+CAGgC,CAAC;KAC7C;IAED,OAAO,IAAI;;;2DAG8C,CAAC;IAE1D,OAAO,OAAO,CAAC;AACjB,CAAC;AAnCD,wCAmCC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? `\nif [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n`\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\nif which sentry-cli >/dev/null; then\n export SENTRY_ORG=${orgSlug}\n export SENTRY_PROJECT=${projectSlug}\n ERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\n if [ ! $? -eq 0 ]; then\n echo \"warning: sentry-cli - $ERROR\"\n fi\nelse\n echo \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = true`;\n }\n\n snippet += `\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n\n return snippet;\n}\n\nexport function getObjcSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = YES;`;\n }\n\n snippet += `\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n\n return snippet;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
@@ -204,7 +204,7 @@ async function runNextjsWizardWithTelemetry(options) {
204
204
  const isLikelyUsingTurbopack = await checkIfLikelyIsUsingTurbopack();
205
205
  if (isLikelyUsingTurbopack || isLikelyUsingTurbopack === null) {
206
206
  await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
207
- message: `Warning: The Sentry SDK is only compatible with Turbopack on Next.js version 15.3.0 (or 15.3.0-canary.8) or later. ${chalk_1.default.bold(`If you are using Turbopack with an older Next.js version, temporarily remove \`--turbo\` or \`--turbopack\` from your dev command until you have verified the SDK is working as expected. Note that the SDK will continue to work for non-Turbopack production builds.`)}`,
207
+ message: 'Warning: The Sentry SDK is only compatible with Turbopack on Next.js version 15.4.1 or later.',
208
208
  options: [
209
209
  {
210
210
  label: 'I understand.',