@sentry/wizard 4.4.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/README.md +23 -19
  3. package/dist/bin.js +13 -0
  4. package/dist/bin.js.map +1 -1
  5. package/dist/e2e-tests/tests/nextjs-14.test.js +4 -5
  6. package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
  7. package/dist/e2e-tests/tests/nextjs-15.test.js +3 -5
  8. package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
  9. package/dist/e2e-tests/utils/index.d.ts +1 -1
  10. package/dist/e2e-tests/utils/index.js +20 -2
  11. package/dist/e2e-tests/utils/index.js.map +1 -1
  12. package/dist/lib/Constants.d.ts +2 -0
  13. package/dist/lib/Constants.js.map +1 -1
  14. package/dist/lib/Helper/File.d.ts +1 -1
  15. package/dist/lib/Helper/File.js +1 -3
  16. package/dist/lib/Helper/File.js.map +1 -1
  17. package/dist/lib/Helper/Logging.d.ts +3 -0
  18. package/dist/lib/Helper/Logging.js +3 -0
  19. package/dist/lib/Helper/Logging.js.map +1 -1
  20. package/dist/lib/Helper/Package.d.ts +5 -3
  21. package/dist/lib/Helper/Package.js +2 -2
  22. package/dist/lib/Helper/Package.js.map +1 -1
  23. package/dist/lib/Helper/SentryCli.d.ts +20 -7
  24. package/dist/lib/Helper/SentryCli.js +21 -13
  25. package/dist/lib/Helper/SentryCli.js.map +1 -1
  26. package/dist/lib/Helper/Wizard.js +9 -5
  27. package/dist/lib/Helper/Wizard.js.map +1 -1
  28. package/dist/lib/Helper/__tests__/SentryCli.js +21 -4
  29. package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
  30. package/dist/lib/Setup.d.ts +3 -1
  31. package/dist/lib/Setup.js.map +1 -1
  32. package/dist/lib/Steps/Integrations/BaseIntegration.js +1 -2
  33. package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
  34. package/dist/lib/Steps/Integrations/Cordova.js +14 -10
  35. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  36. package/dist/lib/Steps/Integrations/Electron.d.ts +4 -1
  37. package/dist/lib/Steps/Integrations/Electron.js +1 -1
  38. package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
  39. package/dist/lib/Steps/Integrations/MobileProject.d.ts +3 -1
  40. package/dist/lib/Steps/Integrations/MobileProject.js +1 -1
  41. package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
  42. package/dist/lib/Steps/PromptForParameters.d.ts +4 -1
  43. package/dist/lib/Steps/PromptForParameters.js.map +1 -1
  44. package/dist/lib/Steps/SentryProjectSelector.d.ts +42 -1
  45. package/dist/lib/Steps/SentryProjectSelector.js +1 -1
  46. package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
  47. package/dist/lib/Steps/WaitForSentry.d.ts +3 -1
  48. package/dist/lib/Steps/WaitForSentry.js +4 -4
  49. package/dist/lib/Steps/WaitForSentry.js.map +1 -1
  50. package/dist/lib/Types.d.ts +14 -0
  51. package/dist/lib/Types.js +3 -0
  52. package/dist/lib/Types.js.map +1 -0
  53. package/dist/lib/__tests__/Env.js +6 -13
  54. package/dist/lib/__tests__/Env.js.map +1 -1
  55. package/dist/src/android/android-wizard.js +15 -12
  56. package/dist/src/android/android-wizard.js.map +1 -1
  57. package/dist/src/android/code-tools.js +1 -1
  58. package/dist/src/android/code-tools.js.map +1 -1
  59. package/dist/src/android/gradle.js +4 -4
  60. package/dist/src/android/gradle.js.map +1 -1
  61. package/dist/src/android/manifest.js +1 -1
  62. package/dist/src/android/manifest.js.map +1 -1
  63. package/dist/src/apple/apple-wizard.d.ts +2 -2
  64. package/dist/src/apple/apple-wizard.js +37 -118
  65. package/dist/src/apple/apple-wizard.js.map +1 -1
  66. package/dist/src/apple/check-installed-cli.d.ts +1 -0
  67. package/dist/src/apple/check-installed-cli.js +60 -0
  68. package/dist/src/apple/check-installed-cli.js.map +1 -0
  69. package/dist/src/apple/cocoapod.js +1 -1
  70. package/dist/src/apple/cocoapod.js.map +1 -1
  71. package/dist/src/apple/code-tools.js +1 -1
  72. package/dist/src/apple/code-tools.js.map +1 -1
  73. package/dist/src/apple/configure-fastlane.d.ts +5 -0
  74. package/dist/src/apple/configure-fastlane.js +66 -0
  75. package/dist/src/apple/configure-fastlane.js.map +1 -0
  76. package/dist/src/apple/fastlane.d.ts +1 -1
  77. package/dist/src/apple/fastlane.js +5 -5
  78. package/dist/src/apple/fastlane.js.map +1 -1
  79. package/dist/src/apple/lookup-xcode-project.d.ts +7 -0
  80. package/dist/src/apple/lookup-xcode-project.js +98 -0
  81. package/dist/src/apple/lookup-xcode-project.js.map +1 -0
  82. package/dist/src/apple/options.d.ts +4 -0
  83. package/dist/src/apple/options.js +3 -0
  84. package/dist/src/apple/options.js.map +1 -0
  85. package/dist/src/apple/search-xcode-project-at-path.d.ts +1 -0
  86. package/dist/src/apple/search-xcode-project-at-path.js +70 -0
  87. package/dist/src/apple/search-xcode-project-at-path.js.map +1 -0
  88. package/dist/src/apple/xcode-manager.js +1 -1
  89. package/dist/src/apple/xcode-manager.js.map +1 -1
  90. package/dist/src/flutter/code-tools.js +3 -3
  91. package/dist/src/flutter/code-tools.js.map +1 -1
  92. package/dist/src/flutter/flutter-wizard.js +21 -15
  93. package/dist/src/flutter/flutter-wizard.js.map +1 -1
  94. package/dist/src/flutter/templates.js +4 -4
  95. package/dist/src/flutter/templates.js.map +1 -1
  96. package/dist/src/nextjs/nextjs-wizard.js +118 -67
  97. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  98. package/dist/src/nextjs/templates.d.ts +11 -3
  99. package/dist/src/nextjs/templates.js +193 -71
  100. package/dist/src/nextjs/templates.js.map +1 -1
  101. package/dist/src/nuxt/nuxt-wizard.js +21 -16
  102. package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
  103. package/dist/src/nuxt/sdk-example.js +3 -3
  104. package/dist/src/nuxt/sdk-example.js.map +1 -1
  105. package/dist/src/nuxt/sdk-setup.js +9 -9
  106. package/dist/src/nuxt/sdk-setup.js.map +1 -1
  107. package/dist/src/nuxt/templates.js +173 -58
  108. package/dist/src/nuxt/templates.js.map +1 -1
  109. package/dist/src/nuxt/utils.js +6 -3
  110. package/dist/src/nuxt/utils.js.map +1 -1
  111. package/dist/src/react-native/expo-env-file.js +1 -1
  112. package/dist/src/react-native/expo-env-file.js.map +1 -1
  113. package/dist/src/react-native/expo-metro.js +4 -4
  114. package/dist/src/react-native/expo-metro.js.map +1 -1
  115. package/dist/src/react-native/expo.js +4 -4
  116. package/dist/src/react-native/expo.js.map +1 -1
  117. package/dist/src/react-native/javascript.js +7 -7
  118. package/dist/src/react-native/javascript.js.map +1 -1
  119. package/dist/src/react-native/metro.js +8 -8
  120. package/dist/src/react-native/metro.js.map +1 -1
  121. package/dist/src/react-native/react-native-wizard.d.ts +1 -1
  122. package/dist/src/react-native/react-native-wizard.js +36 -31
  123. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  124. package/dist/src/react-native/uninstall.js +8 -5
  125. package/dist/src/react-native/uninstall.js.map +1 -1
  126. package/dist/src/react-native/xcode.d.ts +2 -1
  127. package/dist/src/react-native/xcode.js +1 -2
  128. package/dist/src/react-native/xcode.js.map +1 -1
  129. package/dist/src/remix/codemods/handle-error.js +4 -1
  130. package/dist/src/remix/codemods/handle-error.js.map +1 -1
  131. package/dist/src/remix/remix-wizard.js +23 -18
  132. package/dist/src/remix/remix-wizard.js.map +1 -1
  133. package/dist/src/remix/sdk-example.js +163 -64
  134. package/dist/src/remix/sdk-example.js.map +1 -1
  135. package/dist/src/remix/sdk-setup.js +11 -7
  136. package/dist/src/remix/sdk-setup.js.map +1 -1
  137. package/dist/src/run.d.ts +3 -1
  138. package/dist/src/run.js +29 -9
  139. package/dist/src/run.js.map +1 -1
  140. package/dist/src/sourcemaps/sourcemaps-wizard.js +30 -28
  141. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  142. package/dist/src/sourcemaps/tools/angular.js +3 -3
  143. package/dist/src/sourcemaps/tools/angular.js.map +1 -1
  144. package/dist/src/sourcemaps/tools/create-react-app.js +3 -3
  145. package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -1
  146. package/dist/src/sourcemaps/tools/esbuild.js +6 -6
  147. package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
  148. package/dist/src/sourcemaps/tools/nextjs.js +5 -5
  149. package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
  150. package/dist/src/sourcemaps/tools/remix.js +4 -4
  151. package/dist/src/sourcemaps/tools/remix.js.map +1 -1
  152. package/dist/src/sourcemaps/tools/rollup.js +6 -6
  153. package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
  154. package/dist/src/sourcemaps/tools/sentry-cli.js +23 -16
  155. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  156. package/dist/src/sourcemaps/tools/tsc.js +6 -6
  157. package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
  158. package/dist/src/sourcemaps/tools/vite.js +12 -12
  159. package/dist/src/sourcemaps/tools/vite.js.map +1 -1
  160. package/dist/src/sourcemaps/tools/webpack.js +10 -10
  161. package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
  162. package/dist/src/sourcemaps/utils/detect-tool.js +2 -2
  163. package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
  164. package/dist/src/sourcemaps/utils/other-wizards.js +5 -5
  165. package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
  166. package/dist/src/sourcemaps/utils/sdk-version.js +7 -7
  167. package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
  168. package/dist/src/sveltekit/sdk-example.js +1 -1
  169. package/dist/src/sveltekit/sdk-example.js.map +1 -1
  170. package/dist/src/sveltekit/sdk-setup.js +15 -14
  171. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  172. package/dist/src/sveltekit/sveltekit-wizard.js +25 -20
  173. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  174. package/dist/src/sveltekit/templates.js +126 -37
  175. package/dist/src/sveltekit/templates.js.map +1 -1
  176. package/dist/src/telemetry.js +11 -0
  177. package/dist/src/telemetry.js.map +1 -1
  178. package/dist/src/utils/{clack-utils.d.ts → clack/index.d.ts} +54 -15
  179. package/dist/src/utils/{clack-utils.js → clack/index.js} +107 -24
  180. package/dist/src/utils/clack/index.js.map +1 -0
  181. package/dist/src/utils/debug.js +1 -1
  182. package/dist/src/utils/debug.js.map +1 -1
  183. package/dist/src/utils/find-files-with-extension.d.ts +1 -0
  184. package/dist/src/utils/find-files-with-extension.js +39 -0
  185. package/dist/src/utils/find-files-with-extension.js.map +1 -0
  186. package/dist/src/utils/package-manager.d.ts +6 -1
  187. package/dist/src/utils/package-manager.js +32 -27
  188. package/dist/src/utils/package-manager.js.map +1 -1
  189. package/dist/src/utils/sentrycli-utils.js +0 -1
  190. package/dist/src/utils/sentrycli-utils.js.map +1 -1
  191. package/dist/src/utils/types.d.ts +4 -0
  192. package/dist/src/utils/types.js.map +1 -1
  193. package/dist/src/version.d.ts +1 -1
  194. package/dist/src/version.js +1 -1
  195. package/dist/src/version.js.map +1 -1
  196. package/dist/test/android/code-tools.test.js +0 -1
  197. package/dist/test/android/code-tools.test.js.map +1 -1
  198. package/dist/test/apple/cocoapod.test.js +1 -1
  199. package/dist/test/apple/cocoapod.test.js.map +1 -1
  200. package/dist/test/apple/code-tools.test.js +1 -1
  201. package/dist/test/apple/code-tools.test.js.map +1 -1
  202. package/dist/test/apple/fastfile.test.js +1 -1
  203. package/dist/test/apple/fastfile.test.js.map +1 -1
  204. package/dist/test/apple/xcode-manager.test.js +26 -2
  205. package/dist/test/apple/xcode-manager.test.js.map +1 -1
  206. package/dist/test/flutter/code-tools.test.js +0 -2
  207. package/dist/test/flutter/code-tools.test.js.map +1 -1
  208. package/dist/test/flutter/templates.test.js +23 -23
  209. package/dist/test/flutter/templates.test.js.map +1 -1
  210. package/dist/test/nextjs/templates.test.js +127 -133
  211. package/dist/test/nextjs/templates.test.js.map +1 -1
  212. package/dist/test/react-native/expo-metro.test.js +1 -1
  213. package/dist/test/react-native/expo-metro.test.js.map +1 -1
  214. package/dist/test/react-native/javascript.test.js +1 -1
  215. package/dist/test/react-native/javascript.test.js.map +1 -1
  216. package/dist/test/react-native/metro.test.js +1 -1
  217. package/dist/test/react-native/metro.test.js.map +1 -1
  218. package/dist/test/sourcemaps/tools/sentry-cli.test.js +14 -3
  219. package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
  220. package/dist/test/utils/{clack-utils.test.js → clack/index.test.js} +131 -41
  221. package/dist/test/utils/clack/index.test.js.map +1 -0
  222. package/dist/test/utils/package-manager.test.d.ts +1 -0
  223. package/dist/test/utils/package-manager.test.js +29 -0
  224. package/dist/test/utils/package-manager.test.js.map +1 -0
  225. package/package.json +1 -1
  226. package/dist/src/utils/clack-utils.js.map +0 -1
  227. package/dist/test/utils/clack-utils.test.js.map +0 -1
  228. /package/dist/test/utils/{clack-utils.test.d.ts → clack/index.test.d.ts} +0 -0
