@sentry/wizard 3.25.2 → 3.27.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 (43) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/lib/Steps/OpenSentry.js +1 -1
  3. package/dist/lib/Steps/OpenSentry.js.map +1 -1
  4. package/dist/package.json +2 -1
  5. package/dist/src/nextjs/nextjs-wizard.d.ts +1 -1
  6. package/dist/src/nextjs/nextjs-wizard.js +194 -99
  7. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  8. package/dist/src/nextjs/templates.d.ts +7 -3
  9. package/dist/src/nextjs/templates.js +27 -14
  10. package/dist/src/nextjs/templates.js.map +1 -1
  11. package/dist/src/run.js +1 -1
  12. package/dist/src/run.js.map +1 -1
  13. package/dist/src/sourcemaps/sourcemaps-wizard.js +1 -1
  14. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  15. package/dist/src/telemetry.js +10 -3
  16. package/dist/src/telemetry.js.map +1 -1
  17. package/dist/src/utils/clack-utils.d.ts +4 -1
  18. package/dist/src/utils/clack-utils.js +81 -11
  19. package/dist/src/utils/clack-utils.js.map +1 -1
  20. package/dist/src/utils/package-manager.d.ts +5 -2
  21. package/dist/src/utils/package-manager.js +44 -56
  22. package/dist/src/utils/package-manager.js.map +1 -1
  23. package/dist/src/utils/types.d.ts +6 -0
  24. package/dist/src/utils/types.js.map +1 -1
  25. package/dist/src/utils/url.js +7 -2
  26. package/dist/src/utils/url.js.map +1 -1
  27. package/dist/test/nextjs/templates.test.js +79 -1
  28. package/dist/test/nextjs/templates.test.js.map +1 -1
  29. package/dist/test/sourcemaps/tools/sentry-cli.test.js +2 -1
  30. package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
  31. package/lib/Steps/OpenSentry.ts +1 -1
  32. package/package.json +2 -1
  33. package/src/nextjs/nextjs-wizard.ts +209 -101
  34. package/src/nextjs/templates.ts +54 -26
  35. package/src/run.ts +1 -1
  36. package/src/sourcemaps/sourcemaps-wizard.ts +1 -1
  37. package/src/telemetry.ts +7 -1
  38. package/src/utils/clack-utils.ts +77 -7
  39. package/src/utils/package-manager.ts +43 -13
  40. package/src/utils/types.ts +7 -0
  41. package/src/utils/url.ts +6 -2
  42. package/test/nextjs/templates.test.ts +296 -2
  43. package/test/sourcemaps/tools/sentry-cli.test.ts +2 -1
