@sentry/wizard 3.9.2 → 3.11.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 (168) hide show
  1. package/CHANGELOG.md +58 -6
  2. package/dist/lib/Constants.d.ts +2 -0
  3. package/dist/lib/Constants.js +10 -0
  4. package/dist/lib/Constants.js.map +1 -1
  5. package/dist/lib/Steps/ChooseIntegration.js +15 -4
  6. package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
  7. package/dist/lib/Steps/Integrations/Android.d.ts +9 -0
  8. package/dist/lib/Steps/Integrations/Android.js +86 -0
  9. package/dist/lib/Steps/Integrations/Android.js.map +1 -0
  10. package/dist/lib/Steps/Integrations/Cordova.js +5 -1
  11. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  12. package/dist/lib/Steps/Integrations/ReactNative.js +3 -3
  13. package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
  14. package/dist/lib/Steps/Integrations/Remix.d.ts +12 -0
  15. package/dist/lib/Steps/Integrations/Remix.js +98 -0
  16. package/dist/lib/Steps/Integrations/Remix.js.map +1 -0
  17. package/dist/lib/Steps/PromptForParameters.js +36 -3
  18. package/dist/lib/Steps/PromptForParameters.js.map +1 -1
  19. package/dist/lib/Steps/SentryProjectSelector.js +1 -1
  20. package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
  21. package/dist/package.json +4 -3
  22. package/dist/src/android/android-wizard.d.ts +2 -0
  23. package/dist/src/android/android-wizard.js +217 -0
  24. package/dist/src/android/android-wizard.js.map +1 -0
  25. package/dist/src/android/code-tools.d.ts +39 -0
  26. package/dist/src/android/code-tools.js +161 -0
  27. package/dist/src/android/code-tools.js.map +1 -0
  28. package/dist/src/android/gradle.d.ts +62 -0
  29. package/dist/src/android/gradle.js +281 -0
  30. package/dist/src/android/gradle.js.map +1 -0
  31. package/dist/src/android/manifest.d.ts +57 -0
  32. package/dist/src/android/manifest.js +183 -0
  33. package/dist/src/android/manifest.js.map +1 -0
  34. package/dist/src/android/templates.d.ts +11 -0
  35. package/dist/src/android/templates.js +34 -0
  36. package/dist/src/android/templates.js.map +1 -0
  37. package/dist/src/apple/apple-wizard.js +123 -64
  38. package/dist/src/apple/apple-wizard.js.map +1 -1
  39. package/dist/src/apple/cocoapod.js +4 -3
  40. package/dist/src/apple/cocoapod.js.map +1 -1
  41. package/dist/src/apple/code-tools.d.ts +1 -1
  42. package/dist/src/apple/code-tools.js +43 -19
  43. package/dist/src/apple/code-tools.js.map +1 -1
  44. package/dist/src/apple/fastlane.d.ts +1 -1
  45. package/dist/src/apple/fastlane.js +12 -6
  46. package/dist/src/apple/fastlane.js.map +1 -1
  47. package/dist/src/apple/templates.d.ts +2 -2
  48. package/dist/src/apple/templates.js +4 -4
  49. package/dist/src/apple/templates.js.map +1 -1
  50. package/dist/src/apple/xcode-manager.d.ts +19 -3
  51. package/dist/src/apple/xcode-manager.js +126 -24
  52. package/dist/src/apple/xcode-manager.js.map +1 -1
  53. package/dist/src/nextjs/nextjs-wizard.js +49 -11
  54. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  55. package/dist/src/nextjs/templates.d.ts +2 -0
  56. package/dist/src/nextjs/templates.js +6 -2
  57. package/dist/src/nextjs/templates.js.map +1 -1
  58. package/dist/src/remix/codemods/handle-error.d.ts +2 -0
  59. package/dist/src/remix/codemods/handle-error.js +70 -0
  60. package/dist/src/remix/codemods/handle-error.js.map +1 -0
  61. package/dist/src/remix/codemods/root-v1.d.ts +1 -0
  62. package/dist/src/remix/codemods/root-v1.js +133 -0
  63. package/dist/src/remix/codemods/root-v1.js.map +1 -0
  64. package/dist/src/remix/codemods/root-v2.d.ts +1 -0
  65. package/dist/src/remix/codemods/root-v2.js +134 -0
  66. package/dist/src/remix/codemods/root-v2.js.map +1 -0
  67. package/dist/src/remix/remix-wizard.d.ts +2 -0
  68. package/dist/src/remix/remix-wizard.js +196 -0
  69. package/dist/src/remix/remix-wizard.js.map +1 -0
  70. package/dist/src/remix/sdk-setup.d.ts +18 -0
  71. package/dist/src/remix/sdk-setup.js +293 -0
  72. package/dist/src/remix/sdk-setup.js.map +1 -0
  73. package/dist/src/remix/templates.d.ts +2 -0
  74. package/dist/src/remix/templates.js +6 -0
  75. package/dist/src/remix/templates.js.map +1 -0
  76. package/dist/src/remix/utils.d.ts +6 -0
  77. package/dist/src/remix/utils.js +55 -0
  78. package/dist/src/remix/utils.js.map +1 -0
  79. package/dist/src/sourcemaps/sourcemaps-wizard.js +49 -25
  80. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  81. package/dist/src/sourcemaps/tools/nextjs.js +1 -1
  82. package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
  83. package/dist/src/sourcemaps/tools/remix.d.ts +3 -0
  84. package/dist/src/sourcemaps/tools/remix.js +125 -0
  85. package/dist/src/sourcemaps/tools/remix.js.map +1 -0
  86. package/dist/src/sourcemaps/tools/sentry-cli.js +19 -16
  87. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  88. package/dist/src/sourcemaps/tools/vite.d.ts +2 -1
  89. package/dist/src/sourcemaps/tools/vite.js +99 -12
  90. package/dist/src/sourcemaps/tools/vite.js.map +1 -1
  91. package/dist/src/sourcemaps/utils/detect-tool.d.ts +1 -1
  92. package/dist/src/sourcemaps/utils/detect-tool.js +1 -0
  93. package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
  94. package/dist/src/sveltekit/sdk-setup.js +3 -3
  95. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  96. package/dist/src/sveltekit/sveltekit-wizard.js +34 -44
  97. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  98. package/dist/src/telemetry.js +1 -0
  99. package/dist/src/telemetry.js.map +1 -1
  100. package/dist/src/utils/ast-utils.d.ts +2 -2
  101. package/dist/src/utils/ast-utils.js +7 -7
  102. package/dist/src/utils/ast-utils.js.map +1 -1
  103. package/dist/src/utils/clack-utils.d.ts +23 -28
  104. package/dist/src/utils/clack-utils.js +287 -244
  105. package/dist/src/utils/clack-utils.js.map +1 -1
  106. package/dist/src/utils/package-manager.d.ts +10 -0
  107. package/dist/{lib/Helper/PackageManager.js → src/utils/package-manager.js} +42 -74
  108. package/dist/src/utils/package-manager.js.map +1 -0
  109. package/dist/src/utils/release-registry.d.ts +1 -0
  110. package/dist/src/utils/release-registry.js +68 -0
  111. package/dist/src/utils/release-registry.js.map +1 -0
  112. package/dist/src/utils/sentrycli-utils.d.ts +4 -0
  113. package/dist/src/utils/sentrycli-utils.js +41 -0
  114. package/dist/src/utils/sentrycli-utils.js.map +1 -0
  115. package/dist/test/sourcemaps/tools/vite.test.d.ts +1 -0
  116. package/dist/test/sourcemaps/tools/vite.test.js +132 -0
  117. package/dist/test/sourcemaps/tools/vite.test.js.map +1 -0
  118. package/lib/Constants.ts +10 -0
  119. package/lib/Steps/ChooseIntegration.ts +14 -3
  120. package/lib/Steps/Integrations/Android.ts +23 -0
  121. package/lib/Steps/Integrations/Cordova.ts +5 -1
  122. package/lib/Steps/Integrations/ReactNative.ts +9 -3
  123. package/lib/Steps/Integrations/Remix.ts +32 -0
  124. package/lib/Steps/PromptForParameters.ts +48 -3
  125. package/lib/Steps/SentryProjectSelector.ts +3 -1
  126. package/package.json +4 -3
  127. package/src/android/android-wizard.ts +196 -0
  128. package/src/android/code-tools.ts +156 -0
  129. package/src/android/gradle.ts +245 -0
  130. package/src/android/manifest.ts +180 -0
  131. package/src/android/templates.ts +88 -0
  132. package/src/apple/apple-wizard.ts +113 -35
  133. package/src/apple/cocoapod.ts +6 -3
  134. package/src/apple/code-tools.ts +46 -18
  135. package/src/apple/fastlane.ts +6 -12
  136. package/src/apple/templates.ts +2 -8
  137. package/src/apple/xcode-manager.ts +167 -25
  138. package/src/nextjs/nextjs-wizard.ts +72 -8
  139. package/src/nextjs/templates.ts +16 -2
  140. package/src/remix/codemods/handle-error.ts +67 -0
  141. package/src/remix/codemods/root-v1.ts +91 -0
  142. package/src/remix/codemods/root-v2.ts +84 -0
  143. package/src/remix/remix-wizard.ts +132 -0
  144. package/src/remix/sdk-setup.ts +300 -0
  145. package/src/remix/templates.ts +15 -0
  146. package/src/remix/utils.ts +41 -0
  147. package/src/sourcemaps/sourcemaps-wizard.ts +28 -5
  148. package/src/sourcemaps/tools/nextjs.ts +2 -2
  149. package/src/sourcemaps/tools/remix.ts +90 -0
  150. package/src/sourcemaps/tools/sentry-cli.ts +8 -7
  151. package/src/sourcemaps/tools/vite.ts +136 -6
  152. package/src/sourcemaps/utils/detect-tool.ts +4 -1
  153. package/src/sveltekit/sdk-setup.ts +4 -4
  154. package/src/sveltekit/sveltekit-wizard.ts +5 -14
  155. package/src/telemetry.ts +2 -0
  156. package/src/utils/ast-utils.ts +7 -5
  157. package/src/utils/clack-utils.ts +366 -258
  158. package/src/utils/package-manager.ts +61 -0
  159. package/src/utils/release-registry.ts +19 -0
  160. package/src/utils/sentrycli-utils.ts +22 -0
  161. package/test/sourcemaps/tools/vite.test.ts +149 -0
  162. package/dist/lib/Helper/PackageManager.d.ts +0 -22
  163. package/dist/lib/Helper/PackageManager.js.map +0 -1
  164. package/dist/src/utils/vendor/clack-custom-select.d.ts +0 -21
  165. package/dist/src/utils/vendor/clack-custom-select.js +0 -137
  166. package/dist/src/utils/vendor/clack-custom-select.js.map +0 -1
  167. package/lib/Helper/PackageManager.ts +0 -59
  168. package/src/utils/vendor/clack-custom-select.ts +0 -160
