@sentry/wizard 3.26.0 → 3.28.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 (50) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/package.json +2 -1
  3. package/dist/src/nextjs/nextjs-wizard.js +81 -25
  4. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  5. package/dist/src/nextjs/templates.d.ts +4 -1
  6. package/dist/src/nextjs/templates.js +18 -7
  7. package/dist/src/nextjs/templates.js.map +1 -1
  8. package/dist/src/run.js +1 -1
  9. package/dist/src/run.js.map +1 -1
  10. package/dist/src/sourcemaps/sourcemaps-wizard.js +1 -1
  11. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  12. package/dist/src/sveltekit/sdk-setup.js +64 -43
  13. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  14. package/dist/src/sveltekit/sveltekit-wizard.d.ts +1 -1
  15. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  16. package/dist/src/sveltekit/templates.d.ts +8 -2
  17. package/dist/src/sveltekit/templates.js +11 -5
  18. package/dist/src/sveltekit/templates.js.map +1 -1
  19. package/dist/src/utils/clack-utils.d.ts +4 -1
  20. package/dist/src/utils/clack-utils.js +47 -1
  21. package/dist/src/utils/clack-utils.js.map +1 -1
  22. package/dist/src/utils/package-manager.d.ts +4 -1
  23. package/dist/src/utils/package-manager.js +40 -5
  24. package/dist/src/utils/package-manager.js.map +1 -1
  25. package/dist/src/utils/types.d.ts +6 -0
  26. package/dist/src/utils/types.js.map +1 -1
  27. package/dist/src/utils/url.js +7 -2
  28. package/dist/src/utils/url.js.map +1 -1
  29. package/dist/test/nextjs/templates.test.js +65 -1
  30. package/dist/test/nextjs/templates.test.js.map +1 -1
  31. package/dist/test/sourcemaps/tools/sentry-cli.test.js +2 -1
  32. package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
  33. package/dist/test/sveltekit/templates.test.d.ts +1 -0
  34. package/dist/test/sveltekit/templates.test.js +43 -0
  35. package/dist/test/sveltekit/templates.test.js.map +1 -0
  36. package/package.json +2 -1
  37. package/src/nextjs/nextjs-wizard.ts +67 -7
  38. package/src/nextjs/templates.ts +35 -22
  39. package/src/run.ts +1 -1
  40. package/src/sourcemaps/sourcemaps-wizard.ts +1 -1
  41. package/src/sveltekit/sdk-setup.ts +100 -22
  42. package/src/sveltekit/sveltekit-wizard.ts +1 -1
  43. package/src/sveltekit/templates.ts +36 -10
  44. package/src/utils/clack-utils.ts +34 -1
  45. package/src/utils/package-manager.ts +38 -4
  46. package/src/utils/types.ts +7 -0
  47. package/src/utils/url.ts +6 -2
  48. package/test/nextjs/templates.test.ts +240 -2
  49. package/test/sourcemaps/tools/sentry-cli.test.ts +2 -1
  50. package/test/sveltekit/templates.test.ts +152 -0
