@sentry/wizard 6.4.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 (75) hide show
  1. package/CHANGELOG.md +18 -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 +13 -3
  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 +14 -4
  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/android/android-wizard.js +9 -1
  21. package/dist/src/android/android-wizard.js.map +1 -1
  22. package/dist/src/android/manifest.d.ts +1 -1
  23. package/dist/src/android/manifest.js +2 -2
  24. package/dist/src/android/manifest.js.map +1 -1
  25. package/dist/src/android/templates.d.ts +1 -1
  26. package/dist/src/android/templates.js +4 -1
  27. package/dist/src/android/templates.js.map +1 -1
  28. package/dist/src/angular/codemods/main.js +1 -0
  29. package/dist/src/angular/codemods/main.js.map +1 -1
  30. package/dist/src/apple/templates.js +0 -2
  31. package/dist/src/apple/templates.js.map +1 -1
  32. package/dist/src/nextjs/nextjs-wizard.js +1 -1
  33. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  34. package/dist/src/nextjs/templates.js +6 -4
  35. package/dist/src/nextjs/templates.js.map +1 -1
  36. package/dist/src/nuxt/templates.js +10 -2
  37. package/dist/src/nuxt/templates.js.map +1 -1
  38. package/dist/src/react-native/javascript.d.ts +6 -4
  39. package/dist/src/react-native/javascript.js +11 -7
  40. package/dist/src/react-native/javascript.js.map +1 -1
  41. package/dist/src/react-native/react-native-wizard.js +9 -0
  42. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  43. package/dist/src/react-native/xcode.js +5 -3
  44. package/dist/src/react-native/xcode.js.map +1 -1
  45. package/dist/src/remix/sdk-setup.js +1 -0
  46. package/dist/src/remix/sdk-setup.js.map +1 -1
  47. package/dist/src/sveltekit/sdk-setup/setup.d.ts +6 -0
  48. package/dist/src/sveltekit/sdk-setup/setup.js +4 -1
  49. package/dist/src/sveltekit/sdk-setup/setup.js.map +1 -1
  50. package/dist/src/sveltekit/templates.js +9 -0
  51. package/dist/src/sveltekit/templates.js.map +1 -1
  52. package/dist/src/utils/clack/index.js +4 -1
  53. package/dist/src/utils/clack/index.js.map +1 -1
  54. package/dist/src/version.d.ts +1 -1
  55. package/dist/src/version.js +1 -1
  56. package/dist/src/version.js.map +1 -1
  57. package/dist/test/angular/angular-wizard.test.js +113 -17
  58. package/dist/test/angular/angular-wizard.test.js.map +1 -1
  59. package/dist/test/apple/code-tools.test.js +0 -3
  60. package/dist/test/apple/code-tools.test.js.map +1 -1
  61. package/dist/test/apple/templates.test.js +0 -4
  62. package/dist/test/apple/templates.test.js.map +1 -1
  63. package/dist/test/nextjs/templates.test.js +33 -22
  64. package/dist/test/nextjs/templates.test.js.map +1 -1
  65. package/dist/test/nuxt/templates.test.js +50 -10
  66. package/dist/test/nuxt/templates.test.js.map +1 -1
  67. package/dist/test/react-native/javascript.test.js +225 -0
  68. package/dist/test/react-native/javascript.test.js.map +1 -1
  69. package/dist/test/react-native/xcode.test.js +20 -2
  70. package/dist/test/react-native/xcode.test.js.map +1 -1
  71. package/dist/test/remix/client-entry.test.js +10 -4
  72. package/dist/test/remix/client-entry.test.js.map +1 -1
  73. package/dist/test/sveltekit/templates.test.js +214 -0
  74. package/dist/test/sveltekit/templates.test.js.map +1 -1
  75. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nuxt/templates.ts"],"names":[],"mappings":";;;AAAA,sCAAiD;AAQjD,SAAgB,oBAAoB;IAClC,OAAO;;;;;CAKR,CAAC;AACF,CAAC;AAPD,oDAOC;AAED,SAAgB,6BAA6B,CAC3C,OAKC,EACD,oBAA6B;IAE7B,OAAO;;;cAGK,OAAO,CAAC,GAAG;kBACP,OAAO,CAAC,OAAO,KAC7B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAC1D;QAEI,oBAAoB;QAClB,CAAC,CAAC,mDAAmD;QACrD,CAAC,CAAC,EACN;;mCAE+B,CAAC;AACpC,CAAC;AAvBD,sEAuBC;AAED,SAAgB,uBAAuB,CACrC,GAAW,EACX,MAA2B,EAC3B,gBAAwC;IAExC,IAAI,MAAM,KAAK,QAAQ,EAAE;QACvB,OAAO,6BAA6B,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;KAC7D;IAED,OAAO,6BAA6B,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;AAC9D,CAAC;AAVD,0DAUC;AAED,MAAM,iBAAiB,GAAiD;IACtE,WAAW,EAAE;QACX,8EAA8E;QAC9E,wBAAwB;QACxB,0BAA0B;KAC3B,CAAC,IAAI,CAAC,IAAI,CAAC;IACZ,MAAM,EAAE;QACN,8EAA8E;QAC9E,8DAA8D;QAC9D,kCAAkC;QAClC,IAAI;QACJ,gFAAgF;QAChF,qCAAqC;QACrC,kCAAkC;QAClC,IAAI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CAAC,OAI5C;IACC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,cAAc,GAAG,IAAA,uBAAiB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAE3E,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mGA4D0F,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiKhH,CAAC;AACF,CAAC;AAtOD,oEAsOC;AAED,SAAgB,2BAA2B;IACzC,OAAO;;;;;;;CAOR,CAAC;AACF,CAAC;AATD,kEASC;AAED,SAAgB,4BAA4B;IAC1C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ER,CAAC;AACF,CAAC;AA/ED,oEA+EC","sourcesContent":["import { getIssueStreamUrl } from '../utils/url';\n\ntype SelectedSentryFeatures = {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n};\n\nexport function getDefaultNuxtConfig(): string {\n return `// https://nuxt.com/docs/api/configuration/nuxt-config\nexport default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n})\n`;\n}\n\nexport function getNuxtModuleFallbackTemplate(\n options: {\n org: string;\n project: string;\n url: string;\n selfHosted: boolean;\n },\n shouldTopLevelImport: boolean,\n): string {\n return ` modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"${options.org}\",\n project: \"${options.project}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n },${\n shouldTopLevelImport\n ? `\\n autoInjectServerSentry: \"top-level-import\",`\n : ''\n }\n },\n sourcemap: { client: \"hidden\" },`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n): string {\n if (config === 'client') {\n return getSentryClientConfigContents(dsn, selectedFeatures);\n }\n\n return getSentryServerConfigContents(dsn, selectedFeatures);\n}\n\nconst featuresConfigMap: Record<keyof SelectedSentryFeatures, string> = {\n performance: [\n ' // We recommend adjusting this value in production, or using tracesSampler',\n ' // for finer control',\n ' tracesSampleRate: 1.0,',\n ].join('\\n'),\n replay: [\n ' // This sets the sample rate to be 10%. You may want this to be 100% while',\n ' // in development and sample at a lower rate in production',\n ' replaysSessionSampleRate: 0.1,',\n ' ',\n ' // If the entire session is not sampled, use the below sample rate to sample',\n ' // sessions when an error occurs.',\n ' replaysOnErrorSampleRate: 1.0,',\n ' ',\n \" // If you don't want to use Session Replay, just remove the line below:\",\n ' integrations: [Sentry.replayIntegration()],',\n ].join('\\n'),\n logs: [' // Enable logs to be sent to Sentry', ' enableLogs: true,'].join(\n '\\n',\n ),\n};\n\nconst featuresMap: Record<\n 'client' | 'server',\n Array<keyof SelectedSentryFeatures>\n> = {\n client: ['performance', 'replay', 'logs'],\n server: ['performance', 'logs'],\n};\n\nexport function getConfigBody(\n dsn: string,\n variant: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n) {\n return [\n `dsn: \"${dsn}\",`,\n Object.entries(selectedFeatures)\n .map(([feature, activated]: [keyof SelectedSentryFeatures, boolean]) => {\n return featuresMap[variant].includes(feature) && activated\n ? featuresConfigMap[feature]\n : null;\n })\n .filter(Boolean)\n .join('\\n\\n'),\n ]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\nfunction getSentryClientConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n\nSentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n ${getConfigBody(dsn, 'client', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nfunction getSentryServerConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n \nSentry.init({\n ${getConfigBody(dsn, 'server', selectedFeatures)}\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getIndexRouteTemplate(): string {\n return `<!--\nThis is just to verify the sentry-example-page.\nFeel free to delete this file.\n-->\n\n<template></template>`;\n}\n\nexport function getSentryExamplePageTemplate(options: {\n url: string;\n org: string;\n projectId: string;\n}): string {\n const { url, org, projectId } = options;\n const issuesPageLink = getIssueStreamUrl({ url, orgSlug: org, projectId });\n\n return `<!--\nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n\n class SentryExampleFrontendError extends Error {\n constructor(message) {\n super(message);\n this.name = \"SentryExampleFrontendError\";\n }\n }\n\n const hasSentError = ref(false);\n const isConnected = ref(true);\n \n onMounted(async () => {\n try {\n const result = await Sentry.diagnoseSdkConnectivity();\n isConnected.value = result !== 'sentry-unreachable';\n } catch (error) {\n isConnected.value = false;\n }\n });\n \n async function getSentryData() {\n await Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const res = await $fetch('/api/sentry-example-api', { \n method: 'GET',\n ignoreResponseError: true \n }).catch(() => null);\n if (!res) {\n hasSentError.value = true;\n }\n }\n );\n throw new SentryExampleFrontendError(\"This error is raised on the frontend of the example page.\");\n }\n</script>\n\n<template>\n <title>Sentry Onboarding</title>\n <div>\n <main>\n <div class=\"flex-spacer\" />\n <svg height=\"40\" width=\"40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z\" fill=\"currentcolor\"/>\n </svg>\n <h1>\n sentry-example-page\n </h1>\n\n <p class=\"description\">\n Click the button below, and view the sample error on the Sentry <a target=\"_blank\" href=\"${issuesPageLink}\">Issues Page</a>.\n For more details about setting up Sentry, <a target=\"_blank\" href=\"https://docs.sentry.io/platforms/javascript/guides/nuxt/\">read our docs</a>.\n </p>\n\n <button\n type=\"button\"\n @click=\"getSentryData\"\n :disabled=\"!isConnected\"\n >\n <span>\n Throw Sample Error\n </span>\n </button>\n\n <p v-if=\"hasSentError\" class=\"success\">\n Sample error was sent to Sentry.\n </p>\n <div v-else-if=\"!isConnected\" class=\"connectivity-error\">\n <p>It looks like network requests to Sentry are being blocked, which will prevent errors from being captured. Try disabling your ad-blocker to complete the test.</p>\n </div>\n <div v-else class=\"success_placeholder\" />\n\n <div class=\"flex-spacer\" />\n </main>\n </div>\n</template>\n\n<style scoped>\n :global(body) {\n margin: 0;\n\n @media (prefers-color-scheme: dark) {\n color: #ededed;\n background-color: #0a0a0a;\n }\n }\n\n main {\n display: flex;\n min-height: 100vh;\n box-sizing: border-box;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 16px;\n padding: 16px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n\n h1 {\n padding: 0px 4px;\n margin: 0;\n border-radius: 4px;\n background-color: rgba(24, 20, 35, 0.03);\n font-family: monospace;\n font-size: 20px;\n line-height: 1.2;\n }\n\n p {\n margin: 0;\n font-size: 20px;\n }\n\n a {\n color: #6341F0;\n text-decoration: underline;\n cursor: pointer;\n\n @media (prefers-color-scheme: dark) {\n color: #B3A1FF;\n }\n }\n\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0); \n }\n\n &:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n\n & > span {\n transform: translateY(0);\n border: none;\n }\n }\n }\n\n .description {\n text-align: center;\n color: #6E6C75;\n max-width: 500px;\n line-height: 1.5;\n font-size: 20px;\n\n @media (prefers-color-scheme: dark) {\n color: #A49FB5;\n }\n }\n\n .flex-spacer {\n flex: 1;\n }\n\n .success {\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n }\n\n .success_placeholder {\n height: 46px;\n }\n \n .connectivity-error {\n padding: 12px 16px;\n background-color: #E50045;\n border-radius: 8px;\n width: 500px;\n color: #FFFFFF;\n border: 1px solid #A80033;\n text-align: center;\n margin: 0;\n }\n \n .connectivity-error a {\n color: #FFFFFF;\n text-decoration: underline;\n }\n</style>\n\n`;\n}\n\nexport function getSentryExampleApiTemplate() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(() => {\n throw new Error(\"Sentry Example API Route Error\");\n});\n`;\n}\n\nexport function getSentryErrorButtonTemplate() {\n return `<!--\nThis is just a very simple component that throws an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n\n const hasSentError = ref(false);\n \n const throwError = () => {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n () => {\n hasSentError.value = true;\n throw new Error('Sentry Example Error');\n }\n )\n };\n</script>\n\n<template>\n <div v-if=\"hasSentError\" class=\"success\">\n Sample error was sent to Sentry.\n </div>\n <button v-else @click=\"throwError\">\n <span>Throw Sample Error</span>\n </button>\n</template>\n\n<style scoped>\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0);\n }\n }\n\n .success {\n width: max-content;\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n</style>\n`;\n}\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nuxt/templates.ts"],"names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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiKhH,CAAC;AACF,CAAC;AAtOD,oEAsOC;AAED,SAAgB,2BAA2B;IACzC,OAAO;;;;;;;CAOR,CAAC;AACF,CAAC;AATD,kEASC;AAED,SAAgB,4BAA4B;IAC1C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ER,CAAC;AACF,CAAC;AA/ED,oEA+EC","sourcesContent":["import { getIssueStreamUrl } from '../utils/url';\n\ntype SelectedSentryFeatures = {\n performance: boolean;\n replay: boolean;\n logs: boolean;\n};\n\nexport function getDefaultNuxtConfig(): string {\n return `// https://nuxt.com/docs/api/configuration/nuxt-config\nexport default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n})\n`;\n}\n\nexport function getNuxtModuleFallbackTemplate(\n options: {\n org: string;\n project: string;\n url: string;\n selfHosted: boolean;\n },\n shouldTopLevelImport: boolean,\n): string {\n return ` modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"${options.org}\",\n project: \"${options.project}\",${\n options.selfHosted ? `\\n url: \"${options.url}\",` : ''\n }\n },${\n shouldTopLevelImport\n ? `\\n autoInjectServerSentry: \"top-level-import\",`\n : ''\n }\n },\n sourcemap: { client: \"hidden\" },`;\n}\n\nexport function getSentryConfigContents(\n dsn: string,\n config: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n): string {\n if (config === 'client') {\n return getSentryClientConfigContents(dsn, selectedFeatures);\n }\n\n return getSentryServerConfigContents(dsn, selectedFeatures);\n}\n\nconst featuresConfigMap: Record<keyof SelectedSentryFeatures, string> = {\n performance: [\n ' // We recommend adjusting this value in production, or using tracesSampler',\n ' // for finer control',\n ' tracesSampleRate: 1.0,',\n ].join('\\n'),\n replay: [\n ' // This sets the sample rate to be 10%. You may want this to be 100% while',\n ' // in development and sample at a lower rate in production',\n ' replaysSessionSampleRate: 0.1,',\n ' ',\n ' // If the entire session is not sampled, use the below sample rate to sample',\n ' // sessions when an error occurs.',\n ' replaysOnErrorSampleRate: 1.0,',\n ' ',\n \" // If you don't want to use Session Replay, just remove the line below:\",\n ' integrations: [Sentry.replayIntegration()],',\n ].join('\\n'),\n logs: [' // Enable logs to be sent to Sentry', ' enableLogs: true,'].join(\n '\\n',\n ),\n};\n\nconst featuresMap: Record<\n 'client' | 'server',\n Array<keyof SelectedSentryFeatures>\n> = {\n client: ['performance', 'replay', 'logs'],\n server: ['performance', 'logs'],\n};\n\nexport function getConfigBody(\n dsn: string,\n variant: 'client' | 'server',\n selectedFeatures: SelectedSentryFeatures,\n) {\n return [\n `dsn: \"${dsn}\",`,\n Object.entries(selectedFeatures)\n .map(([feature, activated]: [keyof SelectedSentryFeatures, boolean]) => {\n return featuresMap[variant].includes(feature) && activated\n ? featuresConfigMap[feature]\n : null;\n })\n .filter(Boolean)\n .join('\\n\\n'),\n ]\n .filter(Boolean)\n .join('\\n\\n');\n}\n\nfunction getSentryClientConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n\nSentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n ${getConfigBody(dsn, 'client', selectedFeatures)}\n\n // Enable sending of user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nfunction getSentryServerConfigContents(\n dsn: string,\n selectedFeatures: SelectedSentryFeatures,\n): string {\n return `import * as Sentry from \"@sentry/nuxt\";\n \nSentry.init({\n ${getConfigBody(dsn, 'server', selectedFeatures)}\n\n // Enable sending of user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\n\n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n});\n`;\n}\n\nexport function getIndexRouteTemplate(): string {\n return `<!--\nThis is just to verify the sentry-example-page.\nFeel free to delete this file.\n-->\n\n<template></template>`;\n}\n\nexport function getSentryExamplePageTemplate(options: {\n url: string;\n org: string;\n projectId: string;\n}): string {\n const { url, org, projectId } = options;\n const issuesPageLink = getIssueStreamUrl({ url, orgSlug: org, projectId });\n\n return `<!--\nThis is just a very simple page with a button to throw an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n\n class SentryExampleFrontendError extends Error {\n constructor(message) {\n super(message);\n this.name = \"SentryExampleFrontendError\";\n }\n }\n\n const hasSentError = ref(false);\n const isConnected = ref(true);\n \n onMounted(async () => {\n try {\n const result = await Sentry.diagnoseSdkConnectivity();\n isConnected.value = result !== 'sentry-unreachable';\n } catch (error) {\n isConnected.value = false;\n }\n });\n \n async function getSentryData() {\n await Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const res = await $fetch('/api/sentry-example-api', { \n method: 'GET',\n ignoreResponseError: true \n }).catch(() => null);\n if (!res) {\n hasSentError.value = true;\n }\n }\n );\n throw new SentryExampleFrontendError(\"This error is raised on the frontend of the example page.\");\n }\n</script>\n\n<template>\n <title>Sentry Onboarding</title>\n <div>\n <main>\n <div class=\"flex-spacer\" />\n <svg height=\"40\" width=\"40\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z\" fill=\"currentcolor\"/>\n </svg>\n <h1>\n sentry-example-page\n </h1>\n\n <p class=\"description\">\n Click the button below, and view the sample error on the Sentry <a target=\"_blank\" href=\"${issuesPageLink}\">Issues Page</a>.\n For more details about setting up Sentry, <a target=\"_blank\" href=\"https://docs.sentry.io/platforms/javascript/guides/nuxt/\">read our docs</a>.\n </p>\n\n <button\n type=\"button\"\n @click=\"getSentryData\"\n :disabled=\"!isConnected\"\n >\n <span>\n Throw Sample Error\n </span>\n </button>\n\n <p v-if=\"hasSentError\" class=\"success\">\n Sample error was sent to Sentry.\n </p>\n <div v-else-if=\"!isConnected\" class=\"connectivity-error\">\n <p>It looks like network requests to Sentry are being blocked, which will prevent errors from being captured. Try disabling your ad-blocker to complete the test.</p>\n </div>\n <div v-else class=\"success_placeholder\" />\n\n <div class=\"flex-spacer\" />\n </main>\n </div>\n</template>\n\n<style scoped>\n :global(body) {\n margin: 0;\n\n @media (prefers-color-scheme: dark) {\n color: #ededed;\n background-color: #0a0a0a;\n }\n }\n\n main {\n display: flex;\n min-height: 100vh;\n box-sizing: border-box;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 16px;\n padding: 16px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n\n h1 {\n padding: 0px 4px;\n margin: 0;\n border-radius: 4px;\n background-color: rgba(24, 20, 35, 0.03);\n font-family: monospace;\n font-size: 20px;\n line-height: 1.2;\n }\n\n p {\n margin: 0;\n font-size: 20px;\n }\n\n a {\n color: #6341F0;\n text-decoration: underline;\n cursor: pointer;\n\n @media (prefers-color-scheme: dark) {\n color: #B3A1FF;\n }\n }\n\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0); \n }\n\n &:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n\n & > span {\n transform: translateY(0);\n border: none;\n }\n }\n }\n\n .description {\n text-align: center;\n color: #6E6C75;\n max-width: 500px;\n line-height: 1.5;\n font-size: 20px;\n\n @media (prefers-color-scheme: dark) {\n color: #A49FB5;\n }\n }\n\n .flex-spacer {\n flex: 1;\n }\n\n .success {\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n }\n\n .success_placeholder {\n height: 46px;\n }\n \n .connectivity-error {\n padding: 12px 16px;\n background-color: #E50045;\n border-radius: 8px;\n width: 500px;\n color: #FFFFFF;\n border: 1px solid #A80033;\n text-align: center;\n margin: 0;\n }\n \n .connectivity-error a {\n color: #FFFFFF;\n text-decoration: underline;\n }\n</style>\n\n`;\n}\n\nexport function getSentryExampleApiTemplate() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(() => {\n throw new Error(\"Sentry Example API Route Error\");\n});\n`;\n}\n\nexport function getSentryErrorButtonTemplate() {\n return `<!--\nThis is just a very simple component that throws an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n\n const hasSentError = ref(false);\n \n const throwError = () => {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n () => {\n hasSentError.value = true;\n throw new Error('Sentry Example Error');\n }\n )\n };\n</script>\n\n<template>\n <div v-if=\"hasSentError\" class=\"success\">\n Sample error was sent to Sentry.\n </div>\n <button v-else @click=\"throwError\">\n <span>Throw Sample Error</span>\n </button>\n</template>\n\n<style scoped>\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0);\n }\n }\n\n .success {\n width: max-content;\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n</style>\n`;\n}\n"]}