@@ -69,6 +69,10 @@ Feel free to delete this file and the entire sentry route.
69
69
 
70
70
  <script>
71
71
  import * as Sentry from '@sentry/sveltekit';
72
+
73
+ // Svelte Runes (requires Svelte 5)
74
+ // let hasSentError = $state(false);
75
+ let hasSentError = false;
72
76
 
73
77
  function getSentryData() {
74
78
  Sentry.startSpan(
@@ -79,6 +83,7 @@ Feel free to delete this file and the entire sentry route.
79
83
  async () => {
80
84
  const res = await fetch('/sentry-example');
81
85
  if (!res.ok) {
86
+ hasSentError = true;
82
87
  throw new Error('Sentry Example Frontend Error');
83
88
  }
84
89
  }
@@ -86,68 +91,152 @@ Feel free to delete this file and the entire sentry route.
86
91
  }
87
92
  </script>
88
93
 
89
- <title>Sentry Onboarding</title>
94
+ <title>sentry-example-page</title>
90
95
 
91
96
  <div>
92
97
  <main>
93
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 44">
94
- <path
95
- fill="currentColor"
96
- d="M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z"
97
- />
98
+ <div class="flex-spacer"></div>
99
+ <svg height="40" width="40" fill="none" xmlns="http://www.w3.org/2000/svg">
100
+ <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"/>
98
101
  </svg>
99
- <p>
100
- Get Started with this <strong>simple Example:</strong>
101
- </p>
102
-
103
- <p>1. Send us a sample error:</p>
104
- <button type="button" on:click={getSentryData}> Throw error! </button>
102
+ <h1>
103
+ sentry-example-page
104
+ </h1>
105
105
 
106
- <p>
107
- 2. Look for the error on the
108
- <a href="${issuesPageLink}">Issues Page</a>.
106
+ <p class="description">
107
+ Click the button below, and view the sample error on the Sentry <a target="_blank" href="${issuesPageLink}">Issues Page</a>.
108
+ For more details about setting up Sentry, <a target="_blank" href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/">read our docs</a>.
109
109
  </p>
110
- <p style="margin-top: 24px;">
111
- For more information, take a look at the
112
- <a href="https://docs.sentry.io/platforms/javascript/guides/sveltekit/">
113
- Sentry SvelteKit Documentation
114
- </a>
110
+
111
+ <button
112
+ type="button"
113
+ onclick={getSentryData}
114
+ >
115
+ <span>
116
+ Throw Sample Error
117
+ </span>
118
+ </button>
119
+
120
+ {#if hasSentError}
121
+ <p class="success">
122
+ Sample error was sent to Sentry.
123
+ </p>
124
+ {:else}
125
+ <div class="success_placeholder"></div>
126
+ {/if}
127
+
128
+ <div class="flex-spacer"></div>
129
+ <p class="description">
130
+ Adblockers will prevent errors from being sent to Sentry.
115
131
  </p>
116
132
  </main>
117
133
  </div>
118
134
 
119
135
  <style>
136
+ :global(body) {
137
+ margin: 0;
138
+
139
+ @media (prefers-color-scheme: dark) {
140
+ color: #ededed;
141
+ background-color: #0a0a0a;
142
+ }
143
+ }
144
+
120
145
  main {
121
146
  display: flex;
147
+ min-height: 100vh;
122
148
  flex-direction: column;
123
149
  justify-content: center;
124
150
  align-items: center;
151
+ box-sizing: border-box;
152
+ gap: 16px;
153
+ margin: 0;
154
+ padding: 16px;
155
+ font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
125
156
  }
126
157
 
127
- svg {
128
- font-size: 4rem;
129
- margin: 14px 0;
130
- height: 1em;
158
+ h1 {
159
+ padding: 0px 4px;
160
+ border-radius: 4px;
161
+ background-color: rgba(24, 20, 35, 0.03);
162
+ font-family: monospace;
163
+ font-size: 20px;
164
+ line-height: 1.2;
165
+ }
166
+
167
+ p {
168
+ margin: 0;
169
+ font-size: 20px;
170
+ }
171
+
172
+ a {
173
+ color: #6341F0;
174
+ text-decoration: underline;
175
+ cursor: pointer;
176
+
177
+ @media (prefers-color-scheme: dark) {
178
+ color: #B3A1FF;
179
+ }
131
180
  }
132
181
 
133
182
  button {
134
- padding: 12px;
183
+ border-radius: 8px;
184
+ color: white;
135
185
  cursor: pointer;
136
- background-color: rgb(54, 45, 89);
137
- border-radius: 4px;
186
+ background-color: #553DB8;
138
187
  border: none;
139
- color: white;
140
- font-size: 1em;
141
- margin: 1em;
142
- transition: all 0.25s ease-in-out;
188
+ padding: 0;
189
+ margin-top: 4px;
190
+
191
+ & > span {
192
+ display: inline-block;
193
+ padding: 12px 16px;
194
+ border-radius: inherit;
195
+ font-size: 20px;
196
+ font-weight: bold;
197
+ line-height: 1;
198
+ background-color: #7553FF;
199
+ border: 1px solid #553DB8;
200
+ transform: translateY(-4px);
201
+ }
202
+
203
+ &:hover > span {
204
+ transform: translateY(-8px);
205
+ }
206
+
207
+ &:active > span {
208
+ transform: translateY(0);
209
+ }
143
210
  }
144
- button:hover {
145
- background-color: #8c5393;
146
- box-shadow: 4px;
147
- box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);
211
+
212
+ .description {
213
+ text-align: center;
214
+ color: #6E6C75;
215
+ max-width: 500px;
216
+ line-height: 1.5;
217
+ font-size: 20px;
218
+
219
+ @media (prefers-color-scheme: dark) {
220
+ color: #A49FB5;
221
+ }
148
222
  }
149
- button:active {
150
- background-color: #c73852;
223
+
224
+ .flex-spacer {
225
+ flex: 1;
226
+ }
227
+
228
+ .success {
229
+ padding: 12px 16px;
230
+ border-radius: 8px;
231
+ font-size: 20px;
232
+ line-height: 1;
233
+ background-color: #00F261;
234
+ border: 1px solid #00BF4D;
235
+ color: #181423;
236
+ }
237
+
238
+ .success_placeholder {
239
+ height: 46px;
151
240
  }
152
241
  </style>
153
242
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/sveltekit/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,sBAAsB,CACpC,GAAW,EACX,gBAGC;IAED,OAAO;;;;UAIC,GAAG;EAEX,gBAAgB,CAAC,WAAW;QAC1B,CAAC,CAAC;;CAEL;QACG,CAAC,CAAC,EACN;EAEE,gBAAgB,CAAC,MAAM;QACrB,CAAC,CAAC;;;;;;;;;uCASiC;QACnC,CAAC,CAAC,EACN;;;;;CAKC,CAAC;AACF,CAAC;AAtCD,wDAsCC;AAED,SAAgB,sBAAsB,CACpC,GAAW,EACX,gBAGC;IAED,OAAO;;;;;UAKC,GAAG;EAEX,gBAAgB,CAAC,WAAW;QAC1B,CAAC,CAAC;;CAEL;QACG,CAAC,CAAC,EACN;;;;;;;;;;CAUC,CAAC;AACF,CAAC;AA9BD,wDA8BC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CAAC,OAK1C;IACC,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,iBAAiB,OAAO,CAAC,OAAO,oBAAoB,OAAO,CAAC,SAAS,EAAE;QACvF,CAAC,CAAC,WAAW,OAAO,CAAC,OAAO,8BAA8B,OAAO,CAAC,SAAS,EAAE,CAAC;IAEhF,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2CQ,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6C9B,CAAC;AACF,CAAC;AAnGD,gEAmGC;AAED,SAAgB,wBAAwB;IACtC,OAAO;;;;;;CAMR,CAAC;AACF,CAAC;AARD,4DAQC","sourcesContent":["export function getClientHooksTemplate(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n return `import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n${\n selectedFeatures.performance\n ? `\n tracesSampleRate: 1.0,\n`\n : ''\n}\n${\n selectedFeatures.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: [replayIntegration()],`\n : ''\n}\n});\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\nexport function getServerHooksTemplate(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n return `import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n${\n selectedFeatures.performance\n ? `\n tracesSampleRate: 1.0,\n`\n : ''\n}\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});\n\n// If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\n/**\n * +page.svelte with Sentry example\n */\nexport function getSentryExampleSveltePage(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n}) {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.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 and the entire sentry route.\n-->\n\n<script>\n import * as Sentry from '@sentry/sveltekit';\n\n function getSentryData() {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const res = await fetch('/sentry-example');\n if (!res.ok) {\n throw new Error('Sentry Example Frontend Error');\n }\n }\n );\n }\n</script>\n\n<title>Sentry Onboarding</title>\n\n<div>\n <main>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 200 44\">\n <path\n fill=\"currentColor\"\n d=\"M124.32,28.28,109.56,9.22h-3.68V34.77h3.73V15.19l15.18,19.58h3.26V9.22h-3.73ZM87.15,23.54h13.23V20.22H87.14V12.53h14.93V9.21H83.34V34.77h18.92V31.45H87.14ZM71.59,20.3h0C66.44,19.06,65,18.08,65,15.7c0-2.14,1.89-3.59,4.71-3.59a12.06,12.06,0,0,1,7.07,2.55l2-2.83a14.1,14.1,0,0,0-9-3c-5.06,0-8.59,3-8.59,7.27,0,4.6,3,6.19,8.46,7.52C74.51,24.74,76,25.78,76,28.11s-2,3.77-5.09,3.77a12.34,12.34,0,0,1-8.3-3.26l-2.25,2.69a15.94,15.94,0,0,0,10.42,3.85c5.48,0,9-2.95,9-7.51C79.75,23.79,77.47,21.72,71.59,20.3ZM195.7,9.22l-7.69,12-7.64-12h-4.46L186,24.67V34.78h3.84V24.55L200,9.22Zm-64.63,3.46h8.37v22.1h3.84V12.68h8.37V9.22H131.08ZM169.41,24.8c3.86-1.07,6-3.77,6-7.63,0-4.91-3.59-8-9.38-8H154.67V34.76h3.8V25.58h6.45l6.48,9.2h4.44l-7-9.82Zm-10.95-2.5V12.6h7.17c3.74,0,5.88,1.77,5.88,4.84s-2.29,4.86-5.84,4.86Z M29,2.26a4.67,4.67,0,0,0-8,0L14.42,13.53A32.21,32.21,0,0,1,32.17,40.19H27.55A27.68,27.68,0,0,0,12.09,17.47L6,28a15.92,15.92,0,0,1,9.23,12.17H4.62A.76.76,0,0,1,4,39.06l2.94-5a10.74,10.74,0,0,0-3.36-1.9l-2.91,5a4.54,4.54,0,0,0,1.69,6.24A4.66,4.66,0,0,0,4.62,44H19.15a19.4,19.4,0,0,0-8-17.31l2.31-4A23.87,23.87,0,0,1,23.76,44H36.07a35.88,35.88,0,0,0-16.41-31.8l4.67-8a.77.77,0,0,1,1.05-.27c.53.29,20.29,34.77,20.66,35.17a.76.76,0,0,1-.68,1.13H40.6q.09,1.91,0,3.81h4.78A4.59,4.59,0,0,0,50,39.43a4.49,4.49,0,0,0-.62-2.28Z\"\n />\n </svg>\n <p>\n Get Started with this <strong>simple Example:</strong>\n </p>\n\n <p>1. Send us a sample error:</p>\n <button type=\"button\" on:click={getSentryData}> Throw error! </button>\n\n <p>\n 2. Look for the error on the\n <a href=\"${issuesPageLink}\">Issues Page</a>.\n </p>\n <p style=\"margin-top: 24px;\">\n For more information, take a look at the\n <a href=\"https://docs.sentry.io/platforms/javascript/guides/sveltekit/\">\n Sentry SvelteKit Documentation\n </a>\n </p>\n </main>\n</div>\n\n<style>\n main {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n svg {\n font-size: 4rem;\n margin: 14px 0;\n height: 1em;\n }\n\n button {\n padding: 12px;\n cursor: pointer;\n background-color: rgb(54, 45, 89);\n border-radius: 4px;\n border: none;\n color: white;\n font-size: 1em;\n margin: 1em;\n transition: all 0.25s ease-in-out;\n }\n button:hover {\n background-color: #8c5393;\n box-shadow: 4px;\n box-shadow: 0px 0px 15px 2px rgba(140, 83, 147, 0.5);\n }\n button:active {\n background-color: #c73852;\n }\n</style>\n`;\n}\n\nexport function getSentryExampleApiRoute() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file and the entire sentry route.\n\nexport const GET = async () => {\n throw new Error(\"Sentry Example API Route Error\");\n};\n`;\n}\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/sveltekit/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,sBAAsB,CACpC,GAAW,EACX,gBAGC;IAED,OAAO;;;;UAIC,GAAG;EAEX,gBAAgB,CAAC,WAAW;QAC1B,CAAC,CAAC;;CAEL;QACG,CAAC,CAAC,EACN;EAEE,gBAAgB,CAAC,MAAM;QACrB,CAAC,CAAC;;;;;;;;;uCASiC;QACnC,CAAC,CAAC,EACN;;;;;CAKC,CAAC;AACF,CAAC;AAtCD,wDAsCC;AAED,SAAgB,sBAAsB,CACpC,GAAW,EACX,gBAGC;IAED,OAAO;;;;;UAKC,GAAG;EAEX,gBAAgB,CAAC,WAAW;QAC1B,CAAC,CAAC;;CAEL;QACG,CAAC,CAAC,EACN;;;;;;;;;;CAUC,CAAC;AACF,CAAC;AA9BD,wDA8BC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CAAC,OAK1C;IACC,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU;QACvC,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,iBAAiB,OAAO,CAAC,OAAO,oBAAoB,OAAO,CAAC,SAAS,EAAE;QACvF,CAAC,CAAC,WAAW,OAAO,CAAC,OAAO,8BAA8B,OAAO,CAAC,SAAS,EAAE,CAAC;IAEhF,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iGA0CwF,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuI9G,CAAC;AACF,CAAC;AA5LD,gEA4LC;AAED,SAAgB,wBAAwB;IACtC,OAAO;;;;;;CAMR,CAAC;AACF,CAAC;AARD,4DAQC","sourcesContent":["export function getClientHooksTemplate(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n return `import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n${\n selectedFeatures.performance\n ? `\n tracesSampleRate: 1.0,\n`\n : ''\n}\n${\n selectedFeatures.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: [replayIntegration()],`\n : ''\n}\n});\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\nexport function getServerHooksTemplate(\n dsn: string,\n selectedFeatures: {\n performance: boolean;\n replay: boolean;\n },\n) {\n return `import { sequence } from \"@sveltejs/kit/hooks\";\nimport { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\nimport * as Sentry from '@sentry/sveltekit';\n\nSentry.init({\n dsn: '${dsn}',\n${\n selectedFeatures.performance\n ? `\n tracesSampleRate: 1.0,\n`\n : ''\n}\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});\n\n// If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\nexport const handle = sequence(sentryHandle());\n\n// If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\nexport const handleError = handleErrorWithSentry();\n`;\n}\n\n/**\n * +page.svelte with Sentry example\n */\nexport function getSentryExampleSveltePage(options: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n}) {\n const issuesPageLink = options.selfHosted\n ? `${options.url}organizations/${options.orgSlug}/issues/?project=${options.projectId}`\n : `https://${options.orgSlug}.sentry.io/issues/?project=${options.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 and the entire sentry route.\n-->\n\n<script>\n import * as Sentry from '@sentry/sveltekit';\n \n // Svelte Runes (requires Svelte 5)\n // let hasSentError = $state(false);\n let hasSentError = false;\n\n function getSentryData() {\n Sentry.startSpan(\n {\n name: 'Example Frontend Span',\n op: 'test'\n },\n async () => {\n const res = await fetch('/sentry-example');\n if (!res.ok) {\n hasSentError = true;\n throw new Error('Sentry Example Frontend Error');\n }\n }\n );\n }\n</script>\n\n<title>sentry-example-page</title>\n\n<div>\n <main>\n <div class=\"flex-spacer\"></div>\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/sveltekit/\">read our docs</a>.\n </p>\n\n <button\n type=\"button\"\n onclick={getSentryData}\n >\n <span>\n Throw Sample Error\n </span>\n </button>\n\n {#if hasSentError}\n <p class=\"success\">\n Sample error was sent to Sentry.\n </p>\n {:else}\n <div class=\"success_placeholder\"></div>\n {/if}\n\n <div class=\"flex-spacer\"></div> \n <p class=\"description\">\n Adblockers will prevent errors from being sent to Sentry.\n </p>\n </main>\n</div>\n\n<style>\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 flex-direction: column;\n justify-content: center;\n align-items: center;\n box-sizing: border-box;\n gap: 16px;\n margin: 0;\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 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 getSentryExampleApiRoute() {\n return `// This is just a very simple API route that throws an example error.\n// Feel free to delete this file and the entire sentry route.\n\nexport const GET = async () => {\n throw new Error(\"Sentry Example API Route Error\");\n};\n`;\n}\n"]}
@@ -69,6 +69,17 @@ function createSentryInstance(enabled, integration) {
69
69
  hub.setTag('integration', integration);
70
70
  hub.setTag('node', process.version);
71
71
  hub.setTag('platform', process.platform);
72
+ try {
73
+ // The `require` call here is fine because the binary node versions
74
+ // support `require` and we try/catch the call anyway for any other
75
+ // version of node.
76
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
77
+ const sea = require('node:sea');
78
+ hub.setTag('is_binary', sea.isSea());
79
+ }
80
+ catch {
81
+ hub.setTag('is_binary', false);
82
+ }
72
83
  return { sentryHub: hub, sentryClient: client };
73
84
  }
74
85
  function traceStep(step, callback) {
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/telemetry.ts"],"names":[],"mappings":";;;AAAA,uCAYsB;AAEtB,uCAA2C;AAEpC,KAAK,UAAU,aAAa,CACjC,OAIC,EACD,QAA8B;IAE9B,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,oBAAoB,CACtD,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,WAAW,CACpB,CAAC;IAEF,IAAA,eAAQ,EAAC,SAAS,CAAC,CAAC;IAEpB,MAAM,aAAa,GAAG,SAAS,CAAC,YAAY,EAAE,CAAC;IAC/C,SAAS,CAAC,cAAc,EAAE,CAAC;IAE3B,8BAA8B;IAC9B,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IACtE,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9D,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAE5D,IAAI;QACF,OAAO,MAAM,IAAA,gBAAS,EACpB;YACE,IAAI,EAAE,yBAAyB;YAC/B,MAAM,EAAE,IAAI;YACZ,EAAE,EAAE,aAAa;SAClB,EACD,KAAK,IAAI,EAAE;YACT,cAAc,CAAC,OAAO,CAAC,CAAC;YACxB,MAAM,GAAG,GAAG,MAAM,IAAA,0BAAmB,EAAC,QAAQ,CAAC,CAAC;YAChD,cAAc,CAAC,UAAU,CAAC,CAAC;YAE3B,OAAO,GAAG,CAAC;QACb,CAAC,CACF,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,SAAS,CAAC,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;QAC7D,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC;QACjC,MAAM,CAAC,CAAC;KACT;YAAS;QACR,SAAS,CAAC,UAAU,EAAE,CAAC;QACvB,MAAM,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE;YAC7C,sDAAsD;QACxD,CAAC,CAAC,CAAC;QACH,MAAM,IAAA,YAAK,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE;YAChC,sDAAsD;QACxD,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAnDD,sCAmDC;AAED,SAAS,oBAAoB,CAAC,OAAgB,EAAE,WAAmB;IACjE,MAAM,MAAM,GAAG,IAAI,iBAAU,CAAC;QAC5B,GAAG,EAAE,+EAA+E;QACpF,OAAO,EAAE,OAAO;QAEhB,WAAW,EAAE,cAAc,WAAW,EAAE;QAExC,gBAAgB,EAAE,CAAC;QACnB,UAAU,EAAE,CAAC;QAEb,OAAO,EAAE,wBAAc;QACvB,YAAY,EAAE,CAAC,IAAI,mBAAY,CAAC,IAAI,EAAE,CAAC;QACvC,uBAAuB,EAAE,CAAC,wBAAwB,CAAC;QAEnD,WAAW,EAAE,yBAAkB;QAE/B,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAE;YAC/B,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,gCAAgC;YAC1D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBAC7C,OAAO,SAAS,CAAC,UAAU,CAAC;YAC9B,CAAC,CAAC,CAAC;YAEH,OAAO,KAAK,CAAC,WAAW,CAAC,CAAC,gCAAgC;YAC1D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,SAAS,EAAE,wBAAiB;QAE5B,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,IAAI,UAAG,CAAC,MAAM,CAAC,CAAC;IAE5B,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IACvC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEzC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;AAClD,CAAC;AAED,SAAgB,SAAS,CACvB,IAAY,EACZ,QAAuC;IAEvC,cAAc,CAAC,IAAI,CAAC,CAAC;IACrB,OAAO,IAAA,gBAAS,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAChF,CAAC;AAND,8BAMC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,IAAA,aAAM,EAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAC3B,CAAC;AAFD,wCAEC","sourcesContent":["import {\n Hub,\n Integrations,\n NodeClient,\n type Span,\n defaultStackParser,\n flush,\n makeMain,\n makeNodeTransport,\n runWithAsyncContext,\n setTag,\n startSpan,\n} from '@sentry/node';\nimport type { WizardOptions } from './utils/types';\nimport { WIZARD_VERSION } from './version';\n\nexport async function withTelemetry<F>(\n options: {\n enabled: boolean;\n integration: string;\n wizardOptions: WizardOptions;\n },\n callback: () => F | Promise<F>,\n): Promise<F> {\n const { sentryHub, sentryClient } = createSentryInstance(\n options.enabled,\n options.integration,\n );\n\n makeMain(sentryHub);\n\n const sentrySession = sentryHub.startSession();\n sentryHub.captureSession();\n\n // Set tag for passed CLI args\n sentryHub.setTag('args.project', !!options.wizardOptions.projectSlug);\n sentryHub.setTag('args.org', !!options.wizardOptions.orgSlug);\n sentryHub.setTag('args.saas', !!options.wizardOptions.saas);\n\n try {\n return await startSpan(\n {\n name: 'sentry-wizard-execution',\n status: 'ok',\n op: 'wizard.flow',\n },\n async () => {\n updateProgress('start');\n const res = await runWithAsyncContext(callback);\n updateProgress('finished');\n\n return res;\n },\n );\n } catch (e) {\n sentryHub.captureException('Error during wizard execution.');\n sentrySession.status = 'crashed';\n throw e;\n } finally {\n sentryHub.endSession();\n await sentryClient.flush(3000).then(null, () => {\n // If telemetry flushing fails we generally don't care\n });\n await flush(3000).then(null, () => {\n // If telemetry flushing fails we generally don't care\n });\n }\n}\n\nfunction createSentryInstance(enabled: boolean, integration: string) {\n const client = new NodeClient({\n dsn: 'https://8871d3ff64814ed8960c96d1fcc98a27@o1.ingest.sentry.io/4505425820712960',\n enabled: enabled,\n\n environment: `production-${integration}`,\n\n tracesSampleRate: 1,\n sampleRate: 1,\n\n release: WIZARD_VERSION,\n integrations: [new Integrations.Http()],\n tracePropagationTargets: [/^https:\\/\\/sentry.io\\//],\n\n stackParser: defaultStackParser,\n\n beforeSendTransaction: (event) => {\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n beforeSend: (event) => {\n event.exception?.values?.forEach((exception) => {\n delete exception.stacktrace;\n });\n\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n transport: makeNodeTransport,\n\n debug: true,\n });\n\n const hub = new Hub(client);\n\n hub.setTag('integration', integration);\n hub.setTag('node', process.version);\n hub.setTag('platform', process.platform);\n\n return { sentryHub: hub, sentryClient: client };\n}\n\nexport function traceStep<T>(\n step: string,\n callback: (span: Span | undefined) => T,\n): T {\n updateProgress(step);\n return startSpan({ name: step, op: 'wizard.step' }, (span) => callback(span));\n}\n\nexport function updateProgress(step: string) {\n setTag('progress', step);\n}\n"]}
1
+ {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/telemetry.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n Hub,\n Integrations,\n NodeClient,\n type Span,\n defaultStackParser,\n flush,\n makeMain,\n makeNodeTransport,\n runWithAsyncContext,\n setTag,\n startSpan,\n} from '@sentry/node';\nimport type { WizardOptions } from './utils/types';\nimport { WIZARD_VERSION } from './version';\n\nexport async function withTelemetry<F>(\n options: {\n enabled: boolean;\n integration: string;\n wizardOptions: WizardOptions;\n },\n callback: () => F | Promise<F>,\n): Promise<F> {\n const { sentryHub, sentryClient } = createSentryInstance(\n options.enabled,\n options.integration,\n );\n\n makeMain(sentryHub);\n\n const sentrySession = sentryHub.startSession();\n sentryHub.captureSession();\n\n // Set tag for passed CLI args\n sentryHub.setTag('args.project', !!options.wizardOptions.projectSlug);\n sentryHub.setTag('args.org', !!options.wizardOptions.orgSlug);\n sentryHub.setTag('args.saas', !!options.wizardOptions.saas);\n\n try {\n return await startSpan(\n {\n name: 'sentry-wizard-execution',\n status: 'ok',\n op: 'wizard.flow',\n },\n async () => {\n updateProgress('start');\n const res = await runWithAsyncContext(callback);\n updateProgress('finished');\n\n return res;\n },\n );\n } catch (e) {\n sentryHub.captureException('Error during wizard execution.');\n sentrySession.status = 'crashed';\n throw e;\n } finally {\n sentryHub.endSession();\n await sentryClient.flush(3000).then(null, () => {\n // If telemetry flushing fails we generally don't care\n });\n await flush(3000).then(null, () => {\n // If telemetry flushing fails we generally don't care\n });\n }\n}\n\nfunction createSentryInstance(enabled: boolean, integration: string) {\n const client = new NodeClient({\n dsn: 'https://8871d3ff64814ed8960c96d1fcc98a27@o1.ingest.sentry.io/4505425820712960',\n enabled: enabled,\n\n environment: `production-${integration}`,\n\n tracesSampleRate: 1,\n sampleRate: 1,\n\n release: WIZARD_VERSION,\n integrations: [new Integrations.Http()],\n tracePropagationTargets: [/^https:\\/\\/sentry.io\\//],\n\n stackParser: defaultStackParser,\n\n beforeSendTransaction: (event) => {\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n beforeSend: (event) => {\n event.exception?.values?.forEach((exception) => {\n delete exception.stacktrace;\n });\n\n delete event.server_name; // Server name might contain PII\n return event;\n },\n\n transport: makeNodeTransport,\n\n debug: true,\n });\n\n const hub = new Hub(client);\n\n hub.setTag('integration', integration);\n hub.setTag('node', process.version);\n hub.setTag('platform', process.platform);\n\n try {\n // The `require` call here is fine because the binary node versions\n // support `require` and we try/catch the call anyway for any other\n // version of node.\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const sea = require('node:sea') as { isSea: () => boolean };\n hub.setTag('is_binary', sea.isSea());\n } catch {\n hub.setTag('is_binary', false);\n }\n\n return { sentryHub: hub, sentryClient: client };\n}\n\nexport function traceStep<T>(\n step: string,\n callback: (span: Span | undefined) => T,\n): T {\n updateProgress(step);\n return startSpan({ name: step, op: 'wizard.step' }, (span) => callback(span));\n}\n\nexport function updateProgress(step: string) {\n setTag('progress', step);\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { type PackageDotJson } from './package-json';
2
- import { type PackageManager } from './package-manager';
3
- import type { Feature, SentryProjectData, WizardOptions } from './types';
1
+ import { type PackageDotJson } from '../package-json';
2
+ import { type PackageManager } from '../package-manager';
3
+ import type { Feature, SentryProjectData, WizardOptions } from '../types';
4
4
  export declare const SENTRY_DOT_ENV_FILE = ".env.sentry-build-plugin";
5
5
  export declare const SENTRY_CLI_RC_FILE = ".sentryclirc";
6
6
  export declare const SENTRY_PROPERTIES_FILE = "sentry.properties";
@@ -37,8 +37,25 @@ export declare function printWelcome(options: {
37
37
  message?: string;
38
38
  telemetryEnabled?: boolean;
39
39
  }): void;
40
- export declare function confirmContinueIfNoOrDirtyGitRepo(): Promise<void>;
41
- export declare function isInGitRepo(): boolean;
40
+ /**
41
+ * Confirms if the user wants to continue with the wizard if the project is not a git repository.
42
+ *
43
+ * @param options.ignoreGitChanges If true, the wizard will not check if the project is a git repository.
44
+ * @param options.cwd The directory of the project. If undefined, the current process working directory will be used.
45
+ */
46
+ export declare function confirmContinueIfNoOrDirtyGitRepo(options: {
47
+ ignoreGitChanges: boolean | undefined;
48
+ cwd: string | undefined;
49
+ }): Promise<void>;
50
+ /**
51
+ * Checks if the current working directory is a git repository.
52
+ *
53
+ * @param cwd The directory of the project. If undefined, the current process working directory will be used.
54
+ * @returns true if the current working directory is a git repository, false otherwise.
55
+ */
56
+ export declare function isInGitRepo({ cwd }: {
57
+ cwd: string | undefined;
58
+ }): boolean;
42
59
  export declare function getUncommittedOrUntrackedFiles(): string[];
43
60
  export declare function askToInstallSentryCLI(): Promise<boolean>;
44
61
  export declare function askForItemSelection(items: string[], message: string): Promise<{
@@ -52,13 +69,7 @@ export declare function confirmContinueIfPackageVersionNotSupported({ packageId,
52
69
  acceptableVersions: string;
53
70
  note?: string;
54
71
  }): Promise<void>;
55
- /**
56
- * Installs or updates a package with the user's package manager.
57
- *
58
- * IMPORTANT: This function modifies the `package.json`! Be sure to re-read
59
- * it if you make additional modifications to it after calling this function!
60
- */
61
- export declare function installPackage({ packageName, alreadyInstalled, askBeforeUpdating, packageNameDisplayLabel, packageManager, forceInstall, }: {
72
+ type InstallPackageOptions = {
62
73
  /** The string that is passed to the package manager CLI as identifier to install (e.g. `@sentry/nextjs`, or `@sentry/nextjs@^8`) */
63
74
  packageName: string;
64
75
  alreadyInstalled: boolean;
@@ -68,12 +79,26 @@ export declare function installPackage({ packageName, alreadyInstalled, askBefor
68
79
  packageManager?: PackageManager;
69
80
  /** Add force install flag to command to skip install precondition fails */
70
81
  forceInstall?: boolean;
71
- }): Promise<{
82
+ };
83
+ /**
84
+ * Installs or updates a package with the user's package manager.
85
+ *
86
+ * IMPORTANT: This function modifies the `package.json`! Be sure to re-read
87
+ * it if you make additional modifications to it after calling this function!
88
+ */
89
+ export declare function installPackage({ packageName, alreadyInstalled, askBeforeUpdating, packageNameDisplayLabel, packageManager, forceInstall, }: InstallPackageOptions): Promise<{
72
90
  packageManager?: PackageManager;
73
91
  }>;
74
92
  export declare function addSentryCliConfig({ authToken, org, project, url }: CliSetupConfigContent, setupConfig?: CliSetupConfig): Promise<void>;
75
93
  export declare function addDotEnvSentryBuildPluginFile(authToken: string): Promise<void>;
76
- export declare function runPrettierIfInstalled(): Promise<void>;
94
+ /**
95
+ * Runs prettier on the changed or untracked files in the project.
96
+ *
97
+ * @param cwd The directory of the project. If undefined, the current process working directory will be used.
98
+ */
99
+ export declare function runPrettierIfInstalled({ cwd, }: {
100
+ cwd: string | undefined;
101
+ }): Promise<void>;
77
102
  /**
78
103
  * Checks if @param packageId is listed as a dependency in @param packageJson.
79
104
  * If not, it will ask users if they want to continue without the package.
@@ -87,7 +112,21 @@ export declare function runPrettierIfInstalled(): Promise<void>;
87
112
  export declare function ensurePackageIsInstalled(packageJson: PackageDotJson, packageId: string, packageName: string): Promise<void>;
88
113
  export declare function getPackageDotJson(): Promise<PackageDotJson>;
89
114
  export declare function updatePackageDotJson(packageDotJson: PackageDotJson): Promise<void>;
90
- export declare function getPackageManager(): Promise<PackageManager>;
115
+ /**
116
+ * Use this function to get the used JS Package manager.
117
+ *
118
+ * This function:
119
+ * - attempts to auto-detect the used package manager and return it
120
+ * - if unsuccessful, returns the passed fallback package manager
121
+ * - if no fallback is passed, it asks the user to select a package manager
122
+ *
123
+ * The result is cached on the first invocation to avoid asking the user multiple times.
124
+ *
125
+ * @param fallback the package manager to use if auto-detection fails and you don't want to
126
+ * ask the user. This is useful in cases where asking users would be too intrusive/low in value
127
+ * and where it's okay to fall back to a default package manager. Use this with caution.
128
+ */
129
+ export declare function getPackageManager(fallback?: PackageManager): Promise<PackageManager>;
91
130
  export declare function isUsingTypeScript(): boolean;
92
131
  /**
93
132
  * Checks if we already got project data from a previous wizard invocation.
@@ -33,18 +33,18 @@ const os = __importStar(require("node:os"));
33
33
  const node_path_1 = require("node:path");
34
34
  const node_timers_1 = require("node:timers");
35
35
  const node_url_1 = require("node:url");
36
- // @ts-ignore - clack is ESM and TS complains about that. It works though
36
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
37
37
  const clack = __importStar(require("@clack/prompts"));
38
38
  const Sentry = __importStar(require("@sentry/node"));
39
39
  const axios_1 = __importDefault(require("axios"));
40
40
  const chalk_1 = __importDefault(require("chalk"));
41
41
  const opn_1 = __importDefault(require("opn"));
42
- const telemetry_1 = require("../telemetry");
43
- const debug_1 = require("./debug");
44
- const package_json_1 = require("./package-json");
45
- const package_manager_1 = require("./package-manager");
46
- const semver_1 = require("./semver");
47
- const version_1 = require("../version");
42
+ const telemetry_1 = require("../../telemetry");
43
+ const version_1 = require("../../version");
44
+ const debug_1 = require("../debug");
45
+ const package_json_1 = require("../package-json");
46
+ const package_manager_1 = require("../package-manager");
47
+ const semver_1 = require("../semver");
48
48
  exports.SENTRY_DOT_ENV_FILE = '.env.sentry-build-plugin';
49
49
  exports.SENTRY_CLI_RC_FILE = '.sentryclirc';
50
50
  exports.SENTRY_PROPERTIES_FILE = 'sentry.properties';
@@ -146,9 +146,18 @@ You can turn this off at any time by running ${chalk_1.default.cyanBright('sentr
146
146
  clack.note(welcomeText);
147
147
  }
148
148
  exports.printWelcome = printWelcome;
149
- async function confirmContinueIfNoOrDirtyGitRepo() {
149
+ /**
150
+ * Confirms if the user wants to continue with the wizard if the project is not a git repository.
151
+ *
152
+ * @param options.ignoreGitChanges If true, the wizard will not check if the project is a git repository.
153
+ * @param options.cwd The directory of the project. If undefined, the current process working directory will be used.
154
+ */
155
+ async function confirmContinueIfNoOrDirtyGitRepo(options) {
150
156
  return (0, telemetry_1.traceStep)('check-git-status', async () => {
151
- if (!isInGitRepo()) {
157
+ if (!isInGitRepo({
158
+ cwd: options.cwd,
159
+ }) &&
160
+ options.ignoreGitChanges !== true) {
152
161
  const continueWithoutGit = await abortIfCancelled(clack.confirm({
153
162
  message: 'You are not inside a git repository. The wizard will create and update files. Do you want to continue anyway?',
154
163
  }));
@@ -160,7 +169,8 @@ async function confirmContinueIfNoOrDirtyGitRepo() {
160
169
  return;
161
170
  }
162
171
  const uncommittedOrUntrackedFiles = getUncommittedOrUntrackedFiles();
163
- if (uncommittedOrUntrackedFiles.length) {
172
+ if (uncommittedOrUntrackedFiles.length &&
173
+ options.ignoreGitChanges !== true) {
164
174
  clack.log.warn(`You have uncommitted or untracked files in your repo:
165
175
 
166
176
  ${uncommittedOrUntrackedFiles.join('\n')}
@@ -177,10 +187,17 @@ The wizard will create and update files.`);
177
187
  });
178
188
  }
179
189
  exports.confirmContinueIfNoOrDirtyGitRepo = confirmContinueIfNoOrDirtyGitRepo;
180
- function isInGitRepo() {
190
+ /**
191
+ * Checks if the current working directory is a git repository.
192
+ *
193
+ * @param cwd The directory of the project. If undefined, the current process working directory will be used.
194
+ * @returns true if the current working directory is a git repository, false otherwise.
195
+ */
196
+ function isInGitRepo({ cwd }) {
181
197
  try {
182
198
  childProcess.execSync('git rev-parse --is-inside-work-tree', {
183
199
  stdio: 'ignore',
200
+ cwd: cwd,
184
201
  });
185
202
  return true;
186
203
  }
@@ -277,14 +294,47 @@ async function installPackage({ packageName, alreadyInstalled, askBeforeUpdating
277
294
  sdkInstallSpinner.start(`${alreadyInstalled ? 'Updating' : 'Installing'} ${chalk_1.default.bold.cyan(packageNameDisplayLabel ?? packageName)} with ${chalk_1.default.bold(pkgManager.label)}.`);
278
295
  try {
279
296
  await new Promise((resolve, reject) => {
280
- childProcess.exec(`${pkgManager.installCommand} ${packageName} ${pkgManager.flags} ${forceInstall ? pkgManager.forceInstallFlag : ''}`, (err, stdout, stderr) => {
281
- if (err) {
282
- // Write a log file so we can better troubleshoot issues
283
- fs.writeFileSync((0, node_path_1.join)(process.cwd(), `sentry-wizard-installation-error-${Date.now()}.log`), JSON.stringify({
284
- stdout,
285
- stderr,
286
- }), { encoding: 'utf8' });
287
- reject(err);
297
+ const installArgs = [
298
+ pkgManager.installCommand,
299
+ packageName,
300
+ ...(pkgManager.flags ? pkgManager.flags.split(' ') : []),
301
+ ...(forceInstall ? [pkgManager.forceInstallFlag] : []),
302
+ ];
303
+ const stringifiedInstallCmd = `${pkgManager.name} ${installArgs.join(' ')}`;
304
+ function handleErrorAndReject(code, cause, type) {
305
+ // Write a log file so we can better troubleshoot issues
306
+ fs.writeFileSync((0, node_path_1.join)(process.cwd(), `sentry-wizard-installation-error-${Date.now()}.log`), stderr, { encoding: 'utf8' });
307
+ Sentry.captureException('Package Installation Error', {
308
+ tags: {
309
+ 'install-command': stringifiedInstallCmd,
310
+ 'package-manager': pkgManager.name,
311
+ 'package-name': packageName,
312
+ 'error-type': type,
313
+ },
314
+ });
315
+ reject(new Error(`Installation command ${chalk_1.default.cyan(stringifiedInstallCmd)} exited with code ${code ?? 'null'}.`, {
316
+ cause,
317
+ }));
318
+ }
319
+ const installProcess = childProcess.spawn(pkgManager.name, installArgs, {
320
+ shell: true,
321
+ // Ignoring `stdout` to prevent certain node + yarn v4 (observed on ubuntu + snap)
322
+ // combinations from crashing here. See #851
323
+ stdio: ['pipe', 'ignore', 'pipe'],
324
+ });
325
+ let stderr = '';
326
+ // Defining data as unknown to avoid TS and ESLint errors because of `any` type
327
+ installProcess.stderr.on('data', (data) => {
328
+ if (data && data.toString && typeof data.toString === 'function') {
329
+ stderr += data.toString();
330
+ }
331
+ });
332
+ installProcess.on('error', (err) => {
333
+ handleErrorAndReject(null, err, 'spawn_error');
334
+ });
335
+ installProcess.on('close', (code) => {
336
+ if (code !== 0) {
337
+ handleErrorAndReject(code, stderr, 'process_error');
288
338
  }
289
339
  else {
290
340
  resolve();
@@ -423,9 +473,14 @@ async function addCliConfigFileToGitIgnore(filename) {
423
473
  clack.log.error(`Failed adding ${chalk_1.default.cyan(filename)} to ${chalk_1.default.cyan('.gitignore')}. Please add it manually!`);
424
474
  }
425
475
  }
426
- async function runPrettierIfInstalled() {
476
+ /**
477
+ * Runs prettier on the changed or untracked files in the project.
478
+ *
479
+ * @param cwd The directory of the project. If undefined, the current process working directory will be used.
480
+ */
481
+ async function runPrettierIfInstalled({ cwd, }) {
427
482
  return (0, telemetry_1.traceStep)('run-prettier', async () => {
428
- if (!isInGitRepo()) {
483
+ if (!isInGitRepo({ cwd })) {
429
484
  // We only run formatting on changed files. If we're not in a git repo, we can't find
430
485
  // changed files. So let's early-return without showing any formatting-related messages.
431
486
  return;
@@ -536,11 +591,37 @@ async function updatePackageDotJson(packageDotJson) {
536
591
  }
537
592
  }
538
593
  exports.updatePackageDotJson = updatePackageDotJson;
539
- async function getPackageManager() {
540
- const detectedPackageManager = (0, package_manager_1.detectPackageManger)();
594
+ /**
595
+ * Use this function to get the used JS Package manager.
596
+ *
597
+ * This function:
598
+ * - attempts to auto-detect the used package manager and return it
599
+ * - if unsuccessful, returns the passed fallback package manager
600
+ * - if no fallback is passed, it asks the user to select a package manager
601
+ *
602
+ * The result is cached on the first invocation to avoid asking the user multiple times.
603
+ *
604
+ * @param fallback the package manager to use if auto-detection fails and you don't want to
605
+ * ask the user. This is useful in cases where asking users would be too intrusive/low in value
606
+ * and where it's okay to fall back to a default package manager. Use this with caution.
607
+ */
608
+ async function getPackageManager(fallback) {
609
+ const globalWithSentryWizard = global;
610
+ if (globalWithSentryWizard.__sentry_wizard_cached_package_manager) {
611
+ return globalWithSentryWizard.__sentry_wizard_cached_package_manager;
612
+ }
613
+ const detectedPackageManager = (0, package_manager_1._detectPackageManger)();
541
614
  if (detectedPackageManager) {
615
+ globalWithSentryWizard.__sentry_wizard_cached_package_manager =
616
+ detectedPackageManager;
542
617
  return detectedPackageManager;
543
618
  }
619
+ if (fallback) {
620
+ // explicitly avoiding to cache the fallback in case this function
621
+ // gets called again without a fallback (or a different fallback)
622
+ // later on in the wizard flow.
623
+ return fallback;
624
+ }
544
625
  const selectedPackageManager = await abortIfCancelled(clack.select({
545
626
  message: 'Please select your package manager.',
546
627
  options: package_manager_1.packageManagers.map((packageManager) => ({
@@ -548,6 +629,8 @@ async function getPackageManager() {
548
629
  label: packageManager.label,
549
630
  })),
550
631
  }));
632
+ globalWithSentryWizard.__sentry_wizard_cached_package_manager =
633
+ selectedPackageManager;
551
634
  Sentry.setTag('package-manager', selectedPackageManager.name);
552
635
  return selectedPackageManager;
553
636
  }
@@ -1022,4 +1105,4 @@ async function askShouldAddPackageOverride(pkgName, pkgVersion) {
1022
1105
  })));
1023
1106
  }
1024
1107
  exports.askShouldAddPackageOverride = askShouldAddPackageOverride;
1025
- //# sourceMappingURL=clack-utils.js.map
1108
+ //# sourceMappingURL=index.js.map