@@ -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({
@@ -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) => {
@@ -0,0 +1,152 @@
1
+ import {
2
+ getClientHooksTemplate,
3
+ getServerHooksTemplate,
4
+ } from '../../src/sveltekit/templates';
5
+
6
+ describe('getClientHooksTemplate', () => {
7
+ it('should generate client hooks template with all features enabled', () => {
8
+ const result = getClientHooksTemplate('https://sentry.io/123', {
9
+ performance: true,
10
+ replay: true,
11
+ });
12
+
13
+ expect(result).toMatchInlineSnapshot(`
14
+ "import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
15
+ import * as Sentry from '@sentry/sveltekit';
16
+
17
+ Sentry.init({
18
+ dsn: 'https://sentry.io/123',
19
+
20
+ tracesSampleRate: 1.0,
21
+
22
+ // This sets the sample rate to be 10%. You may want this to be 100% while
23
+ // in development and sample at a lower rate in production
24
+ replaysSessionSampleRate: 0.1,
25
+
26
+ // If the entire session is not sampled, use the below sample rate to sample
27
+ // sessions when an error occurs.
28
+ replaysOnErrorSampleRate: 1.0,
29
+
30
+ // If you don't want to use Session Replay, just remove the line below:
31
+ integrations: [replayIntegration()],
32
+ });
33
+
34
+ // If you have a custom error handler, pass it to \`handleErrorWithSentry\`
35
+ export const handleError = handleErrorWithSentry();
36
+ "
37
+ `);
38
+ });
39
+
40
+ it('should generate client hooks template when performance disabled', () => {
41
+ const result = getClientHooksTemplate('https://sentry.io/123', {
42
+ performance: false,
43
+ replay: true,
44
+ });
45
+
46
+ expect(result).toMatchInlineSnapshot(`
47
+ "import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
48
+ import * as Sentry from '@sentry/sveltekit';
49
+
50
+ Sentry.init({
51
+ dsn: 'https://sentry.io/123',
52
+
53
+ // This sets the sample rate to be 10%. You may want this to be 100% while
54
+ // in development and sample at a lower rate in production
55
+ replaysSessionSampleRate: 0.1,
56
+
57
+ // If the entire session is not sampled, use the below sample rate to sample
58
+ // sessions when an error occurs.
59
+ replaysOnErrorSampleRate: 1.0,
60
+
61
+ // If you don't want to use Session Replay, just remove the line below:
62
+ integrations: [replayIntegration()],
63
+ });
64
+
65
+ // If you have a custom error handler, pass it to \`handleErrorWithSentry\`
66
+ export const handleError = handleErrorWithSentry();
67
+ "
68
+ `);
69
+ });
70
+
71
+ it('should generate client hooks template when replay disabled', () => {
72
+ const result = getClientHooksTemplate('https://sentry.io/123', {
73
+ performance: true,
74
+ replay: false,
75
+ });
76
+
77
+ expect(result).toMatchInlineSnapshot(`
78
+ "import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
79
+ import * as Sentry from '@sentry/sveltekit';
80
+
81
+ Sentry.init({
82
+ dsn: 'https://sentry.io/123',
83
+
84
+ tracesSampleRate: 1.0,
85
+
86
+
87
+ });
88
+
89
+ // If you have a custom error handler, pass it to \`handleErrorWithSentry\`
90
+ export const handleError = handleErrorWithSentry();
91
+ "
92
+ `);
93
+ });
94
+ });
95
+
96
+ describe('getServerHooksTemplate', () => {
97
+ it('should generate server hooks template with all features enabled', () => {
98
+ const result = getServerHooksTemplate('https://sentry.io/123', {
99
+ performance: true,
100
+ replay: true,
101
+ });
102
+
103
+ expect(result).toMatchInlineSnapshot(`
104
+ "import { sequence } from "@sveltejs/kit/hooks";
105
+ import { handleErrorWithSentry, sentryHandle } from "@sentry/sveltekit";
106
+ import * as Sentry from '@sentry/sveltekit';
107
+
108
+ Sentry.init({
109
+ dsn: 'https://sentry.io/123',
110
+
111
+ tracesSampleRate: 1.0,
112
+
113
+ // uncomment the line below to enable Spotlight (https://spotlightjs.com)
114
+ // spotlight: import.meta.env.DEV,
115
+ });
116
+
117
+ // If you have custom handlers, make sure to place them after \`sentryHandle()\` in the \`sequence\` function.
118
+ export const handle = sequence(sentryHandle());
119
+
120
+ // If you have a custom error handler, pass it to \`handleErrorWithSentry\`
121
+ export const handleError = handleErrorWithSentry();
122
+ "
123
+ `);
124
+ });
125
+
126
+ it('should generate server hooks template when performance disabled', () => {
127
+ const result = getServerHooksTemplate('https://sentry.io/123', {
128
+ performance: false,
129
+ replay: true,
130
+ });
131
+
132
+ expect(result).toMatchInlineSnapshot(`
133
+ "import { sequence } from "@sveltejs/kit/hooks";
134
+ import { handleErrorWithSentry, sentryHandle } from "@sentry/sveltekit";
135
+ import * as Sentry from '@sentry/sveltekit';
136
+
137
+ Sentry.init({
138
+ dsn: 'https://sentry.io/123',
139
+
140
+ // uncomment the line below to enable Spotlight (https://spotlightjs.com)
141
+ // spotlight: import.meta.env.DEV,
142
+ });
143
+
144
+ // If you have custom handlers, make sure to place them after \`sentryHandle()\` in the \`sequence\` function.
145
+ export const handle = sequence(sentryHandle());
146
+
147
+ // If you have a custom error handler, pass it to \`handleErrorWithSentry\`
148
+ export const handleError = handleErrorWithSentry();
149
+ "
150
+ `);
151
+ });
152
+ });