@@ -6,8 +6,7 @@ import * as path from 'path';
6
6
  import * as fs from 'fs';
7
7
  import {
8
8
  abortIfCancelled,
9
- addSentryCliRc,
10
- detectPackageManager,
9
+ addSentryCliConfig,
11
10
  getPackageDotJson,
12
11
  installPackage,
13
12
  } from '../../utils/clack-utils';
@@ -15,6 +14,7 @@ import {
15
14
  import { SourceMapUploadToolConfigurationOptions } from './types';
16
15
  import { hasPackageInstalled, PackageDotJson } from '../../utils/package-json';
17
16
  import { traceStep } from '../../telemetry';
17
+ import { detectPackageManger } from '../../utils/package-manager';
18
18
 
19
19
  const SENTRY_NPM_SCRIPT_NAME = 'sentry:sourcemaps';
20
20
 
@@ -96,7 +96,7 @@ export async function configureSentryCLI(
96
96
  );
97
97
  }
98
98
 
99
- await addSentryCliRc(options.authToken);
99
+ await addSentryCliConfig(options.authToken);
100
100
  }
101
101
 
102
102
  export async function setupNpmScriptInCI(): Promise<void> {
@@ -205,7 +205,8 @@ async function addSentryCommandToBuildCommand(
205
205
  (s) => s !== SENTRY_NPM_SCRIPT_NAME,
206
206
  );
207
207
 
208
- const pacMan = detectPackageManager() || 'npm';
208
+ const packageManager = detectPackageManger();
209
+ const packageManagerName = packageManager?.name ?? 'npm';
209
210
 
210
211
  // Heuristic to pre-select the build command:
211
212
  // Often, 'build' is the prod build command, so we favour it.
@@ -220,7 +221,7 @@ async function addSentryCommandToBuildCommand(
220
221
  (await abortIfCancelled(
221
222
  clack.confirm({
222
223
  message: `Is ${chalk.cyan(
223
- `${pacMan} run ${buildCommand}`,
224
+ `${packageManagerName} run ${buildCommand}`,
224
225
  )} your production build command?`,
225
226
  }),
226
227
  ));
@@ -228,7 +229,7 @@ async function addSentryCommandToBuildCommand(
228
229
  if (allNpmScripts.length && (!buildCommand || !isProdBuildCommand)) {
229
230
  buildCommand = await abortIfCancelled(
230
231
  clack.select({
231
- message: `Which ${pacMan} command in your ${chalk.cyan(
232
+ message: `Which ${packageManagerName} command in your ${chalk.cyan(
232
233
  'package.json',
233
234
  )} builds your application for production?`,
234
235
  options: allNpmScripts
@@ -254,7 +255,7 @@ Please add it manually to your prod build command.`,
254
255
  packageDotJson.scripts[
255
256
  buildCommand
256
257
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
257
- ] = `${packageDotJson.scripts[buildCommand]} && ${pacMan} run ${SENTRY_NPM_SCRIPT_NAME}`;
258
+ ] = `${packageDotJson.scripts[buildCommand]} && ${packageManager} run ${SENTRY_NPM_SCRIPT_NAME}`;
258
259
 
259
260
  await fs.promises.writeFile(
260
261
  path.join(process.cwd(), 'package.json'),
@@ -1,10 +1,14 @@
1
1
  // @ts-ignore - clack is ESM and TS complains about that. It works though
2
- import clack, { select } from '@clack/prompts';
2
+ import * as clack from '@clack/prompts';
3
3
  // @ts-ignore - magicast is ESM and TS complains about that. It works though
4
4
  import { generateCode, parseModule } from 'magicast';
5
5
  // @ts-ignore - magicast is ESM and TS complains about that. It works though
6
6
  import { addVitePlugin } from 'magicast/helpers';
7
7
 
8
+ import type { namedTypes as t } from 'ast-types';
9
+
10
+ import * as recast from 'recast';
11
+
8
12
  import * as Sentry from '@sentry/node';
9
13
 
10
14
  import chalk from 'chalk';
@@ -20,7 +24,7 @@ import {
20
24
  SourceMapUploadToolConfigurationFunction,
21
25
  SourceMapUploadToolConfigurationOptions,
22
26
  } from './types';
23
- import { findScriptFile, hasSentryContent } from '../../utils/ast-utils';
27
+ import { findFile, hasSentryContent } from '../../utils/ast-utils';
24
28
 
25
29
  import * as path from 'path';
26
30
  import * as fs from 'fs';
@@ -87,7 +91,7 @@ export const configureVitePlugin: SourceMapUploadToolConfigurationFunction =
87
91
  });
88
92
 
89
93
  const viteConfigPath =
90
- findScriptFile(path.resolve(process.cwd(), 'vite.config')) ||
94
+ findFile(path.resolve(process.cwd(), 'vite.config')) ||
91
95
  (await askForViteConfigPath());
92
96
 
93
97
  let successfullyAdded = false;
@@ -139,7 +143,7 @@ async function createNewViteConfig(
139
143
  }
140
144
  }
141
145
 
142
- async function addVitePluginToConfig(
146
+ export async function addVitePluginToConfig(
143
147
  viteConfigPath: string,
144
148
  options: SourceMapUploadToolConfigurationOptions,
145
149
  ): Promise<boolean> {
@@ -176,6 +180,12 @@ async function addVitePluginToConfig(
176
180
  }
177
181
  }
178
182
 
183
+ const enabledSourcemaps = enableSourcemapGeneration(mod.$ast as t.Program);
184
+ if (!enabledSourcemaps) {
185
+ Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');
186
+ return false;
187
+ }
188
+
179
189
  const { orgSlug: org, projectSlug: project, selfHosted, url } = options;
180
190
 
181
191
  addVitePlugin(mod, {
@@ -194,7 +204,7 @@ async function addVitePluginToConfig(
194
204
  await fs.promises.writeFile(viteConfigPath, code);
195
205
 
196
206
  clack.log.success(
197
- `Added the Sentry Vite plugin to ${prettyViteConfigFilename}`,
207
+ `Added the Sentry Vite plugin to ${prettyViteConfigFilename} and enabled source maps`,
198
208
  );
199
209
 
200
210
  return true;
@@ -218,7 +228,7 @@ async function showCopyPasteInstructions(
218
228
  console.log(`\n${getViteConfigSnippet(options, true)}`);
219
229
 
220
230
  await abortIfCancelled(
221
- select({
231
+ clack.select({
222
232
  message: 'Did you copy the snippet above?',
223
233
  options: [{ label: 'Yes, continue!', value: true }],
224
234
  initialValue: true,
@@ -258,3 +268,123 @@ async function askForViteConfigPath(): Promise<string | undefined> {
258
268
  }),
259
269
  );
260
270
  }
271
+
272
+ function enableSourcemapGeneration(program: t.Program): boolean {
273
+ const configObj = getViteConfigObject(program);
274
+
275
+ if (!configObj) {
276
+ return false;
277
+ }
278
+
279
+ const b = recast.types.builders;
280
+
281
+ const buildProp = configObj.properties.find(
282
+ (p: t.ObjectProperty) =>
283
+ p.key.type === 'Identifier' && p.key.name === 'build',
284
+ );
285
+
286
+ // case 1: build property doesn't exist yet, so we can just add it
287
+ if (!buildProp) {
288
+ configObj.properties.push(
289
+ b.objectProperty(
290
+ b.identifier('build'),
291
+ b.objectExpression([
292
+ b.objectProperty(b.identifier('sourcemap'), b.booleanLiteral(true)),
293
+ ]),
294
+ ),
295
+ );
296
+ return true;
297
+ }
298
+
299
+ const isValidBuildProp =
300
+ buildProp.type === 'ObjectProperty' &&
301
+ buildProp.value.type === 'ObjectExpression';
302
+
303
+ if (!isValidBuildProp) {
304
+ return false;
305
+ }
306
+
307
+ const sourceMapsProp =
308
+ buildProp.value.type === 'ObjectExpression' &&
309
+ buildProp.value.properties.find(
310
+ (p: t.ObjectProperty) =>
311
+ p.key.type === 'Identifier' && p.key.name === 'sourcemap',
312
+ );
313
+
314
+ // case 2: build.sourcemap property doesn't exist yet, so we just add it
315
+ if (!sourceMapsProp && buildProp.value.type === 'ObjectExpression') {
316
+ buildProp.value.properties.push(
317
+ b.objectProperty(b.identifier('sourcemap'), b.booleanLiteral(true)),
318
+ );
319
+ return true;
320
+ }
321
+
322
+ if (!sourceMapsProp || sourceMapsProp.type !== 'ObjectProperty') {
323
+ return false;
324
+ }
325
+
326
+ // case 3: build.sourcemap property exists, and it's set to 'hidden'
327
+ if (
328
+ sourceMapsProp.value.type === 'StringLiteral' &&
329
+ sourceMapsProp.value.value === 'hidden'
330
+ ) {
331
+ // nothing to do for us
332
+ return true;
333
+ }
334
+
335
+ // case 4: build.sourcemap property exists, but it's not enabled, so we set it to true
336
+ // or it is already true in which case this is a noop
337
+ sourceMapsProp.value = b.booleanLiteral(true);
338
+ return true;
339
+ }
340
+
341
+ function getViteConfigObject(
342
+ program: t.Program,
343
+ ): t.ObjectExpression | undefined {
344
+ const defaultExport = program.body.find(
345
+ (s) => s.type === 'ExportDefaultDeclaration',
346
+ ) as t.ExportDefaultDeclaration;
347
+
348
+ if (!defaultExport) {
349
+ return undefined;
350
+ }
351
+
352
+ if (defaultExport.declaration.type === 'ObjectExpression') {
353
+ return defaultExport.declaration;
354
+ }
355
+
356
+ if (
357
+ defaultExport.declaration.type === 'CallExpression' &&
358
+ defaultExport.declaration.arguments[0].type === 'ObjectExpression'
359
+ ) {
360
+ return defaultExport.declaration.arguments[0];
361
+ }
362
+
363
+ if (defaultExport.declaration.type === 'Identifier') {
364
+ const configId = defaultExport.declaration.name;
365
+ return findConfigNode(configId, program);
366
+ }
367
+
368
+ return undefined;
369
+ }
370
+
371
+ function findConfigNode(
372
+ configId: string,
373
+ program: t.Program,
374
+ ): t.ObjectExpression | undefined {
375
+ for (const node of program.body) {
376
+ if (node.type === 'VariableDeclaration') {
377
+ for (const declaration of node.declarations) {
378
+ if (
379
+ declaration.type === 'VariableDeclarator' &&
380
+ declaration.id.type === 'Identifier' &&
381
+ declaration.id.name === configId &&
382
+ declaration.init?.type === 'ObjectExpression'
383
+ ) {
384
+ return declaration.init;
385
+ }
386
+ }
387
+ }
388
+ }
389
+ return undefined;
390
+ }
@@ -10,7 +10,9 @@ export type SupportedTools =
10
10
  | 'sentry-cli'
11
11
  | 'create-react-app'
12
12
  | 'angular'
13
- | 'nextjs';
13
+ | 'nextjs'
14
+ | 'remix'
15
+ | 'no-tool';
14
16
 
15
17
  // A map of package names pointing to the tool slug.
16
18
  // The order is important, because we want to detect the most specific tool first.
@@ -25,6 +27,7 @@ export const TOOL_PACKAGE_MAP: Record<string, SupportedTools> = {
25
27
  esbuild: 'esbuild',
26
28
  rollup: 'rollup',
27
29
  typescript: 'tsc',
30
+ remix: 'remix',
28
31
  };
29
32
 
30
33
  export async function detectUsedTool(): Promise<SupportedTools> {
@@ -15,7 +15,7 @@ import { addVitePlugin } from 'magicast/helpers';
15
15
  import { getClientHooksTemplate, getServerHooksTemplate } from './templates';
16
16
  import { abortIfCancelled, isUsingTypeScript } from '../utils/clack-utils';
17
17
  import { debug } from '../utils/debug';
18
- import { findScriptFile, hasSentryContent } from '../utils/ast-utils';
18
+ import { findFile, hasSentryContent } from '../utils/ast-utils';
19
19
 
20
20
  const SVELTE_CONFIG_FILE = 'svelte.config.js';
21
21
 
@@ -46,10 +46,10 @@ export async function createOrMergeSvelteKitFiles(
46
46
  const { clientHooksPath, serverHooksPath } = getHooksConfigDirs(svelteConfig);
47
47
 
48
48
  // full file paths with correct file ending (or undefined if not found)
49
- const originalClientHooksFile = findScriptFile(clientHooksPath);
50
- const originalServerHooksFile = findScriptFile(serverHooksPath);
49
+ const originalClientHooksFile = findFile(clientHooksPath);
50
+ const originalServerHooksFile = findFile(serverHooksPath);
51
51
 
52
- const viteConfig = findScriptFile(path.resolve(process.cwd(), 'vite.config'));
52
+ const viteConfig = findFile(path.resolve(process.cwd(), 'vite.config'));
53
53
 
54
54
  const fileEnding = isUsingTypeScript() ? 'ts' : 'js';
55
55
 
@@ -4,12 +4,10 @@ import chalk from 'chalk';
4
4
 
5
5
  import {
6
6
  abort,
7
- addSentryCliRc,
8
- askForProjectSelection,
9
- askForSelfHosted,
10
- askForWizardLogin,
7
+ addSentryCliConfig,
11
8
  confirmContinueEvenThoughNoGitRepo,
12
9
  ensurePackageIsInstalled,
10
+ getOrAskForProjectData,
13
11
  getPackageDotJson,
14
12
  installPackage,
15
13
  printWelcome,
@@ -32,22 +30,15 @@ export async function runSvelteKitWizard(
32
30
  const packageJson = await getPackageDotJson();
33
31
  await ensurePackageIsInstalled(packageJson, '@sveltejs/kit', 'Sveltekit');
34
32
 
35
- const { url: sentryUrl, selfHosted } = await askForSelfHosted(options.url);
36
-
37
- const { projects, apiKeys } = await askForWizardLogin({
38
- promoCode: options.promoCode,
39
- url: sentryUrl,
40
- platform: 'javascript-sveltekit',
41
- });
42
-
43
- const selectedProject = await askForProjectSelection(projects);
33
+ const { selectedProject, selfHosted, sentryUrl, authToken } =
34
+ await getOrAskForProjectData(options, 'javascript-sveltekit');
44
35
 
45
36
  await installPackage({
46
37
  packageName: '@sentry/sveltekit',
47
38
  alreadyInstalled: hasPackageInstalled('@sentry/sveltekit', packageJson),
48
39
  });
49
40
 
50
- await addSentryCliRc(apiKeys.token);
41
+ await addSentryCliConfig(authToken);
51
42
 
52
43
  const svelteConfig = await loadSvelteConfig();
53
44
 
package/src/telemetry.ts CHANGED
@@ -52,6 +52,8 @@ function createSentryInstance(enabled: boolean, integration: string) {
52
52
  dsn: 'https://8871d3ff64814ed8960c96d1fcc98a27@o1.ingest.sentry.io/4505425820712960',
53
53
  enabled: enabled,
54
54
 
55
+ environment: `production-${integration}`,
56
+
55
57
  tracesSampleRate: 1,
56
58
  sampleRate: 1,
57
59
 
@@ -3,13 +3,15 @@ import * as fs from 'fs';
3
3
  import { ProxifiedModule } from 'magicast';
4
4
 
5
5
  /**
6
- * Checks if a JS/TS file where we don't know its concrete file type yet exists
6
+ * Checks if a file where we don't know its concrete file type yet exists
7
7
  * and returns the full path to the file with the correct file type.
8
8
  */
9
- export function findScriptFile(hooksFile: string): string | undefined {
10
- const possibleFileTypes = ['.js', '.ts', '.mjs'];
11
- return possibleFileTypes
12
- .map((type) => `${hooksFile}${type}`)
9
+ export function findFile(
10
+ filePath: string,
11
+ fileTypes: string[] = ['.js', '.ts', '.mjs'],
12
+ ): string | undefined {
13
+ return fileTypes
14
+ .map((type) => `${filePath}${type}`)
13
15
  .find((file) => fs.existsSync(file));
14
16
  }
15
17