@sentry/wizard 4.7.0 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +19 -19
  3. package/dist/e2e-tests/tests/angular-17.test.d.ts +1 -0
  4. package/dist/e2e-tests/tests/angular-17.test.js +196 -0
  5. package/dist/e2e-tests/tests/angular-17.test.js.map +1 -0
  6. package/dist/e2e-tests/tests/angular-19.test.d.ts +1 -0
  7. package/dist/e2e-tests/tests/angular-19.test.js +194 -0
  8. package/dist/e2e-tests/tests/angular-19.test.js.map +1 -0
  9. package/dist/e2e-tests/tests/expo.test.d.ts +1 -0
  10. package/dist/e2e-tests/tests/expo.test.js +103 -0
  11. package/dist/e2e-tests/tests/expo.test.js.map +1 -0
  12. package/dist/e2e-tests/tests/help-message.test.js +2 -2
  13. package/dist/e2e-tests/tests/help-message.test.js.map +1 -1
  14. package/dist/e2e-tests/tests/react-native.test.d.ts +1 -0
  15. package/dist/e2e-tests/tests/react-native.test.js +132 -0
  16. package/dist/e2e-tests/tests/react-native.test.js.map +1 -0
  17. package/dist/e2e-tests/tests/remix.test.js +4 -4
  18. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  19. package/dist/e2e-tests/tests/sveltekit.test.js +2 -2
  20. package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
  21. package/dist/e2e-tests/utils/index.d.ts +7 -0
  22. package/dist/e2e-tests/utils/index.js +32 -7
  23. package/dist/e2e-tests/utils/index.js.map +1 -1
  24. package/dist/lib/Constants.d.ts +1 -0
  25. package/dist/lib/Constants.js +3 -0
  26. package/dist/lib/Constants.js.map +1 -1
  27. package/dist/lib/Helper/SentryCli.d.ts +0 -11
  28. package/dist/lib/Helper/SentryCli.js +0 -52
  29. package/dist/lib/Helper/SentryCli.js.map +1 -1
  30. package/dist/src/android/templates.js +2 -0
  31. package/dist/src/android/templates.js.map +1 -1
  32. package/dist/src/angular/angular-wizard.d.ts +3 -0
  33. package/dist/src/angular/angular-wizard.js +186 -0
  34. package/dist/src/angular/angular-wizard.js.map +1 -0
  35. package/dist/src/angular/codemods/app-config.d.ts +3 -0
  36. package/dist/src/angular/codemods/app-config.js +211 -0
  37. package/dist/src/angular/codemods/app-config.js.map +1 -0
  38. package/dist/src/angular/codemods/main.d.ts +20 -0
  39. package/dist/src/angular/codemods/main.js +62 -0
  40. package/dist/src/angular/codemods/main.js.map +1 -0
  41. package/dist/src/angular/codemods/sourcemaps.d.ts +21 -0
  42. package/dist/src/angular/codemods/sourcemaps.js +94 -0
  43. package/dist/src/angular/codemods/sourcemaps.js.map +1 -0
  44. package/dist/src/angular/example-component.d.ts +8 -0
  45. package/dist/src/angular/example-component.js +286 -0
  46. package/dist/src/angular/example-component.js.map +1 -0
  47. package/dist/src/angular/sdk-setup.d.ts +6 -0
  48. package/dist/src/angular/sdk-setup.js +99 -0
  49. package/dist/src/angular/sdk-setup.js.map +1 -0
  50. package/dist/src/apple/code-tools.d.ts +4 -2
  51. package/dist/src/apple/code-tools.js +21 -11
  52. package/dist/src/apple/code-tools.js.map +1 -1
  53. package/dist/src/apple/inject-code-snippet.js +5 -3
  54. package/dist/src/apple/inject-code-snippet.js.map +1 -1
  55. package/dist/src/apple/macos-system-helper.d.ts +5 -0
  56. package/dist/src/apple/macos-system-helper.js +86 -0
  57. package/dist/src/apple/macos-system-helper.js.map +1 -0
  58. package/dist/src/apple/templates.js +10 -0
  59. package/dist/src/apple/templates.js.map +1 -1
  60. package/dist/src/apple/xcode-manager.d.ts +237 -11
  61. package/dist/src/apple/xcode-manager.js +736 -65
  62. package/dist/src/apple/xcode-manager.js.map +1 -1
  63. package/dist/src/apple/xcode-project-object-with-id.d.ts +5 -0
  64. package/dist/src/apple/xcode-project-object-with-id.js +3 -0
  65. package/dist/src/apple/xcode-project-object-with-id.js.map +1 -0
  66. package/dist/src/flutter/flutter-wizard.js +10 -2
  67. package/dist/src/flutter/flutter-wizard.js.map +1 -1
  68. package/dist/src/flutter/templates.js +7 -1
  69. package/dist/src/flutter/templates.js.map +1 -1
  70. package/dist/src/nextjs/nextjs-wizard.js +27 -15
  71. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  72. package/dist/src/nextjs/templates.js +56 -7
  73. package/dist/src/nextjs/templates.js.map +1 -1
  74. package/dist/src/nuxt/nuxt-wizard.js +1 -3
  75. package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
  76. package/dist/src/nuxt/templates.js +30 -0
  77. package/dist/src/nuxt/templates.js.map +1 -1
  78. package/dist/src/react-native/expo-env-file.js +5 -0
  79. package/dist/src/react-native/expo-env-file.js.map +1 -1
  80. package/dist/src/react-native/expo-metro.js +22 -6
  81. package/dist/src/react-native/expo-metro.js.map +1 -1
  82. package/dist/src/react-native/expo.js +11 -1
  83. package/dist/src/react-native/expo.js.map +1 -1
  84. package/dist/src/react-native/glob.js +14 -4
  85. package/dist/src/react-native/glob.js.map +1 -1
  86. package/dist/src/react-native/gradle.js +14 -4
  87. package/dist/src/react-native/gradle.js.map +1 -1
  88. package/dist/src/react-native/javascript.d.ts +9 -4
  89. package/dist/src/react-native/javascript.js +52 -23
  90. package/dist/src/react-native/javascript.js.map +1 -1
  91. package/dist/src/react-native/metro.d.ts +1 -1
  92. package/dist/src/react-native/metro.js +36 -4
  93. package/dist/src/react-native/metro.js.map +1 -1
  94. package/dist/src/react-native/react-native-wizard.d.ts +4 -0
  95. package/dist/src/react-native/react-native-wizard.js +32 -4
  96. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  97. package/dist/src/react-native/xcode.js +29 -10
  98. package/dist/src/react-native/xcode.js.map +1 -1
  99. package/dist/src/remix/remix-wizard.js +1 -3
  100. package/dist/src/remix/remix-wizard.js.map +1 -1
  101. package/dist/src/remix/sdk-example.js +30 -1
  102. package/dist/src/remix/sdk-example.js.map +1 -1
  103. package/dist/src/remix/sdk-setup.js +11 -5
  104. package/dist/src/remix/sdk-setup.js.map +1 -1
  105. package/dist/src/run.d.ts +1 -1
  106. package/dist/src/run.js +5 -0
  107. package/dist/src/run.js.map +1 -1
  108. package/dist/src/sourcemaps/sourcemaps-wizard.d.ts +1 -1
  109. package/dist/src/sourcemaps/sourcemaps-wizard.js +35 -20
  110. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  111. package/dist/src/sourcemaps/tools/angular.d.ts +1 -0
  112. package/dist/src/sourcemaps/tools/angular.js +7 -7
  113. package/dist/src/sourcemaps/tools/angular.js.map +1 -1
  114. package/dist/src/sourcemaps/tools/sentry-cli.d.ts +5 -1
  115. package/dist/src/sourcemaps/tools/sentry-cli.js +6 -3
  116. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  117. package/dist/src/sourcemaps/tools/tsc.js +5 -1
  118. package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
  119. package/dist/src/sourcemaps/tools/vite.js +4 -1
  120. package/dist/src/sourcemaps/tools/vite.js.map +1 -1
  121. package/dist/src/sourcemaps/tools/webpack.js +4 -1
  122. package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
  123. package/dist/src/sveltekit/sdk-example.js +1 -1
  124. package/dist/src/sveltekit/sdk-example.js.map +1 -1
  125. package/dist/src/sveltekit/sveltekit-wizard.js +3 -5
  126. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  127. package/dist/src/sveltekit/templates.js +28 -1
  128. package/dist/src/sveltekit/templates.js.map +1 -1
  129. package/dist/src/utils/clack/index.d.ts +13 -15
  130. package/dist/src/utils/clack/index.js +17 -50
  131. package/dist/src/utils/clack/index.js.map +1 -1
  132. package/dist/src/utils/git.d.ts +11 -0
  133. package/dist/src/utils/git.js +69 -0
  134. package/dist/src/utils/git.js.map +1 -0
  135. package/dist/src/utils/sentrycli-utils.js +13 -4
  136. package/dist/src/utils/sentrycli-utils.js.map +1 -1
  137. package/dist/src/version.d.ts +1 -1
  138. package/dist/src/version.js +1 -1
  139. package/dist/src/version.js.map +1 -1
  140. package/dist/test/angular/angular-wizard.test.d.ts +1 -0
  141. package/dist/test/angular/angular-wizard.test.js +27 -0
  142. package/dist/test/angular/angular-wizard.test.js.map +1 -0
  143. package/dist/test/angular/codemods/sourcemaps.test.d.ts +1 -0
  144. package/dist/test/angular/codemods/sourcemaps.test.js +237 -0
  145. package/dist/test/angular/codemods/sourcemaps.test.js.map +1 -0
  146. package/dist/test/angular/example-component.test.d.ts +1 -0
  147. package/dist/test/angular/example-component.test.js +105 -0
  148. package/dist/test/angular/example-component.test.js.map +1 -0
  149. package/dist/test/apple/code-tools.test.js +54 -35
  150. package/dist/test/apple/code-tools.test.js.map +1 -1
  151. package/dist/test/apple/configure-sentry-cli.test.d.ts +1 -0
  152. package/dist/test/apple/configure-sentry-cli.test.js +131 -0
  153. package/dist/test/apple/configure-sentry-cli.test.js.map +1 -0
  154. package/dist/test/apple/macos-system-helper-mocked.test.d.ts +1 -0
  155. package/dist/test/apple/macos-system-helper-mocked.test.js +46 -0
  156. package/dist/test/apple/macos-system-helper-mocked.test.js.map +1 -0
  157. package/dist/test/apple/macos-system-helper.test.d.ts +1 -0
  158. package/dist/test/apple/macos-system-helper.test.js +88 -0
  159. package/dist/test/apple/macos-system-helper.test.js.map +1 -0
  160. package/dist/test/apple/templates.test.js +10 -0
  161. package/dist/test/apple/templates.test.js.map +1 -1
  162. package/dist/test/apple/xcode-manager.test.js +745 -379
  163. package/dist/test/apple/xcode-manager.test.js.map +1 -1
  164. package/dist/test/flutter/templates.test.js +9 -0
  165. package/dist/test/flutter/templates.test.js.map +1 -1
  166. package/dist/test/react-native/javascript.test.js +119 -0
  167. package/dist/test/react-native/javascript.test.js.map +1 -1
  168. package/dist/test/react-native/metro.test.js +113 -0
  169. package/dist/test/react-native/metro.test.js.map +1 -1
  170. package/dist/test/remix/client-entry.test.js +10 -10
  171. package/dist/test/remix/client-entry.test.js.map +1 -1
  172. package/dist/test/utils/git.test.d.ts +1 -0
  173. package/dist/test/utils/git.test.js +70 -0
  174. package/dist/test/utils/git.test.js.map +1 -0
  175. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"nuxt-wizard.js","sourceRoot":"","sources":["../../../src/nuxt/nuxt-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,qDAAuC;AACvC,kDAA0B;AAC1B,mCAAwC;AACxC,4CAAwD;AACxD,0CAcwB;AACxB,wDAA+E;AAE/E,+CAIuB;AACvB,2CAOqB;AACrB,mCAAmC;AAEnC,SAAgB,aAAa,CAAC,OAAsB;IAClD,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,MAAM;QACnB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAC1C,CAAC;AACJ,CAAC;AATD,sCASC;AAEM,KAAK,UAAU,0BAA0B,CAC9C,OAAsB;IAEtB,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE9D,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,oBAAoB;QAChC,SAAS;QACT,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,IAAA,yCAAiC,EAAC;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAE9C,MAAM,IAAA,gCAAwB,EAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE5D,MAAM,WAAW,GAAG,IAAA,gCAAiB,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3D,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,WAAW,IAA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QAEpE,IAAI,yBAAyB,EAAE;YAC7B,MAAM,IAAA,qBAAS,EAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE,CACrD,IAAA,oCAAsB,EAAC,IAAI,CAAC,CAC7B,CAAC;SACH;KACF;IAED,MAAM,IAAA,8BAAsB,EAAC;QAC3B,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,MAAM,IAAA,iCAAqB,EAAC,kBAAkB,CAAC,CAAC;IAEhD,KAAK,CAAC,KAAK,CACT,iBAAiB,CAAC,uBAAuB,EAAE,yBAAyB,CAAC,CACtE,CAAC;AACJ,CAAC;AAvHD,gEAuHC;AAED,SAAS,iBAAiB,CACxB,uBAAgC,EAChC,yBAAkC;IAElC,IAAI,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAEvE,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,+CAA+C,eAAK,CAAC,IAAI,CAC9D,wBAAwB,CACzB,GAAG,CAAC;KACN;IACD,IAAI,yBAAyB,EAAE;QAC7B,GAAG,IAAI,iDAAiD,eAAK,CAAC,IAAI,CAChE,uBAAuB,CACxB,yCAAyC,CAAC;KAC5C;IAED,GAAG,IAAI,kEAAkE,eAAK,CAAC,SAAS,CACtF,0DAA0D,CAC3D,EAAE,CAAC;IAEJ,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport { lt, minVersion } from 'semver';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abort,\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askShouldCreateExampleComponent,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n getPackageManager,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport {\n createExampleComponent,\n createExamplePage,\n supportsExamplePage,\n} from './sdk-example';\nimport {\n addNuxtOverrides,\n addSDKModule,\n askDeploymentPlatform,\n confirmReadImportDocs,\n createConfigFiles,\n getNuxtConfig,\n} from './sdk-setup';\nimport { isNuxtV4 } from './utils';\n\nexport function runNuxtWizard(options: WizardOptions) {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'nuxt',\n wizardOptions: options,\n },\n () => runNuxtWizardWithTelemetry(options),\n );\n}\n\nexport async function runNuxtWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Nuxt Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, 'nuxt', 'Nuxt');\n\n const nuxtVersion = getPackageVersion('nuxt', packageJson);\n Sentry.setTag('nuxt-version', nuxtVersion);\n\n const minVer = minVersion(nuxtVersion || '0.0.0');\n\n if (!nuxtVersion || !minVer || lt(minVer, '3.7.0')) {\n clack.log.warn(\n \"It seems you're using a Nuxt version <3.7.0 which is not supported by Sentry.\\nWe recommend upgrading to the latest version before you continue.\",\n );\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: 'Yes, continue',\n hint: 'The SDK might not work correctly',\n value: true,\n },\n { label: \"No, I'll upgrade first\", value: false },\n ],\n }),\n );\n if (!shouldContinue) {\n await abort('Exiting Wizard', 0);\n return;\n }\n }\n\n const { authToken, selectedProject, selfHosted, sentryUrl } =\n await getOrAskForProjectData(options, 'javascript-nuxt');\n\n const packageManager = await getPackageManager();\n\n await addNuxtOverrides(packageJson, packageManager, minVer, forceInstall);\n\n const sdkAlreadyInstalled = hasPackageInstalled('@sentry/nuxt', packageJson);\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/nuxt@^9',\n alreadyInstalled: sdkAlreadyInstalled,\n packageManager,\n forceInstall,\n });\n\n await addDotEnvSentryBuildPluginFile(authToken);\n\n const nuxtConfig = await traceStep('load-nuxt-config', getNuxtConfig);\n\n const projectData = {\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n selfHosted,\n };\n\n const deploymentPlatform = await askDeploymentPlatform();\n Sentry.setTag('deployment-platform', deploymentPlatform);\n\n await traceStep('configure-sdk', async () => {\n await addSDKModule(nuxtConfig, projectData, deploymentPlatform);\n await createConfigFiles(selectedProject.keys[0].dsn.public);\n });\n\n let shouldCreateExamplePage = false;\n let shouldCreateExampleButton = false;\n\n const isV4 = await isNuxtV4(nuxtConfig, nuxtVersion);\n const canCreateExamplePage = await supportsExamplePage(isV4);\n Sentry.setTag('supports-example-page-creation', canCreateExamplePage);\n\n if (canCreateExamplePage) {\n shouldCreateExamplePage = await askShouldCreateExamplePage();\n\n if (shouldCreateExamplePage) {\n await traceStep('create-example-page', async () =>\n createExamplePage(isV4, projectData),\n );\n }\n } else {\n shouldCreateExampleButton = await askShouldCreateExampleComponent();\n\n if (shouldCreateExampleButton) {\n await traceStep('create-example-component', async () =>\n createExampleComponent(isV4),\n );\n }\n }\n\n await runPrettierIfInstalled({\n cwd: undefined,\n });\n\n await confirmReadImportDocs(deploymentPlatform);\n\n clack.outro(\n buildOutroMessage(shouldCreateExamplePage, shouldCreateExampleButton),\n );\n}\n\nfunction buildOutroMessage(\n shouldCreateExamplePage: boolean,\n shouldCreateExampleButton: boolean,\n): string {\n let msg = chalk.green('\\nSuccessfully installed the Sentry Nuxt SDK!');\n\n if (shouldCreateExamplePage) {\n msg += `\\n\\nYou can validate your setup by visiting ${chalk.cyan(\n '\"/sentry-example-page\"',\n )}.`;\n }\n if (shouldCreateExampleButton) {\n msg += `\\n\\nYou can validate your setup by adding the ${chalk.cyan(\n '`SentryExampleButton`',\n )} component to a page and triggering it.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration: ${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/',\n )}`;\n\n return msg;\n}\n"]}
