@sentry/wizard 6.7.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 +16 -3
- package/dist/e2e-tests/tests/pnpm-workspace.test.d.ts +1 -0
- package/dist/e2e-tests/tests/pnpm-workspace.test.js +206 -0
- package/dist/e2e-tests/tests/pnpm-workspace.test.js.map +1 -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/utils/package-json.js +86 -2
- package/dist/src/utils/package-json.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/dist/test/utils/package-json.test.d.ts +1 -0
- package/dist/test/utils/package-json.test.js +428 -0
- package/dist/test/utils/package-json.test.js.map +1 -0
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
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
|
+
|
|
10
|
+
## 6.8.0
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- feat(pnpm): Allow pnpm catalog in the package.json ([#1117](https://github.com/getsentry/sentry-wizard/pull/1117))
|
|
15
|
+
|
|
3
16
|
## 6.7.0
|
|
4
17
|
|
|
5
18
|
### Features
|
|
6
19
|
|
|
7
20
|
- feat: Add wizard for `react-router` framework mode ([#1076](https://github.com/getsentry/sentry-wizard/pull/1076))
|
|
8
21
|
|
|
9
|
-
This release adds a new wizard setup flow for React Router (framework):
|
|
22
|
+
This release adds a new wizard setup flow for React Router (framework):
|
|
10
23
|
```sh
|
|
11
24
|
npx @sentry/wizard@latest -i reactRouter
|
|
12
25
|
```
|
|
@@ -14,11 +27,11 @@
|
|
|
14
27
|
|
|
15
28
|
This release adds a new mode for setting up the Sentry SDK in NextJS for Spotlight.
|
|
16
29
|
When running
|
|
17
|
-
|
|
30
|
+
|
|
18
31
|
```sh
|
|
19
32
|
npx @sentry/wizard@latest -i nextjs --spotlight
|
|
20
33
|
```
|
|
21
|
-
the NextJS SDK will be configured to only send its telemetry to Spotlight.
|
|
34
|
+
the NextJS SDK will be configured to only send its telemetry to Spotlight.
|
|
22
35
|
No Sentry account is required to complete this flow.
|
|
23
36
|
|
|
24
37
|
## 6.6.1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
const path = __importStar(require("node:path"));
|
|
27
|
+
const fs = __importStar(require("node:fs"));
|
|
28
|
+
const Constants_1 = require("../../lib/Constants");
|
|
29
|
+
const utils_1 = require("../utils");
|
|
30
|
+
const vitest_1 = require("vitest");
|
|
31
|
+
//@ts-expect-error - clifty is ESM only
|
|
32
|
+
const clifty_1 = require("clifty");
|
|
33
|
+
(0, vitest_1.describe)('pnpm workspace', () => {
|
|
34
|
+
const workspaceDir = path.resolve(__dirname, '../test-applications/pnpm-workspace-test-app');
|
|
35
|
+
const projectDir = path.resolve(workspaceDir, 'packages/sveltekit');
|
|
36
|
+
const integration = Constants_1.Integration.sveltekit;
|
|
37
|
+
let wizardExitCode;
|
|
38
|
+
(0, vitest_1.beforeAll)(async () => {
|
|
39
|
+
(0, utils_1.initGit)(workspaceDir);
|
|
40
|
+
(0, utils_1.revertLocalChanges)(workspaceDir);
|
|
41
|
+
wizardExitCode = await (0, clifty_1.withEnv)({
|
|
42
|
+
cwd: projectDir,
|
|
43
|
+
})
|
|
44
|
+
.defineInteraction()
|
|
45
|
+
.expectOutput('The Sentry SvelteKit Wizard will help you set up Sentry for your application')
|
|
46
|
+
.step('package installation', ({ expectOutput, whenAsked }) => {
|
|
47
|
+
whenAsked('Please select your package manager.').respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.DOWN, clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER);
|
|
48
|
+
expectOutput('Installing @sentry/sveltekit');
|
|
49
|
+
})
|
|
50
|
+
.step('SDK setup', ({ whenAsked }) => {
|
|
51
|
+
whenAsked('Do you want to enable Tracing', {
|
|
52
|
+
timeout: 90000, // package installation can take a while in CI
|
|
53
|
+
}).respondWith(clifty_1.KEYS.ENTER);
|
|
54
|
+
whenAsked('Do you want to enable Session Replay').respondWith(clifty_1.KEYS.ENTER);
|
|
55
|
+
whenAsked('Do you want to enable Logs').respondWith(clifty_1.KEYS.ENTER);
|
|
56
|
+
})
|
|
57
|
+
.whenAsked('Do you want to create an example page')
|
|
58
|
+
.respondWith(clifty_1.KEYS.ENTER)
|
|
59
|
+
.whenAsked('Optionally add a project-scoped MCP server configuration for the Sentry MCP?')
|
|
60
|
+
.respondWith(clifty_1.KEYS.DOWN, clifty_1.KEYS.ENTER)
|
|
61
|
+
.expectOutput('Successfully installed the Sentry SvelteKit SDK!')
|
|
62
|
+
.run((0, utils_1.getWizardCommand)(integration));
|
|
63
|
+
});
|
|
64
|
+
(0, vitest_1.afterAll)(() => {
|
|
65
|
+
(0, utils_1.revertLocalChanges)(workspaceDir);
|
|
66
|
+
(0, utils_1.cleanupGit)(workspaceDir);
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.it)('exits with exit code 0', () => {
|
|
69
|
+
(0, vitest_1.expect)(wizardExitCode).toBe(0);
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.it)('adds the SDK dependency to package.json', () => {
|
|
72
|
+
(0, utils_1.checkPackageJson)(projectDir, integration);
|
|
73
|
+
});
|
|
74
|
+
(0, vitest_1.it)('adds the .env.sentry-build-plugin', () => {
|
|
75
|
+
(0, utils_1.checkEnvBuildPlugin)(projectDir);
|
|
76
|
+
});
|
|
77
|
+
(0, vitest_1.it)('adds the example page', () => {
|
|
78
|
+
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+page.svelte'));
|
|
79
|
+
(0, utils_1.checkFileExists)(path.resolve(projectDir, 'src/routes/sentry-example-page/+server.js'));
|
|
80
|
+
});
|
|
81
|
+
(0, vitest_1.it)('adds the sentry plugin to vite.config.ts', () => {
|
|
82
|
+
const viteConfig = fs.readFileSync(path.resolve(projectDir, 'vite.config.ts'));
|
|
83
|
+
(0, vitest_1.expect)(viteConfig.toString()).toMatchInlineSnapshot(`
|
|
84
|
+
"import { sentrySvelteKit } from "@sentry/sveltekit";
|
|
85
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
86
|
+
import { defineConfig } from 'vite';
|
|
87
|
+
|
|
88
|
+
export default defineConfig({
|
|
89
|
+
plugins: [sentrySvelteKit({
|
|
90
|
+
sourceMapsUploadOptions: {
|
|
91
|
+
org: "${utils_1.TEST_ARGS.ORG_SLUG}",
|
|
92
|
+
project: "${utils_1.TEST_ARGS.PROJECT_SLUG}"
|
|
93
|
+
}
|
|
94
|
+
}), sveltekit()]
|
|
95
|
+
});"
|
|
96
|
+
`);
|
|
97
|
+
});
|
|
98
|
+
(0, vitest_1.it)('creates the hook files', () => {
|
|
99
|
+
const clientHooks = fs.readFileSync(path.resolve(projectDir, 'src/hooks.client.ts'));
|
|
100
|
+
const serverHooks = fs.readFileSync(path.resolve(projectDir, 'src/hooks.server.ts'));
|
|
101
|
+
(0, vitest_1.expect)(clientHooks.toString()).toMatchInlineSnapshot(`
|
|
102
|
+
"import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
|
|
103
|
+
import * as Sentry from '@sentry/sveltekit';
|
|
104
|
+
|
|
105
|
+
Sentry.init({
|
|
106
|
+
dsn: '${utils_1.TEST_ARGS.PROJECT_DSN}',
|
|
107
|
+
|
|
108
|
+
tracesSampleRate: 1.0,
|
|
109
|
+
|
|
110
|
+
// Enable logs to be sent to Sentry
|
|
111
|
+
enableLogs: true,
|
|
112
|
+
|
|
113
|
+
// This sets the sample rate to be 10%. You may want this to be 100% while
|
|
114
|
+
// in development and sample at a lower rate in production
|
|
115
|
+
replaysSessionSampleRate: 0.1,
|
|
116
|
+
|
|
117
|
+
// If the entire session is not sampled, use the below sample rate to sample
|
|
118
|
+
// sessions when an error occurs.
|
|
119
|
+
replaysOnErrorSampleRate: 1.0,
|
|
120
|
+
|
|
121
|
+
// If you don't want to use Session Replay, just remove the line below:
|
|
122
|
+
integrations: [replayIntegration()],
|
|
123
|
+
|
|
124
|
+
// Enable sending user PII (Personally Identifiable Information)
|
|
125
|
+
// https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii
|
|
126
|
+
sendDefaultPii: true,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// If you have a custom error handler, pass it to \`handleErrorWithSentry\`
|
|
130
|
+
export const handleError = handleErrorWithSentry();
|
|
131
|
+
"
|
|
132
|
+
`);
|
|
133
|
+
(0, vitest_1.expect)(serverHooks.toString()).toMatchInlineSnapshot(`
|
|
134
|
+
"import {sequence} from "@sveltejs/kit/hooks";
|
|
135
|
+
import * as Sentry from "@sentry/sveltekit";
|
|
136
|
+
export const handle = sequence(Sentry.sentryHandle(), async ({ event, resolve }) => {
|
|
137
|
+
const response = await resolve(event);
|
|
138
|
+
return response;
|
|
139
|
+
});
|
|
140
|
+
export const handleError = Sentry.handleErrorWithSentry();"
|
|
141
|
+
`);
|
|
142
|
+
});
|
|
143
|
+
(0, vitest_1.it)('creates the insturmentation.server file', () => {
|
|
144
|
+
const instrumentationServer = fs.readFileSync(path.resolve(projectDir, 'src/instrumentation.server.ts'));
|
|
145
|
+
(0, vitest_1.expect)(instrumentationServer.toString()).toMatchInlineSnapshot(`
|
|
146
|
+
"import * as Sentry from '@sentry/sveltekit';
|
|
147
|
+
|
|
148
|
+
Sentry.init({
|
|
149
|
+
dsn: '${utils_1.TEST_ARGS.PROJECT_DSN}',
|
|
150
|
+
|
|
151
|
+
tracesSampleRate: 1.0,
|
|
152
|
+
|
|
153
|
+
// Enable logs to be sent to Sentry
|
|
154
|
+
enableLogs: true,
|
|
155
|
+
|
|
156
|
+
// uncomment the line below to enable Spotlight (https://spotlightjs.com)
|
|
157
|
+
// spotlight: import.meta.env.DEV,
|
|
158
|
+
});"
|
|
159
|
+
`);
|
|
160
|
+
});
|
|
161
|
+
(0, vitest_1.it)('enables tracing and instrumentation in svelte.config.js', () => {
|
|
162
|
+
const svelteConfig = fs.readFileSync(path.resolve(projectDir, 'svelte.config.js'));
|
|
163
|
+
(0, vitest_1.expect)(svelteConfig.toString()).toMatchInlineSnapshot(`
|
|
164
|
+
"import adapter from '@sveltejs/adapter-node';
|
|
165
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
166
|
+
|
|
167
|
+
/** @type {import('@sveltejs/kit').Config} */
|
|
168
|
+
const config = {
|
|
169
|
+
// Consult https://svelte.dev/docs/kit/integrations#preprocessors
|
|
170
|
+
// for more information about preprocessors
|
|
171
|
+
preprocess: vitePreprocess(),
|
|
172
|
+
|
|
173
|
+
kit: {
|
|
174
|
+
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
|
175
|
+
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
|
176
|
+
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
|
177
|
+
adapter: adapter(),
|
|
178
|
+
experimental: {
|
|
179
|
+
remoteFunctions: true,
|
|
180
|
+
|
|
181
|
+
tracing: {
|
|
182
|
+
server: true,
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
instrumentation: {
|
|
186
|
+
server: true,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export default config;"
|
|
193
|
+
`);
|
|
194
|
+
});
|
|
195
|
+
// checkSvelteKitProject(projectDir, integration);
|
|
196
|
+
(0, vitest_1.it)('builds successfully', async () => {
|
|
197
|
+
await (0, utils_1.checkIfBuilds)(projectDir);
|
|
198
|
+
});
|
|
199
|
+
(0, vitest_1.it)('runs on dev mode correctly', async () => {
|
|
200
|
+
await (0, utils_1.checkIfRunsOnDevMode)(projectDir, 'ready in');
|
|
201
|
+
});
|
|
202
|
+
(0, vitest_1.it)('runs on prod mode correctly', async () => {
|
|
203
|
+
await (0, utils_1.checkIfRunsOnProdMode)(projectDir, 'to expose', 'preview');
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
//# sourceMappingURL=pnpm-workspace.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnpm-workspace.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/pnpm-workspace.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,4CAA8B;AAC9B,mDAAkD;AAClD,oCAYkB;AAClB,mCAAmE;AAEnE,uCAAuC;AACvC,mCAAuC;AAEvC,IAAA,iBAAQ,EAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,MAAM,YAAY,GAAG,IAAI,CAAC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;;;;;;;;;;;;;;;;;;;;;;OA8BnD,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,kDAAkD;IAClD,IAAA,WAAE,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,IAAA,4BAAoB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,IAAA,6BAAqB,EAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAClE,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('pnpm workspace', () => {\n const workspaceDir = path.resolve(\n __dirname,\n '../test-applications/pnpm-workspace-test-app',\n );\n const projectDir = path.resolve(workspaceDir, 'packages/sveltekit');\n\n const integration = Integration.sveltekit;\n let wizardExitCode: number;\n\n beforeAll(async () => {\n initGit(workspaceDir);\n revertLocalChanges(workspaceDir);\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.DOWN,\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(workspaceDir);\n cleanupGit(workspaceDir);\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"]}
|
|
@@ -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;IA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CAAC,CAAC,CAAC;QAEH,IAAA,iBAAQ,EAAC,GAAG,EAAE;YACZ,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAC/B,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,qBAAqB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAE/C,sEAAsE;QACtE,iEAAiE;QACjE,IAAA,aAAI,EAAC,iDAAiD,EAAE,GAAG,EAAE;YAC3D,IAAA,yBAAiB,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE;gBACjE,8CAA8C;gBAC9C;YACI,iBAAS,CAAC,WAAW;;;;;;;GAO9B;gBACK,0DAA0D;aAC3D,CAAC,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","source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EAC1C;;CAEL,CACI,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,oBAAoB,EAAE,GAAG,EAAE;QAC9B,IAAA,uBAAe,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC;QACjE,IAAA,uBAAe,EAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACrC,MAAM,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,4BAA4B,EAAE,KAAK,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,mC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AAM,EAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BrD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,kDAAkD;QAClD,IAAA,WAAE,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YACnC,MAAM,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;YAC1C,MAAM,IAAA,4BAAoB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,6BAA6B,EAAE,KAAK,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;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;;;;;;;;;;;;;OA8BrD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,kDAAkD;QAClD,IAAA,WAAE,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YACnC,MAAM,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;YAC1C,MAAM,IAAA,4BAAoB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,6BAA6B,EAAE,KAAK,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 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
|
}
|