@sentry/wizard 6.8.0 → 6.8.1
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 +7 -0
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js +70 -84
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js +3 -0
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -1
- package/dist/src/apple/fastlane.js +3 -1
- package/dist/src/apple/fastlane.js.map +1 -1
- package/dist/src/apple/templates.js +1 -1
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.d.ts +1 -0
- package/dist/src/sveltekit/sdk-example.js +3 -1
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +4 -2
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.d.ts +1 -0
- package/dist/src/sveltekit/templates.js +2 -4
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/sveltekit/utils.d.ts +1 -1
- package/dist/src/sveltekit/utils.js +45 -32
- package/dist/src/sveltekit/utils.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +8 -8
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/templates.test.js +1 -1
- package/dist/test/apple/templates.test.js.map +1 -1
- package/dist/test/sveltekit/templates.test.js +478 -0
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/dist/test/sveltekit/utils.test.d.ts +1 -0
- package/dist/test/sveltekit/utils.test.js +68 -0
- package/dist/test/sveltekit/utils.test.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 6.8.1
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- Change fastlane injection to `sentry_debug_files_upload` instead of `sentry_cli` ([#1125](https://github.com/getsentry/sentry-wizard/pull/1125))
|
|
8
|
+
- Ensure example page works on Svelte 4 and 5 ([#1129](https://github.com/getsentry/sentry-wizard/pull/1129))
|
|
9
|
+
|
|
3
10
|
## 6.8.0
|
|
4
11
|
|
|
5
12
|
### Features
|
|
@@ -27,6 +27,8 @@ const path = __importStar(require("node:path"));
|
|
|
27
27
|
const Constants_1 = require("../../lib/Constants");
|
|
28
28
|
const utils_1 = require("../utils");
|
|
29
29
|
const vitest_1 = require("vitest");
|
|
30
|
+
//@ts-expect-error - clifty is ESM only
|
|
31
|
+
const clifty_1 = require("clifty");
|
|
30
32
|
const SERVER_HOOK_TEMPLATE = `import type { Handle } from '@sveltejs/kit';
|
|
31
33
|
|
|
32
34
|
export const handle: Handle = async ({ event, resolve }) => {
|
|
@@ -50,94 +52,13 @@ export async function handleError({ error, event }) {
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
`;
|
|
53
|
-
|
|
54
|
-
const wizardInstance = (0, utils_1.startWizardInstance)(integration, projectDir);
|
|
55
|
-
let kitVersionPrompted = false;
|
|
56
|
-
if (fileModificationFn) {
|
|
57
|
-
fileModificationFn(projectDir, integration);
|
|
58
|
-
// As we modified project, we have a warning prompt before we get the package manager prompt
|
|
59
|
-
await wizardInstance.waitForOutput('Do you want to continue anyway?');
|
|
60
|
-
kitVersionPrompted = await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], "It seems you're using a SvelteKit version");
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
kitVersionPrompted = await wizardInstance.waitForOutput("It seems you're using a SvelteKit version");
|
|
64
|
-
}
|
|
65
|
-
const packageManagerPrompted = kitVersionPrompted &&
|
|
66
|
-
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
67
|
-
// Select "Yes, Continue" to perform hooks-based SDK setup
|
|
68
|
-
[utils_1.KEYS.DOWN, utils_1.KEYS.DOWN, utils_1.KEYS.ENTER], 'Please select your package manager.'));
|
|
69
|
-
const tracingOptionPrompted = packageManagerPrompted &&
|
|
70
|
-
(await wizardInstance.sendStdinAndWaitForOutput(
|
|
71
|
-
// Selecting `yarn` as the package manager
|
|
72
|
-
[utils_1.KEYS.DOWN, utils_1.KEYS.ENTER],
|
|
73
|
-
// "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
|
|
74
|
-
'to track the performance of your application?', {
|
|
75
|
-
timeout: 240000,
|
|
76
|
-
}));
|
|
77
|
-
const replayOptionPrompted = tracingOptionPrompted &&
|
|
78
|
-
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER],
|
|
79
|
-
// "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
|
|
80
|
-
'to get a video-like reproduction of errors during a user session?'));
|
|
81
|
-
const logsOptionPrompted = replayOptionPrompted &&
|
|
82
|
-
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER],
|
|
83
|
-
// "Do you want to enable Logs", sometimes doesn't work as `Logs` can be printed in bold.
|
|
84
|
-
'to send your application logs to Sentry?'));
|
|
85
|
-
const examplePagePrompted = logsOptionPrompted &&
|
|
86
|
-
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], 'Do you want to create an example page', {
|
|
87
|
-
optional: true,
|
|
88
|
-
}));
|
|
89
|
-
// After the example page prompt, we send ENTER to accept it
|
|
90
|
-
// Then handle the MCP prompt that comes after
|
|
91
|
-
const mcpPrompted = examplePagePrompted &&
|
|
92
|
-
(await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.ENTER], // This ENTER is for accepting the example page
|
|
93
|
-
'Optionally add a project-scoped MCP server configuration for the Sentry MCP?', {
|
|
94
|
-
optional: true,
|
|
95
|
-
}));
|
|
96
|
-
// Decline MCP config (default is Yes, so press DOWN then ENTER to select No)
|
|
97
|
-
if (mcpPrompted) {
|
|
98
|
-
await wizardInstance.sendStdinAndWaitForOutput([utils_1.KEYS.DOWN, utils_1.KEYS.ENTER], 'Successfully installed the Sentry SvelteKit SDK!');
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
// If MCP wasn't prompted, wait for success message directly
|
|
102
|
-
await wizardInstance.waitForOutput('Successfully installed the Sentry SvelteKit SDK!');
|
|
103
|
-
}
|
|
104
|
-
wizardInstance.kill();
|
|
105
|
-
}
|
|
106
|
-
function checkSvelteKitProject(projectDir, integration, options) {
|
|
107
|
-
(0, vitest_1.test)('should have the correct package.json', () => {
|
|
108
|
-
(0, utils_1.checkPackageJson)(projectDir, integration);
|
|
109
|
-
});
|
|
110
|
-
(0, vitest_1.test)('should have the correct .env.sentry-build-plugin', () => {
|
|
111
|
-
(0, utils_1.checkEnvBuildPlugin)(projectDir);
|
|
112
|
-
});
|
|
113
|
-
(0, vitest_1.test)('example page exists', () => {
|
|
114
|
-
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'));
|
|
115
|
-
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'));
|
|
116
|
-
});
|
|
117
|
-
(0, vitest_1.test)('vite.config contains sentry plugin', () => {
|
|
118
|
-
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'vite.config.ts'), `plugins: [sentrySvelteKit({
|
|
119
|
-
sourceMapsUploadOptions: {
|
|
120
|
-
`);
|
|
121
|
-
});
|
|
122
|
-
(0, vitest_1.test)('hook files created', () => {
|
|
123
|
-
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.server.ts'));
|
|
124
|
-
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.client.ts'));
|
|
125
|
-
});
|
|
126
|
-
(0, vitest_1.test)('builds successfully', async () => {
|
|
127
|
-
await (0, utils_1.checkIfBuilds)(projectDir);
|
|
128
|
-
});
|
|
129
|
-
(0, vitest_1.test)('runs on dev mode correctly', async () => {
|
|
130
|
-
await (0, utils_1.checkIfRunsOnDevMode)(projectDir, options?.devModeExpectedOutput || 'ready in');
|
|
131
|
-
});
|
|
132
|
-
(0, vitest_1.test)('runs on prod mode correctly', async () => {
|
|
133
|
-
await (0, utils_1.checkIfRunsOnProdMode)(projectDir, options?.prodModeExpectedOutput || 'to expose', 'preview');
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
(0, vitest_1.describe)('Sveltekit', () => {
|
|
55
|
+
vitest_1.describe.sequential('Sveltekit', () => {
|
|
137
56
|
(0, vitest_1.describe)('without existing hooks', () => {
|
|
138
57
|
const integration = Constants_1.Integration.sveltekit;
|
|
139
58
|
const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-hooks-test-app');
|
|
140
59
|
(0, vitest_1.beforeAll)(async () => {
|
|
60
|
+
(0, utils_1.initGit)(projectDir);
|
|
61
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
141
62
|
await runWizardOnSvelteKitProject(projectDir, integration);
|
|
142
63
|
});
|
|
143
64
|
(0, vitest_1.afterAll)(() => {
|
|
@@ -196,11 +117,20 @@ function checkSvelteKitProject(projectDir, integration, options) {
|
|
|
196
117
|
'export const handleError = handleErrorWithSentry();',
|
|
197
118
|
]);
|
|
198
119
|
});
|
|
120
|
+
(0, vitest_1.test)('creates an example route and page', () => {
|
|
121
|
+
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'));
|
|
122
|
+
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),
|
|
123
|
+
// Svelte <5 specific syntax
|
|
124
|
+
['let hasSentError = false;', 'on:click={getSentryData}']);
|
|
125
|
+
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'));
|
|
126
|
+
});
|
|
199
127
|
});
|
|
200
128
|
(0, vitest_1.describe)('with existing hooks', () => {
|
|
201
129
|
const integration = Constants_1.Integration.sveltekit;
|
|
202
130
|
const projectDir = path.resolve(__dirname, '../test-applications/sveltekit-hooks-test-app');
|
|
203
131
|
(0, vitest_1.beforeAll)(async () => {
|
|
132
|
+
(0, utils_1.initGit)(projectDir);
|
|
133
|
+
(0, utils_1.revertLocalChanges)(projectDir);
|
|
204
134
|
await runWizardOnSvelteKitProject(projectDir, integration, (projectDir) => {
|
|
205
135
|
(0, utils_1.createFile)(path.resolve(projectDir, 'src/hooks.server.ts'), SERVER_HOOK_TEMPLATE);
|
|
206
136
|
(0, utils_1.createFile)(path.resolve(projectDir, 'src/hooks.client.ts'), CLIENT_HOOK_TEMPLATE);
|
|
@@ -242,4 +172,60 @@ function checkSvelteKitProject(projectDir, integration, options) {
|
|
|
242
172
|
});
|
|
243
173
|
});
|
|
244
174
|
});
|
|
175
|
+
async function runWizardOnSvelteKitProject(projectDir, integration, fileModificationFn) {
|
|
176
|
+
const wizardInteraction = (0, clifty_1.withEnv)({
|
|
177
|
+
cwd: projectDir,
|
|
178
|
+
}).defineInteraction();
|
|
179
|
+
if (fileModificationFn) {
|
|
180
|
+
fileModificationFn(projectDir, integration);
|
|
181
|
+
wizardInteraction
|
|
182
|
+
.whenAsked('Do you want to continue anyway?')
|
|
183
|
+
.respondWith(clifty_1.KEYS.ENTER);
|
|
184
|
+
}
|
|
185
|
+
wizardInteraction
|
|
186
|
+
.whenAsked("It seems you're using a SvelteKit version")
|
|
187
|
+
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
|
|
188
|
+
.whenAsked('Please select your package manager.')
|
|
189
|
+
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
|
|
190
|
+
.whenAsked('Do you want to enable Tracing', {
|
|
191
|
+
timeout: 90000, // package installation can take a while in CI
|
|
192
|
+
})
|
|
193
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
194
|
+
.whenAsked('Do you want to enable Session Replay')
|
|
195
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
196
|
+
.whenAsked('Do you want to enable Logs')
|
|
197
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
198
|
+
.whenAsked('Do you want to create an example page')
|
|
199
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
200
|
+
.whenAsked('Optionally add a project-scoped MCP server configuration for the Sentry MCP?')
|
|
201
|
+
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
|
|
202
|
+
.expectOutput('Successfully installed the Sentry SvelteKit SDK!');
|
|
203
|
+
await wizardInteraction.run((0, utils_1.getWizardCommand)(Constants_1.Integration.sveltekit));
|
|
204
|
+
}
|
|
205
|
+
function checkSvelteKitProject(projectDir, integration, options) {
|
|
206
|
+
(0, vitest_1.test)('should have the correct package.json', () => {
|
|
207
|
+
(0, utils_1.checkPackageJson)(projectDir, integration);
|
|
208
|
+
});
|
|
209
|
+
(0, vitest_1.test)('should have the correct .env.sentry-build-plugin', () => {
|
|
210
|
+
(0, utils_1.checkEnvBuildPlugin)(projectDir);
|
|
211
|
+
});
|
|
212
|
+
(0, vitest_1.test)('vite.config contains sentry plugin', () => {
|
|
213
|
+
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'vite.config.ts'), `plugins: [sentrySvelteKit({
|
|
214
|
+
sourceMapsUploadOptions: {
|
|
215
|
+
`);
|
|
216
|
+
});
|
|
217
|
+
(0, vitest_1.test)('hook files created', () => {
|
|
218
|
+
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.server.ts'));
|
|
219
|
+
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/hooks.client.ts'));
|
|
220
|
+
});
|
|
221
|
+
(0, vitest_1.test)('builds successfully', async () => {
|
|
222
|
+
await (0, utils_1.checkIfBuilds)(projectDir);
|
|
223
|
+
});
|
|
224
|
+
(0, vitest_1.test)('runs on dev mode correctly', async () => {
|
|
225
|
+
await (0, utils_1.checkIfRunsOnDevMode)(projectDir, options?.devModeExpectedOutput || 'ready in');
|
|
226
|
+
});
|
|
227
|
+
(0, vitest_1.test)('runs on prod mode correctly', async () => {
|
|
228
|
+
await (0, utils_1.checkIfRunsOnProdMode)(projectDir, options?.prodModeExpectedOutput || 'to expose', 'preview');
|
|
229
|
+
});
|
|
230
|
+
}
|
|
245
231
|
//# sourceMappingURL=sveltekit-hooks.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit-hooks.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/sveltekit-hooks.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,mDAAkD;AAClD,oCAckB;AAClB,mCAA6D;AAE7D,MAAM,oBAAoB,GAAG;;;;;;;;;;CAU5B,CAAC;AACF,MAAM,oBAAoB,GAAG;;;;;;;;;;;CAW5B,CAAC;AAEF,KAAK,UAAU,2BAA2B,CACxC,UAAkB,EAClB,WAAwB,EACxB,kBAGY;IAEZ,MAAM,cAAc,GAAG,IAAA,2BAAmB,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpE,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAE/B,IAAI,kBAAkB,EAAE;QACtB,kBAAkB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAE5C,4FAA4F;QAC5F,MAAM,cAAc,CAAC,aAAa,CAAC,iCAAiC,CAAC,CAAC;QAEtE,kBAAkB,GAAG,MAAM,cAAc,CAAC,yBAAyB,CACjE,CAAC,YAAI,CAAC,KAAK,CAAC,EACZ,2CAA2C,CAC5C,CAAC;KACH;SAAM;QACL,kBAAkB,GAAG,MAAM,cAAc,CAAC,aAAa,CACrD,2CAA2C,CAC5C,CAAC;KACH;IAED,MAAM,sBAAsB,GAC1B,kBAAkB;QAClB,CAAC,MAAM,cAAc,CAAC,yBAAyB;QAC7C,0DAA0D;QAC1D,CAAC,YAAI,CAAC,IAAI,EAAE,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,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAA,aAAI,EAAC,sCAAsC,EAAE,GAAG,EAAE;YAChD,IAAA,yBAAiB,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE;gBACjE,8CAA8C;gBAC9C;YACI,iBAAS,CAAC,WAAW;;;;GAI9B;gBACK,4DAA4D;aAC7D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { Integration } from '../../lib/Constants';\nimport {\n KEYS,\n TEST_ARGS,\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n createFile,\n revertLocalChanges,\n startWizardInstance,\n} from '../utils';\nimport { afterAll, beforeAll, describe, test } from 'vitest';\n\nconst SERVER_HOOK_TEMPLATE = `import type { Handle } from '@sveltejs/kit';\n\nexport const handle: Handle = async ({ event, resolve }) => {\n\tif (event.url.pathname.startsWith('/custom')) {\n\t\treturn new Response('custom response');\n\t}\n\n\tconst response = await resolve(event);\n\treturn response;\n};\n`;\nconst CLIENT_HOOK_TEMPLATE = `\nexport async function handleError({ error, event }) {\n // you can capture the \\`error\\` and \\`event\\` from the client\n // but it only runs if the unexpected error comes from \\`+ page.ts\\`\n console.log(error)\n\n return {\n // don't show sensitive data to the user\n message: 'Yikes! 💩',\n }\n}\n`;\n\nasync function runWizardOnSvelteKitProject(\n projectDir: string,\n integration: Integration,\n fileModificationFn?: (\n projectDir: string,\n integration: Integration,\n ) => unknown,\n) {\n const wizardInstance = startWizardInstance(integration, projectDir);\n let kitVersionPrompted = false;\n\n if (fileModificationFn) {\n fileModificationFn(projectDir, integration);\n\n // As we modified project, we have a warning prompt before we get the package manager prompt\n await wizardInstance.waitForOutput('Do you want to continue anyway?');\n\n kitVersionPrompted = await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n \"It seems you're using a SvelteKit version\",\n );\n } else {\n kitVersionPrompted = await wizardInstance.waitForOutput(\n \"It seems you're using a SvelteKit version\",\n );\n }\n\n const packageManagerPrompted =\n kitVersionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Select \"Yes, Continue\" to perform hooks-based SDK setup\n [KEYS.DOWN, KEYS.DOWN, KEYS.ENTER],\n 'Please select your package manager.',\n ));\n\n const tracingOptionPrompted =\n packageManagerPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000,\n },\n ));\n\n const replayOptionPrompted =\n tracingOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n ));\n\n const logsOptionPrompted =\n replayOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Logs\", sometimes doesn't work as `Logs` can be printed in bold.\n 'to send your application logs to Sentry?',\n ));\n\n const examplePagePrompted =\n logsOptionPrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Do you want to create an example page',\n {\n optional: true,\n },\n ));\n\n // After the example page prompt, we send ENTER to accept it\n // Then handle the MCP prompt that comes after\n const mcpPrompted =\n examplePagePrompted &&\n (await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // This ENTER is for accepting the example page\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n {\n optional: true,\n },\n ));\n\n // Decline MCP config (default is Yes, so press DOWN then ENTER to select No)\n if (mcpPrompted) {\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER],\n 'Successfully installed the Sentry SvelteKit SDK!',\n );\n } else {\n // If MCP wasn't prompted, wait for success message directly\n await wizardInstance.waitForOutput(\n 'Successfully installed the Sentry SvelteKit SDK!',\n );\n }\n\n wizardInstance.kill();\n}\n\nfunction checkSvelteKitProject(\n projectDir: string,\n integration: Integration,\n options?: {\n devModeExpectedOutput: string;\n prodModeExpectedOutput: string;\n },\n) {\n test('should have the correct package.json', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('should have the correct .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('example page exists', () => {\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n );\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'),\n );\n });\n\n test('vite.config contains sentry plugin', () => {\n checkFileContents(\n path.resolve(projectDir, 'vite.config.ts'),\n `plugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n`,\n );\n });\n\n test('hook files created', () => {\n checkFileExists(path.resolve(projectDir, 'src/hooks.server.ts'));\n checkFileExists(path.resolve(projectDir, 'src/hooks.client.ts'));\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(\n projectDir,\n options?.devModeExpectedOutput || 'ready in',\n );\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(\n projectDir,\n options?.prodModeExpectedOutput || 'to expose',\n 'preview',\n );\n });\n}\n\ndescribe('Sveltekit', () => {\n describe('without existing hooks', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-hooks-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnSvelteKitProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkSvelteKitProject(projectDir, integration);\n\n test('hooks.client.ts contains sentry', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.client.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n\n // If you don't want to use Session Replay, just remove the line below:\n integrations: [replayIntegration()],\n\n // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\n});`,\n 'export const handleError = handleErrorWithSentry(',\n ]);\n });\n\n test('hooks.server.ts contains sentry', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.server.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n\n // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});`,\n 'export const handleError = handleErrorWithSentry();',\n ]);\n });\n });\n\n describe('with existing hooks', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-hooks-test-app',\n );\n\n beforeAll(async () => {\n await runWizardOnSvelteKitProject(\n projectDir,\n integration,\n (projectDir) => {\n createFile(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n SERVER_HOOK_TEMPLATE,\n );\n\n createFile(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n CLIENT_HOOK_TEMPLATE,\n );\n },\n );\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkSvelteKitProject(projectDir, integration);\n\n // These are removed from the common tests as the content is different\n // when the hooks are merged instead of created from the template\n test('hooks.client.ts contains sentry instrumentation', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.client.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1,\n integrations: [Sentry.replayIntegration()],\n enableLogs: true,\n sendDefaultPii: true\n})`,\n 'export const handleError = Sentry.handleErrorWithSentry(',\n ]);\n });\n\n test('hooks.server.ts contains sentry init', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.server.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n enableLogs: true,\n sendDefaultPii: true\n})`,\n 'export const handleError = Sentry.handleErrorWithSentry();',\n ]);\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"sveltekit-hooks.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/sveltekit-hooks.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,mDAAkD;AAClD,oCAckB;AAClB,mCAA6D;AAC7D,uCAAuC;AACvC,mCAAuC;AAEvC,MAAM,oBAAoB,GAAG;;;;;;;;;;CAU5B,CAAC;AACF,MAAM,oBAAoB,GAAG;;;;;;;;;;;CAW5B,CAAC;AAEF,iBAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,GAAG,EAAE;IACpC,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,WAAW,GAAG,uBAAW,CAAC,SAAS,CAAC;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,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,IAAI,EAAE;QAC5C,MAAM,IAAA,4BAAoB,EACxB,UAAU,EACV,OAAO,EAAE,qBAAqB,IAAI,UAAU,CAC7C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,IAAA,6BAAqB,EACzB,UAAU,EACV,OAAO,EAAE,sBAAsB,IAAI,WAAW,EAC9C,SAAS,CACV,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { Integration } from '../../lib/Constants';\nimport {\n TEST_ARGS,\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n createFile,\n getWizardCommand,\n initGit,\n revertLocalChanges,\n} from '../utils';\nimport { afterAll, beforeAll, describe, test } from 'vitest';\n//@ts-expect-error - clifty is ESM only\nimport { KEYS, withEnv } from 'clifty';\n\nconst SERVER_HOOK_TEMPLATE = `import type { Handle } from '@sveltejs/kit';\n\nexport const handle: Handle = async ({ event, resolve }) => {\n\tif (event.url.pathname.startsWith('/custom')) {\n\t\treturn new Response('custom response');\n\t}\n\n\tconst response = await resolve(event);\n\treturn response;\n};\n`;\nconst CLIENT_HOOK_TEMPLATE = `\nexport async function handleError({ error, event }) {\n // you can capture the \\`error\\` and \\`event\\` from the client\n // but it only runs if the unexpected error comes from \\`+ page.ts\\`\n console.log(error)\n\n return {\n // don't show sensitive data to the user\n message: 'Yikes! 💩',\n }\n}\n`;\n\ndescribe.sequential('Sveltekit', () => {\n describe('without existing hooks', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-hooks-test-app',\n );\n\n beforeAll(async () => {\n initGit(projectDir);\n revertLocalChanges(projectDir);\n\n await runWizardOnSvelteKitProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkSvelteKitProject(projectDir, integration);\n\n test('hooks.client.ts contains sentry', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.client.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n\n // If you don't want to use Session Replay, just remove the line below:\n integrations: [replayIntegration()],\n\n // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\n});`,\n 'export const handleError = handleErrorWithSentry(',\n ]);\n });\n\n test('hooks.server.ts contains sentry', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.server.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n\n // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n});`,\n 'export const handleError = handleErrorWithSentry();',\n ]);\n });\n\n test('creates an example route and page', () => {\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n );\n checkFileContents(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n // Svelte <5 specific syntax\n ['let hasSentError = false;', 'on:click={getSentryData}'],\n );\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'),\n );\n });\n });\n\n describe('with existing hooks', () => {\n const integration = Integration.sveltekit;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-hooks-test-app',\n );\n\n beforeAll(async () => {\n initGit(projectDir);\n revertLocalChanges(projectDir);\n\n await runWizardOnSvelteKitProject(\n projectDir,\n integration,\n (projectDir) => {\n createFile(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n SERVER_HOOK_TEMPLATE,\n );\n\n createFile(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n CLIENT_HOOK_TEMPLATE,\n );\n },\n );\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkSvelteKitProject(projectDir, integration);\n\n // These are removed from the common tests as the content is different\n // when the hooks are merged instead of created from the template\n test('hooks.client.ts contains sentry instrumentation', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.client.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1,\n integrations: [Sentry.replayIntegration()],\n enableLogs: true,\n sendDefaultPii: true\n})`,\n 'export const handleError = Sentry.handleErrorWithSentry(',\n ]);\n });\n\n test('hooks.server.ts contains sentry init', () => {\n checkFileContents(path.resolve(projectDir, 'src/hooks.server.ts'), [\n `import * as Sentry from '@sentry/sveltekit';`,\n `Sentry.init({\n dsn: \"${TEST_ARGS.PROJECT_DSN}\",\n tracesSampleRate: 1,\n enableLogs: true,\n sendDefaultPii: true\n})`,\n 'export const handleError = Sentry.handleErrorWithSentry();',\n ]);\n });\n });\n});\n\nasync function runWizardOnSvelteKitProject(\n projectDir: string,\n integration: Integration,\n fileModificationFn?: (\n projectDir: string,\n integration: Integration,\n ) => unknown,\n) {\n const wizardInteraction = withEnv({\n cwd: projectDir,\n }).defineInteraction();\n\n if (fileModificationFn) {\n fileModificationFn(projectDir, integration);\n\n wizardInteraction\n .whenAsked('Do you want to continue anyway?')\n .respondWith(KEYS.ENTER);\n }\n\n wizardInteraction\n .whenAsked(\"It seems you're using a SvelteKit version\")\n .respondWith(KEYS.DOWN, KEYS.DOWN, KEYS.ENTER)\n .whenAsked('Please select your package manager.')\n .respondWith(KEYS.DOWN, KEYS.ENTER)\n .whenAsked('Do you want to enable Tracing', {\n timeout: 90_000, // package installation can take a while in CI\n })\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to enable Session Replay')\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to enable Logs')\n .respondWith(KEYS.ENTER)\n .whenAsked('Do you want to create an example page')\n .respondWith(KEYS.ENTER)\n .whenAsked(\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n )\n .respondWith(KEYS.DOWN, KEYS.ENTER)\n .expectOutput('Successfully installed the Sentry SvelteKit SDK!');\n\n await wizardInteraction.run(getWizardCommand(Integration.sveltekit));\n}\n\nfunction checkSvelteKitProject(\n projectDir: string,\n integration: Integration,\n options?: {\n devModeExpectedOutput: string;\n prodModeExpectedOutput: string;\n },\n) {\n test('should have the correct package.json', () => {\n checkPackageJson(projectDir, integration);\n });\n\n test('should have the correct .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n test('vite.config contains sentry plugin', () => {\n checkFileContents(\n path.resolve(projectDir, 'vite.config.ts'),\n `plugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n`,\n );\n });\n\n test('hook files created', () => {\n checkFileExists(path.resolve(projectDir, 'src/hooks.server.ts'));\n checkFileExists(path.resolve(projectDir, 'src/hooks.client.ts'));\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(\n projectDir,\n options?.devModeExpectedOutput || 'ready in',\n );\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(\n projectDir,\n options?.prodModeExpectedOutput || 'to expose',\n 'preview',\n );\n });\n}\n"]}
|
|
@@ -77,6 +77,9 @@ const clifty_1 = require("clifty");
|
|
|
77
77
|
(0, vitest_1.it)('adds the example page', () => {
|
|
78
78
|
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'));
|
|
79
79
|
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'));
|
|
80
|
+
(0, utils_1.checkFileContents)(path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),
|
|
81
|
+
// svelte 5 specific syntax
|
|
82
|
+
['let hasSentError = $state(false);', 'onclick={getSentryData}']);
|
|
80
83
|
});
|
|
81
84
|
(0, vitest_1.it)('adds the sentry plugin to vite.config.ts', () => {
|
|
82
85
|
const viteConfig = fs.readFileSync(path.resolve(projectDir, 'vite.config.ts'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit-tracing.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/sveltekit-tracing.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,4CAA8B;AAC9B,mDAAkD;AAClD,oCAYkB;AAClB,mCAAmE;AAEnE,uCAAuC;AACvC,mCAAuC;AAEvC,IAAA,iBAAQ,EAAC,4CAA4C,EAAE,GAAG,EAAE;IAC1D,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B,SAAS,EACT,iDAAiD,CAClD,CAAC;QAEF,MAAM,WAAW,GAAG,uBAAW,CAAC,SAAS,CAAC;QAC1C,IAAI,cAAsB,CAAC;QAE3B,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;YACnB,IAAA,eAAO,EAAC,UAAU,CAAC,CAAC;YACpB,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAE/B,cAAc,GAAG,MAAM,IAAA,gBAAO,EAA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IAAI,EAAE;YAC3C,MAAM,IAAA,6BAAqB,EAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport { Integration } from '../../lib/Constants';\nimport {\n checkEnvBuildPlugin,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n getWizardCommand,\n initGit,\n revertLocalChanges,\n TEST_ARGS,\n} from '../utils';\nimport { afterAll, beforeAll, describe, expect, it } from 'vitest';\n\n//@ts-expect-error - clifty is ESM only\nimport { KEYS, withEnv } from 'clifty';\n\ndescribe('Sveltekit with instrumentation and tracing', () => {\n describe('without existing files', () => {\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-tracing-test-app',\n );\n\n const integration = Integration.sveltekit;\n let wizardExitCode: number;\n\n beforeAll(async () => {\n initGit(projectDir);\n revertLocalChanges(projectDir);\n\n wizardExitCode = await withEnv({\n cwd: projectDir,\n })\n .defineInteraction()\n .expectOutput(\n 'The Sentry SvelteKit Wizard will help you set up Sentry for your application',\n )\n .step('package installation', ({ expectOutput, whenAsked }) => {\n whenAsked('Please select your package manager.').respondWith(\n KEYS.DOWN,\n KEYS.ENTER,\n );\n expectOutput('Installing @sentry/sveltekit');\n })\n .step('SDK setup', ({ whenAsked }) => {\n whenAsked('Do you want to enable Tracing', {\n timeout: 90_000, // package installation can take a while in CI\n }).respondWith(KEYS.ENTER);\n whenAsked('Do you want to enable Session Replay').respondWith(\n KEYS.ENTER,\n );\n whenAsked('Do you want to enable Logs').respondWith(KEYS.ENTER);\n })\n .whenAsked('Do you want to create an example page')\n .respondWith(KEYS.ENTER)\n .whenAsked(\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n )\n .respondWith(KEYS.DOWN, KEYS.ENTER)\n .expectOutput('Successfully installed the Sentry SvelteKit SDK!')\n .run(getWizardCommand(integration));\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n it('exits with exit code 0', () => {\n expect(wizardExitCode).toBe(0);\n });\n\n it('adds the SDK dependency to package.json', () => {\n checkPackageJson(projectDir, integration);\n });\n\n it('adds the .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n it('adds the example page', () => {\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n );\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'),\n );\n });\n\n it('adds the sentry plugin to vite.config.ts', () => {\n const viteConfig = fs.readFileSync(\n path.resolve(projectDir, 'vite.config.ts'),\n );\n expect(viteConfig.toString()).toMatchInlineSnapshot(`\n \"import { sentrySvelteKit } from \"@sentry/sveltekit\";\n import { sveltekit } from '@sveltejs/kit/vite';\n import { defineConfig } from 'vite';\n\n export default defineConfig({\n \tplugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n org: \"${TEST_ARGS.ORG_SLUG}\",\n project: \"${TEST_ARGS.PROJECT_SLUG}\"\n }\n }), sveltekit()]\n });\"\n `);\n });\n\n it('creates the hook files', () => {\n const clientHooks = fs.readFileSync(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n );\n const serverHooks = fs.readFileSync(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n );\n\n expect(clientHooks.toString()).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n\n // If you don't want to use Session Replay, just remove the line below:\n integrations: [replayIntegration()],\n\n // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n\n expect(serverHooks.toString()).toMatchInlineSnapshot(`\n \"import {sequence} from \"@sveltejs/kit/hooks\";\n import * as Sentry from \"@sentry/sveltekit\";\n export const handle = sequence(Sentry.sentryHandle(), async ({ event, resolve }) => {\n const response = await resolve(event);\n return response;\n });\n export const handleError = Sentry.handleErrorWithSentry();\"\n `);\n });\n\n it('creates the insturmentation.server file', () => {\n const instrumentationServer = fs.readFileSync(\n path.resolve(projectDir, 'src/instrumentation.server.ts'),\n );\n\n expect(instrumentationServer.toString()).toMatchInlineSnapshot(`\n \"import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\"\n `);\n });\n\n it('enables tracing and instrumentation in svelte.config.js', () => {\n const svelteConfig = fs.readFileSync(\n path.resolve(projectDir, 'svelte.config.js'),\n );\n expect(svelteConfig.toString()).toMatchInlineSnapshot(`\n \"import adapter from '@sveltejs/adapter-node';\n import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';\n\n /** @type {import('@sveltejs/kit').Config} */\n const config = {\n // Consult https://svelte.dev/docs/kit/integrations#preprocessors\n // for more information about preprocessors\n preprocess: vitePreprocess(),\n\n kit: {\n // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.\n // If your environment is not supported, or you settled on a specific environment, switch out the adapter.\n // See https://svelte.dev/docs/kit/adapters for more information about adapters.\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n\n tracing: {\n server: true,\n },\n\n instrumentation: {\n server: true,\n },\n },\n },\n };\n\n export default config;\"\n `);\n });\n\n // checkSvelteKitProject(projectDir, integration);\n it('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n it('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, 'ready in');\n });\n\n it('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, 'to expose', 'preview');\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"sveltekit-tracing.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/sveltekit-tracing.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,4CAA8B;AAC9B,mDAAkD;AAClD,oCAakB;AAClB,mCAAmE;AAEnE,uCAAuC;AACvC,mCAAuC;AAEvC,IAAA,iBAAQ,EAAC,4CAA4C,EAAE,GAAG,EAAE;IAC1D,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B,SAAS,EACT,iDAAiD,CAClD,CAAC;QAEF,MAAM,WAAW,GAAG,uBAAW,CAAC,SAAS,CAAC;QAC1C,IAAI,cAAsB,CAAC;QAE3B,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;YACnB,IAAA,eAAO,EAAC,UAAU,CAAC,CAAC;YACpB,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAE/B,cAAc,GAAG,MAAM,IAAA,gBAAO,EAAC;gBAC7B,GAAG,EAAE,UAAU;aAChB,CAAC;iBACC,iBAAiB,EAAE;iBACnB,YAAY,CACX,8EAA8E,CAC/E;iBACA,IAAI,CAAC,sBAAsB,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE;gBAC5D,SAAS,CAAC,qCAAqC,CAAC,CAAC,WAAW,CA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CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport { Integration } from '../../lib/Constants';\nimport {\n checkEnvBuildPlugin,\n checkFileContents,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n getWizardCommand,\n initGit,\n revertLocalChanges,\n TEST_ARGS,\n} from '../utils';\nimport { afterAll, beforeAll, describe, expect, it } from 'vitest';\n\n//@ts-expect-error - clifty is ESM only\nimport { KEYS, withEnv } from 'clifty';\n\ndescribe('Sveltekit with instrumentation and tracing', () => {\n describe('without existing files', () => {\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/sveltekit-tracing-test-app',\n );\n\n const integration = Integration.sveltekit;\n let wizardExitCode: number;\n\n beforeAll(async () => {\n initGit(projectDir);\n revertLocalChanges(projectDir);\n\n wizardExitCode = await withEnv({\n cwd: projectDir,\n })\n .defineInteraction()\n .expectOutput(\n 'The Sentry SvelteKit Wizard will help you set up Sentry for your application',\n )\n .step('package installation', ({ expectOutput, whenAsked }) => {\n whenAsked('Please select your package manager.').respondWith(\n KEYS.DOWN,\n KEYS.ENTER,\n );\n expectOutput('Installing @sentry/sveltekit');\n })\n .step('SDK setup', ({ whenAsked }) => {\n whenAsked('Do you want to enable Tracing', {\n timeout: 90_000, // package installation can take a while in CI\n }).respondWith(KEYS.ENTER);\n whenAsked('Do you want to enable Session Replay').respondWith(\n KEYS.ENTER,\n );\n whenAsked('Do you want to enable Logs').respondWith(KEYS.ENTER);\n })\n .whenAsked('Do you want to create an example page')\n .respondWith(KEYS.ENTER)\n .whenAsked(\n 'Optionally add a project-scoped MCP server configuration for the Sentry MCP?',\n )\n .respondWith(KEYS.DOWN, KEYS.ENTER)\n .expectOutput('Successfully installed the Sentry SvelteKit SDK!')\n .run(getWizardCommand(integration));\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n it('exits with exit code 0', () => {\n expect(wizardExitCode).toBe(0);\n });\n\n it('adds the SDK dependency to package.json', () => {\n checkPackageJson(projectDir, integration);\n });\n\n it('adds the .env.sentry-build-plugin', () => {\n checkEnvBuildPlugin(projectDir);\n });\n\n it('adds the example page', () => {\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n );\n checkFileExists(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'),\n );\n checkFileContents(\n path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'),\n // svelte 5 specific syntax\n ['let hasSentError = $state(false);', 'onclick={getSentryData}'],\n );\n });\n\n it('adds the sentry plugin to vite.config.ts', () => {\n const viteConfig = fs.readFileSync(\n path.resolve(projectDir, 'vite.config.ts'),\n );\n expect(viteConfig.toString()).toMatchInlineSnapshot(`\n \"import { sentrySvelteKit } from \"@sentry/sveltekit\";\n import { sveltekit } from '@sveltejs/kit/vite';\n import { defineConfig } from 'vite';\n\n export default defineConfig({\n \tplugins: [sentrySvelteKit({\n sourceMapsUploadOptions: {\n org: \"${TEST_ARGS.ORG_SLUG}\",\n project: \"${TEST_ARGS.PROJECT_SLUG}\"\n }\n }), sveltekit()]\n });\"\n `);\n });\n\n it('creates the hook files', () => {\n const clientHooks = fs.readFileSync(\n path.resolve(projectDir, 'src/hooks.client.ts'),\n );\n const serverHooks = fs.readFileSync(\n path.resolve(projectDir, 'src/hooks.server.ts'),\n );\n\n expect(clientHooks.toString()).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n\n // If you don't want to use Session Replay, just remove the line below:\n integrations: [replayIntegration()],\n\n // Enable sending user PII (Personally Identifiable Information)\n // https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii\n sendDefaultPii: true,\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n\n expect(serverHooks.toString()).toMatchInlineSnapshot(`\n \"import {sequence} from \"@sveltejs/kit/hooks\";\n import * as Sentry from \"@sentry/sveltekit\";\n export const handle = sequence(Sentry.sentryHandle(), async ({ event, resolve }) => {\n const response = await resolve(event);\n return response;\n });\n export const handleError = Sentry.handleErrorWithSentry();\"\n `);\n });\n\n it('creates the insturmentation.server file', () => {\n const instrumentationServer = fs.readFileSync(\n path.resolve(projectDir, 'src/instrumentation.server.ts'),\n );\n\n expect(instrumentationServer.toString()).toMatchInlineSnapshot(`\n \"import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: '${TEST_ARGS.PROJECT_DSN}',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\"\n `);\n });\n\n it('enables tracing and instrumentation in svelte.config.js', () => {\n const svelteConfig = fs.readFileSync(\n path.resolve(projectDir, 'svelte.config.js'),\n );\n expect(svelteConfig.toString()).toMatchInlineSnapshot(`\n \"import adapter from '@sveltejs/adapter-node';\n import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';\n\n /** @type {import('@sveltejs/kit').Config} */\n const config = {\n // Consult https://svelte.dev/docs/kit/integrations#preprocessors\n // for more information about preprocessors\n preprocess: vitePreprocess(),\n\n kit: {\n // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.\n // If your environment is not supported, or you settled on a specific environment, switch out the adapter.\n // See https://svelte.dev/docs/kit/adapters for more information about adapters.\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n\n tracing: {\n server: true,\n },\n\n instrumentation: {\n server: true,\n },\n },\n },\n };\n\n export default config;\"\n `);\n });\n\n // checkSvelteKitProject(projectDir, integration);\n it('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n it('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(projectDir, 'ready in');\n });\n\n it('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(projectDir, 'to expose', 'preview');\n });\n });\n});\n"]}
|
|
@@ -86,10 +86,12 @@ function findLanes(content) {
|
|
|
86
86
|
}
|
|
87
87
|
function addSentryToLane(content, lane, org, project) {
|
|
88
88
|
const laneContent = content.slice(lane.index, lane.index + lane.length);
|
|
89
|
-
const sentryCLIMatch = /
|
|
89
|
+
const sentryCLIMatch = /(\n\s+)sentry_debug_files_upload\s*\([^)]+\)/gim.exec(laneContent);
|
|
90
90
|
if (sentryCLIMatch) {
|
|
91
91
|
// Sentry already added to lane. Update it.
|
|
92
|
+
// sentryCLIMatch[1] contains the leading newline and whitespace
|
|
92
93
|
return (content.slice(0, sentryCLIMatch.index + lane.index) +
|
|
94
|
+
sentryCLIMatch[1] +
|
|
93
95
|
templates.getFastlaneSnippet(org, project).trim() +
|
|
94
96
|
content.slice(sentryCLIMatch.index + sentryCLIMatch[0].length + lane.index));
|
|
95
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastlane.js","sourceRoot":"","sources":["../../../src/apple/fastlane.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,0CAAqD;AACrD,uDAAyC;AACzC,+EAA+E;AAC/E,sDAAwC;AAExC,SAAgB,QAAQ,CAAC,WAAmB;IAC1C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,EAAE,U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AAE,GAAG,EAAE,OAAO,CAAC,CAAC;KACvE;SAAM;QACL,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,YAAY,GAAG,MAAM,IAAA,2BAAmB,EAC5C,SAAS,EACT,+BAA+B,CAChC,CAAC;QACF,IAAI,YAAY,KAAK,SAAS,EAAE;YAC9B,OAAO,KAAK,CAAC;SACd;QACD,cAAc,GAAG,eAAe,CAC9B,WAAW,EACX,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EACzB,GAAG,EACH,OAAO,CACR,CAAC;KACH;IAED,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC;AACd,CAAC;AAlDD,kDAkDC;AAUD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;IACnC,wBAAgB,GAAG;QACjB,eAAe;QACf,SAAS;QACT,eAAe;KAChB,CAAC;CACH","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { askForItemSelection } from '../utils/clack';\nimport * as templates from './templates';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n\nexport function fastFile(projectPath: string): string | null {\n const fastlanePath = path.join(projectPath, 'fastlane', 'Fastfile');\n return fs.existsSync(fastlanePath) ? fastlanePath : null;\n}\n\nfunction findIOSPlatform(\n content: string,\n): { index: number; length: number } | null {\n const platformRegex = /^ *platform\\s+:([^ ]+)[^\\n]*\\n/gim;\n let match = platformRegex.exec(content);\n if (!match) {\n // No platform found, treat whole file as one platform.\n return { index: 0, length: content.length };\n }\n\n let index = -1;\n while (match) {\n if (match[1] === 'ios') {\n index = match.index + match[0].length;\n break;\n }\n match = platformRegex.exec(content);\n }\n\n if (index === -1) {\n return null;\n }\n\n //After finding the platform, we need to find the end of the platform block.\n //This solution has the assumption that the file is well formed,\n //which is not a perfect solution, but it's good enough assumption.\n const platformEndRegex = /^end[^\\n]*/gim;\n match = platformEndRegex.exec(content.slice(index));\n if (!match) {\n return null;\n }\n\n return { index, length: match.index };\n}\n\nfunction findLanes(\n content: string,\n): { index: number; length: number; name: string }[] | null {\n const laneRegex = /^ {2}lane\\s+:([^ ]+)[^\\n]*\\n/gim;\n let match = laneRegex.exec(content);\n if (!match) {\n return null;\n }\n\n const lanes: { index: number; length: number; name: string }[] = [];\n while (match) {\n const laneEnd = /^ {2}end/m.exec(\n content.slice(match.index + match[0].length),\n );\n if (laneEnd === null) {\n return null;\n }\n lanes.push({\n index: match.index + match[0].length,\n length: laneEnd.index,\n name: match[1],\n });\n match = laneRegex.exec(content);\n }\n return lanes;\n}\n\nfunction addSentryToLane(\n content: string,\n lane: { index: number; length: number; name: string },\n org: string,\n project: string,\n): string {\n const laneContent = content.slice(lane.index, lane.index + lane.length);\n const sentryCLIMatch = /(\\n\\s+)sentry_debug_files_upload\\s*\\([^)]+\\)/gim.exec(\n laneContent,\n );\n if (sentryCLIMatch) {\n // Sentry already added to lane. Update it.\n // sentryCLIMatch[1] contains the leading newline and whitespace\n return (\n content.slice(0, sentryCLIMatch.index + lane.index) +\n sentryCLIMatch[1] +\n templates.getFastlaneSnippet(org, project).trim() +\n content.slice(\n sentryCLIMatch.index + sentryCLIMatch[0].length + lane.index,\n )\n );\n }\n\n // Sentry not added to lane. Add it.\n return (\n content.slice(0, lane.index + lane.length) +\n '\\n' +\n templates.getFastlaneSnippet(org, project) +\n '\\n' +\n content.slice(lane.index + lane.length)\n );\n}\n\nexport async function addSentryToFastlane(\n projectDir: string,\n org: string,\n project: string,\n): Promise<boolean> {\n const fastFilePath = fastFile(projectDir);\n if (!fastFilePath) {\n return false;\n }\n\n const fileContent = fs.readFileSync(fastFilePath, 'utf8');\n const platform = findIOSPlatform(fileContent);\n if (!platform) {\n return false;\n }\n\n const platformContent = fileContent.slice(\n platform.index,\n platform.index + platform.length,\n );\n const lanes = findLanes(platformContent);\n lanes?.forEach((l) => (l.index += platform.index));\n\n if (!lanes || lanes.length === 0) {\n clack.log.warn('No suitable lanes in your Fastfile.');\n return false;\n }\n\n let newFileContent: string | undefined;\n if (lanes.length === 1) {\n newFileContent = addSentryToLane(fileContent, lanes[0], org, project);\n } else {\n const laneNames = lanes.map((l) => l.name);\n const selectedLane = await askForItemSelection(\n laneNames,\n 'Select lane to add Sentry to:',\n );\n if (selectedLane === undefined) {\n return false;\n }\n newFileContent = addSentryToLane(\n fileContent,\n lanes[selectedLane.index],\n org,\n project,\n );\n }\n\n fs.writeFileSync(fastFilePath, newFileContent, 'utf8');\n return true;\n}\n\n/**\n * Exported for testing purposes, but should not be used in other modules.\n */\nexport let exportForTesting: {\n findIOSPlatform: typeof findIOSPlatform;\n findLanes: typeof findLanes;\n addSentryToLane: typeof addSentryToLane;\n};\nif (process.env.NODE_ENV === 'test') {\n exportForTesting = {\n findIOSPlatform,\n findLanes,\n addSentryToLane,\n };\n}\n"]}
|
|
@@ -94,7 +94,7 @@ function getObjcSnippet(dsn, enableLogs) {
|
|
|
94
94
|
}
|
|
95
95
|
exports.getObjcSnippet = getObjcSnippet;
|
|
96
96
|
function getFastlaneSnippet(org, project) {
|
|
97
|
-
return `
|
|
97
|
+
return ` sentry_debug_files_upload(
|
|
98
98
|
org_slug: '${org}',
|
|
99
99
|
project_slug: '${project}',
|
|
100
100
|
include_sources: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC;;;;CAIL;QACG,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe;;sBAE5F,OAAO;0BACH,WAAW;0CAEjC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC;;;;;;;CAOD,CAAC;AACF,CAAC;AA5BD,oDA4BC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW,EAAE,UAAmB;IAC9D,IAAI,OAAO,GAAG;6BACa,GAAG;;;;;;;;;;;;;;;;;;sGAkBsE,CAAC;IAErG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;mDAGoC,CAAC;KACjD;IAED,OAAO,IAAI;;;iEAGoD,CAAC;IAEhE,OAAO,OAAO,CAAC;AACjB,CAAC;AAnCD,0CAmCC;AAED,SAAgB,cAAc,CAAC,GAAW,EAAE,UAAmB;IAC7D,IAAI,OAAO,GAAG;0BACU,GAAG;;;;;;;;;;;;;;;;;;oGAkBuE,CAAC;IAEnG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;+CAGgC,CAAC;KAC7C;IAED,OAAO,IAAI;;;2DAG8C,CAAC;IAE1D,OAAO,OAAO,CAAC;AACjB,CAAC;AAnCD,wCAmCC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? `\nif [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n`\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\nif which sentry-cli >/dev/null; then\n export SENTRY_ORG=${orgSlug}\n export SENTRY_PROJECT=${projectSlug}\n ERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\n if [ ! $? -eq 0 ]; then\n echo \"warning: sentry-cli - $ERROR\"\n fi\nelse\n echo \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = true`;\n }\n\n snippet += `\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n\n return snippet;\n}\n\nexport function getObjcSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = YES;`;\n }\n\n snippet += `\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n\n return snippet;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return `
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC;;;;CAIL;QACG,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe;;sBAE5F,OAAO;0BACH,WAAW;0CAEjC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC;;;;;;;CAOD,CAAC;AACF,CAAC;AA5BD,oDA4BC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW,EAAE,UAAmB;IAC9D,IAAI,OAAO,GAAG;6BACa,GAAG;;;;;;;;;;;;;;;;;;sGAkBsE,CAAC;IAErG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;mDAGoC,CAAC;KACjD;IAED,OAAO,IAAI;;;iEAGoD,CAAC;IAEhE,OAAO,OAAO,CAAC;AACjB,CAAC;AAnCD,0CAmCC;AAED,SAAgB,cAAc,CAAC,GAAW,EAAE,UAAmB;IAC7D,IAAI,OAAO,GAAG;0BACU,GAAG;;;;;;;;;;;;;;;;;;oGAkBuE,CAAC;IAEnG,IAAI,UAAU,EAAE;QACd,OAAO,IAAI;;;+CAGgC,CAAC;KAC7C;IAED,OAAO,IAAI;;;2DAG8C,CAAC;IAE1D,OAAO,OAAO,CAAC;AACjB,CAAC;AAnCD,wCAmCC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? `\nif [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n`\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\nif which sentry-cli >/dev/null; then\n export SENTRY_ORG=${orgSlug}\n export SENTRY_PROJECT=${projectSlug}\n ERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\n if [ ! $? -eq 0 ]; then\n echo \"warning: sentry-cli - $ERROR\"\n fi\nelse\n echo \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = true`;\n }\n\n snippet += `\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n\n return snippet;\n}\n\nexport function getObjcSnippet(dsn: string, enableLogs: boolean): string {\n let snippet = ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events`;\n\n if (enableLogs) {\n snippet += `\n \n // Enable experimental logging features\n options.experimental.enableLogs = YES;`;\n }\n\n snippet += `\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n\n return snippet;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_debug_files_upload(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
|
|
@@ -49,7 +49,9 @@ async function createExamplePage(svelteConfig, projectProps) {
|
|
|
49
49
|
prompts_1.default.log.warn(`It seems like a sentry example page already exists (${path.basename(exampleRoutePath)}). Skipping creation of example route.`);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
await fs.promises.writeFile(path.join(exampleRoutePath, '+page.svelte'), (0, templates_1.getSentryExampleSveltePage)(
|
|
52
|
+
await fs.promises.writeFile(path.join(exampleRoutePath, '+page.svelte'), (0, templates_1.getSentryExampleSveltePage)({
|
|
53
|
+
...projectProps,
|
|
54
|
+
}));
|
|
53
55
|
await fs.promises.writeFile(path.join(exampleRoutePath, '+server.js'), (0, templates_1.getSentryExampleApiRoute)());
|
|
54
56
|
}
|
|
55
57
|
exports.createExamplePage = createExamplePage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-example.js","sourceRoot":"","sources":["../../../src/sveltekit/sdk-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,+EAA+E;AAC/E,6DAAmC;AAGnC,2CAGqB;AAErB;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,YAA4D,EAC5D,
|
|
1
|
+
{"version":3,"file":"sdk-example.js","sourceRoot":"","sources":["../../../src/sveltekit/sdk-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,+EAA+E;AAC/E,6DAAmC;AAGnC,2CAGqB;AAErB;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,YAA4D,EAC5D,YAMC;IAED,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,IAAI,YAAY,CAAC;IACxE,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CACnC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAClD,CAAC;IAEF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;QACnC,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,yDAAyD,eAAe,EAAE,CAC3E,CAAC;QACF,EAAE,CAAC,SAAS,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KACpD;IAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACpC,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;KAChC;SAAM;QACL,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,uDAAuD,IAAI,CAAC,QAAQ,CAClE,gBAAgB,CACjB,wCAAwC,CAC1C,CAAC;QACF,OAAO;KACR;IAED,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,EAC3C,IAAA,sCAA0B,EAAC;QACzB,GAAG,YAAY;KAChB,CAAC,CACH,CAAC;IAEF,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,EACzC,IAAA,oCAAwB,GAAE,CAC3B,CAAC;AACJ,CAAC;AA5CD,8CA4CC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n\nimport { PartialBackwardsForwardsCompatibleSvelteConfig } from './sdk-setup/svelte-config';\nimport {\n getSentryExampleApiRoute,\n getSentryExampleSveltePage,\n} from './templates';\n\n/**\n * Creates example page and API route to test Sentry\n */\nexport async function createExamplePage(\n svelteConfig: PartialBackwardsForwardsCompatibleSvelteConfig,\n projectProps: {\n selfHosted: boolean;\n url: string;\n orgSlug: string;\n projectId: string;\n isUsingSvelte5: boolean;\n },\n): Promise<void> {\n const routesDirectory = svelteConfig.kit?.files?.routes || 'src/routes';\n const exampleRoutePath = path.resolve(\n path.join(routesDirectory, 'sentry-example-page'),\n );\n\n if (!fs.existsSync(routesDirectory)) {\n clack.log.warn(\n `Couldn't find your routes directory. Creating it now: ${routesDirectory}`,\n );\n fs.mkdirSync(routesDirectory, { recursive: true });\n }\n\n if (!fs.existsSync(exampleRoutePath)) {\n fs.mkdirSync(exampleRoutePath);\n } else {\n clack.log.warn(\n `It seems like a sentry example page already exists (${path.basename(\n exampleRoutePath,\n )}). Skipping creation of example route.`,\n );\n return;\n }\n\n await fs.promises.writeFile(\n path.join(exampleRoutePath, '+page.svelte'),\n getSentryExampleSveltePage({\n ...projectProps,\n }),\n );\n\n await fs.promises.writeFile(\n path.join(exampleRoutePath, '+server.js'),\n getSentryExampleApiRoute(),\n );\n}\n"]}
|
|
@@ -121,7 +121,8 @@ without SvelteKit's builtin observability.`);
|
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
const svelteVersionBucket = (0, utils_1.getSvelteVersionBucket)((0, package_json_1.getPackageVersion)('svelte', packageJson));
|
|
125
|
+
Sentry.setTag('svelte-version', svelteVersionBucket);
|
|
125
126
|
const projectData = await (0, clack_1.getOrAskForProjectData)(options, 'javascript-sveltekit');
|
|
126
127
|
if (projectData.spotlight) {
|
|
127
128
|
clack.log.warn('Spotlight mode is not yet supported for SvelteKit.');
|
|
@@ -163,11 +164,12 @@ without SvelteKit's builtin observability.`);
|
|
|
163
164
|
const shouldCreateExamplePage = await (0, clack_1.askShouldCreateExamplePage)('/sentry-example-page');
|
|
164
165
|
if (shouldCreateExamplePage) {
|
|
165
166
|
try {
|
|
166
|
-
await (0, telemetry_1.traceStep)('create-example-page', () => (0, sdk_example_1.createExamplePage)(svelteConfig, {
|
|
167
|
+
await (0, telemetry_1.traceStep)('create-example-page', async () => (0, sdk_example_1.createExamplePage)(svelteConfig, {
|
|
167
168
|
selfHosted,
|
|
168
169
|
url: sentryUrl,
|
|
169
170
|
orgSlug: selectedProject.organization.slug,
|
|
170
171
|
projectId: selectedProject.id,
|
|
172
|
+
isUsingSvelte5: ['5.x', '>5.x'].includes(svelteVersionBucket),
|
|
171
173
|
}));
|
|
172
174
|
}
|
|
173
175
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit-wizard.js","sourceRoot":"","sources":["../../../src/sveltekit/sveltekit-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAE1B,qDAAuC;AAEvC,4CAAwD;AACxD,0CAawB;AACxB,wDAA+E;AAC/E,8DAA+C;AAE/C,0DAAwE;AACxE,+CAAkD;AAClD,6CAAgE;AAChE,6DAA6D;AAC7D,mCAAsE;AAE/D,KAAK,UAAU,kBAAkB,CACtC,OAAsB;IAEtB,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,WAAW;QACxB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAC/C,CAAC;AACJ,CAAC;AAXD,gDAWC;AAEM,KAAK,UAAU,+BAA+B,CACnD,OAAsB;IAEtB,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAE9D,IAAA,oBAAY,EAAC;QACX,UAAU,EAAE,yBAAyB;QACrC,SAAS;QACT,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,IAAA,yCAAiC,EAAC;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,IAAA,yBAAiB,GAAE,CAAC;IAE9C,MAAM,IAAA,gCAAwB,EAAC,WAAW,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;IAE1E,MAAM,UAAU,GAAG,IAAA,gCAAiB,EAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IACnE,MAA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,CAAC,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC;KAC5D;IAED,GAAG,IAAI;8DACqD,CAAC;IAE7D,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport * as Sentry from '@sentry/node';\n\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abort,\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n getPackageManager,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { NPM } from '../utils/package-manager';\nimport type { WizardOptions } from '../utils/types';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport { createExamplePage } from './sdk-example';\nimport { createOrMergeSvelteKitFiles } from './sdk-setup/setup';\nimport { loadSvelteConfig } from './sdk-setup/svelte-config';\nimport { getKitVersionBucket, getSvelteVersionBucket } from './utils';\n\nexport async function runSvelteKitWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sveltekit',\n wizardOptions: options,\n },\n () => runSvelteKitWizardWithTelemetry(options),\n );\n}\n\nexport async function runSvelteKitWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry SvelteKit Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, '@sveltejs/kit', 'Sveltekit');\n\n const kitVersion = getPackageVersion('@sveltejs/kit', packageJson);\n const kitVersionBucket = getKitVersionBucket(kitVersion);\n Sentry.setTag('sveltekit-version', kitVersionBucket);\n\n if (kitVersionBucket === '0.x') {\n clack.log.warn(\n \"It seems you're using a SvelteKit version <1.0.0 which is not supported by Sentry.\\nWe recommend upgrading to the latest 1.x version before you continue.\",\n );\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: 'Yes, continue',\n hint: 'The SDK might not work correctly',\n value: true,\n },\n { label: \"No, I'll upgrade first\", value: false },\n ],\n }),\n );\n if (!shouldContinue) {\n await abort('Exiting Wizard', 0);\n return;\n }\n }\n\n let setupForSvelteKitTracing = kitVersionBucket === '>=2.31.0';\n\n if (kitVersionBucket !== '>=2.31.0') {\n clack.log.warn(\n `It seems you're using a SvelteKit version ${chalk.cyan(\n '<2.31.0',\n )} (detected ${chalk.cyan(kitVersion ?? 'unknown')}). \n\nWe recommend upgrading SvelteKit to version ${chalk.cyan(\n '>=2.31.0',\n )} to use SvelteKit's builtin observability:\n${chalk.cyan('https://svelte.dev/docs/kit/observability')}\n\nSentry works best with SvelteKit versions ${chalk.cyan('>=2.31.0')}.\n\nIf you prefer, you can stay on your current version and use the Sentry SDK \nwithout SvelteKit's builtin observability.`,\n );\n\n const decision = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: \"No, I'll upgrade SvelteKit first\",\n hint: 'Recommended',\n value: 'exit-to-upgrade',\n },\n {\n label: \"I'm already on SvelteKit >=2.31.0\",\n hint: 'Sorry, my bad!',\n value: 'install-with-kit-tracing',\n },\n {\n label: 'Yes, continue',\n hint: 'No Problem!',\n value: 'install-without-kit-tracing',\n },\n ],\n }),\n );\n\n if (decision === 'install-with-kit-tracing') {\n setupForSvelteKitTracing = true;\n }\n\n if (decision === 'exit-to-upgrade') {\n await abort('Exiting Wizard', 0);\n return;\n }\n }\n\n Sentry.setTag(\n 'svelte-version',\n getSvelteVersionBucket(getPackageVersion('svelte', packageJson)),\n );\n\n const projectData = await getOrAskForProjectData(\n options,\n 'javascript-sveltekit',\n );\n\n if (projectData.spotlight) {\n clack.log.warn('Spotlight mode is not yet supported for SvelteKit.');\n clack.log.info('Spotlight is currently only available for Next.js.');\n await abort('Exiting wizard', 0);\n return;\n }\n\n const { selectedProject, selfHosted, sentryUrl, authToken } = projectData;\n\n const sdkAlreadyInstalled = hasPackageInstalled(\n '@sentry/sveltekit',\n packageJson,\n );\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/sveltekit@^10',\n packageNameDisplayLabel: '@sentry/sveltekit',\n alreadyInstalled: sdkAlreadyInstalled,\n forceInstall,\n });\n\n await addDotEnvSentryBuildPluginFile(authToken);\n\n const svelteConfig = await traceStep('load-svelte-config', loadSvelteConfig);\n\n try {\n await traceStep('configure-sdk', () =>\n createOrMergeSvelteKitFiles(\n {\n dsn: selectedProject.keys[0].dsn.public,\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n selfHosted,\n url: sentryUrl,\n },\n svelteConfig,\n setupForSvelteKitTracing,\n ),\n );\n } catch (e: unknown) {\n clack.log.error('Error while setting up the SvelteKit SDK:');\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 Sentry.captureException('Error while setting up the SvelteKit SDK');\n await abort('Exiting Wizard');\n return;\n }\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage(\n '/sentry-example-page',\n );\n\n if (shouldCreateExamplePage) {\n try {\n await traceStep('create-example-page', () =>\n createExamplePage(svelteConfig, {\n selfHosted,\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n }),\n );\n } catch (e: unknown) {\n clack.log.error('Error while creating an example page to test Sentry:');\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 Sentry.captureException(\n 'Error while creating an example Svelte page to test Sentry',\n );\n await abort('Exiting Wizard');\n return;\n }\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n clack.outro(await buildOutroMessage(shouldCreateExamplePage));\n}\n\nasync function buildOutroMessage(\n shouldCreateExamplePage: boolean,\n): Promise<string> {\n const packageManager = await getPackageManager(NPM);\n\n let msg = chalk.green('Successfully installed the Sentry SvelteKit SDK!');\n\n if (shouldCreateExamplePage) {\n msg += `\\n\\nYou can validate your setup by starting your dev environment (${chalk.cyan(\n `\\`${packageManager.runScriptCommand} dev\\``,\n )}) and visiting ${chalk.cyan('\"/sentry-example-page\"')}.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/sveltekit/`;\n\n return msg;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sveltekit-wizard.js","sourceRoot":"","sources":["../../../src/sveltekit/sveltekit-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAE1B,qDAAuC;AAEvC,4CAAwD;AACxD,0CAawB;AACxB,wDAA+E;AAC/E,8DAA+C;AAE/C,0DAAwE;AACxE,+CAAkD;AAClD,6CAAgE;AAChE,6DAA6D;AAC7D,mCAAsE;AAE/D,KAAK,UAAU,kBAAkB,CACtC,OAAsB;IAEtB,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,WAAW;QACxB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,+BAA+B,CAAC,OAAO,CAAC,CAC/C,CAAC;AACJ,CAAC;AAXD,gDAWC;AAEM,KAAK,UAAU,+BAA+B,CACnD,OAAsB;IAE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AC9B,OAAO;SACR;KACF;IAED,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAEjD,iFAAiF;IACjF,MAAM,IAAA,wCAA2B,EAC/B,eAAe,CAAC,YAAY,CAAC,IAAI,EACjC,eAAe,CAAC,IAAI,CACrB,CAAC;IAEF,KAAK,CAAC,KAAK,CAAC,MAAM,iBAAiB,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAChE,CAAC;AAhND,0EAgNC;AAED,KAAK,UAAU,iBAAiB,CAC9B,uBAAgC;IAEhC,MAAM,cAAc,GAAG,MAAM,IAAA,yBAAiB,EAAC,qBAAG,CAAC,CAAC;IAEpD,IAAI,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAE1E,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,qEAAqE,eAAK,CAAC,IAAI,CACpF,KAAK,cAAc,CAAC,gBAAgB,QAAQ,CAC7C,kBAAkB,eAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC;KAC5D;IAED,GAAG,IAAI;8DACqD,CAAC;IAE7D,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport * as Sentry from '@sentry/node';\n\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abort,\n abortIfCancelled,\n addDotEnvSentryBuildPluginFile,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n getPackageManager,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { NPM } from '../utils/package-manager';\nimport type { WizardOptions } from '../utils/types';\nimport { offerProjectScopedMcpConfig } from '../utils/clack/mcp-config';\nimport { createExamplePage } from './sdk-example';\nimport { createOrMergeSvelteKitFiles } from './sdk-setup/setup';\nimport { loadSvelteConfig } from './sdk-setup/svelte-config';\nimport { getKitVersionBucket, getSvelteVersionBucket } from './utils';\n\nexport async function runSvelteKitWizard(\n options: WizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'sveltekit',\n wizardOptions: options,\n },\n () => runSvelteKitWizardWithTelemetry(options),\n );\n}\n\nexport async function runSvelteKitWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry SvelteKit Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, '@sveltejs/kit', 'Sveltekit');\n\n const kitVersion = getPackageVersion('@sveltejs/kit', packageJson);\n const kitVersionBucket = getKitVersionBucket(kitVersion);\n Sentry.setTag('sveltekit-version', kitVersionBucket);\n\n if (kitVersionBucket === '0.x') {\n clack.log.warn(\n \"It seems you're using a SvelteKit version <1.0.0 which is not supported by Sentry.\\nWe recommend upgrading to the latest 1.x version before you continue.\",\n );\n const shouldContinue = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: 'Yes, continue',\n hint: 'The SDK might not work correctly',\n value: true,\n },\n { label: \"No, I'll upgrade first\", value: false },\n ],\n }),\n );\n if (!shouldContinue) {\n await abort('Exiting Wizard', 0);\n return;\n }\n }\n\n let setupForSvelteKitTracing = kitVersionBucket === '>=2.31.0';\n\n if (kitVersionBucket !== '>=2.31.0') {\n clack.log.warn(\n `It seems you're using a SvelteKit version ${chalk.cyan(\n '<2.31.0',\n )} (detected ${chalk.cyan(kitVersion ?? 'unknown')}). \n\nWe recommend upgrading SvelteKit to version ${chalk.cyan(\n '>=2.31.0',\n )} to use SvelteKit's builtin observability:\n${chalk.cyan('https://svelte.dev/docs/kit/observability')}\n\nSentry works best with SvelteKit versions ${chalk.cyan('>=2.31.0')}.\n\nIf you prefer, you can stay on your current version and use the Sentry SDK \nwithout SvelteKit's builtin observability.`,\n );\n\n const decision = await abortIfCancelled(\n clack.select({\n message: 'Do you want to continue anyway?',\n options: [\n {\n label: \"No, I'll upgrade SvelteKit first\",\n hint: 'Recommended',\n value: 'exit-to-upgrade',\n },\n {\n label: \"I'm already on SvelteKit >=2.31.0\",\n hint: 'Sorry, my bad!',\n value: 'install-with-kit-tracing',\n },\n {\n label: 'Yes, continue',\n hint: 'No Problem!',\n value: 'install-without-kit-tracing',\n },\n ],\n }),\n );\n\n if (decision === 'install-with-kit-tracing') {\n setupForSvelteKitTracing = true;\n }\n\n if (decision === 'exit-to-upgrade') {\n await abort('Exiting Wizard', 0);\n return;\n }\n }\n\n const svelteVersionBucket = getSvelteVersionBucket(\n getPackageVersion('svelte', packageJson),\n );\n Sentry.setTag('svelte-version', svelteVersionBucket);\n\n const projectData = await getOrAskForProjectData(\n options,\n 'javascript-sveltekit',\n );\n\n if (projectData.spotlight) {\n clack.log.warn('Spotlight mode is not yet supported for SvelteKit.');\n clack.log.info('Spotlight is currently only available for Next.js.');\n await abort('Exiting wizard', 0);\n return;\n }\n\n const { selectedProject, selfHosted, sentryUrl, authToken } = projectData;\n\n const sdkAlreadyInstalled = hasPackageInstalled(\n '@sentry/sveltekit',\n packageJson,\n );\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/sveltekit@^10',\n packageNameDisplayLabel: '@sentry/sveltekit',\n alreadyInstalled: sdkAlreadyInstalled,\n forceInstall,\n });\n\n await addDotEnvSentryBuildPluginFile(authToken);\n\n const svelteConfig = await traceStep('load-svelte-config', loadSvelteConfig);\n\n try {\n await traceStep('configure-sdk', () =>\n createOrMergeSvelteKitFiles(\n {\n dsn: selectedProject.keys[0].dsn.public,\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n selfHosted,\n url: sentryUrl,\n },\n svelteConfig,\n setupForSvelteKitTracing,\n ),\n );\n } catch (e: unknown) {\n clack.log.error('Error while setting up the SvelteKit SDK:');\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 Sentry.captureException('Error while setting up the SvelteKit SDK');\n await abort('Exiting Wizard');\n return;\n }\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage(\n '/sentry-example-page',\n );\n\n if (shouldCreateExamplePage) {\n try {\n await traceStep('create-example-page', async () =>\n createExamplePage(svelteConfig, {\n selfHosted,\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n isUsingSvelte5: ['5.x', '>5.x'].includes(svelteVersionBucket),\n }),\n );\n } catch (e: unknown) {\n clack.log.error('Error while creating an example page to test Sentry:');\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 Sentry.captureException(\n 'Error while creating an example Svelte page to test Sentry',\n );\n await abort('Exiting Wizard');\n return;\n }\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n // Offer optional project-scoped MCP config for Sentry with org and project scope\n await offerProjectScopedMcpConfig(\n selectedProject.organization.slug,\n selectedProject.slug,\n );\n\n clack.outro(await buildOutroMessage(shouldCreateExamplePage));\n}\n\nasync function buildOutroMessage(\n shouldCreateExamplePage: boolean,\n): Promise<string> {\n const packageManager = await getPackageManager(NPM);\n\n let msg = chalk.green('Successfully installed the Sentry SvelteKit SDK!');\n\n if (shouldCreateExamplePage) {\n msg += `\\n\\nYou can validate your setup by starting your dev environment (${chalk.cyan(\n `\\`${packageManager.runScriptCommand} dev\\``,\n )}) and visiting ${chalk.cyan('\"/sentry-example-page\"')}.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/sveltekit/`;\n\n return msg;\n}\n"]}
|