1
+ {"version":3,"file":"nuxt-wizard.js","sourceRoot":"","sources":["../../../src/nuxt/nuxt-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,qDAAuC;AACvC,kDAA0B;AAC1B,mCAAwC;AACxC,4CAAwD;AACxD,0CAcwB;AACxB,wDAA+E;AAE/E,+CAIuB;AACvB,2CAOqB;AACrB,mCAAmC;AAEnC,SAAgB,aAAa,CAAC,OAAsB;IAClD,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,MAAM;QACnB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAC1C,CAAC;AACJ,CAAC;AATD,sCASC;AAEM,KAAK,UAAU,0BAA0B,CAC9C,OAAsB;IAEtB,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE9D,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,oBAAoB;QAChC,SAAS;QACT,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,IAAA,yCAAiC,EAAC;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAE9C,MAAM,IAAA,gCAAwB,EAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE5D,MAAM,WAA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BAAS,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE,CAChD,IAAA,+BAAiB,EAAC,IAAI,EAAE,WAAW,CAAC,CACrC,CAAC;SACH;KACF;SAAM;QACL,yBAAyB,GAAG,MAAM,IAAA,uCAA+B,GAAE,CAAC;QAEpE,IAAI,yBAAyB,EAAE;YAC7B,MAAM,IAAA,qBAAS,EAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE,CACrD,IAAA,oCAAsB,EAAC,IAAI,CAAC,CAC7B,CAAC;SACH;KACF;IAED,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAEjD,MAAM,IAAA,iCAAqB,EAAC,kBAAkB,CAAC,CAAC;IAEhD,KAAK,CAAC,KAAK,CACT,iBAAiB,CAAC,uBAAuB,EAAE,yBAAyB,CAAC,CACtE,CAAC;AACJ,CAAC;AArHD,gEAqHC;AAED,SAAS,iBAAiB,CACxB,uBAAgC,EAChC,yBAAkC;IAElC,IAAI,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAEvE,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,+CAA+C,eAAK,CAAC,IAAI,CAC9D,wBAAwB,CACzB,GAAG,CAAC;KACN;IACD,IAAI,yBAAyB,EAAE;QAC7B,GAAG,IAAI,iDAAiD,eAAK,CAAC,IAAI,CAChE,uBAAuB,CACxB,yCAAyC,CAAC;KAC5C;IAED,GAAG,IAAI,kEAAkE,eAAK,CAAC,SAAS,CACtF,0DAA0D,CAC3D,EAAE,CAAC;IAEJ,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\nimport chalk from 'chalk';\nimport { lt, minVersion } from 'semver';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abort,\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askShouldCreateExampleComponent,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n getPackageManager,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport {\n createExampleComponent,\n createExamplePage,\n supportsExamplePage,\n} from './sdk-example';\nimport {\n addNuxtOverrides,\n addSDKModule,\n askDeploymentPlatform,\n confirmReadImportDocs,\n createConfigFiles,\n getNuxtConfig,\n} from './sdk-setup';\nimport { isNuxtV4 } from './utils';\n\nexport function runNuxtWizard(options: WizardOptions) {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'nuxt',\n wizardOptions: options,\n },\n () => runNuxtWizardWithTelemetry(options),\n );\n}\n\nexport async function runNuxtWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Nuxt Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, 'nuxt', 'Nuxt');\n\n const nuxtVersion = getPackageVersion('nuxt', packageJson);\n Sentry.setTag('nuxt-version', nuxtVersion);\n\n const minVer = minVersion(nuxtVersion || '0.0.0');\n\n if (!nuxtVersion || !minVer || lt(minVer, '3.7.0')) {\n clack.log.warn(\n \"It seems you're using a Nuxt version <3.7.0 which is not supported by Sentry.\\nWe recommend upgrading to the latest version before you continue.\",\n );\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: 'Yes, continue',\n hint: 'The SDK might not work correctly',\n value: true,\n },\n { label: \"No, I'll upgrade first\", value: false },\n ],\n }),\n );\n if (!shouldContinue) {\n await abort('Exiting Wizard', 0);\n return;\n }\n }\n\n const { authToken, selectedProject, selfHosted, sentryUrl } =\n await getOrAskForProjectData(options, 'javascript-nuxt');\n\n const packageManager = await getPackageManager();\n\n await addNuxtOverrides(packageJson, packageManager, minVer, forceInstall);\n\n const sdkAlreadyInstalled = hasPackageInstalled('@sentry/nuxt', packageJson);\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/nuxt@^9',\n alreadyInstalled: sdkAlreadyInstalled,\n packageManager,\n forceInstall,\n });\n\n await addDotEnvSentryBuildPluginFile(authToken);\n\n const nuxtConfig = await traceStep('load-nuxt-config', getNuxtConfig);\n\n const projectData = {\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n selfHosted,\n };\n\n const deploymentPlatform = await askDeploymentPlatform();\n Sentry.setTag('deployment-platform', deploymentPlatform);\n\n await traceStep('configure-sdk', async () => {\n await addSDKModule(nuxtConfig, projectData, deploymentPlatform);\n await createConfigFiles(selectedProject.keys[0].dsn.public);\n });\n\n let shouldCreateExamplePage = false;\n let shouldCreateExampleButton = false;\n\n const isV4 = await isNuxtV4(nuxtConfig, nuxtVersion);\n const canCreateExamplePage = await supportsExamplePage(isV4);\n Sentry.setTag('supports-example-page-creation', canCreateExamplePage);\n\n if (canCreateExamplePage) {\n shouldCreateExamplePage = await askShouldCreateExamplePage();\n\n if (shouldCreateExamplePage) {\n await traceStep('create-example-page', async () =>\n createExamplePage(isV4, projectData),\n );\n }\n } else {\n shouldCreateExampleButton = await askShouldCreateExampleComponent();\n\n if (shouldCreateExampleButton) {\n await traceStep('create-example-component', async () =>\n createExampleComponent(isV4),\n );\n }\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n await confirmReadImportDocs(deploymentPlatform);\n\n clack.outro(\n buildOutroMessage(shouldCreateExamplePage, shouldCreateExampleButton),\n );\n}\n\nfunction buildOutroMessage(\n shouldCreateExamplePage: boolean,\n shouldCreateExampleButton: boolean,\n): string {\n let msg = chalk.green('\\nSuccessfully installed the Sentry Nuxt SDK!');\n\n if (shouldCreateExamplePage) {\n msg += `\\n\\nYou can validate your setup by visiting ${chalk.cyan(\n '\"/sentry-example-page\"',\n )}.`;\n }\n if (shouldCreateExampleButton) {\n msg += `\\n\\nYou can validate your setup by adding the ${chalk.cyan(\n '`SentryExampleButton`',\n )} component to a page and triggering it.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration: ${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/nuxt/',\n )}`;\n\n return msg;\n}\n"]}
@@ -116,6 +116,16 @@ Feel free to delete this file.
116
116
  import { useFetch} from '#imports'
