@sentry/wizard 4.5.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 +17 -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 +3 -2
  6. package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
  7. package/dist/e2e-tests/tests/nextjs-15.test.js +2 -2
  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 -43
  97. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  98. package/dist/src/nextjs/templates.d.ts +10 -1
  99. package/dist/src/nextjs/templates.js +191 -63
  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 +15 -15
  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} +45 -7
  179. package/dist/src/utils/{clack-utils.js → clack/index.js} +72 -19
  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 +25 -19
  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 +128 -83
  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 +5 -5
  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} +91 -18
  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
@@ -2,107 +2,104 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const templates_1 = require("../../src/nextjs/templates");
4
4
  describe('Next.js code templates', () => {
5
- describe('getSentryConfigContents', () => {
6
- describe('client-side', () => {
7
- it('generates client-side Sentry config with all features enabled', () => {
8
- const template = (0, templates_1.getSentryConfigContents)('my-dsn', 'client', {
9
- performance: true,
10
- replay: true,
11
- });
12
- expect(template).toMatchInlineSnapshot(`
13
- "// This file configures the initialization of Sentry on the client.
14
- // The config you add here will be used whenever a users loads a page in their browser.
15
- // https://docs.sentry.io/platforms/javascript/guides/nextjs/
5
+ describe('getInstrumentationClientFileContents', () => {
6
+ it('generates client-side Sentry config with all features enabled', () => {
7
+ const template = (0, templates_1.getInstrumentationClientFileContents)('my-dsn', {
8
+ performance: true,
9
+ replay: true,
10
+ });
11
+ expect(template).toMatchInlineSnapshot(`
12
+ "// This file configures the initialization of Sentry on the client.
13
+ // The added config here will be used whenever a users loads a page in their browser.
14
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
16
15
 
17
- import * as Sentry from "@sentry/nextjs";
16
+ import * as Sentry from "@sentry/nextjs";
18
17
 
19
- Sentry.init({
20
- dsn: "my-dsn",
18
+ Sentry.init({
19
+ dsn: "my-dsn",
21
20
 
22
- // Add optional integrations for additional features
23
- integrations: [
24
- Sentry.replayIntegration(),
25
- ],
21
+ // Add optional integrations for additional features
22
+ integrations: [
23
+ Sentry.replayIntegration(),
24
+ ],
26
25
 
27
- // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
28
- tracesSampleRate: 1,
26
+ // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
27
+ tracesSampleRate: 1,
29
28
 
30
- // Define how likely Replay events are sampled.
31
- // This sets the sample rate to be 10%. You may want this to be 100% while
32
- // in development and sample at a lower rate in production
33
- replaysSessionSampleRate: 0.1,
29
+ // Define how likely Replay events are sampled.
30
+ // This sets the sample rate to be 10%. You may want this to be 100% while
31
+ // in development and sample at a lower rate in production
32
+ replaysSessionSampleRate: 0.1,
34
33
 
35
- // Define how likely Replay events are sampled when an error occurs.
36
- replaysOnErrorSampleRate: 1.0,
34
+ // Define how likely Replay events are sampled when an error occurs.
35
+ replaysOnErrorSampleRate: 1.0,
37
36
 
38
- // Setting this option to true will print useful information to the console while you're setting up Sentry.
39
- debug: false,
40
- });
41
- "
42
- `);
37
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
38
+ debug: false,
39
+ });"
40
+ `);
41
+ });
42
+ it('generates client-side Sentry config with performance monitoring disabled', () => {
43
+ const template = (0, templates_1.getInstrumentationClientFileContents)('my-dsn', {
44
+ performance: false,
45
+ replay: true,
43
46
  });
44
- it('generates client-side Sentry config with performance monitoring disabled', () => {
45
- const template = (0, templates_1.getSentryConfigContents)('my-dsn', 'client', {
46
- performance: false,
47
- replay: true,
48
- });
49
- expect(template).toMatchInlineSnapshot(`
50
- "// This file configures the initialization of Sentry on the client.
51
- // The config you add here will be used whenever a users loads a page in their browser.
52
- // https://docs.sentry.io/platforms/javascript/guides/nextjs/
47
+ expect(template).toMatchInlineSnapshot(`
48
+ "// This file configures the initialization of Sentry on the client.
49
+ // The added config here will be used whenever a users loads a page in their browser.
50
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
53
51
 
54
- import * as Sentry from "@sentry/nextjs";
52
+ import * as Sentry from "@sentry/nextjs";
55
53
 
56
- Sentry.init({
57
- dsn: "my-dsn",
54
+ Sentry.init({
55
+ dsn: "my-dsn",
58
56
 
59
- // Add optional integrations for additional features
60
- integrations: [
61
- Sentry.replayIntegration(),
62
- ],
57
+ // Add optional integrations for additional features
58
+ integrations: [
59
+ Sentry.replayIntegration(),
60
+ ],
63
61
 
64
- // Define how likely Replay events are sampled.
65
- // This sets the sample rate to be 10%. You may want this to be 100% while
66
- // in development and sample at a lower rate in production
67
- replaysSessionSampleRate: 0.1,
62
+ // Define how likely Replay events are sampled.
63
+ // This sets the sample rate to be 10%. You may want this to be 100% while
64
+ // in development and sample at a lower rate in production
65
+ replaysSessionSampleRate: 0.1,
68
66
 
69
- // Define how likely Replay events are sampled when an error occurs.
70
- replaysOnErrorSampleRate: 1.0,
67
+ // Define how likely Replay events are sampled when an error occurs.
68
+ replaysOnErrorSampleRate: 1.0,
71
69
 
72
- // Setting this option to true will print useful information to the console while you're setting up Sentry.
73
- debug: false,
74
- });
75
- "
76
- `);
70
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
71
+ debug: false,
72
+ });"
73
+ `);
74
+ });
75
+ it('generates client-side Sentry config with session replay disabled', () => {
76
+ const template = (0, templates_1.getInstrumentationClientFileContents)('my-dsn', {
77
+ performance: true,
78
+ replay: false,
77
79
  });
78
- it('generates client-side Sentry config with session replay disabled', () => {
79
- const template = (0, templates_1.getSentryConfigContents)('my-dsn', 'client', {
80
- performance: true,
81
- replay: false,
82
- });
83
- expect(template).toMatchInlineSnapshot(`
84
- "// This file configures the initialization of Sentry on the client.
85
- // The config you add here will be used whenever a users loads a page in their browser.
86
- // https://docs.sentry.io/platforms/javascript/guides/nextjs/
80
+ expect(template).toMatchInlineSnapshot(`
81
+ "// This file configures the initialization of Sentry on the client.
82
+ // The added config here will be used whenever a users loads a page in their browser.
83
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
87
84
 
88
- import * as Sentry from "@sentry/nextjs";
85
+ import * as Sentry from "@sentry/nextjs";
89
86
 
90
- Sentry.init({
91
- dsn: "my-dsn",
87
+ Sentry.init({
88
+ dsn: "my-dsn",
92
89
 
93
- // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
94
- tracesSampleRate: 1,
90
+ // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
91
+ tracesSampleRate: 1,
95
92
 
96
- // Setting this option to true will print useful information to the console while you're setting up Sentry.
97
- debug: false,
98
- });
99
- "
100
- `);
101
- });
93
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
94
+ debug: false,
95
+ });"
96
+ `);
102
97
  });
98
+ });
99
+ describe('getSentryServersideConfigContents', () => {
103
100
  describe('server-side', () => {
104
101
  it('generates server-side Sentry config with all features enabled', () => {
105
- const template = (0, templates_1.getSentryConfigContents)('my-dsn', 'server', {
102
+ const template = (0, templates_1.getSentryServersideConfigContents)('my-dsn', 'server', {
106
103
  performance: true,
107
104
  replay: true,
108
105
  });
@@ -126,7 +123,7 @@ describe('Next.js code templates', () => {
126
123
  `);
127
124
  });
128
125
  it('generates server-side Sentry config with performance monitoring disabled', () => {
129
- const template = (0, templates_1.getSentryConfigContents)('my-dsn', 'server', {
126
+ const template = (0, templates_1.getSentryServersideConfigContents)('my-dsn', 'server', {
130
127
  performance: false,
131
128
  replay: true,
132
129
  });
@@ -147,7 +144,7 @@ describe('Next.js code templates', () => {
147
144
  `);
148
145
  });
149
146
  it('generates server-side Sentry config with spotlight disabled', () => {
150
- const template = (0, templates_1.getSentryConfigContents)('my-dsn', 'server', {
147
+ const template = (0, templates_1.getSentryServersideConfigContents)('my-dsn', 'server', {
151
148
  performance: true,
152
149
  replay: true,
153
150
  });
@@ -173,7 +170,7 @@ describe('Next.js code templates', () => {
173
170
  });
174
171
  describe('edge', () => {
175
172
  it('generates edge Sentry config with all features enabled', () => {
176
- const template = (0, templates_1.getSentryConfigContents)('my-dsn', 'edge', {
173
+ const template = (0, templates_1.getSentryServersideConfigContents)('my-dsn', 'edge', {
177
174
  performance: true,
178
175
  replay: true,
179
176
  });
@@ -198,7 +195,7 @@ describe('Next.js code templates', () => {
198
195
  `);
199
196
  });
200
197
  it('generates edge Sentry config with performance monitoring disabled', () => {
201
- const template = (0, templates_1.getSentryConfigContents)('my-dsn', 'edge', {
198
+ const template = (0, templates_1.getSentryServersideConfigContents)('my-dsn', 'edge', {
202
199
  performance: false,
203
200
  replay: true,
204
201
  });
@@ -350,5 +347,53 @@ describe('Next.js code templates', () => {
350
347
  `);
351
348
  });
352
349
  });
350
+ describe('getRootLayout', () => {
351
+ it('generates a root layout component with types', () => {
352
+ expect((0, templates_1.getRootLayout)(true)).toMatchInlineSnapshot(`
353
+ "// This file was generated by the Sentry wizard because we couldn't find a root layout file.
354
+ // You can delete this file at any time.
355
+
356
+ export const metadata = {
357
+ title: 'Sentry NextJS Example',
358
+ description: 'Generated by Sentry',
359
+ }
360
+
361
+ export default function RootLayout({
362
+ children,
363
+ }: {
364
+ children: React.ReactNode
365
+ }) {
366
+ return (
367
+ <html lang="en">
368
+ <body>{children}</body>
369
+ </html>
370
+ )
371
+ }
372
+ "
373
+ `);
374
+ });
375
+ it('generates a root layout component without types', () => {
376
+ expect((0, templates_1.getRootLayout)(false)).toMatchInlineSnapshot(`
377
+ "// This file was generated by the Sentry wizard because we couldn't find a root layout file.
378
+ // You can delete this file at any time.
379
+
380
+ export const metadata = {
381
+ title: 'Sentry NextJS Example',
382
+ description: 'Generated by Sentry',
383
+ }
384
+
385
+ export default function RootLayout({
386
+ children,
387
+ }) {
388
+ return (
389
+ <html lang="en">
390
+ <body>{children}</body>
391
+ </html>
392
+ )
393
+ }
394
+ "
395
+ `);
396
+ });
397
+ });
353
398
  });
354
399
  //# sourceMappingURL=templates.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/nextjs/templates.test.ts"],"names":[],"mappings":";;AAAA,0DAGoC;AAEpC,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACvC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;YAC3B,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;gBACvE,MAAM,QAAQ,GAAG,IAAA,mCAAuB,EAAC,QAAQ,EAAE,QAAQ,EAAE;oBAC3D,WAAW,EAAE,IAAI;oBACjB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAC;gBAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA8BtC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;gBAClF,MAAM,QAAQ,GAAG,IAAA,mCAAuB,EAAC,QAAQ,EAAE,QAAQ,EAAE;oBAC3D,WAAW,EAAE,KAAK;oBAClB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAC;gBAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;SA2BtC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;gBAC1E,MAAM,QAAQ,GAAG,IAAA,mCAAuB,EAAC,QAAQ,EAAE,QAAQ,EAAE;oBAC3D,WAAW,EAAE,IAAI;oBACjB,MAAM,EAAE,KAAK;iBACd,CAAC,CAAC;gBAEH,MAAM,CAAC,QAAQ,CAAC,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B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCtC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;YACtE,MAAM,QAAQ,GAAG,IAAA,8CAAkC,EAAC;gBAClD,OAAO,EAAE,QAAQ;gBACjB,WAAW,EAAE,YAAY;gBACzB,UAAU,EAAE,KAAK;gBACjB,SAAS,EAAE,+BAA+B;gBAC1C,WAAW,EAAE,KAAK;aACnB,CAAC,CAAC;YAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCtC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n getSentryConfigContents,\n getWithSentryConfigOptionsTemplate,\n} from '../../src/nextjs/templates';\n\ndescribe('Next.js code templates', () => {\n describe('getSentryConfigContents', () => {\n describe('client-side', () => {\n it('generates client-side Sentry config with all features enabled', () => {\n const template = getSentryConfigContents('my-dsn', 'client', {\n performance: true,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the client.\n // The config you add here will be used whenever a users loads a page in their browser.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Add optional integrations for additional features\n integrations: [\n Sentry.replayIntegration(),\n ],\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,\n\n // Define how likely Replay events are sampled.\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 // Define how likely Replay events are sampled when an error occurs.\n replaysOnErrorSampleRate: 1.0,\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 });\n\n it('generates client-side Sentry config with performance monitoring disabled', () => {\n const template = getSentryConfigContents('my-dsn', 'client', {\n performance: false,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the client.\n // The config you add here will be used whenever a users loads a page in their browser.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Add optional integrations for additional features\n integrations: [\n Sentry.replayIntegration(),\n ],\n\n // Define how likely Replay events are sampled.\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 // Define how likely Replay events are sampled when an error occurs.\n replaysOnErrorSampleRate: 1.0,\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 });\n\n it('generates client-side Sentry config with session replay disabled', () => {\n const template = getSentryConfigContents('my-dsn', 'client', {\n performance: true,\n replay: false,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the client.\n // The config you add here will be used whenever a users loads a page in their browser.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,\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 });\n });\n\n describe('server-side', () => {\n it('generates server-side Sentry config with all features enabled', () => {\n const template = getSentryConfigContents('my-dsn', 'server', {\n performance: true,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the server.\n // The config you add here will be used whenever the server handles a request.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,\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 });\n\n it('generates server-side Sentry config with performance monitoring disabled', () => {\n const template = getSentryConfigContents('my-dsn', 'server', {\n performance: false,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the server.\n // The config you add here will be used whenever the server handles a request.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\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 });\n\n it('generates server-side Sentry config with spotlight disabled', () => {\n const template = getSentryConfigContents('my-dsn', 'server', {\n performance: true,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the server.\n // The config you add here will be used whenever the server handles a request.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,\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 });\n });\n\n describe('edge', () => {\n it('generates edge Sentry config with all features enabled', () => {\n const template = getSentryConfigContents('my-dsn', 'edge', {\n performance: true,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n // The config you add here will be used whenever one of the edge features is loaded.\n // Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,\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 });\n\n it('generates edge Sentry config with performance monitoring disabled', () => {\n const template = getSentryConfigContents('my-dsn', 'edge', {\n performance: false,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n // The config you add here will be used whenever one of the edge features is loaded.\n // Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\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 });\n });\n });\n\n describe('getWithSentryConfigOptionsTemplate', () => {\n it('generates options for SaaS', () => {\n const template = getWithSentryConfigOptionsTemplate({\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: false,\n sentryUrl: 'https://dont-use-this-url.com',\n tunnelRoute: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"{\n // For all available options, see:\n // https://www.npmjs.com/package/@sentry/webpack-plugin#options\n\n org: \"my-org\",\n project: \"my-project\",\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n tunnelRoute: \"/monitoring\",\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }\"\n `);\n });\n\n it('generates options for self-hosted', () => {\n const template = getWithSentryConfigOptionsTemplate({\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: true,\n sentryUrl: 'https://my-sentry.com',\n tunnelRoute: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"{\n // For all available options, see:\n // https://www.npmjs.com/package/@sentry/webpack-plugin#options\n\n org: \"my-org\",\n project: \"my-project\",\n sentryUrl: \"https://my-sentry.com\",\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n tunnelRoute: \"/monitoring\",\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }\"\n `);\n });\n\n it('comments out tunnelRoute if `tunnelRoute` option is disabled', () => {\n const template = getWithSentryConfigOptionsTemplate({\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: false,\n sentryUrl: 'https://dont-use-this-url.com',\n tunnelRoute: false,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"{\n // For all available options, see:\n // https://www.npmjs.com/package/@sentry/webpack-plugin#options\n\n org: \"my-org\",\n project: \"my-project\",\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n // tunnelRoute: \"/monitoring\",\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }\"\n `);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/nextjs/templates.test.ts"],"names":[],"mappings":";;AAAA,0DAKoC;AAEpC,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;QACpD,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;YACvE,MAAM,QAAQ,GAAG,IAAA,gDAAoC,EAAC,QAAQ,EAAE;gBAC9D,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,IAAI;aACb,CAAC,CAAC;YAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BtC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;YAClF,MAAM,QAAQ,GAAG,IAAA,gDAAoC,EAAC,QAAQ,EAAE;gBAC9D,WAAW,EAAE,KAAK;gBAClB,MAAM,EAAE,IAAI;aACb,CAAC,CAAC;YAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BtC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;YAC1E,MAAM,QAAQ,GAAG,IAAA,gDAAoC,EAAC,QAAQ,EAAE;gBAC9D,WAAW,EAAE,IAAI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;gBAChB,SAAS,EAAE,uBAAuB;gBAClC,WAAW,EAAE,IAAI;aAClB,CAAC,CAAC;YAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCtC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;YACtE,MAAM,QAAQ,GAAG,IAAA,8CAAkC,EAAC;gBAClD,OAAO,EAAE,QAAQ;gBACjB,WAAW,EAAE,YAAY;gBACzB,UAAU,EAAE,KAAK;gBACjB,SAAS,EAAE,+BAA+B;gBAC1C,WAAW,EAAE,KAAK;aACnB,CAAC,CAAC;YAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCtC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;YACtD,MAAM,CAAC,IAAA,yBAAa,EAAC,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;OAqBjD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;YACzD,MAAM,CAAC,IAAA,yBAAa,EAAC,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;OAmBlD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n getRootLayout,\n getSentryServersideConfigContents,\n getInstrumentationClientFileContents,\n getWithSentryConfigOptionsTemplate,\n} from '../../src/nextjs/templates';\n\ndescribe('Next.js code templates', () => {\n describe('getInstrumentationClientFileContents', () => {\n it('generates client-side Sentry config with all features enabled', () => {\n const template = getInstrumentationClientFileContents('my-dsn', {\n performance: true,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the client.\n // The added config here will be used whenever a users loads a page in their browser.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Add optional integrations for additional features\n integrations: [\n Sentry.replayIntegration(),\n ],\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,\n\n // Define how likely Replay events are sampled.\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 // Define how likely Replay events are sampled when an error occurs.\n replaysOnErrorSampleRate: 1.0,\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\n it('generates client-side Sentry config with performance monitoring disabled', () => {\n const template = getInstrumentationClientFileContents('my-dsn', {\n performance: false,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the client.\n // The added config here will be used whenever a users loads a page in their browser.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Add optional integrations for additional features\n integrations: [\n Sentry.replayIntegration(),\n ],\n\n // Define how likely Replay events are sampled.\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 // Define how likely Replay events are sampled when an error occurs.\n replaysOnErrorSampleRate: 1.0,\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\n it('generates client-side Sentry config with session replay disabled', () => {\n const template = getInstrumentationClientFileContents('my-dsn', {\n performance: true,\n replay: false,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the client.\n // The added config here will be used whenever a users loads a page in their browser.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,\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 });\n\n describe('getSentryServersideConfigContents', () => {\n describe('server-side', () => {\n it('generates server-side Sentry config with all features enabled', () => {\n const template = getSentryServersideConfigContents('my-dsn', 'server', {\n performance: true,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the server.\n // The config you add here will be used whenever the server handles a request.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,\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 });\n\n it('generates server-side Sentry config with performance monitoring disabled', () => {\n const template = getSentryServersideConfigContents('my-dsn', 'server', {\n performance: false,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the server.\n // The config you add here will be used whenever the server handles a request.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\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 });\n\n it('generates server-side Sentry config with spotlight disabled', () => {\n const template = getSentryServersideConfigContents('my-dsn', 'server', {\n performance: true,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry on the server.\n // The config you add here will be used whenever the server handles a request.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,\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 });\n });\n\n describe('edge', () => {\n it('generates edge Sentry config with all features enabled', () => {\n const template = getSentryServersideConfigContents('my-dsn', 'edge', {\n performance: true,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n // The config you add here will be used whenever one of the edge features is loaded.\n // Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\n\n // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.\n tracesSampleRate: 1,\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 });\n\n it('generates edge Sentry config with performance monitoring disabled', () => {\n const template = getSentryServersideConfigContents('my-dsn', 'edge', {\n performance: false,\n replay: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).\n // The config you add here will be used whenever one of the edge features is loaded.\n // Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/\n\n import * as Sentry from \"@sentry/nextjs\";\n\n Sentry.init({\n dsn: \"my-dsn\",\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 });\n });\n });\n\n describe('getWithSentryConfigOptionsTemplate', () => {\n it('generates options for SaaS', () => {\n const template = getWithSentryConfigOptionsTemplate({\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: false,\n sentryUrl: 'https://dont-use-this-url.com',\n tunnelRoute: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"{\n // For all available options, see:\n // https://www.npmjs.com/package/@sentry/webpack-plugin#options\n\n org: \"my-org\",\n project: \"my-project\",\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n tunnelRoute: \"/monitoring\",\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }\"\n `);\n });\n\n it('generates options for self-hosted', () => {\n const template = getWithSentryConfigOptionsTemplate({\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: true,\n sentryUrl: 'https://my-sentry.com',\n tunnelRoute: true,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"{\n // For all available options, see:\n // https://www.npmjs.com/package/@sentry/webpack-plugin#options\n\n org: \"my-org\",\n project: \"my-project\",\n sentryUrl: \"https://my-sentry.com\",\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n tunnelRoute: \"/monitoring\",\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }\"\n `);\n });\n\n it('comments out tunnelRoute if `tunnelRoute` option is disabled', () => {\n const template = getWithSentryConfigOptionsTemplate({\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: false,\n sentryUrl: 'https://dont-use-this-url.com',\n tunnelRoute: false,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \"{\n // For all available options, see:\n // https://www.npmjs.com/package/@sentry/webpack-plugin#options\n\n org: \"my-org\",\n project: \"my-project\",\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n // tunnelRoute: \"/monitoring\",\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true,\n }\"\n `);\n });\n });\n\n describe('getRootLayout', () => {\n it('generates a root layout component with types', () => {\n expect(getRootLayout(true)).toMatchInlineSnapshot(`\n \"// This file was generated by the Sentry wizard because we couldn't find a root layout file.\n // You can delete this file at any time.\n\n export const metadata = {\n title: 'Sentry NextJS Example',\n description: 'Generated by Sentry',\n }\n\n export default function RootLayout({\n children,\n }: {\n children: React.ReactNode\n }) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n )\n }\n \"\n `);\n });\n it('generates a root layout component without types', () => {\n expect(getRootLayout(false)).toMatchInlineSnapshot(`\n \"// This file was generated by the Sentry wizard because we couldn't find a root layout file.\n // You can delete this file at any time.\n\n export const metadata = {\n title: 'Sentry NextJS Example',\n description: 'Generated by Sentry',\n }\n\n export default function RootLayout({\n children,\n }) {\n return (\n <html lang=\"en\">\n <body>{children}</body>\n </html>\n )\n }\n \"\n `);\n });\n });\n});\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-ignore - magicast is ESM and TS complains about that. It works though
3
+ // @ts-expect-error - magicast is ESM and TS complains about that. It works though
4
4
  const magicast_1 = require("magicast");
5
5
  const expo_metro_1 = require("../../src/react-native/expo-metro");
6
6
  describe('expo-metro config', () => {
@@ -1 +1 @@
1
- {"version":3,"file":"expo-metro.test.js","sourceRoot":"","sources":["../../../test/react-native/expo-metro.test.ts"],"names":[],"mappings":";;AAAA,4EAA4E;AAC5E,uCAAqD;AACrD,kEAAuE;AAEvE,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAI,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACvC,MAAM,GAAG,GAAG,IAAA,sBAAW,EAAC;;;;;;;;;;;;OAYrB,CAAC,CAAC;QAEL,MAAM,MAAM,GAAG,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CACtC;;;;;;;;;;;;;;CAcL,CAAC,IAAI,EAAE,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAChE,MAAM,GAAG,GAAG,IAAA,sBAAW,EAAC;;;;;;OAMrB,CAAC,CAAC;QAEL,MAAM,MAAM,GAAG,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CACtC;;;;;;;;;;CAUL,CAAC,IAAI,EAAE,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACvD,MAAM,GAAG,GAAG,IAAA,sBAAW,EAAC;;CAE3B,CAAC,CAAC;QAEC,MAAM,MAAM,GAAG,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,MAAM,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CACtC;;CAEL,CAAC,IAAI,EAAE,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule } from 'magicast';\nimport { patchMetroInMemory } from '../../src/react-native/expo-metro';\n\ndescribe('expo-metro config', () => {\n test('patches minimal expo config', () => {\n const mod = parseModule(`\nconst { getDefaultConfig } = require(\"expo/metro-config\");\n\n/** @type {import('expo/metro-config').MetroConfig} */\nconst config = getDefaultConfig(__dirname);\n\nconfig.resolver.assetExts.push(\n // Adds support for .db files for SQLite databases\n 'db'\n);\n\nmodule.exports = config;\n `);\n\n const result = patchMetroInMemory(mod);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(\n `\nconst {\n getSentryExpoConfig\n} = require(\"@sentry/react-native/metro\");\n\n/** @type {import('expo/metro-config').MetroConfig} */\nconst config = getSentryExpoConfig(__dirname);\n\nconfig.resolver.assetExts.push(\n // Adds support for .db files for SQLite databases\n 'db'\n);\n\nmodule.exports = config;\n`.trim(),\n );\n });\n\n test('keeps expo metro config if other imports are present', () => {\n const mod = parseModule(`\nconst { getDefaultConfig, otherExport } = require(\"expo/metro-config\");\n\nconst config = getDefaultConfig(__dirname);\n\nmodule.exports = config;\n `);\n\n const result = patchMetroInMemory(mod);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(\n `\nconst { getDefaultConfig, otherExport } = require(\"expo/metro-config\");\n\nconst {\n getSentryExpoConfig\n} = require(\"@sentry/react-native/metro\");\n\nconst config = getSentryExpoConfig(__dirname);\n\nmodule.exports = config;\n`.trim(),\n );\n });\n\n test('does not modify when sentry already present', () => {\n const mod = parseModule(`\nconst { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n`);\n\n const result = patchMetroInMemory(mod);\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(\n `\nconst { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n`.trim(),\n );\n });\n});\n"]}
1
+ {"version":3,"file":"expo-metro.test.js","sourceRoot":"","sources":["../../../test/react-native/expo-metro.test.ts"],"names":[],"mappings":";;AAAA,kFAAkF;AAClF,uCAAqD;AACrD,kEAAuE;AAEvE,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAI,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACvC,MAAM,GAAG,GAAG,IAAA,sBAAW,EAAC;;;;;;;;;;;;OAYrB,CAAC,CAAC;QAEL,MAAM,MAAM,GAAG,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CACtC;;;;;;;;;;;;;;CAcL,CAAC,IAAI,EAAE,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAChE,MAAM,GAAG,GAAG,IAAA,sBAAW,EAAC;;;;;;OAMrB,CAAC,CAAC;QAEL,MAAM,MAAM,GAAG,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CACtC;;;;;;;;;;CAUL,CAAC,IAAI,EAAE,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACvD,MAAM,GAAG,GAAG,IAAA,sBAAW,EAAC;;CAE3B,CAAC,CAAC;QAEC,MAAM,MAAM,GAAG,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,MAAM,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CACtC;;CAEL,CAAC,IAAI,EAAE,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule } from 'magicast';\nimport { patchMetroInMemory } from '../../src/react-native/expo-metro';\n\ndescribe('expo-metro config', () => {\n test('patches minimal expo config', () => {\n const mod = parseModule(`\nconst { getDefaultConfig } = require(\"expo/metro-config\");\n\n/** @type {import('expo/metro-config').MetroConfig} */\nconst config = getDefaultConfig(__dirname);\n\nconfig.resolver.assetExts.push(\n // Adds support for .db files for SQLite databases\n 'db'\n);\n\nmodule.exports = config;\n `);\n\n const result = patchMetroInMemory(mod);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(\n `\nconst {\n getSentryExpoConfig\n} = require(\"@sentry/react-native/metro\");\n\n/** @type {import('expo/metro-config').MetroConfig} */\nconst config = getSentryExpoConfig(__dirname);\n\nconfig.resolver.assetExts.push(\n // Adds support for .db files for SQLite databases\n 'db'\n);\n\nmodule.exports = config;\n`.trim(),\n );\n });\n\n test('keeps expo metro config if other imports are present', () => {\n const mod = parseModule(`\nconst { getDefaultConfig, otherExport } = require(\"expo/metro-config\");\n\nconst config = getDefaultConfig(__dirname);\n\nmodule.exports = config;\n `);\n\n const result = patchMetroInMemory(mod);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(\n `\nconst { getDefaultConfig, otherExport } = require(\"expo/metro-config\");\n\nconst {\n getSentryExpoConfig\n} = require(\"@sentry/react-native/metro\");\n\nconst config = getSentryExpoConfig(__dirname);\n\nmodule.exports = config;\n`.trim(),\n );\n });\n\n test('does not modify when sentry already present', () => {\n const mod = parseModule(`\nconst { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n`);\n\n const result = patchMetroInMemory(mod);\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(\n `\nconst { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n`.trim(),\n );\n });\n});\n"]}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const javascript_1 = require("../../src/react-native/javascript");
4
- // @ts-ignore - magicast is ESM and TS complains about that. It works though
4
+ // @ts-expect-error - magicast is ESM and TS complains about that. It works though
5
5
  const magicast_1 = require("magicast");
6
6
  describe('react-native javascript', () => {
7
7
  describe('addSentryInitWithSdkImport', () => {
@@ -1 +1 @@
1
- {"version":3,"file":"javascript.test.js","sourceRoot":"","sources":["../../../test/react-native/javascript.test.ts"],"names":[],"mappings":";;AAAA,kEAM2C;AAC3C,4EAA4E;AAC5E,uCAAqD;AAGrD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QA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/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,GAAG,GAAG,IAAA,sBAAW,EAAC,kCAAkC,CAAC,CAAC;QAE5D,MAAM,MAAM,GAAG,IAAA,kCAAqB,EAAC,GAAG,CAAC,IAAiB,CAAC,CAAC;QAE5D,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,GAAG,GAAG,IAAA,sBAAW,EAAC,qBAAqB,CAAC,CAAC;QAE/C,MAAM,MAAM,GAAG,IAAA,kCAAqB,EAAC,GAAG,CAAC,IAAiB,CAAC,CAAC;QAE5D,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n addSentryInitWithSdkImport,\n checkAndWrapRootComponent,\n doesContainSentryWrap,\n doesJsCodeIncludeSdkSentryImport,\n SentryWrapResult,\n} from '../../src/react-native/javascript';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule } from 'magicast';\nimport * as t from '@babel/types';\n\ndescribe('react-native javascript', () => {\n describe('addSentryInitWithSdkImport', () => {\n it('adds sdk import and sentry init under last import in the file', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n const expectedOutput = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'dsn',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(\n expectedOutput,\n );\n });\n\n it('does not add sdk import and sentry init in the file without imports', () => {\n const input = `export const test = 'test';`;\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);\n });\n\n it('does not add sdk import and sentry init in the empty file', () => {\n const input = '';\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);\n });\n });\n\n describe('doesJsCodeIncludeSdkSentryImport', () => {\n it('returns true if code has sdk import', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(true);\n });\n\n it('returns true if code has sdk require', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nconst Sentry = require('@sentry/react-native');\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(true);\n });\n\n it('returns false if code does not have sdk import', () => {\n const input = `export const test = 'test';`;\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(false);\n });\n\n it('returns false for empty file', () => {\n const input = '';\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(false);\n });\n });\n\n describe('addSentryWrap', () => {\n it('wraps the root app component', () => {\n const mod = parseModule(`import * as React from 'react';\nimport * as Sentry from '@sentry/react-native';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`);\n\n const expectedOutput = `import * as React from 'react';\nimport * as Sentry from '@sentry/react-native';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default Sentry.wrap(App);`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a wrapped root app component', () => {\n const mod = parseModule(`import * as React from 'react';\nimport * as Sentry from '@sentry/react-native';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default AnotheWrapper.wrap(App);`);\n\n const expectedOutput = `import * as React from 'react';\nimport * as Sentry from '@sentry/react-native';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default Sentry.wrap(AnotheWrapper.wrap(App));`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a root app named function', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default function RootLayout() {\n return (\n <View>\n Test App\n </View>\n );\n}`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(function RootLayout() {\n return (\n <View>\n Test App\n </View>\n );\n});`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a wrapped root app named function', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default Another.wrapper(function RootLayout() {\n return (\n <View>\n Test App\n </View>\n );\n});`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(Another.wrapper(function RootLayout() {\n return (\n <View>\n Test App\n </View>\n );\n}));`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a root app anonymous function', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default () => {\n return (\n <View>\n Test App\n </View>\n );\n}`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(() => {\n return (\n <View>\n Test App\n </View>\n );\n});`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a wrapped root app anonymous function', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default Another.wrap(() => {\n return (\n <View>\n Test App\n </View>\n );\n});`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(Another.wrap(() => {\n return (\n <View>\n Test App\n </View>\n );\n}));`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a complex root function', () => {\n // This is the default export for a new Expo 52 project\n const mod =\n parseModule(`import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';\nimport { useFonts } from 'expo-font';\nimport { Stack } from 'expo-router';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { StatusBar } from 'expo-status-bar';\nimport { useEffect } from 'react';\nimport 'react-native-reanimated';\n\nimport { useColorScheme } from '@/hooks/useColorScheme';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'https://sentry.io/123',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});\n\n// Prevent the splash screen from auto-hiding before asset loading is complete.\nSplashScreen.preventAutoHideAsync();\n\nexport default function RootLayout() {\n const colorScheme = useColorScheme();\n const [loaded] = useFonts({\n SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),\n });\n\n useEffect(() => {\n if (loaded) {\n SplashScreen.hideAsync();\n }\n }, [loaded]);\n\n if (!loaded) {\n return null;\n }\n\n return (\n <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>\n <Stack>\n <Stack.Screen name=\"(tabs)\" options={{ headerShown: false }} />\n <Stack.Screen name=\"+not-found\" />\n </Stack>\n <StatusBar style=\"auto\" />\n </ThemeProvider>\n );\n}\n`);\n\n const expectedOutput = `import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';\nimport { useFonts } from 'expo-font';\nimport { Stack } from 'expo-router';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { StatusBar } from 'expo-status-bar';\nimport { useEffect } from 'react';\nimport 'react-native-reanimated';\n\nimport { useColorScheme } from '@/hooks/useColorScheme';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'https://sentry.io/123',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});\n\n// Prevent the splash screen from auto-hiding before asset loading is complete.\nSplashScreen.preventAutoHideAsync();\n\nexport default Sentry.wrap(function RootLayout() {\n const colorScheme = useColorScheme();\n const [loaded] = useFonts({\n SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),\n });\n\n useEffect(() => {\n if (loaded) {\n SplashScreen.hideAsync();\n }\n }, [loaded]);\n\n if (!loaded) {\n return null;\n }\n\n return (\n <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>\n <Stack>\n <Stack.Screen name=\"(tabs)\" options={{ headerShown: false }} />\n <Stack.Screen name=\"+not-found\" />\n </Stack>\n <StatusBar style=\"auto\" />\n </ThemeProvider>\n );\n});`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a root app anonymous complex function', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default () => {\n const colorScheme = useColorScheme();\n const [loaded] = useFonts({\n SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),\n });\n\n useEffect(() => {\n if (loaded) {\n SplashScreen.hideAsync();\n }\n }, [loaded]);\n\n if (!loaded) {\n return null;\n }\n\n return (\n <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>\n <Stack>\n <Stack.Screen name=\"(tabs)\" options={{ headerShown: false }} />\n <Stack.Screen name=\"+not-found\" />\n </Stack>\n <StatusBar style=\"auto\" />\n </ThemeProvider>\n );\n}`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(() => {\n const colorScheme = useColorScheme();\n const [loaded] = useFonts({\n SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),\n });\n\n useEffect(() => {\n if (loaded) {\n SplashScreen.hideAsync();\n }\n }, [loaded]);\n\n if (!loaded) {\n return null;\n }\n\n return (\n <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>\n <Stack>\n <Stack.Screen name=\"(tabs)\" options={{ headerShown: false }} />\n <Stack.Screen name=\"+not-found\" />\n </Stack>\n <StatusBar style=\"auto\" />\n </ThemeProvider>\n );\n});`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a default class export', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default class RootLayout extends React.Component {\n render() {\n return (\n <View>\n Test App\n </View>\n );\n }\n}`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(class RootLayout extends React.Component {\n render() {\n return (\n <View>\n Test App\n </View>\n );\n }\n});`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('does not wrap a root app component if not found', () => {\n const input = `import * as React from 'react';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport { App };`;\n const mod = parseModule(input);\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.NotFound);\n expect(generateCode(mod.$ast).code).toBe(input);\n });\n\n it('does not wrap a root app component if already wrapped', () => {\n const input = `import * as React from 'react';\nimport * as Sentry from '@sentry/react-native';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default Sentry.wrap(App);`;\n const mod = parseModule(input);\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.AlreadyWrapped);\n expect(generateCode(mod.$ast).code).toBe(input);\n });\n\n it('does not wrap the root app component in an empty file', () => {\n const mod = parseModule(``);\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.NotFound);\n expect(generateCode(mod.$ast).code).toBe(``);\n });\n });\n\n it('does detect Sentry.wrap if exists', () => {\n const mod = parseModule(`export default Sentry.wrap(App);`);\n\n const result = doesContainSentryWrap(mod.$ast as t.Program);\n\n expect(result).toBeTruthy();\n });\n\n it('does not detect Sentry.wrap if not present', () => {\n const mod = parseModule(`export default App;`);\n\n const result = doesContainSentryWrap(mod.$ast as t.Program);\n\n expect(result).toBeFalsy();\n });\n});\n"]}
1
+ {"version":3,"file":"javascript.test.js","sourceRoot":"","sources":["../../../test/react-native/javascript.test.ts"],"names":[],"mappings":";;AAAA,kEAM2C;AAC3C,kFAAkF;AAClF,uCAAqD;AAGrD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;YACvE,MAAM,KAAK,GAAG;;;;;;;;;;;;;;oBAcA,CAAC;YAEf,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;oBAsBT,CAAC;YAEf,MAAM,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CA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,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,GAAG,GAAG,IAAA,sBAAW,EAAC,qBAAqB,CAAC,CAAC;QAE/C,MAAM,MAAM,GAAG,IAAA,kCAAqB,EAAC,GAAG,CAAC,IAAiB,CAAC,CAAC;QAE5D,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n addSentryInitWithSdkImport,\n checkAndWrapRootComponent,\n doesContainSentryWrap,\n doesJsCodeIncludeSdkSentryImport,\n SentryWrapResult,\n} from '../../src/react-native/javascript';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule } from 'magicast';\nimport * as t from '@babel/types';\n\ndescribe('react-native javascript', () => {\n describe('addSentryInitWithSdkImport', () => {\n it('adds sdk import and sentry init under last import in the file', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n const expectedOutput = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'dsn',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(\n expectedOutput,\n );\n });\n\n it('does not add sdk import and sentry init in the file without imports', () => {\n const input = `export const test = 'test';`;\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);\n });\n\n it('does not add sdk import and sentry init in the empty file', () => {\n const input = '';\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);\n });\n });\n\n describe('doesJsCodeIncludeSdkSentryImport', () => {\n it('returns true if code has sdk import', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(true);\n });\n\n it('returns true if code has sdk require', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nconst Sentry = require('@sentry/react-native');\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(true);\n });\n\n it('returns false if code does not have sdk import', () => {\n const input = `export const test = 'test';`;\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(false);\n });\n\n it('returns false for empty file', () => {\n const input = '';\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(false);\n });\n });\n\n describe('addSentryWrap', () => {\n it('wraps the root app component', () => {\n const mod = parseModule(`import * as React from 'react';\nimport * as Sentry from '@sentry/react-native';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`);\n\n const expectedOutput = `import * as React from 'react';\nimport * as Sentry from '@sentry/react-native';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default Sentry.wrap(App);`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a wrapped root app component', () => {\n const mod = parseModule(`import * as React from 'react';\nimport * as Sentry from '@sentry/react-native';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default AnotheWrapper.wrap(App);`);\n\n const expectedOutput = `import * as React from 'react';\nimport * as Sentry from '@sentry/react-native';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default Sentry.wrap(AnotheWrapper.wrap(App));`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a root app named function', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default function RootLayout() {\n return (\n <View>\n Test App\n </View>\n );\n}`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(function RootLayout() {\n return (\n <View>\n Test App\n </View>\n );\n});`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a wrapped root app named function', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default Another.wrapper(function RootLayout() {\n return (\n <View>\n Test App\n </View>\n );\n});`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(Another.wrapper(function RootLayout() {\n return (\n <View>\n Test App\n </View>\n );\n}));`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a root app anonymous function', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default () => {\n return (\n <View>\n Test App\n </View>\n );\n}`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(() => {\n return (\n <View>\n Test App\n </View>\n );\n});`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a wrapped root app anonymous function', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default Another.wrap(() => {\n return (\n <View>\n Test App\n </View>\n );\n});`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(Another.wrap(() => {\n return (\n <View>\n Test App\n </View>\n );\n}));`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a complex root function', () => {\n // This is the default export for a new Expo 52 project\n const mod =\n parseModule(`import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';\nimport { useFonts } from 'expo-font';\nimport { Stack } from 'expo-router';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { StatusBar } from 'expo-status-bar';\nimport { useEffect } from 'react';\nimport 'react-native-reanimated';\n\nimport { useColorScheme } from '@/hooks/useColorScheme';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'https://sentry.io/123',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});\n\n// Prevent the splash screen from auto-hiding before asset loading is complete.\nSplashScreen.preventAutoHideAsync();\n\nexport default function RootLayout() {\n const colorScheme = useColorScheme();\n const [loaded] = useFonts({\n SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),\n });\n\n useEffect(() => {\n if (loaded) {\n SplashScreen.hideAsync();\n }\n }, [loaded]);\n\n if (!loaded) {\n return null;\n }\n\n return (\n <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>\n <Stack>\n <Stack.Screen name=\"(tabs)\" options={{ headerShown: false }} />\n <Stack.Screen name=\"+not-found\" />\n </Stack>\n <StatusBar style=\"auto\" />\n </ThemeProvider>\n );\n}\n`);\n\n const expectedOutput = `import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';\nimport { useFonts } from 'expo-font';\nimport { Stack } from 'expo-router';\nimport * as SplashScreen from 'expo-splash-screen';\nimport { StatusBar } from 'expo-status-bar';\nimport { useEffect } from 'react';\nimport 'react-native-reanimated';\n\nimport { useColorScheme } from '@/hooks/useColorScheme';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'https://sentry.io/123',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});\n\n// Prevent the splash screen from auto-hiding before asset loading is complete.\nSplashScreen.preventAutoHideAsync();\n\nexport default Sentry.wrap(function RootLayout() {\n const colorScheme = useColorScheme();\n const [loaded] = useFonts({\n SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),\n });\n\n useEffect(() => {\n if (loaded) {\n SplashScreen.hideAsync();\n }\n }, [loaded]);\n\n if (!loaded) {\n return null;\n }\n\n return (\n <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>\n <Stack>\n <Stack.Screen name=\"(tabs)\" options={{ headerShown: false }} />\n <Stack.Screen name=\"+not-found\" />\n </Stack>\n <StatusBar style=\"auto\" />\n </ThemeProvider>\n );\n});`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a root app anonymous complex function', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default () => {\n const colorScheme = useColorScheme();\n const [loaded] = useFonts({\n SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),\n });\n\n useEffect(() => {\n if (loaded) {\n SplashScreen.hideAsync();\n }\n }, [loaded]);\n\n if (!loaded) {\n return null;\n }\n\n return (\n <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>\n <Stack>\n <Stack.Screen name=\"(tabs)\" options={{ headerShown: false }} />\n <Stack.Screen name=\"+not-found\" />\n </Stack>\n <StatusBar style=\"auto\" />\n </ThemeProvider>\n );\n}`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(() => {\n const colorScheme = useColorScheme();\n const [loaded] = useFonts({\n SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),\n });\n\n useEffect(() => {\n if (loaded) {\n SplashScreen.hideAsync();\n }\n }, [loaded]);\n\n if (!loaded) {\n return null;\n }\n\n return (\n <ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>\n <Stack>\n <Stack.Screen name=\"(tabs)\" options={{ headerShown: false }} />\n <Stack.Screen name=\"+not-found\" />\n </Stack>\n <StatusBar style=\"auto\" />\n </ThemeProvider>\n );\n});`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('wraps a default class export', () => {\n const mod = parseModule(`import * as Sentry from '@sentry/react-native';\n\nexport default class RootLayout extends React.Component {\n render() {\n return (\n <View>\n Test App\n </View>\n );\n }\n}`);\n\n const expectedOutput = `import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(class RootLayout extends React.Component {\n render() {\n return (\n <View>\n Test App\n </View>\n );\n }\n});`;\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.Success);\n expect(generateCode(mod.$ast).code).toBe(expectedOutput);\n });\n\n it('does not wrap a root app component if not found', () => {\n const input = `import * as React from 'react';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport { App };`;\n const mod = parseModule(input);\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.NotFound);\n expect(generateCode(mod.$ast).code).toBe(input);\n });\n\n it('does not wrap a root app component if already wrapped', () => {\n const input = `import * as React from 'react';\nimport * as Sentry from '@sentry/react-native';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default Sentry.wrap(App);`;\n const mod = parseModule(input);\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.AlreadyWrapped);\n expect(generateCode(mod.$ast).code).toBe(input);\n });\n\n it('does not wrap the root app component in an empty file', () => {\n const mod = parseModule(``);\n\n const result = checkAndWrapRootComponent(mod);\n\n expect(result).toBe(SentryWrapResult.NotFound);\n expect(generateCode(mod.$ast).code).toBe(``);\n });\n });\n\n it('does detect Sentry.wrap if exists', () => {\n const mod = parseModule(`export default Sentry.wrap(App);`);\n\n const result = doesContainSentryWrap(mod.$ast as t.Program);\n\n expect(result).toBeTruthy();\n });\n\n it('does not detect Sentry.wrap if not present', () => {\n const mod = parseModule(`export default App;`);\n\n const result = doesContainSentryWrap(mod.$ast as t.Program);\n\n expect(result).toBeFalsy();\n });\n});\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // @ts-ignore - magicast is ESM and TS complains about that. It works though
3
+ // @ts-expect-error - magicast is ESM and TS complains about that. It works though
4
4
  const magicast_1 = require("magicast");
5
5
  const metro_1 = require("../../src/react-native/metro");
6
6
  describe('patch metro config - sentry serializer', () => {