@sentry/wizard 3.14.0 → 3.15.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 (34) hide show
  1. package/CHANGELOG.md +15 -3
  2. package/dist/package.json +1 -1
  3. package/dist/src/remix/codemods/handle-error.js +28 -0
  4. package/dist/src/remix/codemods/handle-error.js.map +1 -1
  5. package/dist/src/remix/codemods/root-common.d.ts +2 -0
  6. package/dist/src/remix/codemods/root-common.js +70 -0
  7. package/dist/src/remix/codemods/root-common.js.map +1 -0
  8. package/dist/src/remix/codemods/root-v1.js +5 -36
  9. package/dist/src/remix/codemods/root-v1.js.map +1 -1
  10. package/dist/src/remix/codemods/root-v2.js +53 -4
  11. package/dist/src/remix/codemods/root-v2.js.map +1 -1
  12. package/dist/src/remix/remix-wizard.js +7 -4
  13. package/dist/src/remix/remix-wizard.js.map +1 -1
  14. package/dist/src/remix/sdk-setup.d.ts +1 -0
  15. package/dist/src/remix/sdk-setup.js +10 -6
  16. package/dist/src/remix/sdk-setup.js.map +1 -1
  17. package/dist/src/remix/templates.d.ts +1 -1
  18. package/dist/src/remix/templates.js +1 -1
  19. package/dist/src/remix/templates.js.map +1 -1
  20. package/dist/src/remix/utils.d.ts +2 -0
  21. package/dist/src/remix/utils.js +6 -1
  22. package/dist/src/remix/utils.js.map +1 -1
  23. package/dist/src/sveltekit/sdk-setup.js +7 -3
  24. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  25. package/package.json +1 -1
  26. package/src/remix/codemods/handle-error.ts +30 -0
  27. package/src/remix/codemods/root-common.ts +63 -0
  28. package/src/remix/codemods/root-v1.ts +3 -53
  29. package/src/remix/codemods/root-v2.ts +71 -2
  30. package/src/remix/remix-wizard.ts +7 -4
  31. package/src/remix/sdk-setup.ts +14 -6
  32. package/src/remix/templates.ts +2 -6
  33. package/src/remix/utils.ts +5 -0
  34. package/src/sveltekit/sdk-setup.ts +6 -3
@@ -164,6 +164,7 @@ export async function updateBuildScript(args: {
164
164
  org: string;
165
165
  project: string;
166
166
  url?: string;
167
+ isHydrogen: boolean;
167
168
  }): Promise<void> {
168
169
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
169
170
  // Add sourcemaps option to build script
@@ -177,17 +178,24 @@ export async function updateBuildScript(args: {
177
178
  packageJson.scripts = {};
178
179
  }
179
180
 
181
+ const buildCommand = args.isHydrogen
182
+ ? 'shopify hydrogen build'
183
+ : 'remix build';
184
+
185
+ const instrumentedBuildCommand =
186
+ `${buildCommand} --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +
187
+ (args.url ? ` --url ${args.url}` : '') +
188
+ (args.isHydrogen ? ' --buildPath ./dist' : '');
189
+
180
190
  if (!packageJson.scripts.build) {
181
- packageJson.scripts.build =
182
- `remix build --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +
183
- (args.url ? ` --url ${args.url}` : '');
191
+ packageJson.scripts.build = instrumentedBuildCommand;
184
192
 
185
193
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
186
- } else if (packageJson.scripts.build.includes('remix build')) {
194
+ } else if (packageJson.scripts.build.includes(buildCommand)) {
187
195
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
188
196
  packageJson.scripts.build = packageJson.scripts.build.replace(
189
- 'remix build',
190
- 'remix build --sourcemap && sentry-upload-sourcemaps',
197
+ buildCommand,
198
+ instrumentedBuildCommand,
191
199
  );
192
200
  }
193
201
 
@@ -5,11 +5,7 @@ export const ERROR_BOUNDARY_TEMPLATE_V2 = `const ErrorBoundary = () => {
5
5
  };
6
6
  `;
7
7
 
8
- export const HANDLE_ERROR_TEMPLATE_V2 = `function handleError(error) {
9
- if (error instanceof Error) {
10
- Sentry.captureRemixErrorBoundaryError(error);
11
- } else {
12
- Sentry.captureException(error);
13
- }
8
+ export const HANDLE_ERROR_TEMPLATE_V2 = `function handleError(error, { request }) {
9
+ Sentry.captureRemixServerException(error, 'remix.server', request);
14
10
  }
15
11
  `;
@@ -5,6 +5,7 @@ import * as path from 'path';
5
5
  // @ts-expect-error - clack is ESM and TS complains about that. It works though
6
6
  import clack from '@clack/prompts';
7
7
  import chalk from 'chalk';
8
+ import { PackageDotJson, hasPackageInstalled } from '../utils/package-json';
8
9
 
9
10
  // Copied from sveltekit wizard
10
11
  export function hasSentryContent(
@@ -39,3 +40,7 @@ export function getInitCallInsertionIndex(
39
40
 
40
41
  return 0;
41
42
  }
43
+
44
+ export function isHydrogenApp(packageJson: PackageDotJson): boolean {
45
+ return hasPackageInstalled('@shopify/hydrogen', packageJson);
46
+ }
@@ -440,14 +440,14 @@ async function modifyViteConfig(
440
440
 
441
441
  const { org, project, url, selfHosted } = projectInfo;
442
442
 
443
+ const prettyViteConfigFilename = chalk.cyan(path.basename(viteConfigPath));
444
+
443
445
  try {
444
446
  const viteModule = parseModule(viteConfigContent);
445
447
 
446
448
  if (hasSentryContent(viteModule.$ast as t.Program)) {
447
449
  clack.log.warn(
448
- `File ${chalk.cyan(
449
- path.basename(viteConfigPath),
450
- )} already contains Sentry code.
450
+ `File ${prettyViteConfigFilename} already contains Sentry code.
451
451
  Skipping adding Sentry functionality to.`,
452
452
  );
453
453
  Sentry.setTag(`modified-vite-cfg`, 'fail');
@@ -490,6 +490,9 @@ Skipping adding Sentry functionality to.`,
490
490
  );
491
491
  Sentry.captureException('Sveltekit Vite Config Modification Fail');
492
492
  }
493
+
494
+ clack.log.success(`Added Sentry code to ${prettyViteConfigFilename}`);
495
+ Sentry.setTag(`modified-vite-cfg`, 'success');
493
496
  }
494
497
 
495
498
  async function showFallbackViteCopyPasteSnippet(