@sentry/wizard 6.3.0 → 6.4.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 (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/e2e-tests/tests/{sveltekit.test.js → sveltekit-hooks.test.js} +10 -6
  3. package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -0
  4. package/dist/e2e-tests/tests/sveltekit-tracing.test.d.ts +1 -0
  5. package/dist/e2e-tests/tests/sveltekit-tracing.test.js +203 -0
  6. package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -0
  7. package/dist/src/sveltekit/sdk-example.d.ts +2 -2
  8. package/dist/src/sveltekit/sdk-example.js.map +1 -1
  9. package/dist/src/sveltekit/sdk-setup/setup.d.ts +3 -0
  10. package/dist/src/sveltekit/{sdk-setup.js → sdk-setup/setup.js} +113 -157
  11. package/dist/src/sveltekit/sdk-setup/setup.js.map +1 -0
  12. package/dist/src/sveltekit/sdk-setup/svelte-config.d.ts +25 -0
  13. package/dist/src/sveltekit/sdk-setup/svelte-config.js +291 -0
  14. package/dist/src/sveltekit/sdk-setup/svelte-config.js.map +1 -0
  15. package/dist/src/sveltekit/sdk-setup/types.d.ts +7 -0
  16. package/dist/src/sveltekit/sdk-setup/types.js +3 -0
  17. package/dist/src/sveltekit/sdk-setup/types.js.map +1 -0
  18. package/dist/src/sveltekit/sdk-setup/utils.d.ts +6 -0
  19. package/dist/src/sveltekit/sdk-setup/utils.js +45 -0
  20. package/dist/src/sveltekit/sdk-setup/utils.js.map +1 -0
  21. package/dist/src/sveltekit/sdk-setup/vite.d.ts +2 -0
  22. package/dist/src/sveltekit/sdk-setup/vite.js +120 -0
  23. package/dist/src/sveltekit/sdk-setup/vite.js.map +1 -0
  24. package/dist/src/sveltekit/sveltekit-wizard.js +45 -5
  25. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  26. package/dist/src/sveltekit/templates.d.ts +4 -0
  27. package/dist/src/sveltekit/templates.js +33 -10
  28. package/dist/src/sveltekit/templates.js.map +1 -1
  29. package/dist/src/sveltekit/utils.d.ts +2 -1
  30. package/dist/src/sveltekit/utils.js +7 -2
  31. package/dist/src/sveltekit/utils.js.map +1 -1
  32. package/dist/src/version.d.ts +1 -1
  33. package/dist/src/version.js +1 -1
  34. package/dist/src/version.js.map +1 -1
  35. package/dist/test/sveltekit/sdk-setup/svelte-config.test.d.ts +1 -0
  36. package/dist/test/sveltekit/sdk-setup/svelte-config.test.js +529 -0
  37. package/dist/test/sveltekit/sdk-setup/svelte-config.test.js.map +1 -0
  38. package/dist/test/sveltekit/templates.test.js +103 -10
  39. package/dist/test/sveltekit/templates.test.js.map +1 -1
  40. package/package.json +1 -1
  41. package/dist/e2e-tests/tests/sveltekit.test.js.map +0 -1
  42. package/dist/src/sveltekit/sdk-setup.d.ts +0 -21
  43. package/dist/src/sveltekit/sdk-setup.js.map +0 -1
  44. /package/dist/e2e-tests/tests/{sveltekit.test.d.ts → sveltekit-hooks.test.d.ts} +0 -0
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports._enableTracingAndInstrumentationInConfig = exports.enableTracingAndInstrumentation = exports.loadSvelteConfig = void 0;
30
+ const fs = __importStar(require("fs"));
31
+ const path = __importStar(require("path"));
32
+ const url = __importStar(require("url"));
33
+ const chalk_1 = __importDefault(require("chalk"));
34
+ const Sentry = __importStar(require("@sentry/node"));
35
+ const recast = __importStar(require("recast"));
36
+ //@ts-expect-error - clack is ESM and TS complains about that. It works though
37
+ const prompts_1 = __importDefault(require("@clack/prompts"));
38
+ const clack_1 = require("../../utils/clack");
39
+ // @ts-expect-error - magicast is ESM and TS complains about that. It works though
40
+ const magicast_1 = require("magicast");
41
+ const debug_1 = require("../../utils/debug");
42
+ const SVELTE_CONFIG_FILE = 'svelte.config.js';
43
+ const b = recast.types.builders;
44
+ async function loadSvelteConfig() {
45
+ const configFilePath = path.join(process.cwd(), SVELTE_CONFIG_FILE);
46
+ try {
47
+ if (!fs.existsSync(configFilePath)) {
48
+ return {};
49
+ }
50
+ const configUrl = url.pathToFileURL(configFilePath).href;
51
+ const svelteConfigModule = (await import(configUrl));
52
+ return svelteConfigModule?.default || {};
53
+ }
54
+ catch (e) {
55
+ prompts_1.default.log.error(`Couldn't load ${chalk_1.default.cyan(SVELTE_CONFIG_FILE)}.
56
+ Are you running this wizard from the root of your SvelteKit project?`);
57
+ prompts_1.default.log.info(chalk_1.default.dim(typeof e === 'object' && e != null && 'toString' in e
58
+ ? e.toString()
59
+ : typeof e === 'string'
60
+ ? e
61
+ : 'Unknown error'));
62
+ return {};
63
+ }
64
+ }
65
+ exports.loadSvelteConfig = loadSvelteConfig;
66
+ async function enableTracingAndInstrumentation(originalSvelteConfig, enableTracing) {
67
+ const hasTracingEnabled = originalSvelteConfig.kit?.experimental?.tracing;
68
+ const hasInstrumentationEnabled = originalSvelteConfig.kit?.experimental?.instrumentation;
69
+ if (hasTracingEnabled && hasInstrumentationEnabled) {
70
+ prompts_1.default.log.info('Tracing and instrumentation are already enabled.');
71
+ return;
72
+ }
73
+ if (hasTracingEnabled || hasInstrumentationEnabled) {
74
+ prompts_1.default.log.info('Tracing and instrumentation are partially enabled. Make sure both options are enabled.');
75
+ await showFallbackConfigSnippet();
76
+ return;
77
+ }
78
+ else {
79
+ try {
80
+ const configPath = path.join(process.cwd(), SVELTE_CONFIG_FILE);
81
+ const svelteConfigContent = await fs.promises.readFile(configPath, 'utf-8');
82
+ const { error, result } = _enableTracingAndInstrumentationInConfig(svelteConfigContent, enableTracing);
83
+ if (error) {
84
+ prompts_1.default.log.warning('Failed to automatically enable SvelteKit tracing and instrumentation.');
85
+ (0, debug_1.debug)(error);
86
+ Sentry.captureException(error);
87
+ await showFallbackConfigSnippet();
88
+ return;
89
+ }
90
+ if (result) {
91
+ await fs.promises.writeFile(configPath, result);
92
+ }
93
+ prompts_1.default.log.success(`Enabled tracing and instrumentation in ${chalk_1.default.cyan(SVELTE_CONFIG_FILE)}`);
94
+ }
95
+ catch (e) {
96
+ prompts_1.default.log.error(`Failed to enable tracing and instrumentation in ${chalk_1.default.cyan(SVELTE_CONFIG_FILE)}.`);
97
+ (0, debug_1.debug)(e);
98
+ Sentry.captureException(`Failed to enable tracing and instrumentation in ${SVELTE_CONFIG_FILE}`);
99
+ await showFallbackConfigSnippet();
100
+ return;
101
+ }
102
+ }
103
+ }
104
+ exports.enableTracingAndInstrumentation = enableTracingAndInstrumentation;
105
+ function _enableTracingAndInstrumentationInConfig(config, enableTracing) {
106
+ let svelteConfig;
107
+ try {
108
+ svelteConfig = (0, magicast_1.parseModule)(config);
109
+ }
110
+ catch (e) {
111
+ return {
112
+ error: 'Failed to parse Svelte config',
113
+ };
114
+ }
115
+ let configObject = undefined;
116
+ // Cases to handle for finding the config object:
117
+ // 1. default export is named object
118
+ // 2. default export is in-place object
119
+ // 3. default export is an identifier, so look up the variable declaration
120
+ recast.visit(svelteConfig.$ast, {
121
+ visitExportDefaultDeclaration(path) {
122
+ const exportDeclarationNode = path.node;
123
+ if (exportDeclarationNode.declaration.type === 'AssignmentExpression' &&
124
+ exportDeclarationNode.declaration.right.type === 'ObjectExpression') {
125
+ configObject = exportDeclarationNode.declaration.right;
126
+ return false;
127
+ }
128
+ if (exportDeclarationNode.declaration.type === 'ObjectExpression') {
129
+ configObject = exportDeclarationNode.declaration;
130
+ return false;
131
+ }
132
+ if (exportDeclarationNode.declaration.type === 'Identifier') {
133
+ const identifierName = exportDeclarationNode.declaration.name;
134
+ recast.visit(svelteConfig.$ast, {
135
+ visitVariableDeclarator(path) {
136
+ if (path.node.id?.type === 'Identifier' &&
137
+ path.node.id.name === identifierName &&
138
+ path.node.init?.type === 'ObjectExpression') {
139
+ configObject = path.node.init;
140
+ return false;
141
+ }
142
+ this.traverse(path);
143
+ },
144
+ });
145
+ }
146
+ this.traverse(path);
147
+ },
148
+ });
149
+ if (!_isValidConfigObject(configObject)) {
150
+ return {
151
+ error: "Couldn't find the config object",
152
+ };
153
+ }
154
+ // This type cast is safe. For some reason, TS still assumes that `configObject`
155
+ // is `undefined` so we have to tell it that it's not (see check above)
156
+ const validatedConfigObject = configObject;
157
+ const kitProp = validatedConfigObject.properties.find((prop) => prop.type === 'ObjectProperty' &&
158
+ prop.key.type === 'Identifier' &&
159
+ prop.key.name === 'kit');
160
+ if (!kitProp || kitProp.type !== 'ObjectProperty') {
161
+ return {
162
+ error: "Couldn't find the `kit` property",
163
+ };
164
+ }
165
+ if (kitProp.value.type !== 'ObjectExpression') {
166
+ return {
167
+ error: `\`kit\` property has unexpected type: ${kitProp.value.type}`,
168
+ };
169
+ }
170
+ // 1. find or add `kit.experimental` property
171
+ // type-cast because TS can't infer the type in `.find` :(
172
+ const kitExperimentalProp = kitProp.value.properties.find((prop) => prop.type === 'ObjectProperty' &&
173
+ prop.key.type === 'Identifier' &&
174
+ prop.key.name === 'experimental');
175
+ let experimentalObject;
176
+ if (kitExperimentalProp) {
177
+ if (kitExperimentalProp.value.type !== 'ObjectExpression') {
178
+ return {
179
+ error: `Property \`kit.experimental\` has unexpected type: ${kitExperimentalProp.value.type}`,
180
+ };
181
+ }
182
+ experimentalObject = kitExperimentalProp.value;
183
+ }
184
+ else {
185
+ experimentalObject = b.objectExpression([]);
186
+ kitProp.value.properties.push(b.objectProperty(b.identifier('experimental'), experimentalObject));
187
+ }
188
+ // 2. find or add `kit.experimental.tracing` property
189
+ // find or add `kit.experimental.instrumentation` property
190
+ const kitExperimentalTraingProp = experimentalObject.properties.find((prop) => prop.type === 'ObjectProperty' &&
191
+ prop.key.type === 'Identifier' &&
192
+ prop.key.name === 'tracing');
193
+ const kitExperimentalInstrumentationProp = experimentalObject.properties.find((prop) => prop.type === 'ObjectProperty' &&
194
+ prop.key.type === 'Identifier' &&
195
+ prop.key.name === 'instrumentation');
196
+ let experimentalTracingObject;
197
+ let experimentalInstrumentationObject;
198
+ if (kitExperimentalTraingProp) {
199
+ if (kitExperimentalTraingProp.value.type !== 'ObjectExpression') {
200
+ return {
201
+ error: `Property \`kit.experimental.tracing\` has unexpected type: ${kitExperimentalTraingProp.value.type}`,
202
+ };
203
+ }
204
+ experimentalTracingObject = kitExperimentalTraingProp.value;
205
+ }
206
+ else {
207
+ experimentalTracingObject = b.objectExpression([]);
208
+ experimentalObject.properties.push(b.objectProperty(b.identifier('tracing'), experimentalTracingObject));
209
+ }
210
+ if (kitExperimentalInstrumentationProp) {
211
+ if (kitExperimentalInstrumentationProp.value.type !== 'ObjectExpression') {
212
+ return {
213
+ error: `Property \`kit.experimental.instrumentation\` has unexpected type: ${kitExperimentalInstrumentationProp.value.type}`,
214
+ };
215
+ }
216
+ experimentalInstrumentationObject =
217
+ kitExperimentalInstrumentationProp.value;
218
+ }
219
+ else {
220
+ experimentalInstrumentationObject = b.objectExpression([]);
221
+ experimentalObject.properties.push(b.objectProperty(b.identifier('instrumentation'), experimentalInstrumentationObject));
222
+ }
223
+ // 3. find or add `kit.experimental.tracing.server` property
224
+ // find or add `kit.experimental.instrumentation.server` property
225
+ const kitExperimentalTracingSeverProp = experimentalTracingObject.properties.find((prop) => prop.type === 'ObjectProperty' &&
226
+ prop.key.type === 'Identifier' &&
227
+ prop.key.name === 'server');
228
+ const kitExperimentalInstrumentationSeverProp = experimentalInstrumentationObject.properties.find((prop) => prop.type === 'ObjectProperty' &&
229
+ prop.key.type === 'Identifier' &&
230
+ prop.key.name === 'server');
231
+ if (kitExperimentalTracingSeverProp) {
232
+ if (kitExperimentalTracingSeverProp.value.type !== 'BooleanLiteral') {
233
+ return {
234
+ error: `Property \`kit.experimental.tracing.server\` has unexpected type: ${kitExperimentalTracingSeverProp.value.type}`,
235
+ };
236
+ }
237
+ kitExperimentalTracingSeverProp.value = b.booleanLiteral(enableTracing);
238
+ }
239
+ else {
240
+ experimentalTracingObject.properties.push(b.objectProperty(b.identifier('server'), b.booleanLiteral(enableTracing)));
241
+ }
242
+ if (kitExperimentalInstrumentationSeverProp) {
243
+ if (kitExperimentalInstrumentationSeverProp.value.type !== 'BooleanLiteral') {
244
+ return {
245
+ error: `Property \`kit.experimental.instrumentation.server\` has unexpected type: ${kitExperimentalInstrumentationSeverProp.value.type}`,
246
+ };
247
+ }
248
+ kitExperimentalInstrumentationSeverProp.value = b.booleanLiteral(true);
249
+ }
250
+ else {
251
+ experimentalInstrumentationObject.properties.push(b.objectProperty(b.identifier('server'), b.booleanLiteral(true)));
252
+ }
253
+ try {
254
+ return {
255
+ result: (0, magicast_1.generateCode)(svelteConfig).code,
256
+ };
257
+ }
258
+ catch (e) {
259
+ (0, debug_1.debug)(e);
260
+ return {
261
+ error: 'Failed to generate code for Svelte config',
262
+ };
263
+ }
264
+ }
265
+ exports._enableTracingAndInstrumentationInConfig = _enableTracingAndInstrumentationInConfig;
266
+ function _isValidConfigObject(o) {
267
+ return !!o && o.type === 'ObjectExpression';
268
+ }
269
+ async function showFallbackConfigSnippet() {
270
+ const codeSnippet = (0, clack_1.makeCodeSnippet)(true, (unchanged, plus) => unchanged(`const config = {
271
+ preprocess: vitePreprocess(),
272
+
273
+ kit: {
274
+ adapter: adapter(),
275
+ ${plus(`experimental: {
276
+ instrumentation: {
277
+ server: true,
278
+ },
279
+ tracing: {
280
+ server: true,
281
+ },
282
+ },`)}
283
+ },
284
+ };
285
+ `));
286
+ await (0, clack_1.showCopyPasteInstructions)({
287
+ filename: 'svelte.config.js',
288
+ codeSnippet,
289
+ });
290
+ }
291
+ //# sourceMappingURL=svelte-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svelte-config.js","sourceRoot":"","sources":["../../../../src/sveltekit/sdk-setup/svelte-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,yCAA2B;AAC3B,kDAA0B;AAC1B,qDAAuC;AACvC,+CAAiC;AAIjC,8EAA8E;AAC9E,6DAAmC;AACnC,6CAA+E;AAC/E,kFAAkF;AAClF,uCAAsE;AACtE,6CAA0C;AAE1C,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAE9C,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAsBzB,KAAK,UAAU,gBAAgB;IACpC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAEpE,IAAI;QACF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;YAClC,OAAO,EAAE,CAAC;SACX;QAED,MAAM,SAAS,GAAG,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC;QACzD,MAAM,kBAAkB,GAAG,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAElD,CAAC;QAEF,OAAO,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,CAAC,CAC1E,CAAC;KACH;IAED,IAAI,uCAAuC,EAAE;QAC3C,IACE,uCAAuC,CAAC,KAAK,CAAC,IAAI,KAAK,gBAAgB,EACvE;YACA,OAAO;gBACL,KAAK,EAAE,6EAA6E,uCAAuC,CAAC,KAAK,CAAC,IAAI,EAAE;aACzI,CAAC;SACH;QACD,uCAAuC,CAAC,KAAK,GAAG,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;KACxE;SAAM;QACL,iCAAiC,CAAC,UAAU,CAAC,IAAI,CAC/C,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CACjE,CAAC;KACH;IAED,IAAI;QACF,OAAO;YACL,MAAM,EAAE,IAAA,uBAAY,EAAC,YAAY,CAAC,CAAC,IAAI;SACxC,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,aAAK,EAAC,CAAC,CAAC,CAAC;QACT,OAAO;YACL,KAAK,EAAE,2CAA2C;SACnD,CAAC;KACH;AACH,CAAC;AAlOD,4FAkOC;AAED,SAAS,oBAAoB,CAC3B,CAAiC;IAEjC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC;AAC9C,CAAC;AAED,KAAK,UAAU,yBAAyB;IACtC,MAAM,WAAW,GAAG,IAAA,uBAAe,EAAC,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,CAC5D,SAAS,CAAC;;;;;IAKV,IAAI,CAAC;;;;;;;KAOJ,CAAC;;;CAGL,CAAC,CACC,CAAC;IAEF,MAAM,IAAA,iCAAyB,EAAC;QAC9B,QAAQ,EAAE,kBAAkB;QAC5B,WAAW;KACZ,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as url from 'url';\nimport chalk from 'chalk';\nimport * as Sentry from '@sentry/node';\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\n//@ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../../utils/clack';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule, ProxifiedModule } from 'magicast';\nimport { debug } from '../../utils/debug';\n\nconst SVELTE_CONFIG_FILE = 'svelte.config.js';\n\nconst b = recast.types.builders;\n\nexport type PartialBackwardsForwardsCompatibleSvelteConfig = {\n kit?: {\n files?: {\n hooks?: {\n client?: string;\n server?: string;\n };\n routes?: string;\n };\n experimental?: {\n tracing?: {\n server?: boolean;\n };\n instrumentation?: {\n server?: boolean;\n };\n };\n };\n};\n\nexport async function loadSvelteConfig(): Promise<PartialBackwardsForwardsCompatibleSvelteConfig> {\n const configFilePath = path.join(process.cwd(), SVELTE_CONFIG_FILE);\n\n try {\n if (!fs.existsSync(configFilePath)) {\n return {};\n }\n\n const configUrl = url.pathToFileURL(configFilePath).href;\n const svelteConfigModule = (await import(configUrl)) as {\n default: PartialBackwardsForwardsCompatibleSvelteConfig;\n };\n\n return svelteConfigModule?.default || {};\n } catch (e: unknown) {\n clack.log.error(`Couldn't load ${chalk.cyan(SVELTE_CONFIG_FILE)}.\nAre you running this wizard from the root of your SvelteKit project?`);\n clack.log.info(\n chalk.dim(\n typeof e === 'object' && e != null && 'toString' in e\n ? e.toString()\n : typeof e === 'string'\n ? e\n : 'Unknown error',\n ),\n );\n\n return {};\n }\n}\n\nexport async function enableTracingAndInstrumentation(\n originalSvelteConfig: PartialBackwardsForwardsCompatibleSvelteConfig,\n enableTracing: boolean,\n) {\n const hasTracingEnabled = originalSvelteConfig.kit?.experimental?.tracing;\n const hasInstrumentationEnabled =\n originalSvelteConfig.kit?.experimental?.instrumentation;\n\n if (hasTracingEnabled && hasInstrumentationEnabled) {\n clack.log.info('Tracing and instrumentation are already enabled.');\n return;\n }\n\n if (hasTracingEnabled || hasInstrumentationEnabled) {\n clack.log.info(\n 'Tracing and instrumentation are partially enabled. Make sure both options are enabled.',\n );\n await showFallbackConfigSnippet();\n return;\n } else {\n try {\n const configPath = path.join(process.cwd(), SVELTE_CONFIG_FILE);\n const svelteConfigContent = await fs.promises.readFile(\n configPath,\n 'utf-8',\n );\n\n const { error, result } = _enableTracingAndInstrumentationInConfig(\n svelteConfigContent,\n enableTracing,\n );\n\n if (error) {\n clack.log.warning(\n 'Failed to automatically enable SvelteKit tracing and instrumentation.',\n );\n debug(error);\n Sentry.captureException(error);\n await showFallbackConfigSnippet();\n return;\n }\n\n if (result) {\n await fs.promises.writeFile(configPath, result);\n }\n\n clack.log.success(\n `Enabled tracing and instrumentation in ${chalk.cyan(\n SVELTE_CONFIG_FILE,\n )}`,\n );\n } catch (e) {\n clack.log.error(\n `Failed to enable tracing and instrumentation in ${chalk.cyan(\n SVELTE_CONFIG_FILE,\n )}.`,\n );\n debug(e);\n Sentry.captureException(\n `Failed to enable tracing and instrumentation in ${SVELTE_CONFIG_FILE}`,\n );\n await showFallbackConfigSnippet();\n return;\n }\n }\n}\n\nexport function _enableTracingAndInstrumentationInConfig(\n config: string,\n enableTracing: boolean,\n): {\n result?: string;\n error?: string;\n} {\n let svelteConfig: ProxifiedModule<t.Program>;\n try {\n svelteConfig = parseModule(config);\n } catch (e) {\n return {\n error: 'Failed to parse Svelte config',\n };\n }\n\n let configObject: t.ObjectExpression | undefined = undefined;\n\n // Cases to handle for finding the config object:\n // 1. default export is named object\n // 2. default export is in-place object\n // 3. default export is an identifier, so look up the variable declaration\n recast.visit(svelteConfig.$ast, {\n visitExportDefaultDeclaration(path) {\n const exportDeclarationNode = path.node;\n if (\n exportDeclarationNode.declaration.type === 'AssignmentExpression' &&\n exportDeclarationNode.declaration.right.type === 'ObjectExpression'\n ) {\n configObject = exportDeclarationNode.declaration.right;\n return false;\n }\n\n if (exportDeclarationNode.declaration.type === 'ObjectExpression') {\n configObject = exportDeclarationNode.declaration;\n return false;\n }\n\n if (exportDeclarationNode.declaration.type === 'Identifier') {\n const identifierName = exportDeclarationNode.declaration.name;\n recast.visit(svelteConfig.$ast, {\n visitVariableDeclarator(path) {\n if (\n path.node.id?.type === 'Identifier' &&\n path.node.id.name === identifierName &&\n path.node.init?.type === 'ObjectExpression'\n ) {\n configObject = path.node.init;\n return false;\n }\n\n this.traverse(path);\n },\n });\n }\n\n this.traverse(path);\n },\n });\n\n if (!_isValidConfigObject(configObject)) {\n return {\n error: \"Couldn't find the config object\",\n };\n }\n\n // This type cast is safe. For some reason, TS still assumes that `configObject`\n // is `undefined` so we have to tell it that it's not (see check above)\n const validatedConfigObject =\n configObject as recast.types.namedTypes.ObjectExpression;\n\n const kitProp = validatedConfigObject.properties.find(\n (prop) =>\n prop.type === 'ObjectProperty' &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'kit',\n );\n\n if (!kitProp || kitProp.type !== 'ObjectProperty') {\n return {\n error: \"Couldn't find the `kit` property\",\n };\n }\n\n if (kitProp.value.type !== 'ObjectExpression') {\n return {\n error: `\\`kit\\` property has unexpected type: ${kitProp.value.type}`,\n };\n }\n\n // 1. find or add `kit.experimental` property\n // type-cast because TS can't infer the type in `.find` :(\n const kitExperimentalProp = kitProp.value.properties.find(\n (prop) =>\n prop.type === 'ObjectProperty' &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'experimental',\n ) as t.ObjectProperty | undefined;\n\n let experimentalObject: t.ObjectExpression;\n\n if (kitExperimentalProp) {\n if (kitExperimentalProp.value.type !== 'ObjectExpression') {\n return {\n error: `Property \\`kit.experimental\\` has unexpected type: ${kitExperimentalProp.value.type}`,\n };\n }\n\n experimentalObject = kitExperimentalProp.value;\n } else {\n experimentalObject = b.objectExpression([]);\n kitProp.value.properties.push(\n b.objectProperty(b.identifier('experimental'), experimentalObject),\n );\n }\n\n // 2. find or add `kit.experimental.tracing` property\n // find or add `kit.experimental.instrumentation` property\n const kitExperimentalTraingProp = experimentalObject.properties.find(\n (prop) =>\n prop.type === 'ObjectProperty' &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'tracing',\n ) as t.ObjectProperty | undefined;\n\n const kitExperimentalInstrumentationProp = experimentalObject.properties.find(\n (prop) =>\n prop.type === 'ObjectProperty' &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'instrumentation',\n ) as t.ObjectProperty | undefined;\n\n let experimentalTracingObject: t.ObjectExpression;\n let experimentalInstrumentationObject: t.ObjectExpression;\n\n if (kitExperimentalTraingProp) {\n if (kitExperimentalTraingProp.value.type !== 'ObjectExpression') {\n return {\n error: `Property \\`kit.experimental.tracing\\` has unexpected type: ${kitExperimentalTraingProp.value.type}`,\n };\n }\n\n experimentalTracingObject = kitExperimentalTraingProp.value;\n } else {\n experimentalTracingObject = b.objectExpression([]);\n experimentalObject.properties.push(\n b.objectProperty(b.identifier('tracing'), experimentalTracingObject),\n );\n }\n\n if (kitExperimentalInstrumentationProp) {\n if (kitExperimentalInstrumentationProp.value.type !== 'ObjectExpression') {\n return {\n error: `Property \\`kit.experimental.instrumentation\\` has unexpected type: ${kitExperimentalInstrumentationProp.value.type}`,\n };\n }\n\n experimentalInstrumentationObject =\n kitExperimentalInstrumentationProp.value;\n } else {\n experimentalInstrumentationObject = b.objectExpression([]);\n experimentalObject.properties.push(\n b.objectProperty(\n b.identifier('instrumentation'),\n experimentalInstrumentationObject,\n ),\n );\n }\n\n // 3. find or add `kit.experimental.tracing.server` property\n // find or add `kit.experimental.instrumentation.server` property\n const kitExperimentalTracingSeverProp =\n experimentalTracingObject.properties.find(\n (prop) =>\n prop.type === 'ObjectProperty' &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'server',\n ) as t.ObjectProperty | undefined;\n\n const kitExperimentalInstrumentationSeverProp =\n experimentalInstrumentationObject.properties.find(\n (prop) =>\n prop.type === 'ObjectProperty' &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'server',\n ) as t.ObjectProperty | undefined;\n\n if (kitExperimentalTracingSeverProp) {\n if (kitExperimentalTracingSeverProp.value.type !== 'BooleanLiteral') {\n return {\n error: `Property \\`kit.experimental.tracing.server\\` has unexpected type: ${kitExperimentalTracingSeverProp.value.type}`,\n };\n }\n\n kitExperimentalTracingSeverProp.value = b.booleanLiteral(enableTracing);\n } else {\n experimentalTracingObject.properties.push(\n b.objectProperty(b.identifier('server'), b.booleanLiteral(enableTracing)),\n );\n }\n\n if (kitExperimentalInstrumentationSeverProp) {\n if (\n kitExperimentalInstrumentationSeverProp.value.type !== 'BooleanLiteral'\n ) {\n return {\n error: `Property \\`kit.experimental.instrumentation.server\\` has unexpected type: ${kitExperimentalInstrumentationSeverProp.value.type}`,\n };\n }\n kitExperimentalInstrumentationSeverProp.value = b.booleanLiteral(true);\n } else {\n experimentalInstrumentationObject.properties.push(\n b.objectProperty(b.identifier('server'), b.booleanLiteral(true)),\n );\n }\n\n try {\n return {\n result: generateCode(svelteConfig).code,\n };\n } catch (e) {\n debug(e);\n return {\n error: 'Failed to generate code for Svelte config',\n };\n }\n}\n\nfunction _isValidConfigObject(\n o: t.ObjectExpression | undefined,\n): o is t.ObjectExpression {\n return !!o && o.type === 'ObjectExpression';\n}\n\nasync function showFallbackConfigSnippet(): Promise<void> {\n const codeSnippet = makeCodeSnippet(true, (unchanged, plus) =>\n unchanged(`const config = {\npreprocess: vitePreprocess(),\n\nkit: {\n adapter: adapter(),\n ${plus(`experimental: {\n instrumentation: {\n server: true,\n },\n tracing: {\n server: true,\n },\n },`)}\n},\n};\n`),\n );\n\n await showCopyPasteInstructions({\n filename: 'svelte.config.js',\n codeSnippet,\n });\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export type ProjectInfo = {
2
+ dsn: string;
3
+ org: string;
4
+ project: string;
5
+ selfHosted: boolean;
6
+ url: string;
7
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/sveltekit/sdk-setup/types.ts"],"names":[],"mappings":"","sourcesContent":["export type ProjectInfo = {\n dsn: string;\n org: string;\n project: string;\n selfHosted: boolean;\n url: string;\n};\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Applies the @param modifyCallback and records Sentry tags if the call failed.
3
+ * In case of a failure, a tag is set with @param reason as a fail reason
4
+ * and the error is rethrown.
5
+ */
6
+ export declare function modifyAndRecordFail<T>(modifyCallback: () => T | Promise<T>, reason: string, fileType: 'server-hooks' | 'client-hooks' | 'vite-cfg' | 'instrumentation-server'): Promise<void>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.modifyAndRecordFail = void 0;
27
+ const telemetry_1 = require("../../telemetry");
28
+ const Sentry = __importStar(require("@sentry/node"));
29
+ /**
30
+ * Applies the @param modifyCallback and records Sentry tags if the call failed.
31
+ * In case of a failure, a tag is set with @param reason as a fail reason
32
+ * and the error is rethrown.
33
+ */
34
+ async function modifyAndRecordFail(modifyCallback, reason, fileType) {
35
+ try {
36
+ await (0, telemetry_1.traceStep)(`${fileType}-${reason}`, modifyCallback);
37
+ }
38
+ catch (e) {
39
+ Sentry.setTag(`modified-${fileType}`, 'fail');
40
+ Sentry.setTag(`${fileType}-mod-fail-reason`, reason);
41
+ throw e;
42
+ }
43
+ }
44
+ exports.modifyAndRecordFail = modifyAndRecordFail;
45
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/sveltekit/sdk-setup/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA4C;AAC5C,qDAAuC;AAEvC;;;;GAIG;AACI,KAAK,UAAU,mBAAmB,CACvC,cAAoC,EACpC,MAAc,EACd,QAI4B;IAE5B,IAAI;QACF,MAAM,IAAA,qBAAS,EAAC,GAAG,QAAQ,IAAI,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC;KAC1D;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,MAAM,CAAC,YAAY,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,kBAAkB,EAAE,MAAM,CAAC,CAAC;QACrD,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AAhBD,kDAgBC","sourcesContent":["import { traceStep } from '../../telemetry';\nimport * as Sentry from '@sentry/node';\n\n/**\n * Applies the @param modifyCallback and records Sentry tags if the call failed.\n * In case of a failure, a tag is set with @param reason as a fail reason\n * and the error is rethrown.\n */\nexport async function modifyAndRecordFail<T>(\n modifyCallback: () => T | Promise<T>,\n reason: string,\n fileType:\n | 'server-hooks'\n | 'client-hooks'\n | 'vite-cfg'\n | 'instrumentation-server',\n): Promise<void> {\n try {\n await traceStep(`${fileType}-${reason}`, modifyCallback);\n } catch (e) {\n Sentry.setTag(`modified-${fileType}`, 'fail');\n Sentry.setTag(`${fileType}-mod-fail-reason`, reason);\n throw e;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { ProjectInfo } from './types';
2
+ export declare function modifyViteConfig(viteConfigPath: string, projectInfo: ProjectInfo): Promise<void>;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.modifyViteConfig = void 0;
30
+ const Sentry = __importStar(require("@sentry/node"));
31
+ const fs = __importStar(require("fs"));
32
+ const path = __importStar(require("path"));
33
+ const chalk_1 = __importDefault(require("chalk"));
34
+ //@ts-expect-error - clack is ESM and TS complains about that. It works though
35
+ const prompts_1 = __importDefault(require("@clack/prompts"));
36
+ // @ts-expect-error - magicast is ESM and TS complains about that. It works though
37
+ const magicast_1 = require("magicast");
38
+ // @ts-expect-error - magicast is ESM and TS complains about that. It works though
39
+ const helpers_1 = require("magicast/helpers");
40
+ const ast_utils_1 = require("../../utils/ast-utils");
41
+ const debug_1 = require("../../utils/debug");
42
+ const clack_1 = require("../../utils/clack");
43
+ const utils_1 = require("./utils");
44
+ async function modifyViteConfig(viteConfigPath, projectInfo) {
45
+ const viteConfigContent = (await fs.promises.readFile(viteConfigPath, 'utf-8')).toString();
46
+ const { org, project, url, selfHosted } = projectInfo;
47
+ const prettyViteConfigFilename = chalk_1.default.cyan(path.basename(viteConfigPath));
48
+ try {
49
+ const viteModule = (0, magicast_1.parseModule)(viteConfigContent);
50
+ if ((0, ast_utils_1.hasSentryContent)(viteModule.$ast)) {
51
+ prompts_1.default.log.warn(`File ${prettyViteConfigFilename} already contains Sentry code.
52
+ Skipping adding Sentry functionality to.`);
53
+ Sentry.setTag(`modified-vite-cfg`, 'fail');
54
+ Sentry.setTag(`vite-cfg-fail-reason`, 'has-sentry-content');
55
+ return;
56
+ }
57
+ await (0, utils_1.modifyAndRecordFail)(() => (0, helpers_1.addVitePlugin)(viteModule, {
58
+ imported: 'sentrySvelteKit',
59
+ from: '@sentry/sveltekit',
60
+ constructor: 'sentrySvelteKit',
61
+ options: {
62
+ sourceMapsUploadOptions: {
63
+ org,
64
+ project,
65
+ ...(selfHosted && { url }),
66
+ },
67
+ },
68
+ index: 0,
69
+ }), 'add-vite-plugin', 'vite-cfg');
70
+ await (0, utils_1.modifyAndRecordFail)(async () => {
71
+ const code = (0, magicast_1.generateCode)(viteModule.$ast).code;
72
+ await fs.promises.writeFile(viteConfigPath, code);
73
+ }, 'write-file', 'vite-cfg');
74
+ }
75
+ catch (e) {
76
+ (0, debug_1.debug)(e);
77
+ await showFallbackViteCopyPasteSnippet(viteConfigPath, getViteConfigCodeSnippet(org, project, selfHosted, url));
78
+ Sentry.captureException('Sveltekit Vite Config Modification Fail');
79
+ }
80
+ prompts_1.default.log.success(`Added Sentry code to ${prettyViteConfigFilename}`);
81
+ Sentry.setTag(`modified-vite-cfg`, 'success');
82
+ }
83
+ exports.modifyViteConfig = modifyViteConfig;
84
+ async function showFallbackViteCopyPasteSnippet(viteConfigPath, codeSnippet) {
85
+ const viteConfigFilename = path.basename(viteConfigPath);
86
+ prompts_1.default.log.warning(`Couldn't automatically modify your ${chalk_1.default.cyan(viteConfigFilename)}
87
+ ${chalk_1.default.dim(`This sometimes happens when we encounter more complex vite configs.
88
+ It may not seem like it but sometimes our magical powers are limited ;)`)}`);
89
+ prompts_1.default.log.info("But don't worry - it's super easy to do this yourself!");
90
+ prompts_1.default.log.step(`Add the following code to your ${chalk_1.default.cyan(viteConfigFilename)}:`);
91
+ // Intentionally logging to console here for easier copy/pasting
92
+ // eslint-disable-next-line no-console
93
+ console.log(codeSnippet);
94
+ await (0, clack_1.abortIfCancelled)(prompts_1.default.select({
95
+ message: 'Did you copy the snippet above?',
96
+ options: [
97
+ { label: 'Yes!', value: true, hint: "Great, that's already it!" },
98
+ ],
99
+ initialValue: true,
100
+ }));
101
+ }
102
+ const getViteConfigCodeSnippet = (org, project, selfHosted, url) => chalk_1.default.gray(`
103
+ import { sveltekit } from '@sveltejs/kit/vite';
104
+ import { defineConfig } from 'vite';
105
+ ${chalk_1.default.greenBright("import { sentrySvelteKit } from '@sentry/sveltekit'")}
106
+
107
+ export default defineConfig({
108
+ plugins: [
109
+ // Make sure \`sentrySvelteKit\` is registered before \`sveltekit\`
110
+ ${chalk_1.default.greenBright(`sentrySvelteKit({
111
+ sourceMapsUploadOptions: {
112
+ org: '${org}',
113
+ project: '${project}',${selfHosted ? `\n url: '${url}',` : ''}
114
+ }
115
+ }),`)}
116
+ sveltekit(),
117
+ ]
118
+ });
119
+ `);
120
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../../../../src/sveltekit/sdk-setup/vite.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,q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AG,CAAC,WAAW,CAAC,CAAC;IAEzB,MAAM,IAAA,wBAAgB,EACpB,iBAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,iCAAiC;QAC1C,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,2BAA2B,EAAE;SAClE;QACD,YAAY,EAAE,IAAI;KACnB,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,wBAAwB,GAAG,CAC/B,GAAW,EACX,OAAe,EACf,UAAmB,EACnB,GAAW,EACX,EAAE,CACF,eAAK,CAAC,IAAI,CAAC;;;EAGX,eAAK,CAAC,WAAW,CAAC,qDAAqD,CAAC;;;;;MAKpE,eAAK,CAAC,WAAW,CAAC;;gBAER,GAAG;oBACC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE;;QAEpE,CAAC;;;;CAIR,CAAC,CAAC","sourcesContent":["import * as Sentry from '@sentry/node';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport chalk from 'chalk';\n\n//@ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule } from 'magicast';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { addVitePlugin } from 'magicast/helpers';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nimport { hasSentryContent } from '../../utils/ast-utils';\nimport { debug } from '../../utils/debug';\nimport { abortIfCancelled } from '../../utils/clack';\nimport type { ProjectInfo } from './types';\nimport { modifyAndRecordFail } from './utils';\n\nexport async function modifyViteConfig(\n viteConfigPath: string,\n projectInfo: ProjectInfo,\n): Promise<void> {\n const viteConfigContent = (\n await fs.promises.readFile(viteConfigPath, 'utf-8')\n ).toString();\n\n const { org, project, url, selfHosted } = projectInfo;\n\n const prettyViteConfigFilename = chalk.cyan(path.basename(viteConfigPath));\n\n try {\n const viteModule = parseModule(viteConfigContent);\n\n if (hasSentryContent(viteModule.$ast as t.Program)) {\n clack.log.warn(\n `File ${prettyViteConfigFilename} already contains Sentry code.\nSkipping adding Sentry functionality to.`,\n );\n Sentry.setTag(`modified-vite-cfg`, 'fail');\n Sentry.setTag(`vite-cfg-fail-reason`, 'has-sentry-content');\n return;\n }\n\n await modifyAndRecordFail(\n () =>\n addVitePlugin(viteModule, {\n imported: 'sentrySvelteKit',\n from: '@sentry/sveltekit',\n constructor: 'sentrySvelteKit',\n options: {\n sourceMapsUploadOptions: {\n org,\n project,\n ...(selfHosted && { url }),\n },\n },\n index: 0,\n }),\n 'add-vite-plugin',\n 'vite-cfg',\n );\n\n await modifyAndRecordFail(\n async () => {\n const code = generateCode(viteModule.$ast).code;\n await fs.promises.writeFile(viteConfigPath, code);\n },\n 'write-file',\n 'vite-cfg',\n );\n } catch (e) {\n debug(e);\n await showFallbackViteCopyPasteSnippet(\n viteConfigPath,\n getViteConfigCodeSnippet(org, project, selfHosted, url),\n );\n Sentry.captureException('Sveltekit Vite Config Modification Fail');\n }\n\n clack.log.success(`Added Sentry code to ${prettyViteConfigFilename}`);\n Sentry.setTag(`modified-vite-cfg`, 'success');\n}\n\nasync function showFallbackViteCopyPasteSnippet(\n viteConfigPath: string,\n codeSnippet: string,\n) {\n const viteConfigFilename = path.basename(viteConfigPath);\n\n clack.log.warning(\n `Couldn't automatically modify your ${chalk.cyan(viteConfigFilename)}\n${chalk.dim(`This sometimes happens when we encounter more complex vite configs.\nIt may not seem like it but sometimes our magical powers are limited ;)`)}`,\n );\n\n clack.log.info(\"But don't worry - it's super easy to do this yourself!\");\n\n clack.log.step(\n `Add the following code to your ${chalk.cyan(viteConfigFilename)}:`,\n );\n\n // Intentionally logging to console here for easier copy/pasting\n // eslint-disable-next-line no-console\n console.log(codeSnippet);\n\n await abortIfCancelled(\n clack.select({\n message: 'Did you copy the snippet above?',\n options: [\n { label: 'Yes!', value: true, hint: \"Great, that's already it!\" },\n ],\n initialValue: true,\n }),\n );\n}\n\nconst getViteConfigCodeSnippet = (\n org: string,\n project: string,\n selfHosted: boolean,\n url: string,\n) =>\n chalk.gray(`\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { defineConfig } from 'vite';\n${chalk.greenBright(\"import { sentrySvelteKit } from '@sentry/sveltekit'\")}\n\nexport default defineConfig({\n plugins: [\n // Make sure \\`sentrySvelteKit\\` is registered before \\`sveltekit\\`\n ${chalk.greenBright(`sentrySvelteKit({\n sourceMapsUploadOptions: {\n org: '${org}',\n project: '${project}',${selfHosted ? `\\n url: '${url}',` : ''}\n }\n }),`)}\n sveltekit(),\n ]\n});\n`);\n"]}
@@ -37,7 +37,8 @@ const package_json_1 = require("../utils/package-json");
37
37
  const package_manager_1 = require("../utils/package-manager");
38
38
  const mcp_config_1 = require("../utils/clack/mcp-config");
39
39
  const sdk_example_1 = require("./sdk-example");
40
- const sdk_setup_1 = require("./sdk-setup");
40
+ const setup_1 = require("./sdk-setup/setup");
41
+ const svelte_config_1 = require("./sdk-setup/svelte-config");
41
42
  const utils_1 = require("./utils");
42
43
  async function runSvelteKitWizard(options) {
43
44
  return (0, telemetry_1.withTelemetry)({
@@ -81,6 +82,45 @@ async function runSvelteKitWizardWithTelemetry(options) {
81
82
  return;
82
83
  }
83
84
  }
85
+ let setupForSvelteKitTracing = kitVersionBucket === '>=2.31.0';
86
+ if (kitVersionBucket !== '>=2.31.0') {
87
+ clack.log.warn(`It seems you're using a SvelteKit version ${chalk_1.default.cyan('<2.31.0')} (detected ${chalk_1.default.cyan(kitVersion ?? 'unknown')}).
88
+
89
+ We recommend upgrading SvelteKit to version ${chalk_1.default.cyan('>=2.31.0')} to use SvelteKit's builtin observability:
90
+ ${chalk_1.default.cyan('https://svelte.dev/docs/kit/observability')}
91
+
92
+ Sentry works best with SvelteKit versions ${chalk_1.default.cyan('>=2.31.0')}.
93
+
94
+ If you prefer, you can stay on your current version and use the Sentry SDK
95
+ without SvelteKit's builtin observability.`);
96
+ const decision = await (0, clack_1.abortIfCancelled)(clack.select({
97
+ message: 'Do you want to continue anyway?',
98
+ options: [
99
+ {
100
+ label: "No, I'll upgrade SvelteKit first",
101
+ hint: 'Recommended',
102
+ value: 'exit-to-upgrade',
103
+ },
104
+ {
105
+ label: "I'm already on SvelteKit >=2.31.0",
106
+ hint: 'Sorry, my bad!',
107
+ value: 'install-with-kit-tracing',
108
+ },
109
+ {
110
+ label: 'Yes, continue',
111
+ hint: 'No Problem!',
112
+ value: 'install-without-kit-tracing',
113
+ },
114
+ ],
115
+ }));
116
+ if (decision === 'install-with-kit-tracing') {
117
+ setupForSvelteKitTracing = true;
118
+ }
119
+ if (decision === 'exit-to-upgrade') {
120
+ await (0, clack_1.abort)('Exiting Wizard', 0);
121
+ return;
122
+ }
123
+ }
84
124
  Sentry.setTag('svelte-version', (0, utils_1.getSvelteVersionBucket)((0, package_json_1.getPackageVersion)('svelte', packageJson)));
85
125
  const { selectedProject, selfHosted, sentryUrl, authToken } = await (0, clack_1.getOrAskForProjectData)(options, 'javascript-sveltekit');
86
126
  const sdkAlreadyInstalled = (0, package_json_1.hasPackageInstalled)('@sentry/sveltekit', packageJson);
@@ -92,15 +132,15 @@ async function runSvelteKitWizardWithTelemetry(options) {
92
132
  forceInstall,
93
133
  });
94
134
  await (0, clack_1.addDotEnvSentryBuildPluginFile)(authToken);
95
- const svelteConfig = await (0, telemetry_1.traceStep)('load-svelte-config', sdk_setup_1.loadSvelteConfig);
135
+ const svelteConfig = await (0, telemetry_1.traceStep)('load-svelte-config', svelte_config_1.loadSvelteConfig);
96
136
  try {
97
- await (0, telemetry_1.traceStep)('configure-sdk', () => (0, sdk_setup_1.createOrMergeSvelteKitFiles)({
137
+ await (0, telemetry_1.traceStep)('configure-sdk', () => (0, setup_1.createOrMergeSvelteKitFiles)({
98
138
  dsn: selectedProject.keys[0].dsn.public,
99
139
  org: selectedProject.organization.slug,
100
140
  project: selectedProject.slug,
101
141
  selfHosted,
102
142
  url: sentryUrl,
103
- }, svelteConfig));
143
+ }, svelteConfig, setupForSvelteKitTracing));
104
144
  }
105
145
  catch (e) {
106
146
  clack.log.error('Error while setting up the SvelteKit SDK:');
@@ -143,7 +183,7 @@ async function runSvelteKitWizardWithTelemetry(options) {
143
183
  exports.runSvelteKitWizardWithTelemetry = runSvelteKitWizardWithTelemetry;
144
184
  async function buildOutroMessage(shouldCreateExamplePage) {
145
185
  const packageManager = await (0, clack_1.getPackageManager)(package_manager_1.NPM);
146
- let msg = chalk_1.default.green('\nSuccessfully installed the Sentry SvelteKit SDK!');
186
+ let msg = chalk_1.default.green('Successfully installed the Sentry SvelteKit SDK!');
147
187
  if (shouldCreateExamplePage) {
148
188
  msg += `\n\nYou can validate your setup by starting your dev environment (${chalk_1.default.cyan(`\`${packageManager.runScriptCommand} dev\``)}) and visiting ${chalk_1.default.cyan('"/sentry-example-page"')}.`;
149
189
  }