117
117
 
118
118
  const hasSentError = ref(false);
119
+ const isConnected = ref(true);
120
+
121
+ onMounted(async () => {
122
+ try {
123
+ const result = await Sentry.diagnoseSdkConnectivity();
124
+ isConnected.value = result !== 'sentry-unreachable';
125
+ } catch (error) {
126
+ isConnected.value = false;
127
+ }
128
+ });
119
129
 
120
130
  function getSentryData() {
121
131
  Sentry.startSpan(
@@ -163,6 +173,9 @@ Feel free to delete this file.
163
173
  <p v-if="hasSentError" class="success">
164
174
  Sample error was sent to Sentry.
165
175
  </p>
176
+ <div v-else-if="!isConnected" class="connectivity-error">
177
+ <p>The Sentry SDK is not able to reach Sentry right now - this may be due to an adblocker. For more information, see <a target="_blank" href="https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#the-sdk-is-not-sending-any-data">the troubleshooting guide</a>.</p>
178
+ </div>
166
179
  <div v-else class="success_placeholder" />
167
180
 
168
181
  <div class="flex-spacer" />
@@ -279,7 +292,24 @@ Feel free to delete this file.
279
292
  .success_placeholder {
280
293
  height: 46px;
281
294
  }
295
+
296
+ .connectivity-error {
297
+ padding: 12px 16px;
298
+ background-color: #E50045;
299
+ border-radius: 8px;
300
+ width: 500px;
301
+ color: #FFFFFF;
302
+ border: 1px solid #A80033;
303
+ text-align: center;
304
+ margin: 0;
305
+ }
306
+
307
+ .connectivity-error a {
308
+ color: #FFFFFF;
309
+ text-decoration: underline;
310
+ }
282
311
  </style>
312
+
283
313
  `;
284
314
  }
285
315
  exports.getSentryExamplePageTemplate = getSentryExamplePageTemplate;
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nuxt/templates.ts"],"names":[],"mappings":";;;AAAA,sCAAiD;AAOjD,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;QACJ,2EAA2E;QAC3E,+CAA+C;KAChD,CAAC,IAAI,CAAC,IAAI,CAAC;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AS,EAAE,CAAC,CAAC;IAE3E,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mGAyC0F,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqIhH,CAAC;AACF,CAAC;AAvLD,oEAuLC;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};\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};\n\nconst featuresMap: Record<\n 'client' | 'server',\n Array<keyof SelectedSentryFeatures>\n> = {\n client: ['performance', 'replay'],\n server: ['performance'],\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 import { useFetch} from '#imports'\n\n const hasSentError = ref(false);\n \n function getSentryData() {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const { error } = await useFetch('/api/sentry-example-api');\n if (error.value) {\n hasSentError.value = true;\n throw new Error('Sentry Example Frontend Error');\n }\n }\n )\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 >\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 class=\"success_placeholder\" />\n\n <div class=\"flex-spacer\" />\n <p class=\"description\">\n Adblockers will prevent errors from being sent to Sentry.\n </p>\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\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</style>\n`;\n}\n\nexport function getSentryExampleApiTemplate() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file.\nimport { defineEventHandler } from '#imports';\n\nexport default defineEventHandler(() => {\n throw new Error(\"Sentry Example API Route Error\");\n});\n`;\n}\n\nexport function getSentryErrorButtonTemplate() {\n return `<!--\nThis is just a very simple component that throws an example error.\nFeel free to delete this file.\n-->\n\n<script setup>\n import * as Sentry from '@sentry/nuxt';\n\n const hasSentError = ref(false);\n \n const throwError = () => {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n () => {\n hasSentError.value = true;\n throw new Error('Sentry Example Error');\n }\n )\n };\n</script>\n\n<template>\n <div v-if=\"hasSentError\" class=\"success\">\n Sample error was sent to Sentry.\n </div>\n <button v-else @click=\"throwError\">\n <span>Throw Sample Error</span>\n </button>\n</template>\n\n<style scoped>\n button {\n border-radius: 8px;\n color: white;\n cursor: pointer;\n background-color: #553DB8;\n border: none;\n padding: 0;\n margin-top: 4px;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n\n & > span {\n display: inline-block;\n padding: 12px 16px;\n border-radius: inherit;\n font-size: 20px;\n font-weight: bold;\n line-height: 1;\n background-color: #7553FF;\n border: 1px solid #553DB8;\n transform: translateY(-4px);\n }\n\n &:hover > span {\n transform: translateY(-8px);\n }\n\n &:active > span {\n transform: translateY(0);\n }\n }\n\n .success {\n width: max-content;\n padding: 12px 16px;\n border-radius: 8px;\n font-size: 20px;\n line-height: 1;\n background-color: #00F261;\n border: 1px solid #00BF4D;\n color: #181423;\n font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", sans-serif;\n }\n</style>\n`;\n}\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/nuxt/templates.ts"],"names":[],"mappings":";;;AAAA,sCAAiD;AAOjD,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,gF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EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,cAAc,GAAG,IAAA,uBAAiB,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAE3E,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mGAmD0F,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyJhH,CAAC;AACF,CAAC;AArND,oEAqNC;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};\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};\n\nconst featuresMap: Record<\n 'client' | 'server',\n Array<keyof SelectedSentryFeatures>\n> = {\n client: ['performance', 'replay'],\n server: ['performance'],\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 import { useFetch} from '#imports'\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 function getSentryData() {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const { error } = await useFetch('/api/sentry-example-api');\n if (error.value) {\n hasSentError.value = true;\n throw new Error('Sentry Example Frontend Error');\n }\n }\n )\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 >\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>The Sentry SDK is not able to reach Sentry right now - this may be due to an adblocker. For more information, see <a target=\"_blank\" href=\"https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#the-sdk-is-not-sending-any-data\">the troubleshooting guide</a>.</p>\n </div>\n <div v-else class=\"success_placeholder\" />\n\n <div class=\"flex-spacer\" />\n <p class=\"description\">\n Adblockers will prevent errors from being sent to Sentry.\n </p>\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\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"]}
@@ -38,10 +38,13 @@ async function addExpoEnvLocal(options) {
38
38
  const newContent = `#DO NOT COMMIT THIS\nSENTRY_AUTH_TOKEN=${options.authToken}\n`;
39
39
  const added = await (0, git_1.addToGitignore)(EXPO_ENV_LOCAL_FILE);
40
40
  if (added) {
41
+ Sentry.setTag('expo-env-local', 'added-to-gitignore');
41
42
  clack.log.success(`Added ${chalk_1.default.cyan(EXPO_ENV_LOCAL_FILE)} to .gitignore.`);
42
43
  }
43
44
  else {
45
+ Sentry.setTag('expo-env-local', 'add-to-gitignore-error');
44
46
  clack.log.error(`Could not add ${chalk_1.default.cyan(EXPO_ENV_LOCAL_FILE)} to .gitignore, please add it to not commit your auth key.`);
47
+ Sentry.captureException(`Could not add ${EXPO_ENV_LOCAL_FILE} to .gitignore`);
45
48
  }
46
49
  if (!fs_1.default.existsSync(EXPO_ENV_LOCAL_FILE)) {
47
50
  try {
@@ -53,6 +56,7 @@ async function addExpoEnvLocal(options) {
53
56
  catch (error) {
54
57
  Sentry.setTag('expo-env-local', 'write-error');
55
58
  clack.log.error(`Unable to write ${chalk_1.default.cyan(EXPO_ENV_LOCAL_FILE)}.`);
59
+ Sentry.captureException(`Unable to write ${EXPO_ENV_LOCAL_FILE}.`);
56
60
  return false;
57
61
  }
58
62
  }
@@ -67,6 +71,7 @@ async function addExpoEnvLocal(options) {
67
71
  catch (error) {
68
72
  Sentry.setTag('expo-env-local', 'update-error');
69
73
  clack.log.error(`Unable to update ${chalk_1.default.cyan(EXPO_ENV_LOCAL_FILE)}.`);
74
+ Sentry.captureException(`Unable to update ${EXPO_ENV_LOCAL_FILE}.`);
70
75
  return false;
71
76
  }
72
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"expo-env-file.js","sourceRoot":"","sources":["../../../src/react-native/expo-env-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,4CAAoB;AACpB,qDAAuC;AAEvC,+BAAuC;AAEvC,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAElC,KAAK,UAAU,eAAe,CACnC,OAAgC;IAEhC,MAAM,UAAU,GAAG,0CAA0C,OAAO,CAAC,SAAS,IAAI,CAAC;IAEnF,MAAM,KAAK,GAAG,MAAM,IAAA,oBAAc,EAAC,mBAAmB,CAAC,CAAC;IACxD,IAAI,KAAK,EAAE;QACT,KAAK,CAAC,GAAG,CAAC,OAAO,CACf,SAAS,eAAK,CAA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K,EAAE;QACd,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAChD,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACxE,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AA5CD,0CA4CC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport * as Sentry from '@sentry/node';\nimport { RNCliSetupConfigContent } from './react-native-wizard';\nimport { addToGitignore } from './git';\n\nconst EXPO_ENV_LOCAL_FILE = '.env.local';\n\nexport async function addExpoEnvLocal(\n options: RNCliSetupConfigContent,\n): Promise<boolean> {\n const newContent = `#DO NOT COMMIT THIS\\nSENTRY_AUTH_TOKEN=${options.authToken}\\n`;\n\n const added = await addToGitignore(EXPO_ENV_LOCAL_FILE);\n if (added) {\n clack.log.success(\n `Added ${chalk.cyan(EXPO_ENV_LOCAL_FILE)} to .gitignore.`,\n );\n } else {\n clack.log.error(\n `Could not add ${chalk.cyan(\n EXPO_ENV_LOCAL_FILE,\n )} to .gitignore, please add it to not commit your auth key.`,\n );\n }\n\n if (!fs.existsSync(EXPO_ENV_LOCAL_FILE)) {\n try {\n await fs.promises.writeFile(EXPO_ENV_LOCAL_FILE, newContent);\n Sentry.setTag('expo-env-local', 'written');\n clack.log.success(`Written ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n return true;\n } catch (error) {\n Sentry.setTag('expo-env-local', 'write-error');\n clack.log.error(`Unable to write ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n return false;\n }\n }\n\n Sentry.setTag('expo-env-local', 'exists');\n clack.log.info(`Updating existing ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n\n try {\n await fs.promises.appendFile(EXPO_ENV_LOCAL_FILE, newContent);\n Sentry.setTag('expo-env-local', 'updated');\n clack.log.success(`Updated ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n return true;\n } catch (error) {\n Sentry.setTag('expo-env-local', 'update-error');\n clack.log.error(`Unable to update ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"expo-env-file.js","sourceRoot":"","sources":["../../../src/react-native/expo-env-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,4CAAoB;AACpB,qDAAuC;AAEvC,+BAAuC;AAEvC,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAElC,KAAK,UAAU,eAAe,CACnC,OAAgC;IAEhC,MAAM,UAAU,GAAG,0CAA0C,OAAO,CAAC,SAAS,IAAI,CAAC;IAEnF,MAAM,KAAK,GAAG,MAAM,IAAA,oBAAc,EAAC,mBAAmB,CAAC,CAAC;IACxD,IAAI,KAAK,EAAE;QACT,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;QACtD,KAAK,CAAC,GAAG,CAAC,OAAO,CACf,SAAS,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAC1D,CAAC;KACH;SAAM;QACL,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,wBAAwB,CAAC,CAAC;QAC1D,KAAK,CAAC,GAAG,CAAC,KAAK,CACb,iBAAiB,eAAK,CAAC,IAAI,CACzB,mBAAmB,CACpB,4DAA4D,CAC9D,CAAC;QACF,MAAM,CAAC,gBAAgB,CACrB,iBAAiB,mBAAmB,gBAAgB,CACrD,CAAC;KACH;IAED,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE;QACvC,IAAI;YACF,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;YAC7D,MAAM,CAAC,MAAM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AnDD,0CAmDC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport * as Sentry from '@sentry/node';\nimport { RNCliSetupConfigContent } from './react-native-wizard';\nimport { addToGitignore } from './git';\n\nconst EXPO_ENV_LOCAL_FILE = '.env.local';\n\nexport async function addExpoEnvLocal(\n options: RNCliSetupConfigContent,\n): Promise<boolean> {\n const newContent = `#DO NOT COMMIT THIS\\nSENTRY_AUTH_TOKEN=${options.authToken}\\n`;\n\n const added = await addToGitignore(EXPO_ENV_LOCAL_FILE);\n if (added) {\n Sentry.setTag('expo-env-local', 'added-to-gitignore');\n clack.log.success(\n `Added ${chalk.cyan(EXPO_ENV_LOCAL_FILE)} to .gitignore.`,\n );\n } else {\n Sentry.setTag('expo-env-local', 'add-to-gitignore-error');\n clack.log.error(\n `Could not add ${chalk.cyan(\n EXPO_ENV_LOCAL_FILE,\n )} to .gitignore, please add it to not commit your auth key.`,\n );\n Sentry.captureException(\n `Could not add ${EXPO_ENV_LOCAL_FILE} to .gitignore`,\n );\n }\n\n if (!fs.existsSync(EXPO_ENV_LOCAL_FILE)) {\n try {\n await fs.promises.writeFile(EXPO_ENV_LOCAL_FILE, newContent);\n Sentry.setTag('expo-env-local', 'written');\n clack.log.success(`Written ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n return true;\n } catch (error) {\n Sentry.setTag('expo-env-local', 'write-error');\n clack.log.error(`Unable to write ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n Sentry.captureException(`Unable to write ${EXPO_ENV_LOCAL_FILE}.`);\n return false;\n }\n }\n\n Sentry.setTag('expo-env-local', 'exists');\n clack.log.info(`Updating existing ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n\n try {\n await fs.promises.appendFile(EXPO_ENV_LOCAL_FILE, newContent);\n Sentry.setTag('expo-env-local', 'updated');\n clack.log.success(`Updated ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n return true;\n } catch (error) {\n Sentry.setTag('expo-env-local', 'update-error');\n clack.log.error(`Unable to update ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n Sentry.captureException(`Unable to update ${EXPO_ENV_LOCAL_FILE}.`);\n return false;\n }\n}\n"]}
@@ -47,13 +47,18 @@ async function addSentryToExpoMetroConfig() {
47
47
  Sentry.setTag('expo-metro-config', 'created-new');
48
48
  return undefined;
49
49
  }
50
+ Sentry.setTag('expo-metro-config', 'exists');
51
+ clack.log.info(`Updating existing ${metro_1.metroConfigPath}.`);
50
52
  const mod = await (0, metro_1.parseMetroConfig)();
53
+ if (!mod) {
54
+ return await showInstructions();
55
+ }
51
56
  let didPatch = false;
52
57
  try {
53
58
  didPatch = patchMetroInMemory(mod);
54
59
  }
55
60
  catch (e) {
56
- // noop
61
+ Sentry.captureException('Unable to patch expo metro config');
57
62
  }
58
63
  if (!didPatch) {
59
64
  Sentry.setTag('expo-metro-config', 'patch-error');
@@ -67,7 +72,7 @@ async function addSentryToExpoMetroConfig() {
67
72
  }
68
73
  else {
69
74
  Sentry.setTag('expo-metro-config', 'patch-save-error');
70
- clack.log.warn(`Could not save changes to ${chalk_1.default.cyan(metro_1.metroConfigPath)}, please follow the manual steps.`);
75
+ clack.log.error(`Could not save changes to ${chalk_1.default.cyan(metro_1.metroConfigPath)}, please follow the manual steps.`);
71
76
  return await showInstructions();
72
77
  }
73
78
  }
@@ -128,9 +133,16 @@ function patchMetroInMemory(mod) {
128
133
  }
129
134
  exports.patchMetroInMemory = patchMetroInMemory;
130
135
  function addSentryExpoConfigRequire(program) {
131
- const lastRequireIndex = (0, ast_utils_1.getLastRequireIndex)(program);
132
- const sentryExpoConfigRequire = createSentryExpoConfigRequire();
133
- program.body.splice(lastRequireIndex + 1, 0, sentryExpoConfigRequire);
136
+ try {
137
+ const lastRequireIndex = (0, ast_utils_1.getLastRequireIndex)(program);
138
+ const sentryExpoConfigRequire = createSentryExpoConfigRequire();
139
+ // Add the require statement after the last require or at the beginning
140
+ program.body.splice(lastRequireIndex + 1, 0, sentryExpoConfigRequire);
141
+ }
142
+ catch (error) {
143
+ clack.log.error(`Could not add Sentry Expo config require statement to ${chalk_1.default.cyan(metro_1.metroConfigPath)}.`);
144
+ Sentry.captureException(`Could not add Sentry Expo config require statement to ${metro_1.metroConfigPath}.`);
145
+ }
134
146
  }
135
147
  exports.addSentryExpoConfigRequire = addSentryExpoConfigRequire;
136
148
  /**
@@ -161,13 +173,17 @@ module.exports = config;
161
173
  }
162
174
  catch (e) {
163
175
  clack.log.error(`Could not create ${chalk_1.default.cyan(metro_1.metroConfigPath)} with Sentry configuration.`);
176
+ Sentry.captureException(`Could not create ${metro_1.metroConfigPath} with Sentry configuration.`);
164
177
  return false;
165
178
  }
166
179
  clack.log.success(`Created ${chalk_1.default.cyan(metro_1.metroConfigPath)} with Sentry configuration.`);
167
180
  return true;
168
181
  }
169
182
  function showInstructions() {
170
- return (0, clack_1.showCopyPasteInstructions)(metro_1.metroConfigPath, getMetroWithSentryExpoConfigSnippet(true));
183
+ return (0, clack_1.showCopyPasteInstructions)({
184
+ filename: metro_1.metroConfigPath,
185
+ codeSnippet: getMetroWithSentryExpoConfigSnippet(true),
186
+ });
171
187
  }
172
188
  function getMetroWithSentryExpoConfigSnippet(colors) {
173
189
  return (0, clack_1.makeCodeSnippet)(colors, (unchanged, plus, minus) => unchanged(`${minus(`// const { getDefaultConfig } = require("expo/metro-config");`)}
@@ -1 +1 @@
1
- {"version":3,"file":"expo-metro.js","sourceRoot":"","sources":["../../../src/react-native/expo-metro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,+EAA+E;AAC/E,sDAAwC;AAGxC,kDAA0B;AAC1B,qDAAuC;AAEvC,kDAA2E;AAC3E,0CAA4E;AAE5E,mCAA8E;AAE9E,+CAAiC;AAIjC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,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AAI,CAC5B,uBAAe,CAChB,6BAA6B,CAC/B,CAAC;QACF,OAAO,KAAK,CAAC;KACd;IACD,KAAK,CAAC,GAAG,CAAC,OAAO,CACf,WAAW,eAAK,CAAC,IAAI,CAAC,uBAAe,CAAC,6BAA6B,CACpE,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB;IACvB,OAAO,IAAA,iCAAyB,EAC9B,uBAAe,EACf,mCAAmC,CAAC,IAAI,CAAC,CAC1C,CAAC;AACJ,CAAC;AAED,SAAS,mCAAmC,CAAC,MAAe;IAC1D,OAAO,IAAA,uBAAe,EAAC,MAAM,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CACxD,SAAS,CAAC,GAAG,KAAK,CAChB,+DAA+D,CAChE;EACH,IAAI,CACJ,wEAAwE,CACzE;;EAEC,KAAK,CAAC,gDAAgD,CAAC;EACvD,IAAI,CAAC,gDAAgD,CAAC;;yBAE/B,CAAC,CACvB,CAAC;AACJ,CAAC","sourcesContent":["import * 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';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\nimport chalk from 'chalk';\nimport * as Sentry from '@sentry/node';\n\nimport { getLastRequireIndex, hasSentryContent } from '../utils/ast-utils';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\n\nimport { metroConfigPath, parseMetroConfig, writeMetroConfig } from './metro';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nconst b = recast.types.builders;\n\nexport async function addSentryToExpoMetroConfig() {\n if (!fs.existsSync(metroConfigPath)) {\n const success = await createSentryExpoMetroConfig();\n if (!success) {\n Sentry.setTag('expo-metro-config', 'create-new-error');\n return await showInstructions();\n }\n Sentry.setTag('expo-metro-config', 'created-new');\n return undefined;\n }\n\n const mod = await parseMetroConfig();\n\n let didPatch = false;\n try {\n didPatch = patchMetroInMemory(mod);\n } catch (e) {\n // noop\n }\n if (!didPatch) {\n Sentry.setTag('expo-metro-config', 'patch-error');\n clack.log.error(\n `Could not patch ${chalk.cyan(\n metroConfigPath,\n )} with Sentry configuration.`,\n );\n return await showInstructions();\n }\n\n const saved = await writeMetroConfig(mod);\n if (saved) {\n Sentry.setTag('expo-metro-config', 'patch-saved');\n clack.log.success(\n chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),\n );\n } else {\n Sentry.setTag('expo-metro-config', 'patch-save-error');\n clack.log.warn(\n `Could not save changes to ${chalk.cyan(\n metroConfigPath,\n )}, please follow the manual steps.`,\n );\n return await showInstructions();\n }\n}\n\nexport function patchMetroInMemory(mod: ProxifiedModule): boolean {\n const ast = mod.$ast as t.Program;\n\n if (hasSentryContent(ast)) {\n clack.log.warn(\n `The ${chalk.cyan(\n metroConfigPath,\n )} file already has Sentry configuration.`,\n );\n return false;\n }\n\n let didReplaceDefaultConfigCall = false;\n\n recast.visit(ast, {\n visitVariableDeclaration(path) {\n const { node } = path;\n\n if (\n // path is require(\"expo/metro-config\")\n // and only getDefaultConfig is being destructured\n // then remove the entire declaration\n node.declarations.length > 0 &&\n node.declarations[0].type === 'VariableDeclarator' &&\n node.declarations[0].init &&\n node.declarations[0].init.type === 'CallExpression' &&\n node.declarations[0].init.callee &&\n node.declarations[0].init.callee.type === 'Identifier' &&\n node.declarations[0].init.callee.name === 'require' &&\n node.declarations[0].init.arguments[0].type === 'StringLiteral' &&\n node.declarations[0].init.arguments[0].value === 'expo/metro-config' &&\n node.declarations[0].id.type === 'ObjectPattern' &&\n node.declarations[0].id.properties.length === 1 &&\n node.declarations[0].id.properties[0].type === 'ObjectProperty' &&\n node.declarations[0].id.properties[0].key.type === 'Identifier' &&\n node.declarations[0].id.properties[0].key.name === 'getDefaultConfig'\n ) {\n path.prune();\n return false;\n }\n\n this.traverse(path);\n },\n\n visitCallExpression(path) {\n const { node } = path;\n if (\n // path is getDefaultConfig\n // then rename it to getSentryExpoConfig\n node.callee.type === 'Identifier' &&\n node.callee.name === 'getDefaultConfig'\n ) {\n node.callee.name = 'getSentryExpoConfig';\n didReplaceDefaultConfigCall = true;\n return false;\n }\n\n this.traverse(path);\n },\n });\n\n if (!didReplaceDefaultConfigCall) {\n clack.log.warn(\n `Could not find \\`getDefaultConfig\\` in ${chalk.cyan(metroConfigPath)}.`,\n );\n return false;\n }\n\n addSentryExpoConfigRequire(ast);\n\n return true;\n}\n\nexport function addSentryExpoConfigRequire(program: t.Program) {\n const lastRequireIndex = getLastRequireIndex(program);\n const sentryExpoConfigRequire = createSentryExpoConfigRequire();\n program.body.splice(lastRequireIndex + 1, 0, sentryExpoConfigRequire);\n}\n\n/**\n * Creates const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n */\nfunction createSentryExpoConfigRequire() {\n return b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('getSentryExpoConfig'),\n value: b.identifier('getSentryExpoConfig'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.literal('@sentry/react-native/metro'),\n ]),\n ),\n ]);\n}\n\nasync function createSentryExpoMetroConfig(): Promise<boolean> {\n const snippet = `const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n\nconst config = getSentryExpoConfig(__dirname);\n\nmodule.exports = config;\n`;\n try {\n await fs.promises.writeFile(metroConfigPath, snippet);\n } catch (e) {\n clack.log.error(\n `Could not create ${chalk.cyan(\n metroConfigPath,\n )} with Sentry configuration.`,\n );\n return false;\n }\n clack.log.success(\n `Created ${chalk.cyan(metroConfigPath)} with Sentry configuration.`,\n );\n return true;\n}\n\nfunction showInstructions() {\n return showCopyPasteInstructions(\n metroConfigPath,\n getMetroWithSentryExpoConfigSnippet(true),\n );\n}\n\nfunction getMetroWithSentryExpoConfigSnippet(colors: boolean): string {\n return makeCodeSnippet(colors, (unchanged, plus, minus) =>\n unchanged(`${minus(\n `// const { getDefaultConfig } = require(\"expo/metro-config\");`,\n )}\n${plus(\n `const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");`,\n)}\n\n${minus(`// const config = getDefaultConfig(__dirname);`)}\n${plus(`const config = getSentryExpoConfig(__dirname);`)}\n\nmodule.exports = config;`),\n );\n}\n"]}
1
+ {"version":3,"file":"expo-metro.js","sourceRoot":"","sources":["../../../src/react-native/expo-metro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,+EAA+E;AAC/E,sDAAwC;AAGxC,kDAA0B;AAC1B,qDAAuC;AAEvC,kDAA2E;AAC3E,0CAA4E;AAE5E,mCAA8E;AAE9E,+CAAiC;AAIjC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEzB,KAAK,UAAU,0BAA0B;IAC9C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,uBAAe,CAAC,EAAE;QACnC,MAAM,OAAO,GAAG,MAAM,2BAA2B,EAAE,CAAC;QACpD,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;YACvD,OAAO,MAAM,gBAAgB,EAAE,CAAC;SACjC;QACD,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;QAClD,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IAC7C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,uBAAe,GAAG,CAAC,CAAC;IAExD,MAAM,GAAG,GAAG,MAAM,IAAA,wBAAgB,GAAE,CAAC;IACrC,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,MAAM,gBAAgB,EAAE,CAAC;KACjC;IAED,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI;QACF,QAAQ,GAAG,kBAA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CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB;IACvB,OAAO,IAAA,iCAAyB,EAAC;QAC/B,QAAQ,EAAE,uBAAe;QACzB,WAAW,EAAE,mCAAmC,CAAC,IAAI,CAAC;KACvD,CAAC,CAAC;AACL,CAAC;AAED,SAAS,mCAAmC,CAAC,MAAe;IAC1D,OAAO,IAAA,uBAAe,EAAC,MAAM,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CACxD,SAAS,CAAC,GAAG,KAAK,CAChB,+DAA+D,CAChE;EACH,IAAI,CACJ,wEAAwE,CACzE;;EAEC,KAAK,CAAC,gDAAgD,CAAC;EACvD,IAAI,CAAC,gDAAgD,CAAC;;yBAE/B,CAAC,CACvB,CAAC;AACJ,CAAC","sourcesContent":["import * 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';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\nimport chalk from 'chalk';\nimport * as Sentry from '@sentry/node';\n\nimport { getLastRequireIndex, hasSentryContent } from '../utils/ast-utils';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\n\nimport { metroConfigPath, parseMetroConfig, writeMetroConfig } from './metro';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nconst b = recast.types.builders;\n\nexport async function addSentryToExpoMetroConfig() {\n if (!fs.existsSync(metroConfigPath)) {\n const success = await createSentryExpoMetroConfig();\n if (!success) {\n Sentry.setTag('expo-metro-config', 'create-new-error');\n return await showInstructions();\n }\n Sentry.setTag('expo-metro-config', 'created-new');\n return undefined;\n }\n\n Sentry.setTag('expo-metro-config', 'exists');\n clack.log.info(`Updating existing ${metroConfigPath}.`);\n\n const mod = await parseMetroConfig();\n if (!mod) {\n return await showInstructions();\n }\n\n let didPatch = false;\n try {\n didPatch = patchMetroInMemory(mod);\n } catch (e) {\n Sentry.captureException('Unable to patch expo metro config');\n }\n if (!didPatch) {\n Sentry.setTag('expo-metro-config', 'patch-error');\n clack.log.error(\n `Could not patch ${chalk.cyan(\n metroConfigPath,\n )} with Sentry configuration.`,\n );\n return await showInstructions();\n }\n\n const saved = await writeMetroConfig(mod);\n if (saved) {\n Sentry.setTag('expo-metro-config', 'patch-saved');\n clack.log.success(\n chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),\n );\n } else {\n Sentry.setTag('expo-metro-config', 'patch-save-error');\n clack.log.error(\n `Could not save changes to ${chalk.cyan(\n metroConfigPath,\n )}, please follow the manual steps.`,\n );\n return await showInstructions();\n }\n}\n\nexport function patchMetroInMemory(mod: ProxifiedModule): boolean {\n const ast = mod.$ast as t.Program;\n\n if (hasSentryContent(ast)) {\n clack.log.warn(\n `The ${chalk.cyan(\n metroConfigPath,\n )} file already has Sentry configuration.`,\n );\n return false;\n }\n\n let didReplaceDefaultConfigCall = false;\n\n recast.visit(ast, {\n visitVariableDeclaration(path) {\n const { node } = path;\n\n if (\n // path is require(\"expo/metro-config\")\n // and only getDefaultConfig is being destructured\n // then remove the entire declaration\n node.declarations.length > 0 &&\n node.declarations[0].type === 'VariableDeclarator' &&\n node.declarations[0].init &&\n node.declarations[0].init.type === 'CallExpression' &&\n node.declarations[0].init.callee &&\n node.declarations[0].init.callee.type === 'Identifier' &&\n node.declarations[0].init.callee.name === 'require' &&\n node.declarations[0].init.arguments[0].type === 'StringLiteral' &&\n node.declarations[0].init.arguments[0].value === 'expo/metro-config' &&\n node.declarations[0].id.type === 'ObjectPattern' &&\n node.declarations[0].id.properties.length === 1 &&\n node.declarations[0].id.properties[0].type === 'ObjectProperty' &&\n node.declarations[0].id.properties[0].key.type === 'Identifier' &&\n node.declarations[0].id.properties[0].key.name === 'getDefaultConfig'\n ) {\n path.prune();\n return false;\n }\n\n this.traverse(path);\n },\n\n visitCallExpression(path) {\n const { node } = path;\n if (\n // path is getDefaultConfig\n // then rename it to getSentryExpoConfig\n node.callee.type === 'Identifier' &&\n node.callee.name === 'getDefaultConfig'\n ) {\n node.callee.name = 'getSentryExpoConfig';\n didReplaceDefaultConfigCall = true;\n return false;\n }\n\n this.traverse(path);\n },\n });\n\n if (!didReplaceDefaultConfigCall) {\n clack.log.warn(\n `Could not find \\`getDefaultConfig\\` in ${chalk.cyan(metroConfigPath)}.`,\n );\n return false;\n }\n\n addSentryExpoConfigRequire(ast);\n\n return true;\n}\n\nexport function addSentryExpoConfigRequire(program: t.Program) {\n try {\n const lastRequireIndex = getLastRequireIndex(program);\n const sentryExpoConfigRequire = createSentryExpoConfigRequire();\n\n // Add the require statement after the last require or at the beginning\n program.body.splice(lastRequireIndex + 1, 0, sentryExpoConfigRequire);\n } catch (error) {\n clack.log.error(\n `Could not add Sentry Expo config require statement to ${chalk.cyan(\n metroConfigPath,\n )}.`,\n );\n Sentry.captureException(\n `Could not add Sentry Expo config require statement to ${metroConfigPath}.`,\n );\n }\n}\n\n/**\n * Creates const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n */\nfunction createSentryExpoConfigRequire() {\n return b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('getSentryExpoConfig'),\n value: b.identifier('getSentryExpoConfig'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.literal('@sentry/react-native/metro'),\n ]),\n ),\n ]);\n}\n\nasync function createSentryExpoMetroConfig(): Promise<boolean> {\n const snippet = `const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n\nconst config = getSentryExpoConfig(__dirname);\n\nmodule.exports = config;\n`;\n try {\n await fs.promises.writeFile(metroConfigPath, snippet);\n } catch (e) {\n clack.log.error(\n `Could not create ${chalk.cyan(\n metroConfigPath,\n )} with Sentry configuration.`,\n );\n Sentry.captureException(\n `Could not create ${metroConfigPath} with Sentry configuration.`,\n );\n return false;\n }\n clack.log.success(\n `Created ${chalk.cyan(metroConfigPath)} with Sentry configuration.`,\n );\n return true;\n}\n\nfunction showInstructions() {\n return showCopyPasteInstructions({\n filename: metroConfigPath,\n codeSnippet: getMetroWithSentryExpoConfigSnippet(true),\n });\n}\n\nfunction getMetroWithSentryExpoConfigSnippet(colors: boolean): string {\n return makeCodeSnippet(colors, (unchanged, plus, minus) =>\n unchanged(`${minus(\n `// const { getDefaultConfig } = require(\"expo/metro-config\");`,\n )}\n${plus(\n `const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");`,\n)}\n\n${minus(`// const config = getDefaultConfig(__dirname);`)}\n${plus(`const config = getSentryExpoConfig(__dirname);`)}\n\nmodule.exports = config;`),\n );\n}\n"]}
@@ -49,7 +49,11 @@ exports.printSentryExpoMigrationOutro = printSentryExpoMigrationOutro;
49
49
  */
50
50
  async function patchExpoAppConfig(options) {
51
51
  function showInstructions() {
52
- return (0, clack_1.showCopyPasteInstructions)(APP_CONFIG_JSON, getSentryAppConfigJsonCodeSnippet(options), 'This ensures auto upload of source maps during native app build.');
52
+ return (0, clack_1.showCopyPasteInstructions)({
53
+ filename: APP_CONFIG_JSON,
54
+ codeSnippet: getSentryAppConfigJsonCodeSnippet(options),
55
+ hint: 'This ensures auto upload of source maps during native app build.',
56
+ });
53
57
  }
54
58
  const appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);
55
59
  Sentry.setTag('app-config-file-status', appConfigJsonExists ? 'found' : 'not-found');
@@ -58,6 +62,8 @@ async function patchExpoAppConfig(options) {
58
62
  }
59
63
  const patched = await patchAppConfigJson(APP_CONFIG_JSON, options);
60
64
  if (!patched) {
65
+ Sentry.setTag('app-config-file-status', 'patch-error');
66
+ clack.log.error(`Unable to patch ${chalk_1.default.cyan('app.config.json')}.`);
61
67
  return await showInstructions();
62
68
  }
63
69
  }
@@ -74,6 +80,7 @@ async function patchAppConfigJson(path, options) {
74
80
  catch (error) {
75
81
  Sentry.setTag('app-config-file-status', 'json-write-error');
76
82
  clack.log.error(`Unable to write ${chalk_1.default.cyan('app.config.json')}.`);
83
+ Sentry.captureException(`Unable to write 'app.config.json'.`);
77
84
  return false;
78
85
  }
79
86
  Sentry.setTag('app-config-file-status', 'json-write-success');
@@ -94,12 +101,14 @@ function addWithSentryToAppConfigJson(appConfigContent, options) {
94
101
  if (parsedAppConfig.expo !== undefined &&
95
102
  !(0, utils_1.isPlainObject)(parsedAppConfig.expo)) {
96
103
  Sentry.setTag('app-config-file-status', 'invalid-json');
104
+ clack.log.error(`Unable to find expo in your ${chalk_1.default.cyan('app.config.json')}. Make sure it has a valid format!`);
97
105
  return null;
98
106
  }
99
107
  if (parsedAppConfig.expo &&
100
108
  parsedAppConfig.expo.plugins !== undefined &&
101
109
  !Array.isArray(parsedAppConfig.expo.plugins)) {
102
110
  Sentry.setTag('app-config-file-status', 'invalid-json');
111
+ clack.log.error(`Unable to find expo plugins in your ${chalk_1.default.cyan('app.config.json')}. Make sure it has a valid format!`);
103
112
  return null;
104
113
  }
105
114
  parsedAppConfig.expo = parsedAppConfig.expo ?? {};
@@ -117,6 +126,7 @@ function addWithSentryToAppConfigJson(appConfigContent, options) {
117
126
  catch (error) {
118
127
  Sentry.setTag('app-config-file-status', 'invalid-json');
119
128
  clack.log.error(`Unable to parse your ${chalk_1.default.cyan('app.config.json')}. Make sure it has a valid format!`);
129
+ Sentry.captureException(`Error to parsing 'app.config.json'`);
120
130
  return null;
121
131
  }
122
132
  }
@@ -1 +1 @@
1
- {"version":3,"file":"expo.js","sourceRoot":"","sources":["../../../src/react-native/expo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,uCAAyB;AACzB,2BAAyB;AAEzB,yCAA8C;AAC9C,qDAAuC;AACvC,0CAA4E;AAE5E,4CAAyC;AAE5B,QAAA,uBAAuB,GAAG,2BAA2B,CAAC;AACtD,QAAA,kCAAkC,GAAG,aAAa,CAAC;AAEnD,QAAA,2BAA2B,GAAG,YAAY,CAA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,CAAC,CAAC;AACL,CAAC;AApBD,8EAoBC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport { EOL } from 'os';\n\nimport { isPlainObject } from '@sentry/utils';\nimport * as Sentry from '@sentry/node';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\nimport { RNCliSetupConfigContent } from './react-native-wizard';\nimport { traceStep } from '../telemetry';\n\nexport const SENTRY_EXPO_PLUGIN_NAME = '@sentry/react-native/expo';\nexport const DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = 'sentry-expo';\n\nexport const SENTRY_PLUGIN_FUNCTION_NAME = 'withSentry';\n\nconst APP_CONFIG_JSON = `app.json`;\n\nexport interface AppConfigJson {\n expo?: {\n plugins?: Array<[string, undefined | Record<string, unknown>]>;\n };\n}\n\nexport function printSentryExpoMigrationOutro(): void {\n clack.outro(\n `Deprecated ${chalk.cyan(\n 'sentry-expo',\n )} package installed in your dependencies. Please follow the migration guide at ${chalk.cyan(\n 'https://docs.sentry.io/platforms/react-native/migration/sentry-expo/',\n )}`,\n );\n}\n\n/**\n * Finds app.json in the project root and add Sentry Expo `withSentry` plugin.\n */\nexport async function patchExpoAppConfig(options: RNCliSetupConfigContent) {\n function showInstructions() {\n return showCopyPasteInstructions(\n APP_CONFIG_JSON,\n getSentryAppConfigJsonCodeSnippet(options),\n 'This ensures auto upload of source maps during native app build.',\n );\n }\n\n const appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);\n\n Sentry.setTag(\n 'app-config-file-status',\n appConfigJsonExists ? 'found' : 'not-found',\n );\n if (!appConfigJsonExists) {\n return await showInstructions();\n }\n\n const patched = await patchAppConfigJson(APP_CONFIG_JSON, options);\n if (!patched) {\n return await showInstructions();\n }\n}\n\nasync function patchAppConfigJson(\n path: string,\n options: RNCliSetupConfigContent,\n): Promise<boolean> {\n const appConfigContent = (\n await fs.promises.readFile(path, { encoding: 'utf-8' })\n ).toString();\n const patchedContent = traceStep('app-config-json-patch', () =>\n addWithSentryToAppConfigJson(appConfigContent, options),\n );\n if (patchedContent === null) {\n return false;\n }\n\n try {\n await fs.promises.writeFile(path, patchedContent);\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'json-write-error');\n clack.log.error(`Unable to write ${chalk.cyan('app.config.json')}.`);\n return false;\n }\n Sentry.setTag('app-config-file-status', 'json-write-success');\n clack.log.success(\n `Added Sentry Expo plugin to ${chalk.cyan('app.config.json')}.`,\n );\n return true;\n}\n\nexport function addWithSentryToAppConfigJson(\n appConfigContent: string,\n options: RNCliSetupConfigContent,\n): string | null {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const parsedAppConfig: AppConfigJson = JSON.parse(appConfigContent);\n const includesWithSentry =\n appConfigContent.includes(SENTRY_EXPO_PLUGIN_NAME) ||\n appConfigContent.includes(DEPRECATED_SENTRY_EXPO_PLUGIN_NAME);\n\n if (includesWithSentry) {\n Sentry.setTag('app-config-file-status', 'already-patched');\n clack.log.warn(\n `Your ${chalk.cyan(\n 'app.config.json',\n )} already includes the Sentry Expo plugin.`,\n );\n return null;\n }\n\n if (\n parsedAppConfig.expo !== undefined &&\n !isPlainObject(parsedAppConfig.expo)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n return null;\n }\n if (\n parsedAppConfig.expo &&\n parsedAppConfig.expo.plugins !== undefined &&\n !Array.isArray(parsedAppConfig.expo.plugins)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n return null;\n }\n\n parsedAppConfig.expo = parsedAppConfig.expo ?? {};\n parsedAppConfig.expo.plugins = parsedAppConfig.expo.plugins ?? [];\n parsedAppConfig.expo.plugins.push([\n SENTRY_EXPO_PLUGIN_NAME,\n {\n url: options.url,\n project: options.project,\n organization: options.org,\n },\n ]);\n\n return JSON.stringify(parsedAppConfig, null, 2) + EOL;\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n clack.log.error(\n `Unable to parse your ${chalk.cyan(\n 'app.config.json',\n )}. Make sure it has a valid format!`,\n );\n return null;\n }\n}\n\nexport function getSentryAppConfigJsonCodeSnippet({\n url,\n project,\n org,\n}: Omit<RNCliSetupConfigContent, 'authToken'>) {\n return makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`{\n \"name\": \"my app\",\n \"plugins\": [\n ${plus(`[\n \"@sentry/react-native/expo\",\n {\n \"url\": \"${url}\",\n \"project\": \"${project}\",\n \"organization\": \"${org}\"\n }\n ]`)}\n ],\n}`);\n });\n}\n"]}
1
+ {"version":3,"file":"expo.js","sourceRoot":"","sources":["../../../src/react-native/expo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,uCAAyB;AACzB,2BAAyB;AAEzB,yCAA8C;AAC9C,qDAAuC;AACvC,0CAA4E;AAE5E,4CAAyC;AAE5B,QAAA,uBAAuB,GAAG,2BAA2B,CAAC;AACtD,QAAA,kCAAkC,GAAG,aAAa,CAAC;AAEnD,QAAA,2BAA2B,GAAG,YAAY,CAAC;AAExD,MAAM,eAAe,GAAG,UAAU,CAAC;AAQnC,SAAgB,6BAA6B;IAC3C,KAAK,CAAC,KAAK,CACT,cAAc,eAAK,CAAC,IAAI,CACtB,aAAa,CACd,iFAAiF,eAAK,CAAC,IAAI,CAC1F,sEAAsE,CACvE,EAAE,CACJ,CAAC;AACJ,CAAC;AARD,sEAQC;AAED;;GAEG;AACI,KAAK,UAAU,kBAAkB,CAAC,OAAgC;IACvE,SAAS,gBAAgB;QACvB,OAAO,IAAA,iCAAyB,EAAC;YAC/B,QAAQ,EAAE,eAAe;YACzB,WAAW,EAAE,iCAAiC,CAAC,OAAO,CAAC;YACvD,IAAI,EAAE,kEAAkE;SACzE,CAAC,CAAC;IACL,CAAC;IAED,MAAM,mBAAmB,GAAG,EAAE,CAAC,UAAU,CAAC,eAAe,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C;;EAEL,CAAC,CAAC;IACF,CAAC,CAAC,CAAC;AACL,CAAC;AApBD,8EAoBC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport { EOL } from 'os';\n\nimport { isPlainObject } from '@sentry/utils';\nimport * as Sentry from '@sentry/node';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\nimport { RNCliSetupConfigContent } from './react-native-wizard';\nimport { traceStep } from '../telemetry';\n\nexport const SENTRY_EXPO_PLUGIN_NAME = '@sentry/react-native/expo';\nexport const DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = 'sentry-expo';\n\nexport const SENTRY_PLUGIN_FUNCTION_NAME = 'withSentry';\n\nconst APP_CONFIG_JSON = `app.json`;\n\nexport interface AppConfigJson {\n expo?: {\n plugins?: Array<[string, undefined | Record<string, unknown>]>;\n };\n}\n\nexport function printSentryExpoMigrationOutro(): void {\n clack.outro(\n `Deprecated ${chalk.cyan(\n 'sentry-expo',\n )} package installed in your dependencies. Please follow the migration guide at ${chalk.cyan(\n 'https://docs.sentry.io/platforms/react-native/migration/sentry-expo/',\n )}`,\n );\n}\n\n/**\n * Finds app.json in the project root and add Sentry Expo `withSentry` plugin.\n */\nexport async function patchExpoAppConfig(options: RNCliSetupConfigContent) {\n function showInstructions() {\n return showCopyPasteInstructions({\n filename: APP_CONFIG_JSON,\n codeSnippet: getSentryAppConfigJsonCodeSnippet(options),\n hint: 'This ensures auto upload of source maps during native app build.',\n });\n }\n\n const appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);\n\n Sentry.setTag(\n 'app-config-file-status',\n appConfigJsonExists ? 'found' : 'not-found',\n );\n if (!appConfigJsonExists) {\n return await showInstructions();\n }\n\n const patched = await patchAppConfigJson(APP_CONFIG_JSON, options);\n if (!patched) {\n Sentry.setTag('app-config-file-status', 'patch-error');\n clack.log.error(`Unable to patch ${chalk.cyan('app.config.json')}.`);\n return await showInstructions();\n }\n}\n\nasync function patchAppConfigJson(\n path: string,\n options: RNCliSetupConfigContent,\n): Promise<boolean> {\n const appConfigContent = (\n await fs.promises.readFile(path, { encoding: 'utf-8' })\n ).toString();\n const patchedContent = traceStep('app-config-json-patch', () =>\n addWithSentryToAppConfigJson(appConfigContent, options),\n );\n if (patchedContent === null) {\n return false;\n }\n\n try {\n await fs.promises.writeFile(path, patchedContent);\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'json-write-error');\n clack.log.error(`Unable to write ${chalk.cyan('app.config.json')}.`);\n Sentry.captureException(`Unable to write 'app.config.json'.`);\n return false;\n }\n Sentry.setTag('app-config-file-status', 'json-write-success');\n clack.log.success(\n `Added Sentry Expo plugin to ${chalk.cyan('app.config.json')}.`,\n );\n return true;\n}\n\nexport function addWithSentryToAppConfigJson(\n appConfigContent: string,\n options: RNCliSetupConfigContent,\n): string | null {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const parsedAppConfig: AppConfigJson = JSON.parse(appConfigContent);\n const includesWithSentry =\n appConfigContent.includes(SENTRY_EXPO_PLUGIN_NAME) ||\n appConfigContent.includes(DEPRECATED_SENTRY_EXPO_PLUGIN_NAME);\n\n if (includesWithSentry) {\n Sentry.setTag('app-config-file-status', 'already-patched');\n clack.log.warn(\n `Your ${chalk.cyan(\n 'app.config.json',\n )} already includes the Sentry Expo plugin.`,\n );\n return null;\n }\n\n if (\n parsedAppConfig.expo !== undefined &&\n !isPlainObject(parsedAppConfig.expo)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n clack.log.error(\n `Unable to find expo in your ${chalk.cyan(\n 'app.config.json',\n )}. Make sure it has a valid format!`,\n );\n return null;\n }\n if (\n parsedAppConfig.expo &&\n parsedAppConfig.expo.plugins !== undefined &&\n !Array.isArray(parsedAppConfig.expo.plugins)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n clack.log.error(\n `Unable to find expo plugins in your ${chalk.cyan(\n 'app.config.json',\n )}. Make sure it has a valid format!`,\n );\n return null;\n }\n\n parsedAppConfig.expo = parsedAppConfig.expo ?? {};\n parsedAppConfig.expo.plugins = parsedAppConfig.expo.plugins ?? [];\n parsedAppConfig.expo.plugins.push([\n SENTRY_EXPO_PLUGIN_NAME,\n {\n url: options.url,\n project: options.project,\n organization: options.org,\n },\n ]);\n\n return JSON.stringify(parsedAppConfig, null, 2) + EOL;\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n clack.log.error(\n `Unable to parse your ${chalk.cyan(\n 'app.config.json',\n )}. Make sure it has a valid format!`,\n );\n Sentry.captureException(`Error to parsing 'app.config.json'`);\n return null;\n }\n}\n\nexport function getSentryAppConfigJsonCodeSnippet({\n url,\n project,\n org,\n}: Omit<RNCliSetupConfigContent, 'authToken'>) {\n return makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`{\n \"name\": \"my app\",\n \"plugins\": [\n ${plus(`[\n \"@sentry/react-native/expo\",\n {\n \"url\": \"${url}\",\n \"project\": \"${project}\",\n \"organization\": \"${org}\"\n }\n ]`)}\n ],\n}`);\n });\n}\n"]}
@@ -25,14 +25,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.getFirstMatchedPath = exports.APP_BUILD_GRADLE = exports.XCODE_PROJECT = void 0;
27
27
  const glob = __importStar(require("glob"));
28
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
29
+ const clack = __importStar(require("@clack/prompts"));
30
+ const Sentry = __importStar(require("@sentry/node"));
28
31
  exports.XCODE_PROJECT = 'ios/*.xcodeproj/project.pbxproj';
29
32
  exports.APP_BUILD_GRADLE = '**/app/build.gradle';
30
33
  const IGNORE_PATTERNS = ['node_modules/**', 'ios/Pods/**', '**/Pods/**'];
31
34
  function getFirstMatchedPath(pattern) {
32
- const matches = glob.sync(pattern, {
33
- ignore: IGNORE_PATTERNS,
34
- });
35
- return matches[0];
35
+ try {
36
+ const matches = glob.sync(pattern, {
37
+ ignore: IGNORE_PATTERNS,
38
+ });
39
+ return matches[0];
40
+ }
41
+ catch (error) {
42
+ clack.log.error(`Error while matching path pattern "${pattern}"`);
43
+ Sentry.captureException(`Error while matching path pattern "${pattern}"`);
44
+ return undefined;
45
+ }
36
46
  }
37
47
  exports.getFirstMatchedPath = getFirstMatchedPath;
38
48
  //# sourceMappingURL=glob.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/react-native/glob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAEhB,QAAA,aAAa,GAAG,iCAAiC,CAAC;AAClD,QAAA,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,MAAM,eAAe,GAAG,CAAC,iBAAiB,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AACzE,SAAgB,mBAAmB,CAAC,OAAe;IACjD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACjC,MAAM,EAAE,eAAe;KACxB,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAND,kDAMC","sourcesContent":["import * as glob from 'glob';\n\nexport const XCODE_PROJECT = 'ios/*.xcodeproj/project.pbxproj';\nexport const APP_BUILD_GRADLE = '**/app/build.gradle';\n\nconst IGNORE_PATTERNS = ['node_modules/**', 'ios/Pods/**', '**/Pods/**'];\nexport function getFirstMatchedPath(pattern: string): string | undefined {\n const matches = glob.sync(pattern, {\n ignore: IGNORE_PATTERNS,\n });\n\n return matches[0];\n}\n"]}
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../src/react-native/glob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,+EAA+E;AAC/E,sDAAwC;AACxC,qDAAuC;AAE1B,QAAA,aAAa,GAAG,iCAAiC,CAAC;AAClD,QAAA,gBAAgB,GAAG,qBAAqB,CAAC;AAEtD,MAAM,eAAe,GAAG,CAAC,iBAAiB,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AACzE,SAAgB,mBAAmB,CAAC,OAAe;IACjD,IAAI;QACF,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjC,MAAM,EAAE,eAAe;SACxB,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;KACnB;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,sCAAsC,OAAO,GAAG,CAAC,CAAC;QAClE,MAAM,CAAC,gBAAgB,CAAC,sCAAsC,OAAO,GAAG,CAAC,CAAC;QAC1E,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAZD,kDAYC","sourcesContent":["import * as glob from 'glob';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\n\nexport const XCODE_PROJECT = 'ios/*.xcodeproj/project.pbxproj';\nexport const APP_BUILD_GRADLE = '**/app/build.gradle';\n\nconst IGNORE_PATTERNS = ['node_modules/**', 'ios/Pods/**', '**/Pods/**'];\nexport function getFirstMatchedPath(pattern: string): string | undefined {\n try {\n const matches = glob.sync(pattern, {\n ignore: IGNORE_PATTERNS,\n });\n\n return matches[0];\n } catch (error) {\n clack.log.error(`Error while matching path pattern \"${pattern}\"`);\n Sentry.captureException(`Error while matching path pattern \"${pattern}\"`);\n return undefined;\n }\n}\n"]}
@@ -25,6 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.writeAppBuildGradle = exports.removeRNSentryGradlePlugin = exports.addRNSentryGradlePlugin = exports.doesAppBuildGradleIncludeRNSentryGradlePlugin = void 0;
27
27
  const fs = __importStar(require("fs"));
28
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
29
+ const clack = __importStar(require("@clack/prompts"));
30
+ const Sentry = __importStar(require("@sentry/node"));
28
31
  const applyFrom = `apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")`;
29
32
  function doesAppBuildGradleIncludeRNSentryGradlePlugin(content) {
30
33
  return content.includes('sentry.gradle');
@@ -39,11 +42,18 @@ function removeRNSentryGradlePlugin(content) {
39
42
  }
40
43
  exports.removeRNSentryGradlePlugin = removeRNSentryGradlePlugin;
41
44
  function writeAppBuildGradle(path, newContent) {
42
- const currentContent = fs.readFileSync(path, 'utf-8');
43
- if (newContent === currentContent) {
44
- return;
45
+ try {
46
+ const currentContent = fs.readFileSync(path, 'utf-8');
47
+ if (newContent === currentContent) {
48
+ clack.log.info(`No changes to ${path}.`);
49
+ return;
50
+ }
51
+ fs.writeFileSync(path, newContent, 'utf-8');
52
+ }
53
+ catch (error) {
54
+ clack.log.error(`Error while writing ${path}`);
55
+ Sentry.captureException('Error while writing app/build.gradle');
45
56
  }
46
- fs.writeFileSync(path, newContent, 'utf-8');
47
57
  }
48
58
  exports.writeAppBuildGradle = writeAppBuildGradle;
49
59
  //# sourceMappingURL=gradle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gradle.js","sourceRoot":"","sources":["../../../src/react-native/gradle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,MAAM,SAAS,GAAG,6IAA6I,CAAC;AAEhK,SAAgB,6CAA6C,CAC3D,OAAe;IAEf,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAJD,sGAIC;AAED,SAAgB,uBAAuB,CAAC,OAAe;IACrD,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,SAAS,KAAK,KAAK,EAAE,CAAC,CAAC;AAC7E,CAAC;AAFD,0DAEC;AAED,SAAgB,0BAA0B,CAAC,OAAe;IACxD,OAAO,OAAO,CAAC,OAAO,CAAC,+CAA+C,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAFD,gEAEC;AAED,SAAgB,mBAAmB,CAAC,IAAY,EAAE,UAAkB;IAClE,MAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,UAAU,KAAK,cAAc,EAAE;QACjC,OAAO;KACR;IAED,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAPD,kDAOC","sourcesContent":["import * as fs from 'fs';\n\nconst applyFrom = `apply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")`;\n\nexport function doesAppBuildGradleIncludeRNSentryGradlePlugin(\n content: string,\n): boolean {\n return content.includes('sentry.gradle');\n}\n\nexport function addRNSentryGradlePlugin(content: string): string {\n return content.replace(/^android {/m, (match) => `${applyFrom}\\n${match}`);\n}\n\nexport function removeRNSentryGradlePlugin(content: string): string {\n return content.replace(/^\\s*apply from:.*sentry\\.gradle.*;?\\s*?\\r?\\n/m, '');\n}\n\nexport function writeAppBuildGradle(path: string, newContent: string): void {\n const currentContent = fs.readFileSync(path, 'utf-8');\n if (newContent === currentContent) {\n return;\n }\n\n fs.writeFileSync(path, newContent, 'utf-8');\n}\n"]}
1
+ {"version":3,"file":"gradle.js","sourceRoot":"","sources":["../../../src/react-native/gradle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,+EAA+E;AAC/E,sDAAwC;AACxC,qDAAuC;AAEvC,MAAM,SAAS,GAAG,6IAA6I,CAAC;AAEhK,SAAgB,6CAA6C,CAC3D,OAAe;IAEf,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAJD,sGAIC;AAED,SAAgB,uBAAuB,CAAC,OAAe;IACrD,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,SAAS,KAAK,KAAK,EAAE,CAAC,CAAC;AAC7E,CAAC;AAFD,0DAEC;AAED,SAAgB,0BAA0B,CAAC,OAAe;IACxD,OAAO,OAAO,CAAC,OAAO,CAAC,+CAA+C,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAFD,gEAEC;AAED,SAAgB,mBAAmB,CAAC,IAAY,EAAE,UAAkB;IAClE,IAAI;QACF,MAAM,cAAc,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,UAAU,KAAK,cAAc,EAAE;YACjC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,IAAI,GAAG,CAAC,CAAC;YACzC,OAAO;SACR;QAED,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;KAC7C;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,gBAAgB,CAAC,sCAAsC,CAAC,CAAC;KACjE;AACH,CAAC;AAbD,kDAaC","sourcesContent":["import * as fs from 'fs';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport * as Sentry from '@sentry/node';\n\nconst applyFrom = `apply from: new File([\"node\", \"--print\", \"require.resolve('@sentry/react-native/package.json')\"].execute().text.trim(), \"../sentry.gradle\")`;\n\nexport function doesAppBuildGradleIncludeRNSentryGradlePlugin(\n content: string,\n): boolean {\n return content.includes('sentry.gradle');\n}\n\nexport function addRNSentryGradlePlugin(content: string): string {\n return content.replace(/^android {/m, (match) => `${applyFrom}\\n${match}`);\n}\n\nexport function removeRNSentryGradlePlugin(content: string): string {\n return content.replace(/^\\s*apply from:.*sentry\\.gradle.*;?\\s*?\\r?\\n/m, '');\n}\n\nexport function writeAppBuildGradle(path: string, newContent: string): void {\n try {\n const currentContent = fs.readFileSync(path, 'utf-8');\n if (newContent === currentContent) {\n clack.log.info(`No changes to ${path}.`);\n return;\n }\n\n fs.writeFileSync(path, newContent, 'utf-8');\n } catch (error) {\n clack.log.error(`Error while writing ${path}`);\n Sentry.captureException('Error while writing app/build.gradle');\n }\n}\n"]}
@@ -1,18 +1,23 @@
1
1
  import { ProxifiedModule } from 'magicast';
2
2
  import * as t from '@babel/types';
3
- export declare function addSentryInit({ dsn, enableSessionReplay, }: {
3
+ export declare const sessionReplaySampleRate = 0.1;
4
+ export declare const sessionReplayOnErrorSampleRate = 1;
5
+ export declare function addSentryInit({ dsn, enableSessionReplay, enableFeedbackWidget, }: {
4
6
  dsn: string;
5
7
  enableSessionReplay?: boolean;
8
+ enableFeedbackWidget?: boolean;
6
9
  }): Promise<void>;
7
- export declare function addSentryInitWithSdkImport(js: string, { dsn, enableSessionReplay, }: {
10
+ export declare function addSentryInitWithSdkImport(js: string, { dsn, enableSessionReplay, enableFeedbackWidget, }: {
8
11
  dsn: string;
9
12
  enableSessionReplay?: boolean;
13
+ enableFeedbackWidget?: boolean;
10
14
  }): string;
11
15
  export declare function doesJsCodeIncludeSdkSentryImport(js: string, { sdkPackageName }: {
12
16
  sdkPackageName: string;
13
17
  }): boolean;
14
- export declare function getSentryInitColoredCodeSnippet(dsn: string, enableSessionReplay?: boolean): string;
15
- export declare function getSentryInitPlainTextSnippet(dsn: string, enableSessionReplay?: boolean): string;
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 getSentryIntegrationsPlainTextSnippet(enableSessionReplay?: boolean, enableFeedbackWidget?: boolean): string;
16
21
  /**
17
22
  * This step should be executed after `addSentryInit`
18
23
  */