@@ -2,21 +2,23 @@ import { ProxifiedModule } from 'magicast';
2
2
  import * as t from '@babel/types';
3
3
  export declare const sessionReplaySampleRate = 0.1;
4
4
  export declare const sessionReplayOnErrorSampleRate = 1;
5
- export declare function addSentryInit({ dsn, enableSessionReplay, enableFeedbackWidget, }: {
5
+ export declare function addSentryInit({ dsn, enableSessionReplay, enableFeedbackWidget, enableLogs, }: {
6
6
  dsn: string;
7
7
  enableSessionReplay?: boolean;
8
8
  enableFeedbackWidget?: boolean;
9
+ enableLogs?: boolean;
9
10
  }): Promise<void>;
10
- export declare function addSentryInitWithSdkImport(js: string, { dsn, enableSessionReplay, enableFeedbackWidget, }: {
11
+ export declare function addSentryInitWithSdkImport(js: string, { dsn, enableSessionReplay, enableFeedbackWidget, enableLogs, }: {
11
12
  dsn: string;
12
13
  enableSessionReplay?: boolean;
13
14
  enableFeedbackWidget?: boolean;
15
+ enableLogs?: boolean;
14
16
  }): string;
15
17
  export declare function doesJsCodeIncludeSdkSentryImport(js: string, { sdkPackageName }: {
16
18
  sdkPackageName: string;
17
19
  }): boolean;
18
- export declare function getSentryInitColoredCodeSnippet(dsn: string, enableSessionReplay?: boolean, enableFeedbackWidget?: boolean): string;
19
- export declare function getSentryInitPlainTextSnippet(dsn: string, enableSessionReplay?: boolean, enableFeedbackWidget?: boolean): string;
20
+ export declare function getSentryInitColoredCodeSnippet(dsn: string, enableSessionReplay?: boolean, enableFeedbackWidget?: boolean, enableLogs?: boolean): string;
21
+ export declare function getSentryInitPlainTextSnippet(dsn: string, enableSessionReplay?: boolean, enableFeedbackWidget?: boolean, enableLogs?: boolean): string;
20
22
  export declare function getSentryIntegrationsPlainTextSnippet(enableSessionReplay?: boolean, enableFeedbackWidget?: boolean): string;
21
23
  /**
22
24
  * This step should be executed after `addSentryInit`
@@ -44,7 +44,7 @@ const magicast_1 = require("magicast");
44
44
  const t = __importStar(require("@babel/types"));
45
45
  exports.sessionReplaySampleRate = 0.1;
46
46
  exports.sessionReplayOnErrorSampleRate = 1.0;
47
- async function addSentryInit({ dsn, enableSessionReplay = false, enableFeedbackWidget = false, }) {
47
+ async function addSentryInit({ dsn, enableSessionReplay = false, enableFeedbackWidget = false, enableLogs = false, }) {
48
48
  const jsPath = getMainAppFilePath();
49
49
  Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');
50
50
  if (!jsPath) {
@@ -52,7 +52,7 @@ async function addSentryInit({ dsn, enableSessionReplay = false, enableFeedbackW
52
52
  Sentry.captureException('Could not find main App file.');
53
53
  await (0, clack_1.showCopyPasteInstructions)({
54
54
  filename: 'App.js or _layout.tsx',
55
- codeSnippet: getSentryInitColoredCodeSnippet(dsn, enableSessionReplay, enableFeedbackWidget),
55
+ codeSnippet: getSentryInitColoredCodeSnippet(dsn, enableSessionReplay, enableFeedbackWidget, enableLogs),
56
56
  hint: 'This ensures the Sentry SDK is ready to capture errors.',
57
57
  });
58
58
  return;
@@ -72,6 +72,7 @@ async function addSentryInit({ dsn, enableSessionReplay = false, enableFeedbackW
72
72
  dsn,
73
73
  enableSessionReplay,
74
74
  enableFeedbackWidget,
75
+ enableLogs,
75
76
  });
76
77
  try {
77
78
  fs.writeFileSync(jsPath, newContent, 'utf-8');
@@ -86,22 +87,22 @@ async function addSentryInit({ dsn, enableSessionReplay = false, enableFeedbackW
86
87
  prompts_1.default.log.success(chalk_1.default.green(`${chalk_1.default.cyan(jsRelativePath)} changes saved.`));
87
88
  }
88
89
  exports.addSentryInit = addSentryInit;
89
- function addSentryInitWithSdkImport(js, { dsn, enableSessionReplay = false, enableFeedbackWidget = false, }) {
90
+ function addSentryInitWithSdkImport(js, { dsn, enableSessionReplay = false, enableFeedbackWidget = false, enableLogs = false, }) {
90
91
  return js.replace(/^([^]*)(import\s+[^;]*?;$)/m, (match) => `${match}
91
- ${getSentryInitPlainTextSnippet(dsn, enableSessionReplay, enableFeedbackWidget)}`);
92
+ ${getSentryInitPlainTextSnippet(dsn, enableSessionReplay, enableFeedbackWidget, enableLogs)}`);
92
93
  }
93
94
  exports.addSentryInitWithSdkImport = addSentryInitWithSdkImport;
94
95
  function doesJsCodeIncludeSdkSentryImport(js, { sdkPackageName }) {
95
96
  return !!js.match(sdkPackageName);
96
97
  }
97
98
  exports.doesJsCodeIncludeSdkSentryImport = doesJsCodeIncludeSdkSentryImport;
98
- function getSentryInitColoredCodeSnippet(dsn, enableSessionReplay = false, enableFeedbackWidget = false) {
99
+ function getSentryInitColoredCodeSnippet(dsn, enableSessionReplay = false, enableFeedbackWidget = false, enableLogs = false) {
99
100
  return (0, clack_1.makeCodeSnippet)(true, (_unchanged, plus, _minus) => {
100
- return plus(getSentryInitPlainTextSnippet(dsn, enableSessionReplay, enableFeedbackWidget));
101
+ return plus(getSentryInitPlainTextSnippet(dsn, enableSessionReplay, enableFeedbackWidget, enableLogs));
101
102
  });
102
103
  }
103
104
  exports.getSentryInitColoredCodeSnippet = getSentryInitColoredCodeSnippet;
104
- function getSentryInitPlainTextSnippet(dsn, enableSessionReplay = false, enableFeedbackWidget = false) {
105
+ function getSentryInitPlainTextSnippet(dsn, enableSessionReplay = false, enableFeedbackWidget = false, enableLogs = false) {
105
106
  return `import * as Sentry from '@sentry/react-native';
106
107
 
107
108
  Sentry.init({
@@ -110,6 +111,9 @@ Sentry.init({
110
111
  // Adds more context data to events (IP address, cookies, user, etc.)
111
112
  // For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/
112
113
  sendDefaultPii: true,
114
+
115
+ // Enable Logs
116
+ enableLogs: ${enableLogs ? 'true' : 'false'},
113
117
  ${enableSessionReplay
114
118
  ? `
115
119
  // Configure Session Replay
@@ -1 +1 @@
1
- {"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../src/react-native/javascript.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,2CAA6B;AAC7B,iDAAmC;AACnC,uCAAyB;AACzB,qDAAuC;AAEvC,4CAAyC;AACzC,0CAA4E;AAC5E,iCAA6C;AAC7C,+DAAuD;AAEvD,kFAAkF;AAClF,uCAAsE;AACtE,gDAAkC;AAErB,QAAA,uBAAuB,GAAG,GAAG,CAAC;AAC9B,QAAA,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AAC;AACf,CAAC;AAXD,oDAWC;AAED,SAAgB,qBAAqB,CAAC,OAAkB;IACtD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE;QAC/B,IAAI,CAAC,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE;YACtC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;YACrC,IAAI,CAAC,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE;gBACnC,MAAM,QAAQ,GAAG,WAAW,CAAC;gBAC7B,IAAI,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;oBACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;oBAC/B,IACE,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC;wBAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ;wBAC/B,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC;wBAC/B,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,MAAM,EAC/B;wBACA,OAAO,IAAI,CAAC;qBACb;iBACF;aACF;SACF;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AArBD,sDAqBC;AAED,SAAS,+BAA+B;IACtC,OAAO,IAAA,uBAAe,EAAC,IAAI,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QACxD,OAAO,IAAI,CAAC;;iCAEiB,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable max-lines */\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport * as process from 'process';\nimport * as fs from 'fs';\nimport * as Sentry from '@sentry/node';\n\nimport { traceStep } from '../telemetry';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\nimport { getFirstMatchedPath } from './glob';\nimport { RN_SDK_PACKAGE } from './react-native-wizard';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, ProxifiedModule, parseModule } from 'magicast';\nimport * as t from '@babel/types';\n\nexport const sessionReplaySampleRate = 0.1;\nexport const sessionReplayOnErrorSampleRate = 1.0;\n\nexport async function addSentryInit({\n dsn,\n enableSessionReplay = false,\n enableFeedbackWidget = false,\n}: {\n dsn: string;\n enableSessionReplay?: boolean;\n enableFeedbackWidget?: boolean;\n}) {\n const jsPath = getMainAppFilePath();\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file. Place the following code snippet close to the Apps Root component.`,\n );\n Sentry.captureException('Could not find main App file.');\n await showCopyPasteInstructions({\n filename: 'App.js or _layout.tsx',\n codeSnippet: getSentryInitColoredCodeSnippet(\n dsn,\n enableSessionReplay,\n enableFeedbackWidget,\n ),\n hint: 'This ensures the Sentry SDK is ready to capture errors.',\n });\n return;\n }\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n const includesSentry = doesJsCodeIncludeSdkSentryImport(js, {\n sdkPackageName: RN_SDK_PACKAGE,\n });\n if (includesSentry) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry. We wont't add it again.`,\n );\n return;\n }\n\n traceStep('add-sentry-init', () => {\n const newContent = addSentryInitWithSdkImport(js, {\n dsn,\n enableSessionReplay,\n enableFeedbackWidget,\n });\n\n try {\n fs.writeFileSync(jsPath, newContent, 'utf-8');\n clack.log.success(\n `Added ${chalk.cyan('Sentry.init')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n } catch (error) {\n clack.log.error(`Error while writing ${jsPath}`);\n Sentry.captureException('Error while writing app.js');\n }\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-init');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\n );\n}\n\nexport function addSentryInitWithSdkImport(\n js: string,\n {\n dsn,\n enableSessionReplay = false,\n enableFeedbackWidget = false,\n }: {\n dsn: string;\n enableSessionReplay?: boolean;\n enableFeedbackWidget?: boolean;\n },\n): string {\n return js.replace(\n /^([^]*)(import\\s+[^;]*?;$)/m,\n (match: string) => `${match}\n${getSentryInitPlainTextSnippet(\n dsn,\n enableSessionReplay,\n enableFeedbackWidget,\n)}`,\n );\n}\n\nexport function doesJsCodeIncludeSdkSentryImport(\n js: string,\n { sdkPackageName }: { sdkPackageName: string },\n): boolean {\n return !!js.match(sdkPackageName);\n}\n\nexport function getSentryInitColoredCodeSnippet(\n dsn: string,\n enableSessionReplay = false,\n enableFeedbackWidget = false,\n) {\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(\n getSentryInitPlainTextSnippet(\n dsn,\n enableSessionReplay,\n enableFeedbackWidget,\n ),\n );\n });\n}\n\nexport function getSentryInitPlainTextSnippet(\n dsn: string,\n enableSessionReplay = false,\n enableFeedbackWidget = false,\n) {\n return `import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: '${dsn}',\n\n // Adds more context data to events (IP address, cookies, user, etc.)\n // For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/\n sendDefaultPii: true,\n${\n enableSessionReplay\n ? `\n // Configure Session Replay\n replaysSessionSampleRate: ${sessionReplaySampleRate},\n replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate},\n`\n : ''\n}${getSentryIntegrationsPlainTextSnippet(\n enableSessionReplay,\n enableFeedbackWidget,\n )}\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});`;\n}\n\nexport function getSentryIntegrationsPlainTextSnippet(\n enableSessionReplay = false,\n enableFeedbackWidget = false,\n) {\n if (!enableSessionReplay && !enableFeedbackWidget) {\n return '';\n }\n return ` integrations: [${\n enableSessionReplay ? 'Sentry.mobileReplayIntegration()' : ''\n }${enableSessionReplay && enableFeedbackWidget ? ', ' : ''}${\n enableFeedbackWidget ? 'Sentry.feedbackIntegration()' : ''\n }],\n`;\n}\n\nfunction getMainAppFilePath(): string | undefined {\n const prefixGlob = '{.,./src,./app}';\n const suffixGlob = '@(j|t|cj|mj)s?(x)';\n const universalGlob = `@(App|_layout).${suffixGlob}`;\n const jsFileGlob = `${prefixGlob}/+(${universalGlob})`;\n const jsPath = traceStep('find-app-js-file', () =>\n getFirstMatchedPath(jsFileGlob),\n );\n return jsPath;\n}\n\n/**\n * This step should be executed after `addSentryInit`\n */\nexport async function wrapRootComponent() {\n const showInstructions = () =>\n showCopyPasteInstructions({\n filename: 'App.js or _layout.tsx',\n codeSnippet: getSentryWrapColoredCodeSnippet(),\n });\n\n const jsPath = getMainAppFilePath();\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file. Please wrap your App's Root component.`,\n );\n await showInstructions();\n return;\n }\n\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n\n const mod = parseModule(js);\n const result = checkAndWrapRootComponent(mod);\n\n if (result === SentryWrapResult.AlreadyWrapped) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry-wrap');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry.wrap. We wont't add it again.`,\n );\n return;\n }\n\n if (result === SentryWrapResult.NotFound) {\n clack.log.warn(\n `Could not find your App's Root component. Please wrap your App's Root component manually.`,\n );\n await showInstructions();\n return;\n }\n\n traceStep('add-sentry-wrap', () => {\n try {\n fs.writeFileSync(jsPath, generateCode(mod.$ast).code, 'utf-8');\n clack.log.success(\n `Added ${chalk.cyan('Sentry.wrap')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n } catch (error) {\n clack.log.error(`Error while writing ${jsPath}`);\n Sentry.captureException('Error while writing app.js');\n return;\n }\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-wrap');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\n );\n}\n\nexport enum SentryWrapResult {\n NotFound = 'RootComponentNotFound',\n AlreadyWrapped = 'AlreadyWrapped',\n Success = 'Success',\n}\n\nexport function checkAndWrapRootComponent(\n mod: ProxifiedModule,\n): SentryWrapResult {\n if (doesContainSentryWrap(mod.$ast as t.Program)) {\n return SentryWrapResult.AlreadyWrapped;\n }\n\n const defaultExport = getDefaultExport(mod.$ast as t.Program);\n if (!defaultExport) {\n return SentryWrapResult.NotFound;\n }\n\n const wrappedConfig = wrapWithSentry(defaultExport);\n\n const replacedDefaultExport = replaceDefaultExport(\n mod.$ast as t.Program,\n wrappedConfig,\n );\n\n if (!replacedDefaultExport) {\n return SentryWrapResult.NotFound;\n }\n\n return SentryWrapResult.Success;\n}\n\nexport function getDefaultExport(\n program: t.Program,\n):\n | t.Identifier\n | t.CallExpression\n | t.ObjectExpression\n | t.FunctionDeclaration\n | t.ArrowFunctionExpression\n | t.ClassDeclaration\n | undefined {\n for (const node of program.body) {\n if (\n t.isExportDefaultDeclaration(node) &&\n (t.isIdentifier(node.declaration) ||\n t.isCallExpression(node.declaration) ||\n t.isObjectExpression(node.declaration) ||\n t.isFunctionDeclaration(node.declaration) ||\n t.isArrowFunctionExpression(node.declaration) ||\n t.isClassDeclaration(node.declaration))\n ) {\n Sentry.setTag('app-js-file-status', 'default-export');\n return node.declaration;\n }\n }\n\n Sentry.setTag('app-js-file-status', 'default-export-not-found');\n return undefined;\n}\n\nexport function wrapWithSentry(\n configObj:\n | t.Identifier\n | t.CallExpression\n | t.ObjectExpression\n | t.FunctionDeclaration\n | t.ArrowFunctionExpression\n | t.ClassDeclaration,\n): t.CallExpression {\n if (t.isFunctionDeclaration(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [\n t.functionExpression(\n configObj.id,\n configObj.params,\n configObj.body,\n configObj.generator,\n configObj.async,\n ),\n ],\n );\n }\n\n if (t.isArrowFunctionExpression(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [configObj],\n );\n }\n\n if (t.isClassDeclaration(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [\n t.classExpression(\n configObj.id,\n configObj.superClass,\n configObj.body,\n configObj.decorators,\n ),\n ],\n );\n }\n\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [configObj],\n );\n}\n\nexport function replaceDefaultExport(\n program: t.Program,\n wrappedDefaultExport: t.CallExpression,\n): boolean {\n for (const node of program.body) {\n if (t.isExportDefaultDeclaration(node)) {\n node.declaration = wrappedDefaultExport;\n return true;\n }\n }\n return false;\n}\n\nexport function doesContainSentryWrap(program: t.Program): boolean {\n for (const node of program.body) {\n if (t.isExportDefaultDeclaration(node)) {\n const declaration = node.declaration;\n if (t.isCallExpression(declaration)) {\n const callExpr = declaration;\n if (t.isMemberExpression(callExpr.callee)) {\n const callee = callExpr.callee;\n if (\n t.isIdentifier(callee.object) &&\n callee.object.name === 'Sentry' &&\n t.isIdentifier(callee.property) &&\n callee.property.name === 'wrap'\n ) {\n return true;\n }\n }\n }\n }\n }\n return false;\n}\n\nfunction getSentryWrapColoredCodeSnippet() {\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(`import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(App);`);\n });\n}\n"]}
1
+ {"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../src/react-native/javascript.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,2CAA6B;AAC7B,iDAAmC;AACnC,uCAAyB;AACzB,qDAAuC;AAEvC,4CAAyC;AACzC,0CAA4E;AAC5E,iCAA6C;AAC7C,+DAAuD;AAEvD,kFAAkF;AAClF,uCA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L,CAAC","sourcesContent":["/* eslint-disable max-lines */\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport * as process from 'process';\nimport * as fs from 'fs';\nimport * as Sentry from '@sentry/node';\n\nimport { traceStep } from '../telemetry';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\nimport { getFirstMatchedPath } from './glob';\nimport { RN_SDK_PACKAGE } from './react-native-wizard';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, ProxifiedModule, parseModule } from 'magicast';\nimport * as t from '@babel/types';\n\nexport const sessionReplaySampleRate = 0.1;\nexport const sessionReplayOnErrorSampleRate = 1.0;\n\nexport async function addSentryInit({\n dsn,\n enableSessionReplay = false,\n enableFeedbackWidget = false,\n enableLogs = false,\n}: {\n dsn: string;\n enableSessionReplay?: boolean;\n enableFeedbackWidget?: boolean;\n enableLogs?: boolean;\n}) {\n const jsPath = getMainAppFilePath();\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file. Place the following code snippet close to the Apps Root component.`,\n );\n Sentry.captureException('Could not find main App file.');\n await showCopyPasteInstructions({\n filename: 'App.js or _layout.tsx',\n codeSnippet: getSentryInitColoredCodeSnippet(\n dsn,\n enableSessionReplay,\n enableFeedbackWidget,\n enableLogs,\n ),\n hint: 'This ensures the Sentry SDK is ready to capture errors.',\n });\n return;\n }\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n const includesSentry = doesJsCodeIncludeSdkSentryImport(js, {\n sdkPackageName: RN_SDK_PACKAGE,\n });\n if (includesSentry) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry. We wont't add it again.`,\n );\n return;\n }\n\n traceStep('add-sentry-init', () => {\n const newContent = addSentryInitWithSdkImport(js, {\n dsn,\n enableSessionReplay,\n enableFeedbackWidget,\n enableLogs,\n });\n\n try {\n fs.writeFileSync(jsPath, newContent, 'utf-8');\n clack.log.success(\n `Added ${chalk.cyan('Sentry.init')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n } catch (error) {\n clack.log.error(`Error while writing ${jsPath}`);\n Sentry.captureException('Error while writing app.js');\n }\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-init');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\n );\n}\n\nexport function addSentryInitWithSdkImport(\n js: string,\n {\n dsn,\n enableSessionReplay = false,\n enableFeedbackWidget = false,\n enableLogs = false,\n }: {\n dsn: string;\n enableSessionReplay?: boolean;\n enableFeedbackWidget?: boolean;\n enableLogs?: boolean;\n },\n): string {\n return js.replace(\n /^([^]*)(import\\s+[^;]*?;$)/m,\n (match: string) => `${match}\n${getSentryInitPlainTextSnippet(\n dsn,\n enableSessionReplay,\n enableFeedbackWidget,\n enableLogs,\n)}`,\n );\n}\n\nexport function doesJsCodeIncludeSdkSentryImport(\n js: string,\n { sdkPackageName }: { sdkPackageName: string },\n): boolean {\n return !!js.match(sdkPackageName);\n}\n\nexport function getSentryInitColoredCodeSnippet(\n dsn: string,\n enableSessionReplay = false,\n enableFeedbackWidget = false,\n enableLogs = false,\n) {\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(\n getSentryInitPlainTextSnippet(\n dsn,\n enableSessionReplay,\n enableFeedbackWidget,\n enableLogs,\n ),\n );\n });\n}\n\nexport function getSentryInitPlainTextSnippet(\n dsn: string,\n enableSessionReplay = false,\n enableFeedbackWidget = false,\n enableLogs = false,\n) {\n return `import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: '${dsn}',\n\n // Adds more context data to events (IP address, cookies, user, etc.)\n // For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/\n sendDefaultPii: true,\n\n // Enable Logs\n enableLogs: ${enableLogs ? 'true' : 'false'},\n${\n enableSessionReplay\n ? `\n // Configure Session Replay\n replaysSessionSampleRate: ${sessionReplaySampleRate},\n replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate},\n`\n : ''\n}${getSentryIntegrationsPlainTextSnippet(\n enableSessionReplay,\n enableFeedbackWidget,\n )}\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});`;\n}\n\nexport function getSentryIntegrationsPlainTextSnippet(\n enableSessionReplay = false,\n enableFeedbackWidget = false,\n) {\n if (!enableSessionReplay && !enableFeedbackWidget) {\n return '';\n }\n return ` integrations: [${\n enableSessionReplay ? 'Sentry.mobileReplayIntegration()' : ''\n }${enableSessionReplay && enableFeedbackWidget ? ', ' : ''}${\n enableFeedbackWidget ? 'Sentry.feedbackIntegration()' : ''\n }],\n`;\n}\n\nfunction getMainAppFilePath(): string | undefined {\n const prefixGlob = '{.,./src,./app}';\n const suffixGlob = '@(j|t|cj|mj)s?(x)';\n const universalGlob = `@(App|_layout).${suffixGlob}`;\n const jsFileGlob = `${prefixGlob}/+(${universalGlob})`;\n const jsPath = traceStep('find-app-js-file', () =>\n getFirstMatchedPath(jsFileGlob),\n );\n return jsPath;\n}\n\n/**\n * This step should be executed after `addSentryInit`\n */\nexport async function wrapRootComponent() {\n const showInstructions = () =>\n showCopyPasteInstructions({\n filename: 'App.js or _layout.tsx',\n codeSnippet: getSentryWrapColoredCodeSnippet(),\n });\n\n const jsPath = getMainAppFilePath();\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file. Please wrap your App's Root component.`,\n );\n await showInstructions();\n return;\n }\n\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n\n const mod = parseModule(js);\n const result = checkAndWrapRootComponent(mod);\n\n if (result === SentryWrapResult.AlreadyWrapped) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry-wrap');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry.wrap. We wont't add it again.`,\n );\n return;\n }\n\n if (result === SentryWrapResult.NotFound) {\n clack.log.warn(\n `Could not find your App's Root component. Please wrap your App's Root component manually.`,\n );\n await showInstructions();\n return;\n }\n\n traceStep('add-sentry-wrap', () => {\n try {\n fs.writeFileSync(jsPath, generateCode(mod.$ast).code, 'utf-8');\n clack.log.success(\n `Added ${chalk.cyan('Sentry.wrap')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n } catch (error) {\n clack.log.error(`Error while writing ${jsPath}`);\n Sentry.captureException('Error while writing app.js');\n return;\n }\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-wrap');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\n );\n}\n\nexport enum SentryWrapResult {\n NotFound = 'RootComponentNotFound',\n AlreadyWrapped = 'AlreadyWrapped',\n Success = 'Success',\n}\n\nexport function checkAndWrapRootComponent(\n mod: ProxifiedModule,\n): SentryWrapResult {\n if (doesContainSentryWrap(mod.$ast as t.Program)) {\n return SentryWrapResult.AlreadyWrapped;\n }\n\n const defaultExport = getDefaultExport(mod.$ast as t.Program);\n if (!defaultExport) {\n return SentryWrapResult.NotFound;\n }\n\n const wrappedConfig = wrapWithSentry(defaultExport);\n\n const replacedDefaultExport = replaceDefaultExport(\n mod.$ast as t.Program,\n wrappedConfig,\n );\n\n if (!replacedDefaultExport) {\n return SentryWrapResult.NotFound;\n }\n\n return SentryWrapResult.Success;\n}\n\nexport function getDefaultExport(\n program: t.Program,\n):\n | t.Identifier\n | t.CallExpression\n | t.ObjectExpression\n | t.FunctionDeclaration\n | t.ArrowFunctionExpression\n | t.ClassDeclaration\n | undefined {\n for (const node of program.body) {\n if (\n t.isExportDefaultDeclaration(node) &&\n (t.isIdentifier(node.declaration) ||\n t.isCallExpression(node.declaration) ||\n t.isObjectExpression(node.declaration) ||\n t.isFunctionDeclaration(node.declaration) ||\n t.isArrowFunctionExpression(node.declaration) ||\n t.isClassDeclaration(node.declaration))\n ) {\n Sentry.setTag('app-js-file-status', 'default-export');\n return node.declaration;\n }\n }\n\n Sentry.setTag('app-js-file-status', 'default-export-not-found');\n return undefined;\n}\n\nexport function wrapWithSentry(\n configObj:\n | t.Identifier\n | t.CallExpression\n | t.ObjectExpression\n | t.FunctionDeclaration\n | t.ArrowFunctionExpression\n | t.ClassDeclaration,\n): t.CallExpression {\n if (t.isFunctionDeclaration(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [\n t.functionExpression(\n configObj.id,\n configObj.params,\n configObj.body,\n configObj.generator,\n configObj.async,\n ),\n ],\n );\n }\n\n if (t.isArrowFunctionExpression(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [configObj],\n );\n }\n\n if (t.isClassDeclaration(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [\n t.classExpression(\n configObj.id,\n configObj.superClass,\n configObj.body,\n configObj.decorators,\n ),\n ],\n );\n }\n\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [configObj],\n );\n}\n\nexport function replaceDefaultExport(\n program: t.Program,\n wrappedDefaultExport: t.CallExpression,\n): boolean {\n for (const node of program.body) {\n if (t.isExportDefaultDeclaration(node)) {\n node.declaration = wrappedDefaultExport;\n return true;\n }\n }\n return false;\n}\n\nexport function doesContainSentryWrap(program: t.Program): boolean {\n for (const node of program.body) {\n if (t.isExportDefaultDeclaration(node)) {\n const declaration = node.declaration;\n if (t.isCallExpression(declaration)) {\n const callExpr = declaration;\n if (t.isMemberExpression(callExpr.callee)) {\n const callee = callExpr.callee;\n if (\n t.isIdentifier(callee.object) &&\n callee.object.name === 'Sentry' &&\n t.isIdentifier(callee.property) &&\n callee.property.name === 'wrap'\n ) {\n return true;\n }\n }\n }\n }\n }\n return false;\n}\n\nfunction getSentryWrapColoredCodeSnippet() {\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(`import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(App);`);\n });\n}\n"]}
@@ -155,10 +155,19 @@ Or setup using ${chalk_1.default.cyan('https://docs.sentry.io/platforms/react-na
155
155
  if (enableFeedbackWidget) {
156
156
  prompts_1.default.log.info(`The Feedback Widget will be enabled with default settings. You can show the widget by calling Sentry.showFeedbackWidget() in your code.`);
157
157
  }
158
+ // Ask if user wants to enable Logs
159
+ const enableLogs = await (0, clack_1.abortIfCancelled)(prompts_1.default.confirm({
160
+ message: 'Do you want to enable Logs? (See https://docs.sentry.io/platforms/react-native/logs/)',
161
+ }));
162
+ Sentry.setTag('enable-logs', enableLogs);
163
+ if (enableLogs) {
164
+ prompts_1.default.log.info(`Logs will be enabled with default settings. You can send logs using the Sentry.logger APIs.`);
165
+ }
158
166
  await (0, telemetry_1.traceStep)('patch-app-js', () => (0, javascript_1.addSentryInit)({
159
167
  dsn: selectedProject.keys[0].dsn.public,
160
168
  enableSessionReplay,
161
169
  enableFeedbackWidget,
170
+ enableLogs,
162
171
  }));
163
172
  await (0, telemetry_1.traceStep)('patch-app-js-wrap', () => (0, javascript_1.wrapRootComponent)());
164
173
  if (isExpo) {
@@ -1 +1 @@
1
- {"version":3,"file":"react-native-wizard.js","sourceRoot":"","sources":["../../../src/react-native/react-native-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,uCAAyB;AAEzB,qDAAuC;AACvC,2BAA8B;AAC9B,gDAA+C;AAC/C,4CAAwD;AACxD,0DAAwE;AACxE,0CAcwB;AACxB,wDAA+E;AAC/E,sCAAiD;AACjD,iCAA2E;AAC3E,mDAAkD;AAClD,6CAA0D;AAC1D,iCAA8E;AAC9E,qCAIkB;AAClB,6CAKsB;AACtB,mCAAqD;AA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G,CAAC,OAAO,CACf,oCAAoC,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CACtE,CAAC;IAEF,IAAA,qBAAS,EAAC,wBAAwB,EAAE,GAAG,EAAE,CACvC,IAAA,4BAAmB,EAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAC/D,CAAC;IACF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,eAAK,CAAC,KAAK,CAAC,WAAW,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAChE,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,iBAAiB;IAC9B,OAAO,IAAA,qBAAS,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,sBAAsB,GAAG,MAAM,IAAA,wBAAgB,EACnD,iBAAK,CAAC,MAAM,CAAC;YACX,OAAO,EAAE,uCAAuC;YAChD,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,IAAI;oBACX,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,mEAAmE;iBAC1E;gBACD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE;aAChD;YACD,YAAY,EAAE,IAAI;SACnB,CAAC,CACH,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAC;QACnE,OAAO,sBAAsB,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable max-lines */\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\n\nimport * as Sentry from '@sentry/node';\nimport { platform } from 'os';\nimport { podInstall } from '../apple/cocoapod';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport {\n CliSetupConfigContent,\n abort,\n abortIfCancelled,\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n confirmContinueIfPackageVersionNotSupported,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n propertiesCliSetupConfig,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { getIssueStreamUrl } from '../utils/url';\nimport { patchExpoAppConfig, printSentryExpoMigrationOutro } from './expo';\nimport { addExpoEnvLocal } from './expo-env-file';\nimport { addSentryToExpoMetroConfig } from './expo-metro';\nimport { APP_BUILD_GRADLE, XCODE_PROJECT, getFirstMatchedPath } from './glob';\nimport {\n addRNSentryGradlePlugin,\n doesAppBuildGradleIncludeRNSentryGradlePlugin,\n writeAppBuildGradle,\n} from './gradle';\nimport {\n addSentryInit,\n sessionReplayOnErrorSampleRate,\n sessionReplaySampleRate,\n wrapRootComponent,\n} from './javascript';\nimport { patchMetroWithSentryConfig } from './metro';\nimport { ReactNativeWizardOptions } from './options';\nimport {\n addDebugFilesUploadPhaseWithBundledScripts,\n addSentryWithBundledScriptsToBundleShellScript,\n findBundlePhase,\n findDebugFilesUploadPhase,\n getValidExistingBuildPhases,\n patchBundlePhase,\n writeXcodeProject,\n} from './xcode';\n\nimport xcode from 'xcode';\n\nexport const RN_SDK_PACKAGE = '@sentry/react-native';\nexport const RN_SDK_SUPPORTED_RANGE = '>=6.12.0';\n\nexport const RN_PACKAGE = 'react-native';\nexport const RN_HUMAN_NAME = 'React Native';\n\nexport const SUPPORTED_RN_RANGE = '>=0.69.0';\nexport const SUPPORTED_EXPO_RANGE = '>=50.0.0';\n\nexport type RNCliSetupConfigContent = Pick<\n Required<CliSetupConfigContent>,\n 'authToken' | 'org' | 'project' | 'url'\n>;\n\nexport async function runReactNativeWizard(\n params: ReactNativeWizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: params.telemetryEnabled,\n integration: 'react-native',\n wizardOptions: params,\n },\n () => runReactNativeWizardWithTelemetry(params),\n );\n}\n\nexport async function runReactNativeWizardWithTelemetry(\n options: ReactNativeWizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry React Native Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n const hasInstalled = (dep: string) => hasPackageInstalled(dep, packageJson);\n\n if (hasInstalled('sentry-expo')) {\n Sentry.setTag('has-sentry-expo-installed', true);\n printSentryExpoMigrationOutro();\n return;\n }\n\n await ensurePackageIsInstalled(packageJson, RN_PACKAGE, RN_HUMAN_NAME);\n\n const rnVersion = getPackageVersion(RN_PACKAGE, packageJson);\n if (rnVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: RN_HUMAN_NAME,\n packageVersion: rnVersion,\n packageId: RN_PACKAGE,\n acceptableVersions: SUPPORTED_RN_RANGE,\n note: `Please upgrade to ${SUPPORTED_RN_RANGE} if you wish to use the Sentry Wizard.\nOr setup using ${chalk.cyan(\n 'https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/',\n )}`,\n });\n }\n\n await installPackage({\n packageName: RN_SDK_PACKAGE,\n alreadyInstalled: hasPackageInstalled(RN_SDK_PACKAGE, packageJson),\n forceInstall,\n });\n const sdkVersion = getPackageVersion(\n RN_SDK_PACKAGE,\n await getPackageDotJson(),\n );\n if (sdkVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: 'Sentry React Native SDK',\n packageVersion: sdkVersion,\n packageId: RN_SDK_PACKAGE,\n acceptableVersions: RN_SDK_SUPPORTED_RANGE,\n note: `Please upgrade to ${RN_SDK_SUPPORTED_RANGE} to continue with the wizard in this project.`,\n });\n } else {\n const continueWithoutSdk = await abortIfCancelled(\n clack.confirm({\n message:\n 'Could not detect Sentry React Native SDK version. Do you want to continue anyway?',\n }),\n );\n if (!continueWithoutSdk) {\n await abort(undefined, 0);\n }\n }\n Sentry.setTag(`detected-sentry-react-native-sdk-version`, sdkVersion);\n\n const expoVersion = getPackageVersion('expo', packageJson);\n const isExpo = !!expoVersion;\n if (expoVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: 'Expo SDK',\n packageVersion: expoVersion,\n packageId: 'expo',\n acceptableVersions: SUPPORTED_EXPO_RANGE,\n note: `Please upgrade to ${SUPPORTED_EXPO_RANGE} to continue with the wizard in this Expo project.`,\n });\n }\n\n const { selectedProject, authToken, sentryUrl } =\n await getOrAskForProjectData(options, 'react-native');\n const orgSlug = selectedProject.organization.slug;\n const projectSlug = selectedProject.slug;\n const projectId = selectedProject.id;\n const cliConfig: RNCliSetupConfigContent = {\n authToken,\n org: orgSlug,\n project: projectSlug,\n url: sentryUrl,\n };\n\n // Ask if user wants to enable Session Replay\n const enableSessionReplay = await abortIfCancelled(\n clack.confirm({\n message:\n 'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)',\n }),\n );\n Sentry.setTag('enable-session-replay', enableSessionReplay);\n\n if (enableSessionReplay) {\n clack.log.info(\n `Session Replay will be enabled with default settings (replaysSessionSampleRate: ${sessionReplaySampleRate}, replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate}).`,\n );\n clack.log.message(\n 'By default, all text content, images, and webviews will be masked for privacy. You can customize this in your code later.',\n );\n }\n\n // Ask if user wants to enable the Feedback Widget\n const enableFeedbackWidget = await abortIfCancelled(\n clack.confirm({\n message:\n 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)',\n }),\n );\n Sentry.setTag('enable-feedback-widget', enableFeedbackWidget);\n\n if (enableFeedbackWidget) {\n clack.log.info(\n `The Feedback Widget will be enabled with default settings. You can show the widget by calling Sentry.showFeedbackWidget() in your code.`,\n );\n }\n\n await traceStep('patch-app-js', () =>\n addSentryInit({\n dsn: selectedProject.keys[0].dsn.public,\n enableSessionReplay,\n enableFeedbackWidget,\n }),\n );\n\n await traceStep('patch-app-js-wrap', () => wrapRootComponent());\n\n if (isExpo) {\n await traceStep('patch-expo-app-config', () =>\n patchExpoAppConfig(cliConfig),\n );\n await traceStep('add-expo-env-local', () => addExpoEnvLocal(cliConfig));\n }\n\n if (isExpo) {\n await traceStep('patch-metro-config', addSentryToExpoMetroConfig);\n } else {\n await traceStep('patch-metro-config', patchMetroWithSentryConfig);\n }\n\n if (fs.existsSync('ios')) {\n Sentry.setTag('patch-ios', true);\n await traceStep('patch-xcode-files', () => patchXcodeFiles(cliConfig));\n }\n\n if (fs.existsSync('android')) {\n Sentry.setTag('patch-android', true);\n await traceStep('patch-android-files', () => patchAndroidFiles(cliConfig));\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n const confirmedFirstException = await confirmFirstSentryException(\n sentryUrl,\n orgSlug,\n projectId,\n );\n\n Sentry.setTag('user-confirmed-first-error', confirmedFirstException);\n\n if (confirmedFirstException) {\n clack.outro(\n `${chalk.green('Everything is set up!')}\n\n ${chalk.dim(\n 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n } else {\n clack.outro(\n `${chalk.dim(\n 'Let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n }\n}\n\nasync function confirmFirstSentryException(\n url: string,\n orgSlug: string,\n projectId: string,\n) {\n const issuesStreamUrl = getIssueStreamUrl({ url, orgSlug, projectId });\n\n clack.log\n .step(`To make sure everything is set up correctly, put the following code snippet into your application.\nThe snippet will create a button that, when tapped, sends a test event to Sentry.\n\nAfter that check your project issues:\n\n${chalk.cyan(issuesStreamUrl)}`);\n\n // We want the code snippet to be easily copy-pasteable, without any clack artifacts\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\n<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>\n`),\n );\n\n const firstErrorConfirmed = clack.confirm({\n message: `Have you successfully sent a test event?`,\n });\n\n return firstErrorConfirmed;\n}\n\nasync function patchXcodeFiles(config: RNCliSetupConfigContent) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'ios/sentry.properties',\n gitignore: false,\n });\n\n if (platform() === 'darwin' && (await confirmPodInstall())) {\n await traceStep('pod-install', () => podInstall('ios'));\n }\n\n const xcodeProjectPath = traceStep('find-xcode-project', () =>\n getFirstMatchedPath(XCODE_PROJECT),\n );\n Sentry.setTag(\n 'xcode-project-status',\n xcodeProjectPath ? 'found' : 'not-found',\n );\n if (!xcodeProjectPath) {\n clack.log.warn(\n `Could not find Xcode project file using ${chalk.cyan(XCODE_PROJECT)}.`,\n );\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const [xcodeProject, buildPhasesMap] = traceStep(\n 'parse-xcode-project',\n () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n const project = xcode.project(xcodeProjectPath);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n project.parseSync();\n\n const map = getValidExistingBuildPhases(project);\n return [project, map];\n },\n );\n Sentry.setTag('xcode-project-status', 'parsed');\n\n await traceStep('patch-bundle-phase', async () => {\n const bundlePhase = findBundlePhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-bundle-phase-status',\n bundlePhase ? 'found' : 'not-found',\n );\n\n await patchBundlePhase(\n bundlePhase,\n addSentryWithBundledScriptsToBundleShellScript,\n );\n\n Sentry.setTag('xcode-bundle-phase-status', 'patched');\n });\n\n traceStep('add-debug-files-upload-phase', () => {\n const debugFilesUploadPhaseExists =\n !!findDebugFilesUploadPhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-debug-files-upload-phase-status',\n debugFilesUploadPhaseExists ? 'already-exists' : undefined,\n );\n\n addDebugFilesUploadPhaseWithBundledScripts(xcodeProject, {\n debugFilesUploadPhaseExists,\n });\n\n Sentry.setTag('xcode-debug-files-upload-phase-status', 'added');\n });\n\n traceStep('write-xcode-project', () => {\n writeXcodeProject(xcodeProjectPath, xcodeProject);\n });\n Sentry.setTag('xcode-project-status', 'patched');\n}\n\nasync function patchAndroidFiles(config: RNCliSetupConfigContent) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'android/sentry.properties',\n gitignore: false,\n });\n\n const appBuildGradlePath = traceStep('find-app-build-gradle', () =>\n getFirstMatchedPath(APP_BUILD_GRADLE),\n );\n Sentry.setTag(\n 'app-build-gradle-status',\n appBuildGradlePath ? 'found' : 'not-found',\n );\n if (!appBuildGradlePath) {\n clack.log.warn(\n `Could not find Android ${chalk.cyan(\n 'app/build.gradle',\n )} file using ${chalk.cyan(APP_BUILD_GRADLE)}.`,\n );\n return;\n }\n\n const appBuildGradle = traceStep('read-app-build-gradle', () =>\n fs.readFileSync(appBuildGradlePath, 'utf-8'),\n );\n const includesSentry =\n doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle);\n if (includesSentry) {\n Sentry.setTag('app-build-gradle-status', 'already-includes-sentry');\n clack.log.warn(\n `Android ${chalk.cyan('app/build.gradle')} file already includes Sentry.`,\n );\n return;\n }\n\n const patchedAppBuildGradle = traceStep('add-rn-sentry-gradle-plugin', () =>\n addRNSentryGradlePlugin(appBuildGradle),\n );\n if (!doesAppBuildGradleIncludeRNSentryGradlePlugin(patchedAppBuildGradle)) {\n Sentry.setTag(\n 'app-build-gradle-status',\n 'failed-to-add-rn-sentry-gradle-plugin',\n );\n clack.log.warn(\n `Could not add Sentry RN Gradle Plugin to ${chalk.cyan(\n 'app/build.gradle',\n )}.`,\n );\n return;\n }\n\n Sentry.setTag('app-build-gradle-status', 'added-rn-sentry-gradle-plugin');\n clack.log.success(\n `Added Sentry RN Gradle Plugin to ${chalk.bold('app/build.gradle')}.`,\n );\n\n traceStep('write-app-build-gradle', () =>\n writeAppBuildGradle(appBuildGradlePath, patchedAppBuildGradle),\n );\n clack.log.success(\n chalk.green(`Android ${chalk.cyan('app/build.gradle')} saved.`),\n );\n}\n\nasync function confirmPodInstall(): Promise<boolean> {\n return traceStep('confirm-pod-install', async () => {\n const continueWithPodInstall = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run `pod install` now?',\n options: [\n {\n value: true,\n label: 'Yes',\n hint: 'Recommended for smaller projects, this might take several minutes',\n },\n { value: false, label: `No, I'll do it later` },\n ],\n initialValue: true,\n }),\n );\n Sentry.setTag('continue-with-pod-install', continueWithPodInstall);\n return continueWithPodInstall;\n });\n}\n"]}
1
+ {"version":3,"file":"react-native-wizard.js","sourceRoot":"","sources":["../../../src/react-native/react-native-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,uCAAyB;AAEzB,qDAAuC;AACvC,2BAA8B;AAC9B,gDAA+C;AAC/C,4CAAwD;AACxD,0DAAwE;AACxE,0CAcwB;AACxB,wDAA+E;AAC/E,sCAAiD;AACjD,iCAA2E;AAC3E,mDAAkD;AAClD,6CAA0D;AAC1D,iCAA8E;AAC9E,qCAIkB;AAClB,6CAKsB;AACtB,mCAAqD;AAErD,mCAQiB;AAEjB,kDAA0B;AAEb,QAAA,cAAc,GAAG,sBAAsB,CAAC;AACxC,QAAA,sBAAsB,GAAG,UAAU,CAAC;AAEpC,QAAA,UAAU,GAAG,cAAc,CAAC;AAC5B,QAAA,aAAa,GAAG,cAAc,CAAC;AAE/B,QAAA,kBAAkB,GAAG,UAAU,CAAC;AAChC,QAAA,oBAAoB,GAAG,UAAU,CAAC;AAOxC,KAAK,UAAU,oBAAoB,CACxC,MAAgC;IAEhC,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,MAAM,CAAC,gBAAgB;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AAG,CACtE,CAAC;IAEF,IAAA,qBAAS,EAAC,wBAAwB,EAAE,GAAG,EAAE,CACvC,IAAA,4BAAmB,EAAC,kBAAkB,EAAE,qBAAqB,CAAC,CAC/D,CAAC;IACF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,eAAK,CAAC,KAAK,CAAC,WAAW,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAChE,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,iBAAiB;IAC9B,OAAO,IAAA,qBAAS,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,sBAAsB,GAAG,MAAM,IAAA,wBAAgB,EACnD,iBAAK,CAAC,MAAM,CAAC;YACX,OAAO,EAAE,uCAAuC;YAChD,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,IAAI;oBACX,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,mEAAmE;iBAC1E;gBACD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE;aAChD;YACD,YAAY,EAAE,IAAI;SACnB,CAAC,CACH,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAC;QACnE,OAAO,sBAAsB,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable max-lines */\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\n\nimport * as Sentry from '@sentry/node';\nimport { platform } from 'os';\nimport { podInstall } from '../apple/cocoapod';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport {\n CliSetupConfigContent,\n abort,\n abortIfCancelled,\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n confirmContinueIfPackageVersionNotSupported,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n propertiesCliSetupConfig,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { getIssueStreamUrl } from '../utils/url';\nimport { patchExpoAppConfig, printSentryExpoMigrationOutro } from './expo';\nimport { addExpoEnvLocal } from './expo-env-file';\nimport { addSentryToExpoMetroConfig } from './expo-metro';\nimport { APP_BUILD_GRADLE, XCODE_PROJECT, getFirstMatchedPath } from './glob';\nimport {\n addRNSentryGradlePlugin,\n doesAppBuildGradleIncludeRNSentryGradlePlugin,\n writeAppBuildGradle,\n} from './gradle';\nimport {\n addSentryInit,\n sessionReplayOnErrorSampleRate,\n sessionReplaySampleRate,\n wrapRootComponent,\n} from './javascript';\nimport { patchMetroWithSentryConfig } from './metro';\nimport { ReactNativeWizardOptions } from './options';\nimport {\n addDebugFilesUploadPhaseWithBundledScripts,\n addSentryWithBundledScriptsToBundleShellScript,\n findBundlePhase,\n findDebugFilesUploadPhase,\n getValidExistingBuildPhases,\n patchBundlePhase,\n writeXcodeProject,\n} from './xcode';\n\nimport xcode from 'xcode';\n\nexport const RN_SDK_PACKAGE = '@sentry/react-native';\nexport const RN_SDK_SUPPORTED_RANGE = '>=6.12.0';\n\nexport const RN_PACKAGE = 'react-native';\nexport const RN_HUMAN_NAME = 'React Native';\n\nexport const SUPPORTED_RN_RANGE = '>=0.69.0';\nexport const SUPPORTED_EXPO_RANGE = '>=50.0.0';\n\nexport type RNCliSetupConfigContent = Pick<\n Required<CliSetupConfigContent>,\n 'authToken' | 'org' | 'project' | 'url'\n>;\n\nexport async function runReactNativeWizard(\n params: ReactNativeWizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: params.telemetryEnabled,\n integration: 'react-native',\n wizardOptions: params,\n },\n () => runReactNativeWizardWithTelemetry(params),\n );\n}\n\nexport async function runReactNativeWizardWithTelemetry(\n options: ReactNativeWizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry React Native Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n const hasInstalled = (dep: string) => hasPackageInstalled(dep, packageJson);\n\n if (hasInstalled('sentry-expo')) {\n Sentry.setTag('has-sentry-expo-installed', true);\n printSentryExpoMigrationOutro();\n return;\n }\n\n await ensurePackageIsInstalled(packageJson, RN_PACKAGE, RN_HUMAN_NAME);\n\n const rnVersion = getPackageVersion(RN_PACKAGE, packageJson);\n if (rnVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: RN_HUMAN_NAME,\n packageVersion: rnVersion,\n packageId: RN_PACKAGE,\n acceptableVersions: SUPPORTED_RN_RANGE,\n note: `Please upgrade to ${SUPPORTED_RN_RANGE} if you wish to use the Sentry Wizard.\nOr setup using ${chalk.cyan(\n 'https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/',\n )}`,\n });\n }\n\n await installPackage({\n packageName: RN_SDK_PACKAGE,\n alreadyInstalled: hasPackageInstalled(RN_SDK_PACKAGE, packageJson),\n forceInstall,\n });\n const sdkVersion = getPackageVersion(\n RN_SDK_PACKAGE,\n await getPackageDotJson(),\n );\n if (sdkVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: 'Sentry React Native SDK',\n packageVersion: sdkVersion,\n packageId: RN_SDK_PACKAGE,\n acceptableVersions: RN_SDK_SUPPORTED_RANGE,\n note: `Please upgrade to ${RN_SDK_SUPPORTED_RANGE} to continue with the wizard in this project.`,\n });\n } else {\n const continueWithoutSdk = await abortIfCancelled(\n clack.confirm({\n message:\n 'Could not detect Sentry React Native SDK version. Do you want to continue anyway?',\n }),\n );\n if (!continueWithoutSdk) {\n await abort(undefined, 0);\n }\n }\n Sentry.setTag(`detected-sentry-react-native-sdk-version`, sdkVersion);\n\n const expoVersion = getPackageVersion('expo', packageJson);\n const isExpo = !!expoVersion;\n if (expoVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: 'Expo SDK',\n packageVersion: expoVersion,\n packageId: 'expo',\n acceptableVersions: SUPPORTED_EXPO_RANGE,\n note: `Please upgrade to ${SUPPORTED_EXPO_RANGE} to continue with the wizard in this Expo project.`,\n });\n }\n\n const { selectedProject, authToken, sentryUrl } =\n await getOrAskForProjectData(options, 'react-native');\n const orgSlug = selectedProject.organization.slug;\n const projectSlug = selectedProject.slug;\n const projectId = selectedProject.id;\n const cliConfig: RNCliSetupConfigContent = {\n authToken,\n org: orgSlug,\n project: projectSlug,\n url: sentryUrl,\n };\n\n // Ask if user wants to enable Session Replay\n const enableSessionReplay = await abortIfCancelled(\n clack.confirm({\n message:\n 'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)',\n }),\n );\n Sentry.setTag('enable-session-replay', enableSessionReplay);\n\n if (enableSessionReplay) {\n clack.log.info(\n `Session Replay will be enabled with default settings (replaysSessionSampleRate: ${sessionReplaySampleRate}, replaysOnErrorSampleRate: ${sessionReplayOnErrorSampleRate}).`,\n );\n clack.log.message(\n 'By default, all text content, images, and webviews will be masked for privacy. You can customize this in your code later.',\n );\n }\n\n // Ask if user wants to enable the Feedback Widget\n const enableFeedbackWidget = await abortIfCancelled(\n clack.confirm({\n message:\n 'Do you want to enable the Feedback Widget to collect feedback from your users? (See https://docs.sentry.io/platforms/react-native/user-feedback/)',\n }),\n );\n Sentry.setTag('enable-feedback-widget', enableFeedbackWidget);\n\n if (enableFeedbackWidget) {\n clack.log.info(\n `The Feedback Widget will be enabled with default settings. You can show the widget by calling Sentry.showFeedbackWidget() in your code.`,\n );\n }\n\n // Ask if user wants to enable Logs\n const enableLogs = await abortIfCancelled(\n clack.confirm({\n message:\n 'Do you want to enable Logs? (See https://docs.sentry.io/platforms/react-native/logs/)',\n }),\n );\n Sentry.setTag('enable-logs', enableLogs);\n\n if (enableLogs) {\n clack.log.info(\n `Logs will be enabled with default settings. You can send logs using the Sentry.logger APIs.`,\n );\n }\n\n await traceStep('patch-app-js', () =>\n addSentryInit({\n dsn: selectedProject.keys[0].dsn.public,\n enableSessionReplay,\n enableFeedbackWidget,\n enableLogs,\n }),\n );\n\n await traceStep('patch-app-js-wrap', () => wrapRootComponent());\n\n if (isExpo) {\n await traceStep('patch-expo-app-config', () =>\n patchExpoAppConfig(cliConfig),\n );\n await traceStep('add-expo-env-local', () => addExpoEnvLocal(cliConfig));\n }\n\n if (isExpo) {\n await traceStep('patch-metro-config', addSentryToExpoMetroConfig);\n } else {\n await traceStep('patch-metro-config', patchMetroWithSentryConfig);\n }\n\n if (fs.existsSync('ios')) {\n Sentry.setTag('patch-ios', true);\n await traceStep('patch-xcode-files', () => patchXcodeFiles(cliConfig));\n }\n\n if (fs.existsSync('android')) {\n Sentry.setTag('patch-android', true);\n await traceStep('patch-android-files', () => patchAndroidFiles(cliConfig));\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n const confirmedFirstException = await confirmFirstSentryException(\n sentryUrl,\n orgSlug,\n projectId,\n );\n\n Sentry.setTag('user-confirmed-first-error', confirmedFirstException);\n\n if (confirmedFirstException) {\n clack.outro(\n `${chalk.green('Everything is set up!')}\n\n ${chalk.dim(\n 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n } else {\n clack.outro(\n `${chalk.dim(\n 'Let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n }\n}\n\nasync function confirmFirstSentryException(\n url: string,\n orgSlug: string,\n projectId: string,\n) {\n const issuesStreamUrl = getIssueStreamUrl({ url, orgSlug, projectId });\n\n clack.log\n .step(`To make sure everything is set up correctly, put the following code snippet into your application.\nThe snippet will create a button that, when tapped, sends a test event to Sentry.\n\nAfter that check your project issues:\n\n${chalk.cyan(issuesStreamUrl)}`);\n\n // We want the code snippet to be easily copy-pasteable, without any clack artifacts\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\n<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>\n`),\n );\n\n const firstErrorConfirmed = clack.confirm({\n message: `Have you successfully sent a test event?`,\n });\n\n return firstErrorConfirmed;\n}\n\nasync function patchXcodeFiles(config: RNCliSetupConfigContent) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'ios/sentry.properties',\n gitignore: false,\n });\n\n if (platform() === 'darwin' && (await confirmPodInstall())) {\n await traceStep('pod-install', () => podInstall('ios'));\n }\n\n const xcodeProjectPath = traceStep('find-xcode-project', () =>\n getFirstMatchedPath(XCODE_PROJECT),\n );\n Sentry.setTag(\n 'xcode-project-status',\n xcodeProjectPath ? 'found' : 'not-found',\n );\n if (!xcodeProjectPath) {\n clack.log.warn(\n `Could not find Xcode project file using ${chalk.cyan(XCODE_PROJECT)}.`,\n );\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const [xcodeProject, buildPhasesMap] = traceStep(\n 'parse-xcode-project',\n () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n const project = xcode.project(xcodeProjectPath);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n project.parseSync();\n\n const map = getValidExistingBuildPhases(project);\n return [project, map];\n },\n );\n Sentry.setTag('xcode-project-status', 'parsed');\n\n await traceStep('patch-bundle-phase', async () => {\n const bundlePhase = findBundlePhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-bundle-phase-status',\n bundlePhase ? 'found' : 'not-found',\n );\n\n await patchBundlePhase(\n bundlePhase,\n addSentryWithBundledScriptsToBundleShellScript,\n );\n\n Sentry.setTag('xcode-bundle-phase-status', 'patched');\n });\n\n traceStep('add-debug-files-upload-phase', () => {\n const debugFilesUploadPhaseExists =\n !!findDebugFilesUploadPhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-debug-files-upload-phase-status',\n debugFilesUploadPhaseExists ? 'already-exists' : undefined,\n );\n\n addDebugFilesUploadPhaseWithBundledScripts(xcodeProject, {\n debugFilesUploadPhaseExists,\n });\n\n Sentry.setTag('xcode-debug-files-upload-phase-status', 'added');\n });\n\n traceStep('write-xcode-project', () => {\n writeXcodeProject(xcodeProjectPath, xcodeProject);\n });\n Sentry.setTag('xcode-project-status', 'patched');\n}\n\nasync function patchAndroidFiles(config: RNCliSetupConfigContent) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'android/sentry.properties',\n gitignore: false,\n });\n\n const appBuildGradlePath = traceStep('find-app-build-gradle', () =>\n getFirstMatchedPath(APP_BUILD_GRADLE),\n );\n Sentry.setTag(\n 'app-build-gradle-status',\n appBuildGradlePath ? 'found' : 'not-found',\n );\n if (!appBuildGradlePath) {\n clack.log.warn(\n `Could not find Android ${chalk.cyan(\n 'app/build.gradle',\n )} file using ${chalk.cyan(APP_BUILD_GRADLE)}.`,\n );\n return;\n }\n\n const appBuildGradle = traceStep('read-app-build-gradle', () =>\n fs.readFileSync(appBuildGradlePath, 'utf-8'),\n );\n const includesSentry =\n doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle);\n if (includesSentry) {\n Sentry.setTag('app-build-gradle-status', 'already-includes-sentry');\n clack.log.warn(\n `Android ${chalk.cyan('app/build.gradle')} file already includes Sentry.`,\n );\n return;\n }\n\n const patchedAppBuildGradle = traceStep('add-rn-sentry-gradle-plugin', () =>\n addRNSentryGradlePlugin(appBuildGradle),\n );\n if (!doesAppBuildGradleIncludeRNSentryGradlePlugin(patchedAppBuildGradle)) {\n Sentry.setTag(\n 'app-build-gradle-status',\n 'failed-to-add-rn-sentry-gradle-plugin',\n );\n clack.log.warn(\n `Could not add Sentry RN Gradle Plugin to ${chalk.cyan(\n 'app/build.gradle',\n )}.`,\n );\n return;\n }\n\n Sentry.setTag('app-build-gradle-status', 'added-rn-sentry-gradle-plugin');\n clack.log.success(\n `Added Sentry RN Gradle Plugin to ${chalk.bold('app/build.gradle')}.`,\n );\n\n traceStep('write-app-build-gradle', () =>\n writeAppBuildGradle(appBuildGradlePath, patchedAppBuildGradle),\n );\n clack.log.success(\n chalk.green(`Android ${chalk.cyan('app/build.gradle')} saved.`),\n );\n}\n\nasync function confirmPodInstall(): Promise<boolean> {\n return traceStep('confirm-pod-install', async () => {\n const continueWithPodInstall = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run `pod install` now?',\n options: [\n {\n value: true,\n label: 'Yes',\n hint: 'Recommended for smaller projects, this might take several minutes',\n },\n { value: false, label: `No, I'll do it later` },\n ],\n initialValue: true,\n }),\n );\n Sentry.setTag('continue-with-pod-install', continueWithPodInstall);\n return continueWithPodInstall;\n });\n}\n"]}
@@ -92,9 +92,11 @@ function addSentryWithBundledScriptsToBundleShellScript(script) {
92
92
  let patchedScript = script;
93
93
  const isLikelyPlainReactNativeScript = script.includes('$REACT_NATIVE_XCODE');
94
94
  if (isLikelyPlainReactNativeScript) {
95
- patchedScript = script.replace('$REACT_NATIVE_XCODE',
96
- // eslint-disable-next-line no-useless-escape
97
- '\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\\"');
95
+ patchedScript = script
96
+ .replaceAll('REACT_NATIVE_XCODE', 'SENTRY_XCODE')
97
+ .replace('react-native/scripts/react-native-xcode.sh', '@sentry/react-native/scripts/sentry-xcode.sh')
98
+ // that might be needed for older versions of React Native (< 0.81)
99
+ .replace('$REACT_NATIVE_PATH/scripts/react-native-xcode.sh', '$REACT_NATIVE_PATH/../@sentry/react-native/scripts/sentry-xcode.sh');
98
100
  }
99
101
  const isLikelyExpoScript = script.includes('expo');
100
102
  if (isLikelyExpoScript) {
@@ -1 +1 @@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AO,CACf,eAAK,CAAC,KAAK,CACT,iBAAiB,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAC/D,CACF,CAAC;KACH;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,GAAG,CAAC,KAAK,CACb,qCAAqC,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CACpE,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,mCAAmC,CAAC,CAAC;KAC9D;AACH,CAAC;AAvBD,8CAuBC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport * as fs from 'node:fs';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\nimport { Project } from 'xcode';\nimport * as Sentry from '@sentry/node';\n\ntype BuildPhase = { shellScript: string };\ntype BuildPhaseMap = Record<string, BuildPhase>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getValidExistingBuildPhases(xcodeProject: any): BuildPhaseMap {\n const map: BuildPhaseMap = {};\n const raw = xcodeProject.hash.project.objects.PBXShellScriptBuildPhase || {};\n for (const key in raw) {\n const val = raw[key];\n val.isa && (map[key] = val);\n }\n\n return map;\n}\n\nexport class ErrorPatchSnippet {\n constructor(public snippet: string) {}\n}\n\nexport async function patchBundlePhase(\n bundlePhase: BuildPhase | undefined,\n patch: (script: string) => string | ErrorPatchSnippet,\n) {\n if (!bundlePhase) {\n clack.log.warn(\n `Could not find ${chalk.cyan(\n 'Bundle React Native code and images',\n )} build phase.`,\n );\n return;\n }\n\n const bundlePhaseIncludesSentry = doesBundlePhaseIncludeSentry(bundlePhase);\n if (bundlePhaseIncludesSentry) {\n clack.log.warn(\n `Build phase ${chalk.cyan(\n 'Bundle React Native code and images',\n )} already includes Sentry.`,\n );\n return;\n }\n\n const script: string = JSON.parse(bundlePhase.shellScript);\n const patchedScript = patch(script);\n if (patchedScript instanceof ErrorPatchSnippet) {\n await showCopyPasteInstructions({\n filename: 'Xcode project',\n codeSnippet: patchedScript.snippet,\n hint: `Apply in the 'Bundle React Native code and images' build phase`,\n });\n return;\n }\n bundlePhase.shellScript = JSON.stringify(patchedScript);\n clack.log.success(\n `Patched Build phase ${chalk.cyan('Bundle React Native code and images')}.`,\n );\n}\n\nexport function findBundlePhase(buildPhases: BuildPhaseMap) {\n return Object.values(buildPhases).find((buildPhase) =>\n buildPhase.shellScript.match(/\\/scripts\\/react-native-xcode\\.sh/i),\n );\n}\n\nexport function doesBundlePhaseIncludeSentry(buildPhase: BuildPhase) {\n const containsSentryCliRNCommand = !!buildPhase.shellScript.match(\n /sentry-cli\\s+react-native\\s+xcode/i,\n );\n const containsBundledScript =\n buildPhase.shellScript.includes('sentry-xcode.sh');\n return containsSentryCliRNCommand || containsBundledScript;\n}\n\nexport function addSentryWithBundledScriptsToBundleShellScript(\n script: string,\n): string | ErrorPatchSnippet {\n let patchedScript = script;\n const isLikelyPlainReactNativeScript = script.includes('$REACT_NATIVE_XCODE');\n if (isLikelyPlainReactNativeScript) {\n patchedScript = script.replace(\n '$REACT_NATIVE_XCODE',\n // eslint-disable-next-line no-useless-escape\n '\\\\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\\\\\"',\n );\n }\n\n const isLikelyExpoScript = script.includes('expo');\n if (isLikelyExpoScript) {\n const SENTRY_REACT_NATIVE_XCODE_PATH =\n \"`\\\"$NODE_BINARY\\\" --print \\\"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\\\"`\";\n patchedScript = script.replace(\n /^.*?(packager|scripts)\\/react-native-xcode\\.sh\\s*(\\\\'\\\\\\\\\")?/m,\n // eslint-disable-next-line no-useless-escape\n (match: string) => `/bin/sh ${SENTRY_REACT_NATIVE_XCODE_PATH} ${match}`,\n );\n }\n\n if (patchedScript === script) {\n // No changes were made\n clack.log.error(\n `Failed to patch ${chalk.cyan(\n 'Bundle React Native code and images',\n )} build phase.`,\n );\n Sentry.captureException(\n `Failed to patch 'Bundle React Native code and images' build phase.`,\n );\n if (isLikelyExpoScript) {\n return new ErrorPatchSnippet(\n makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(\n `${plus(\n `/bin/sh \\`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\"\\``,\n )} \\`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'\"\\``,\n );\n }),\n );\n } else {\n // plain react-native\n return new ErrorPatchSnippet(\n makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT ${plus(\n `\\\\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh `,\n )}$REACT_NATIVE_XCODE${plus(`\\\\\"`)}\"\n`);\n }),\n );\n }\n }\n\n return patchedScript;\n}\n\nexport function addDebugFilesUploadPhaseWithBundledScripts(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xcodeProject: any,\n { debugFilesUploadPhaseExists }: { debugFilesUploadPhaseExists: boolean },\n) {\n if (debugFilesUploadPhaseExists) {\n clack.log.warn(\n `Build phase ${chalk.cyan(\n 'Upload Debug Symbols to Sentry',\n )} already exists.`,\n );\n return;\n }\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n null,\n {\n shellPath: '/bin/sh',\n shellScript: `/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh`,\n },\n );\n clack.log.success(\n `Added Build phase ${chalk.cyan('Upload Debug Symbols to Sentry')}.`,\n );\n}\n\nexport function findDebugFilesUploadPhase(\n buildPhasesMap: Record<string, BuildPhase>,\n): [key: string, buildPhase: BuildPhase] | undefined {\n return Object.entries(buildPhasesMap).find(([_, buildPhase]) => {\n const containsCliDebugUpload =\n typeof buildPhase !== 'string' &&\n !!buildPhase.shellScript.match(\n /sentry-cli\\s+(upload-dsym|debug-files upload)\\b/,\n );\n const containsBundledDebugUpload =\n typeof buildPhase !== 'string' &&\n buildPhase.shellScript.includes('sentry-xcode-debug-files.sh');\n return containsCliDebugUpload || containsBundledDebugUpload;\n });\n}\n\nexport function writeXcodeProject(\n xcodeProjectPath: string,\n xcodeProject: Project,\n) {\n try {\n const newContent = xcodeProject.writeSync();\n const currentContent = fs.readFileSync(xcodeProjectPath, 'utf-8');\n if (newContent === currentContent) {\n return;\n }\n\n fs.writeFileSync(xcodeProjectPath, newContent, 'utf-8');\n clack.log.success(\n chalk.green(\n `Xcode project ${chalk.cyan(xcodeProjectPath)} changes saved.`,\n ),\n );\n } catch (error) {\n clack.log.error(\n `Error while writing Xcode project ${chalk.cyan(xcodeProjectPath)}`,\n );\n Sentry.captureException('Error while writing Xcode project');\n }\n}\n"]}
1
+ {"version":3,"file":"xcode.js","sourceRoot":"","sources":["../../../src/react-native/xcode.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,sDAAsD;AACtD,+DAA+D;AAC/D,4CAA8B;AAC9B,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,0CAA4E;AAE5E,qDAAuC;AAKvC,8DAA8D;AAC9D,SAAgB,2BAA2B,CAAC,YAAiB;IAC3D,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,wBAAwB,IAAI,EAAE,CAAC;I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eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport * as fs from 'node:fs';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\nimport { Project } from 'xcode';\nimport * as Sentry from '@sentry/node';\n\ntype BuildPhase = { shellScript: string };\ntype BuildPhaseMap = Record<string, BuildPhase>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getValidExistingBuildPhases(xcodeProject: any): BuildPhaseMap {\n const map: BuildPhaseMap = {};\n const raw = xcodeProject.hash.project.objects.PBXShellScriptBuildPhase || {};\n for (const key in raw) {\n const val = raw[key];\n val.isa && (map[key] = val);\n }\n\n return map;\n}\n\nexport class ErrorPatchSnippet {\n constructor(public snippet: string) {}\n}\n\nexport async function patchBundlePhase(\n bundlePhase: BuildPhase | undefined,\n patch: (script: string) => string | ErrorPatchSnippet,\n) {\n if (!bundlePhase) {\n clack.log.warn(\n `Could not find ${chalk.cyan(\n 'Bundle React Native code and images',\n )} build phase.`,\n );\n return;\n }\n\n const bundlePhaseIncludesSentry = doesBundlePhaseIncludeSentry(bundlePhase);\n if (bundlePhaseIncludesSentry) {\n clack.log.warn(\n `Build phase ${chalk.cyan(\n 'Bundle React Native code and images',\n )} already includes Sentry.`,\n );\n return;\n }\n\n const script: string = JSON.parse(bundlePhase.shellScript);\n const patchedScript = patch(script);\n if (patchedScript instanceof ErrorPatchSnippet) {\n await showCopyPasteInstructions({\n filename: 'Xcode project',\n codeSnippet: patchedScript.snippet,\n hint: `Apply in the 'Bundle React Native code and images' build phase`,\n });\n return;\n }\n bundlePhase.shellScript = JSON.stringify(patchedScript);\n clack.log.success(\n `Patched Build phase ${chalk.cyan('Bundle React Native code and images')}.`,\n );\n}\n\nexport function findBundlePhase(buildPhases: BuildPhaseMap) {\n return Object.values(buildPhases).find((buildPhase) =>\n buildPhase.shellScript.match(/\\/scripts\\/react-native-xcode\\.sh/i),\n );\n}\n\nexport function doesBundlePhaseIncludeSentry(buildPhase: BuildPhase) {\n const containsSentryCliRNCommand = !!buildPhase.shellScript.match(\n /sentry-cli\\s+react-native\\s+xcode/i,\n );\n const containsBundledScript =\n buildPhase.shellScript.includes('sentry-xcode.sh');\n return containsSentryCliRNCommand || containsBundledScript;\n}\n\nexport function addSentryWithBundledScriptsToBundleShellScript(\n script: string,\n): string | ErrorPatchSnippet {\n let patchedScript = script;\n const isLikelyPlainReactNativeScript = script.includes('$REACT_NATIVE_XCODE');\n if (isLikelyPlainReactNativeScript) {\n patchedScript = script\n .replaceAll('REACT_NATIVE_XCODE', 'SENTRY_XCODE')\n .replace(\n 'react-native/scripts/react-native-xcode.sh',\n '@sentry/react-native/scripts/sentry-xcode.sh',\n )\n // that might be needed for older versions of React Native (< 0.81)\n .replace(\n '$REACT_NATIVE_PATH/scripts/react-native-xcode.sh',\n '$REACT_NATIVE_PATH/../@sentry/react-native/scripts/sentry-xcode.sh',\n );\n }\n\n const isLikelyExpoScript = script.includes('expo');\n if (isLikelyExpoScript) {\n const SENTRY_REACT_NATIVE_XCODE_PATH =\n \"`\\\"$NODE_BINARY\\\" --print \\\"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\\\"`\";\n patchedScript = script.replace(\n /^.*?(packager|scripts)\\/react-native-xcode\\.sh\\s*(\\\\'\\\\\\\\\")?/m,\n // eslint-disable-next-line no-useless-escape\n (match: string) => `/bin/sh ${SENTRY_REACT_NATIVE_XCODE_PATH} ${match}`,\n );\n }\n\n if (patchedScript === script) {\n // No changes were made\n clack.log.error(\n `Failed to patch ${chalk.cyan(\n 'Bundle React Native code and images',\n )} build phase.`,\n );\n Sentry.captureException(\n `Failed to patch 'Bundle React Native code and images' build phase.`,\n );\n if (isLikelyExpoScript) {\n return new ErrorPatchSnippet(\n makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(\n `${plus(\n `/bin/sh \\`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\"\\``,\n )} \\`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/react-native-xcode.sh'\"\\``,\n );\n }),\n );\n } else {\n // plain react-native\n return new ErrorPatchSnippet(\n makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT ${plus(\n `\\\\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh `,\n )}$REACT_NATIVE_XCODE${plus(`\\\\\"`)}\"\n`);\n }),\n );\n }\n }\n\n return patchedScript;\n}\n\nexport function addDebugFilesUploadPhaseWithBundledScripts(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n xcodeProject: any,\n { debugFilesUploadPhaseExists }: { debugFilesUploadPhaseExists: boolean },\n) {\n if (debugFilesUploadPhaseExists) {\n clack.log.warn(\n `Build phase ${chalk.cyan(\n 'Upload Debug Symbols to Sentry',\n )} already exists.`,\n );\n return;\n }\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n null,\n {\n shellPath: '/bin/sh',\n shellScript: `/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh`,\n },\n );\n clack.log.success(\n `Added Build phase ${chalk.cyan('Upload Debug Symbols to Sentry')}.`,\n );\n}\n\nexport function findDebugFilesUploadPhase(\n buildPhasesMap: Record<string, BuildPhase>,\n): [key: string, buildPhase: BuildPhase] | undefined {\n return Object.entries(buildPhasesMap).find(([_, buildPhase]) => {\n const containsCliDebugUpload =\n typeof buildPhase !== 'string' &&\n !!buildPhase.shellScript.match(\n /sentry-cli\\s+(upload-dsym|debug-files upload)\\b/,\n );\n const containsBundledDebugUpload =\n typeof buildPhase !== 'string' &&\n buildPhase.shellScript.includes('sentry-xcode-debug-files.sh');\n return containsCliDebugUpload || containsBundledDebugUpload;\n });\n}\n\nexport function writeXcodeProject(\n xcodeProjectPath: string,\n xcodeProject: Project,\n) {\n try {\n const newContent = xcodeProject.writeSync();\n const currentContent = fs.readFileSync(xcodeProjectPath, 'utf-8');\n if (newContent === currentContent) {\n return;\n }\n\n fs.writeFileSync(xcodeProjectPath, newContent, 'utf-8');\n clack.log.success(\n chalk.green(\n `Xcode project ${chalk.cyan(xcodeProjectPath)} changes saved.`,\n ),\n );\n } catch (error) {\n clack.log.error(\n `Error while writing Xcode project ${chalk.cyan(xcodeProjectPath)}`,\n );\n Sentry.captureException('Error while writing Xcode project');\n }\n}\n"]}
@@ -87,6 +87,7 @@ function getInitCallArgs(dsn, type, selectedFeatures) {
87
87
  initCallArgs.replaysSessionSampleRate = 0.1;
88
88
  initCallArgs.replaysOnErrorSampleRate = 1.0;
89
89
  }
90
+ initCallArgs.sendDefaultPii = true;
90
91
  }
91
92
  return initCallArgs;
92
93
  }