@sentry/wizard 3.23.0 → 3.23.2
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.
- package/CHANGELOG.md +11 -0
- package/dist/lib/Steps/Integrations/Electron.js +4 -2
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/lib/Steps/PromptForParameters.d.ts +1 -0
- package/dist/lib/Steps/PromptForParameters.js +8 -2
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/apple/xcode-manager.js +5 -3
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +24 -16
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +3 -3
- package/dist/src/nextjs/templates.js +3 -3
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/test/nextjs/templates.test.d.ts +1 -0
- package/dist/test/nextjs/templates.test.js +38 -0
- package/dist/test/nextjs/templates.test.js.map +1 -0
- package/lib/Steps/Integrations/Electron.ts +18 -3
- package/lib/Steps/PromptForParameters.ts +12 -1
- package/package.json +1 -1
- package/src/apple/xcode-manager.ts +9 -5
- package/src/nextjs/nextjs-wizard.ts +32 -12
- package/src/nextjs/templates.ts +7 -5
- package/test/nextjs/templates.test.ts +147 -0
|
@@ -66,6 +66,8 @@ export async function runNextjsWizardWithTelemetry(
|
|
|
66
66
|
telemetryEnabled: options.telemetryEnabled,
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
const typeScriptDetected = isUsingTypeScript();
|
|
70
|
+
|
|
69
71
|
await confirmContinueIfNoOrDirtyGitRepo();
|
|
70
72
|
|
|
71
73
|
const packageJson = await getPackageDotJson();
|
|
@@ -236,15 +238,19 @@ export async function runNextjsWizardWithTelemetry(
|
|
|
236
238
|
: undefined;
|
|
237
239
|
|
|
238
240
|
if (!globalErrorPageFile) {
|
|
241
|
+
const newGlobalErrorFileName = `global-error.${
|
|
242
|
+
typeScriptDetected ? 'tsx' : 'jsx'
|
|
243
|
+
}`;
|
|
244
|
+
|
|
239
245
|
await fs.promises.writeFile(
|
|
240
|
-
path.join(process.cwd(), ...appDirLocation,
|
|
246
|
+
path.join(process.cwd(), ...appDirLocation, newGlobalErrorFileName),
|
|
241
247
|
getSentryDefaultGlobalErrorPage(),
|
|
242
248
|
{ encoding: 'utf8', flag: 'w' },
|
|
243
249
|
);
|
|
244
250
|
|
|
245
251
|
clack.log.success(
|
|
246
252
|
`Created ${chalk.cyan(
|
|
247
|
-
path.join(...appDirLocation,
|
|
253
|
+
path.join(...appDirLocation, newGlobalErrorFileName),
|
|
248
254
|
)}.`,
|
|
249
255
|
);
|
|
250
256
|
} else {
|
|
@@ -417,11 +423,14 @@ async function createOrMergeNextJsFiles(
|
|
|
417
423
|
}
|
|
418
424
|
|
|
419
425
|
if (instrumentationHookLocation === 'does-not-exist') {
|
|
426
|
+
const newInstrumentationFileName = `instrumentation.${
|
|
427
|
+
typeScriptDetected ? 'ts' : 'js'
|
|
428
|
+
}`;
|
|
420
429
|
const srcFolderExists = fs.existsSync(path.join(process.cwd(), 'src'));
|
|
421
430
|
|
|
422
431
|
const instrumentationHookPath = srcFolderExists
|
|
423
|
-
? path.join(process.cwd(), 'src',
|
|
424
|
-
: path.join(process.cwd(),
|
|
432
|
+
? path.join(process.cwd(), 'src', newInstrumentationFileName)
|
|
433
|
+
: path.join(process.cwd(), newInstrumentationFileName);
|
|
425
434
|
|
|
426
435
|
const successfullyCreated = await createNewConfigFile(
|
|
427
436
|
instrumentationHookPath,
|
|
@@ -430,7 +439,7 @@ async function createOrMergeNextJsFiles(
|
|
|
430
439
|
|
|
431
440
|
if (!successfullyCreated) {
|
|
432
441
|
await showCopyPasteInstructions(
|
|
433
|
-
|
|
442
|
+
newInstrumentationFileName,
|
|
434
443
|
getInstrumentationHookCopyPasteSnippet(
|
|
435
444
|
srcFolderExists ? 'src' : 'root',
|
|
436
445
|
),
|
|
@@ -455,7 +464,7 @@ async function createOrMergeNextJsFiles(
|
|
|
455
464
|
orgSlug: selectedProject.organization.slug,
|
|
456
465
|
projectSlug: selectedProject.slug,
|
|
457
466
|
selfHosted,
|
|
458
|
-
|
|
467
|
+
sentryUrl,
|
|
459
468
|
tunnelRoute: sdkConfigOptions.tunnelRoute,
|
|
460
469
|
});
|
|
461
470
|
|
|
@@ -630,6 +639,8 @@ async function createExamplePage(
|
|
|
630
639
|
const maybeAppDirPath = path.join(process.cwd(), 'app');
|
|
631
640
|
const maybeSrcAppDirPath = path.join(srcDir, 'app');
|
|
632
641
|
|
|
642
|
+
const typeScriptDetected = isUsingTypeScript();
|
|
643
|
+
|
|
633
644
|
let pagesLocation =
|
|
634
645
|
fs.existsSync(maybePagesDirPath) &&
|
|
635
646
|
fs.lstatSync(maybePagesDirPath).isDirectory()
|
|
@@ -665,7 +676,7 @@ async function createExamplePage(
|
|
|
665
676
|
selfHosted,
|
|
666
677
|
orgSlug: selectedProject.organization.slug,
|
|
667
678
|
projectId: selectedProject.id,
|
|
668
|
-
|
|
679
|
+
sentryUrl,
|
|
669
680
|
useClient: true,
|
|
670
681
|
});
|
|
671
682
|
|
|
@@ -676,12 +687,14 @@ async function createExamplePage(
|
|
|
676
687
|
},
|
|
677
688
|
);
|
|
678
689
|
|
|
690
|
+
const newPageFileName = `page.${typeScriptDetected ? 'tsx' : 'jsx'}`;
|
|
691
|
+
|
|
679
692
|
await fs.promises.writeFile(
|
|
680
693
|
path.join(
|
|
681
694
|
process.cwd(),
|
|
682
695
|
...appLocation,
|
|
683
696
|
'sentry-example-page',
|
|
684
|
-
|
|
697
|
+
newPageFileName,
|
|
685
698
|
),
|
|
686
699
|
examplePageContents,
|
|
687
700
|
{ encoding: 'utf8', flag: 'w' },
|
|
@@ -689,7 +702,7 @@ async function createExamplePage(
|
|
|
689
702
|
|
|
690
703
|
clack.log.success(
|
|
691
704
|
`Created ${chalk.cyan(
|
|
692
|
-
path.join(...appLocation, 'sentry-example-page',
|
|
705
|
+
path.join(...appLocation, 'sentry-example-page', newPageFileName),
|
|
693
706
|
)}.`,
|
|
694
707
|
);
|
|
695
708
|
|
|
@@ -700,13 +713,15 @@ async function createExamplePage(
|
|
|
700
713
|
},
|
|
701
714
|
);
|
|
702
715
|
|
|
716
|
+
const newRouteFileName = `route.${typeScriptDetected ? 'ts' : 'js'}`;
|
|
717
|
+
|
|
703
718
|
await fs.promises.writeFile(
|
|
704
719
|
path.join(
|
|
705
720
|
process.cwd(),
|
|
706
721
|
...appLocation,
|
|
707
722
|
'api',
|
|
708
723
|
'sentry-example-api',
|
|
709
|
-
|
|
724
|
+
newRouteFileName,
|
|
710
725
|
),
|
|
711
726
|
getSentryExampleAppDirApiRoute(),
|
|
712
727
|
{ encoding: 'utf8', flag: 'w' },
|
|
@@ -714,7 +729,12 @@ async function createExamplePage(
|
|
|
714
729
|
|
|
715
730
|
clack.log.success(
|
|
716
731
|
`Created ${chalk.cyan(
|
|
717
|
-
path.join(
|
|
732
|
+
path.join(
|
|
733
|
+
...appLocation,
|
|
734
|
+
'api',
|
|
735
|
+
'sentry-example-api',
|
|
736
|
+
newRouteFileName,
|
|
737
|
+
),
|
|
718
738
|
)}.`,
|
|
719
739
|
);
|
|
720
740
|
} else if (pagesLocation) {
|
|
@@ -722,7 +742,7 @@ async function createExamplePage(
|
|
|
722
742
|
selfHosted,
|
|
723
743
|
orgSlug: selectedProject.organization.slug,
|
|
724
744
|
projectId: selectedProject.id,
|
|
725
|
-
|
|
745
|
+
sentryUrl,
|
|
726
746
|
useClient: false,
|
|
727
747
|
});
|
|
728
748
|
|
package/src/nextjs/templates.ts
CHANGED
|
@@ -5,7 +5,7 @@ type WithSentryConfigOptions = {
|
|
|
5
5
|
orgSlug: string;
|
|
6
6
|
projectSlug: string;
|
|
7
7
|
selfHosted: boolean;
|
|
8
|
-
|
|
8
|
+
sentryUrl: string;
|
|
9
9
|
tunnelRoute: boolean;
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -14,14 +14,16 @@ export function getWithSentryConfigOptionsTemplate({
|
|
|
14
14
|
projectSlug,
|
|
15
15
|
selfHosted,
|
|
16
16
|
tunnelRoute,
|
|
17
|
-
|
|
17
|
+
sentryUrl,
|
|
18
18
|
}: WithSentryConfigOptions): string {
|
|
19
19
|
return `{
|
|
20
20
|
// For all available options, see:
|
|
21
21
|
// https://github.com/getsentry/sentry-webpack-plugin#options
|
|
22
22
|
|
|
23
23
|
org: "${orgSlug}",
|
|
24
|
-
project: "${projectSlug}",${
|
|
24
|
+
project: "${projectSlug}",${
|
|
25
|
+
selfHosted ? `\n sentryUrl: "${sentryUrl}"` : ''
|
|
26
|
+
}
|
|
25
27
|
|
|
26
28
|
// Only print logs for uploading source maps in CI
|
|
27
29
|
silent: !process.env.CI,
|
|
@@ -168,13 +170,13 @@ Sentry.init({
|
|
|
168
170
|
|
|
169
171
|
export function getSentryExamplePageContents(options: {
|
|
170
172
|
selfHosted: boolean;
|
|
171
|
-
|
|
173
|
+
sentryUrl: string;
|
|
172
174
|
orgSlug: string;
|
|
173
175
|
projectId: string;
|
|
174
176
|
useClient: boolean;
|
|
175
177
|
}): string {
|
|
176
178
|
const issuesPageLink = options.selfHosted
|
|
177
|
-
? `${options.
|
|
179
|
+
? `${options.sentryUrl}organizations/${options.orgSlug}/issues/?project=${options.projectId}`
|
|
178
180
|
: `https://${options.orgSlug}.sentry.io/issues/?project=${options.projectId}`;
|
|
179
181
|
|
|
180
182
|
return `${
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { getWithSentryConfigOptionsTemplate } from '../../src/nextjs/templates';
|
|
2
|
+
|
|
3
|
+
describe('NextJS code templates', () => {
|
|
4
|
+
describe('getWithSentryConfigOptionsTemplate', () => {
|
|
5
|
+
it('generates options for SaaS', () => {
|
|
6
|
+
const template = getWithSentryConfigOptionsTemplate({
|
|
7
|
+
orgSlug: 'my-org',
|
|
8
|
+
projectSlug: 'my-project',
|
|
9
|
+
selfHosted: false,
|
|
10
|
+
sentryUrl: 'https://dont-use-this-url.com',
|
|
11
|
+
tunnelRoute: true,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
expect(template).toMatchInlineSnapshot(`
|
|
15
|
+
"{
|
|
16
|
+
// For all available options, see:
|
|
17
|
+
// https://github.com/getsentry/sentry-webpack-plugin#options
|
|
18
|
+
|
|
19
|
+
org: "my-org",
|
|
20
|
+
project: "my-project",
|
|
21
|
+
|
|
22
|
+
// Only print logs for uploading source maps in CI
|
|
23
|
+
silent: !process.env.CI,
|
|
24
|
+
|
|
25
|
+
// For all available options, see:
|
|
26
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
|
27
|
+
|
|
28
|
+
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
|
29
|
+
widenClientFileUpload: true,
|
|
30
|
+
|
|
31
|
+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
|
|
32
|
+
// This can increase your server load as well as your hosting bill.
|
|
33
|
+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
|
|
34
|
+
// side errors will fail.
|
|
35
|
+
tunnelRoute: "/monitoring",
|
|
36
|
+
|
|
37
|
+
// Hides source maps from generated client bundles
|
|
38
|
+
hideSourceMaps: true,
|
|
39
|
+
|
|
40
|
+
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
41
|
+
disableLogger: true,
|
|
42
|
+
|
|
43
|
+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
|
|
44
|
+
// See the following for more information:
|
|
45
|
+
// https://docs.sentry.io/product/crons/
|
|
46
|
+
// https://vercel.com/docs/cron-jobs
|
|
47
|
+
automaticVercelMonitors: true,
|
|
48
|
+
}"
|
|
49
|
+
`);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('generates options for self-hosted', () => {
|
|
53
|
+
const template = getWithSentryConfigOptionsTemplate({
|
|
54
|
+
orgSlug: 'my-org',
|
|
55
|
+
projectSlug: 'my-project',
|
|
56
|
+
selfHosted: true,
|
|
57
|
+
sentryUrl: 'https://my-sentry.com',
|
|
58
|
+
tunnelRoute: true,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(template).toMatchInlineSnapshot(`
|
|
62
|
+
"{
|
|
63
|
+
// For all available options, see:
|
|
64
|
+
// https://github.com/getsentry/sentry-webpack-plugin#options
|
|
65
|
+
|
|
66
|
+
org: "my-org",
|
|
67
|
+
project: "my-project",
|
|
68
|
+
sentryUrl: "https://my-sentry.com"
|
|
69
|
+
|
|
70
|
+
// Only print logs for uploading source maps in CI
|
|
71
|
+
silent: !process.env.CI,
|
|
72
|
+
|
|
73
|
+
// For all available options, see:
|
|
74
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
|
75
|
+
|
|
76
|
+
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
|
77
|
+
widenClientFileUpload: true,
|
|
78
|
+
|
|
79
|
+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
|
|
80
|
+
// This can increase your server load as well as your hosting bill.
|
|
81
|
+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
|
|
82
|
+
// side errors will fail.
|
|
83
|
+
tunnelRoute: "/monitoring",
|
|
84
|
+
|
|
85
|
+
// Hides source maps from generated client bundles
|
|
86
|
+
hideSourceMaps: true,
|
|
87
|
+
|
|
88
|
+
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
89
|
+
disableLogger: true,
|
|
90
|
+
|
|
91
|
+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
|
|
92
|
+
// See the following for more information:
|
|
93
|
+
// https://docs.sentry.io/product/crons/
|
|
94
|
+
// https://vercel.com/docs/cron-jobs
|
|
95
|
+
automaticVercelMonitors: true,
|
|
96
|
+
}"
|
|
97
|
+
`);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('comments out tunnelRoute if `tunnelRoute` option is disabled', () => {
|
|
101
|
+
const template = getWithSentryConfigOptionsTemplate({
|
|
102
|
+
orgSlug: 'my-org',
|
|
103
|
+
projectSlug: 'my-project',
|
|
104
|
+
selfHosted: false,
|
|
105
|
+
sentryUrl: 'https://dont-use-this-url.com',
|
|
106
|
+
tunnelRoute: false,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
expect(template).toMatchInlineSnapshot(`
|
|
110
|
+
"{
|
|
111
|
+
// For all available options, see:
|
|
112
|
+
// https://github.com/getsentry/sentry-webpack-plugin#options
|
|
113
|
+
|
|
114
|
+
org: "my-org",
|
|
115
|
+
project: "my-project",
|
|
116
|
+
|
|
117
|
+
// Only print logs for uploading source maps in CI
|
|
118
|
+
silent: !process.env.CI,
|
|
119
|
+
|
|
120
|
+
// For all available options, see:
|
|
121
|
+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
|
122
|
+
|
|
123
|
+
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
|
124
|
+
widenClientFileUpload: true,
|
|
125
|
+
|
|
126
|
+
// Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
|
|
127
|
+
// This can increase your server load as well as your hosting bill.
|
|
128
|
+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
|
|
129
|
+
// side errors will fail.
|
|
130
|
+
// tunnelRoute: "/monitoring",
|
|
131
|
+
|
|
132
|
+
// Hides source maps from generated client bundles
|
|
133
|
+
hideSourceMaps: true,
|
|
134
|
+
|
|
135
|
+
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
136
|
+
disableLogger: true,
|
|
137
|
+
|
|
138
|
+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
|
|
139
|
+
// See the following for more information:
|
|
140
|
+
// https://docs.sentry.io/product/crons/
|
|
141
|
+
// https://vercel.com/docs/cron-jobs
|
|
142
|
+
automaticVercelMonitors: true,
|
|
143
|
+
}"
|
|
144
|
+
`);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|