@@ -1,6 +1,244 @@
1
- import { getWithSentryConfigOptionsTemplate } from '../../src/nextjs/templates';
1
+ import {
2
+ getSentryConfigContents,
3
+ getWithSentryConfigOptionsTemplate,
4
+ } from '../../src/nextjs/templates';
5
+
6
+ describe('Next.js code templates', () => {
7
+ describe('getSentryConfigContents', () => {
8
+ describe('client-side', () => {
9
+ it('generates client-side Sentry config with all features enabled', () => {
10
+ const template = getSentryConfigContents('my-dsn', 'client', {
11
+ performance: true,
12
+ replay: true,
13
+ });
14
+
15
+ expect(template).toMatchInlineSnapshot(`
16
+ "// This file configures the initialization of Sentry on the client.
17
+ // The config you add here will be used whenever a users loads a page in their browser.
18
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
19
+
20
+ import * as Sentry from "@sentry/nextjs";
21
+
22
+ Sentry.init({
23
+ dsn: "my-dsn",
24
+
25
+ // Add optional integrations for additional features
26
+ integrations: [
27
+ Sentry.replayIntegration(),
28
+ ],
29
+
30
+ // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
31
+ tracesSampleRate: 1,
32
+
33
+ // Define how likely Replay events are sampled.
34
+ // This sets the sample rate to be 10%. You may want this to be 100% while
35
+ // in development and sample at a lower rate in production
36
+ replaysSessionSampleRate: 0.1,
37
+
38
+ // Define how likely Replay events are sampled when an error occurs.
39
+ replaysOnErrorSampleRate: 1.0,
40
+
41
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
42
+ debug: false,
43
+ });
44
+ "
45
+ `);
46
+ });
47
+
48
+ it('generates client-side Sentry config with performance monitoring disabled', () => {
49
+ const template = getSentryConfigContents('my-dsn', 'client', {
50
+ performance: false,
51
+ replay: true,
52
+ });
53
+
54
+ expect(template).toMatchInlineSnapshot(`
55
+ "// This file configures the initialization of Sentry on the client.
56
+ // The config you add here will be used whenever a users loads a page in their browser.
57
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
58
+
59
+ import * as Sentry from "@sentry/nextjs";
60
+
61
+ Sentry.init({
62
+ dsn: "my-dsn",
63
+
64
+ // Add optional integrations for additional features
65
+ integrations: [
66
+ Sentry.replayIntegration(),
67
+ ],
68
+
69
+ // Define how likely Replay events are sampled.
70
+ // This sets the sample rate to be 10%. You may want this to be 100% while
71
+ // in development and sample at a lower rate in production
72
+ replaysSessionSampleRate: 0.1,
73
+
74
+ // Define how likely Replay events are sampled when an error occurs.
75
+ replaysOnErrorSampleRate: 1.0,
76
+
77
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
78
+ debug: false,
79
+ });
80
+ "
81
+ `);
82
+ });
83
+
84
+ it('generates client-side Sentry config with session replay disabled', () => {
85
+ const template = getSentryConfigContents('my-dsn', 'client', {
86
+ performance: true,
87
+ replay: false,
88
+ });
89
+
90
+ expect(template).toMatchInlineSnapshot(`
91
+ "// This file configures the initialization of Sentry on the client.
92
+ // The config you add here will be used whenever a users loads a page in their browser.
93
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
94
+
95
+ import * as Sentry from "@sentry/nextjs";
96
+
97
+ Sentry.init({
98
+ dsn: "my-dsn",
99
+
100
+ // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
101
+ tracesSampleRate: 1,
102
+
103
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
104
+ debug: false,
105
+ });
106
+ "
107
+ `);
108
+ });
109
+ });
110
+
111
+ describe('server-side', () => {
112
+ it('generates server-side Sentry config with all features enabled', () => {
113
+ const template = getSentryConfigContents('my-dsn', 'server', {
114
+ performance: true,
115
+ replay: true,
116
+ });
117
+
118
+ expect(template).toMatchInlineSnapshot(`
119
+ "// This file configures the initialization of Sentry on the server.
120
+ // The config you add here will be used whenever the server handles a request.
121
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
122
+
123
+ import * as Sentry from "@sentry/nextjs";
124
+
125
+ Sentry.init({
126
+ dsn: "my-dsn",
127
+
128
+ // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
129
+ tracesSampleRate: 1,
130
+
131
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
132
+ debug: false,
133
+ });
134
+ "
135
+ `);
136
+ });
137
+
138
+ it('generates server-side Sentry config with performance monitoring disabled', () => {
139
+ const template = getSentryConfigContents('my-dsn', 'server', {
140
+ performance: false,
141
+ replay: true,
142
+ });
143
+
144
+ expect(template).toMatchInlineSnapshot(`
145
+ "// This file configures the initialization of Sentry on the server.
146
+ // The config you add here will be used whenever the server handles a request.
147
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
148
+
149
+ import * as Sentry from "@sentry/nextjs";
150
+
151
+ Sentry.init({
152
+ dsn: "my-dsn",
153
+
154
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
155
+ debug: false,
156
+ });
157
+ "
158
+ `);
159
+ });
160
+
161
+ it('generates server-side Sentry config with spotlight disabled', () => {
162
+ const template = getSentryConfigContents('my-dsn', 'server', {
163
+ performance: true,
164
+ replay: true,
165
+ });
166
+
167
+ expect(template).toMatchInlineSnapshot(`
168
+ "// This file configures the initialization of Sentry on the server.
169
+ // The config you add here will be used whenever the server handles a request.
170
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
171
+
172
+ import * as Sentry from "@sentry/nextjs";
173
+
174
+ Sentry.init({
175
+ dsn: "my-dsn",
176
+
177
+ // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
178
+ tracesSampleRate: 1,
179
+
180
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
181
+ debug: false,
182
+ });
183
+ "
184
+ `);
185
+ });
186
+ });
187
+
188
+ describe('edge', () => {
189
+ it('generates edge Sentry config with all features enabled', () => {
190
+ const template = getSentryConfigContents('my-dsn', 'edge', {
191
+ performance: true,
192
+ replay: true,
193
+ });
194
+
195
+ expect(template).toMatchInlineSnapshot(`
196
+ "// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
197
+ // The config you add here will be used whenever one of the edge features is loaded.
198
+ // Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
199
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
200
+
201
+ import * as Sentry from "@sentry/nextjs";
202
+
203
+ Sentry.init({
204
+ dsn: "my-dsn",
205
+
206
+ // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
207
+ tracesSampleRate: 1,
208
+
209
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
210
+ debug: false,
211
+ });
212
+ "
213
+ `);
214
+ });
215
+
216
+ it('generates edge Sentry config with performance monitoring disabled', () => {
217
+ const template = getSentryConfigContents('my-dsn', 'edge', {
218
+ performance: false,
219
+ replay: true,
220
+ });
221
+
222
+ expect(template).toMatchInlineSnapshot(`
223
+ "// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on).
224
+ // The config you add here will be used whenever one of the edge features is loaded.
225
+ // Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.
226
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/
227
+
228
+ import * as Sentry from "@sentry/nextjs";
229
+
230
+ Sentry.init({
231
+ dsn: "my-dsn",
232
+
233
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
234
+ debug: false,
235
+ });
236
+ "
237
+ `);
238
+ });
239
+ });
240
+ });
2
241
 
3
- describe('NextJS code templates', () => {
4
242
  describe('getWithSentryConfigOptionsTemplate', () => {
5
243
  it('generates options for SaaS', () => {
6
244
  const template = getWithSentryConfigOptionsTemplate({
@@ -9,6 +247,7 @@ describe('NextJS code templates', () => {
9
247
  selfHosted: false,
10
248
  sentryUrl: 'https://dont-use-this-url.com',
11
249
  tunnelRoute: true,
250
+ reactComponentAnnotation: false,
12
251
  });
13
252
 
14
253
  expect(template).toMatchInlineSnapshot(`
@@ -56,6 +295,7 @@ describe('NextJS code templates', () => {
56
295
  selfHosted: true,
57
296
  sentryUrl: 'https://my-sentry.com',
58
297
  tunnelRoute: true,
298
+ reactComponentAnnotation: false,
59
299
  });
60
300
 
61
301
  expect(template).toMatchInlineSnapshot(`
@@ -104,6 +344,7 @@ describe('NextJS code templates', () => {
104
344
  selfHosted: false,
105
345
  sentryUrl: 'https://dont-use-this-url.com',
106
346
  tunnelRoute: false,
347
+ reactComponentAnnotation: false,
107
348
  });
108
349
 
109
350
  expect(template).toMatchInlineSnapshot(`
@@ -143,5 +384,58 @@ describe('NextJS code templates', () => {
143
384
  }"
144
385
  `);
145
386
  });
387
+
388
+ it('adds `reactComponentAnnotations` option if `reactComponentAnnotations` is enabled', () => {
389
+ const template = getWithSentryConfigOptionsTemplate({
390
+ orgSlug: 'my-org',
391
+ projectSlug: 'my-project',
392
+ selfHosted: false,
393
+ sentryUrl: 'https://dont-use-this-url.com',
394
+ tunnelRoute: true,
395
+ reactComponentAnnotation: true,
396
+ });
397
+
398
+ expect(template).toMatchInlineSnapshot(`
399
+ "{
400
+ // For all available options, see:
401
+ // https://github.com/getsentry/sentry-webpack-plugin#options
402
+
403
+ org: "my-org",
404
+ project: "my-project",
405
+
406
+ // Only print logs for uploading source maps in CI
407
+ silent: !process.env.CI,
408
+
409
+ // For all available options, see:
410
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
411
+
412
+ // Upload a larger set of source maps for prettier stack traces (increases build time)
413
+ widenClientFileUpload: true,
414
+
415
+ // Automatically annotate React components to show their full name in breadcrumbs and session replay
416
+ reactComponentAnnotation: {
417
+ enabled: true,
418
+ },
419
+
420
+ // Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
421
+ // This can increase your server load as well as your hosting bill.
422
+ // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
423
+ // side errors will fail.
424
+ tunnelRoute: "/monitoring",
425
+
426
+ // Hides source maps from generated client bundles
427
+ hideSourceMaps: true,
428
+
429
+ // Automatically tree-shake Sentry logger statements to reduce bundle size
430
+ disableLogger: true,
431
+
432
+ // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
433
+ // See the following for more information:
434
+ // https://docs.sentry.io/product/crons/
435
+ // https://vercel.com/docs/cron-jobs
436
+ automaticVercelMonitors: true,
437
+ }"
438
+ `);
439
+ });
146
440
  });
147
441
  });
@@ -38,7 +38,8 @@ describe('addSentryCommandToBuildCommand', () => {
38
38
  [
39
39
  packageManagerHelpers.NPM,
40
40
  packageManagerHelpers.PNPM,
41
- packageManagerHelpers.YARN,
41
+ packageManagerHelpers.YARN_V1,
42
+ packageManagerHelpers.YARN_V2,
42
43
  packageManagerHelpers.BUN,
43
44
  ],
44
45
  ])('adds the cli command to the script command (%s)', async (_, pacMan) => {