Skip to content

Commit a76f243

Browse files
s1gr1dandreiborza
andauthored
feat(v8/solidstart): Add withSentry wrapper for SolidStart config (#15135)
Backport of #14862 and #14863 --------- Co-authored-by: Andrei Borza <[email protected]>
1 parent d5f80af commit a76f243

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2751
-7
lines changed

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,50 @@
1010

1111
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
1212

13+
- **feat(solidstart): Default to `--import` setup and add `autoInjectServerSentry` ([#14862](https://github.com/getsentry/sentry-javascript/pull/14862))**
14+
15+
To enable the SolidStart SDK, wrap your SolidStart Config with `withSentry`. The `sentrySolidStartVite` plugin is now automatically
16+
added by `withSentry` and you can pass the Sentry build-time options like this:
17+
18+
```js
19+
import { defineConfig } from '@solidjs/start/config';
20+
import { withSentry } from '@sentry/solidstart';
21+
22+
export default defineConfig(
23+
withSentry(
24+
{
25+
/* Your SolidStart config options... */
26+
},
27+
{
28+
// Options for setting up source maps
29+
org: process.env.SENTRY_ORG,
30+
project: process.env.SENTRY_PROJECT,
31+
authToken: process.env.SENTRY_AUTH_TOKEN,
32+
},
33+
),
34+
);
35+
```
36+
37+
With the `withSentry` wrapper, the Sentry server config should not be added to the `public` directory anymore.
38+
Add the Sentry server config in `src/instrument.server.ts`. Then, the server config will be placed inside the server build output as `instrument.server.mjs`.
39+
40+
Now, there are two options to set up the SDK:
41+
42+
1. **(recommended)** Provide an `--import` CLI flag to the start command like this (path depends on your server setup):
43+
`node --import ./.output/server/instrument.server.mjs .output/server/index.mjs`
44+
2. Add `autoInjectServerSentry: 'top-level-import'` and the Sentry config will be imported at the top of the server entry (comes with tracing limitations)
45+
```js
46+
withSentry(
47+
{
48+
/* Your SolidStart config options... */
49+
},
50+
{
51+
// Optional: Install Sentry with a top-level import
52+
autoInjectServerSentry: 'top-level-import',
53+
},
54+
);
55+
```
56+
1357
## 8.51.0
1458

1559
### Important Changes
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
dist
3+
.solid
4+
.output
5+
.vercel
6+
.netlify
7+
.vinxi
8+
9+
# Environment
10+
.env
11+
.env*.local
12+
13+
# dependencies
14+
/node_modules
15+
/.pnp
16+
.pnp.js
17+
18+
# IDEs and editors
19+
/.idea
20+
.project
21+
.classpath
22+
*.launch
23+
.settings/
24+
25+
# Temp
26+
gitignore
27+
28+
# testing
29+
/coverage
30+
31+
# misc
32+
.DS_Store
33+
.env.local
34+
.env.development.local
35+
.env.test.local
36+
.env.production.local
37+
38+
npm-debug.log*
39+
yarn-debug.log*
40+
yarn-error.log*
41+
42+
/test-results/
43+
/playwright-report/
44+
/playwright/.cache/
45+
46+
!*.d.ts
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@sentry:registry=http://127.0.0.1:4873
2+
@sentry-internal:registry=http://127.0.0.1:4873
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SolidStart
2+
3+
Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com);
4+
5+
## Creating a project
6+
7+
```bash
8+
# create a new project in the current directory
9+
npm init solid@latest
10+
11+
# create a new project in my-app
12+
npm init solid@latest my-app
13+
```
14+
15+
## Developing
16+
17+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a
18+
development server:
19+
20+
```bash
21+
npm run dev
22+
23+
# or start the server and open the app in a new browser tab
24+
npm run dev -- --open
25+
```
26+
27+
## Building
28+
29+
Solid apps are built with _presets_, which optimise your project for deployment to different environments.
30+
31+
By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different preset, add
32+
it to the `devDependencies` in `package.json` and specify in your `app.config.js`.
33+
34+
## Testing
35+
36+
Tests are written with `vitest`, `@solidjs/testing-library` and `@testing-library/jest-dom` to extend expect with some
37+
helpful custom matchers.
38+
39+
To run them, simply start:
40+
41+
```sh
42+
npm test
43+
```
44+
45+
## This project was created with the [Solid CLI](https://solid-cli.netlify.app)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { withSentry } from '@sentry/solidstart';
2+
import { defineConfig } from '@solidjs/start/config';
3+
4+
export default defineConfig(
5+
withSentry(
6+
{},
7+
{
8+
autoInjectServerSentry: 'experimental_dynamic-import',
9+
},
10+
),
11+
);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "solidstart-dynamic-import-e2e-testapp",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"clean": "pnpx rimraf node_modules pnpm-lock.yaml .vinxi .output",
6+
"dev": "vinxi dev",
7+
"build": "vinxi build && sh ./post_build.sh",
8+
"preview": "HOST=localhost PORT=3030 vinxi start",
9+
"test:prod": "TEST_ENV=production playwright test",
10+
"test:build": "pnpm install && pnpm build",
11+
"test:assert": "pnpm test:prod"
12+
},
13+
"type": "module",
14+
"dependencies": {
15+
"@sentry/solidstart": "latest || *"
16+
},
17+
"devDependencies": {
18+
"@playwright/test": "^1.44.1",
19+
"@solidjs/meta": "^0.29.4",
20+
"@solidjs/router": "^0.13.4",
21+
"@solidjs/start": "^1.0.2",
22+
"@solidjs/testing-library": "^0.8.7",
23+
"@testing-library/jest-dom": "^6.4.2",
24+
"@testing-library/user-event": "^14.5.2",
25+
"@vitest/ui": "^1.5.0",
26+
"jsdom": "^24.0.0",
27+
"solid-js": "1.8.17",
28+
"typescript": "^5.4.5",
29+
"vinxi": "^0.4.0",
30+
"vite": "^5.4.10",
31+
"vite-plugin-solid": "^2.10.2",
32+
"vitest": "^1.5.0"
33+
},
34+
"overrides": {
35+
"@vercel/nft": "0.27.4"
36+
}
37+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const config = getPlaywrightConfig({
4+
startCommand: 'pnpm preview',
5+
port: 3030,
6+
});
7+
8+
export default config;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# TODO: Investigate the need for this script periodically and remove once these modules are correctly resolved.
2+
3+
# This script copies `import-in-the-middle` and `@sentry/solidstart` from the E2E test project root `node_modules`
4+
# to the nitro server build output `node_modules` as these are not properly resolved in our yarn workspace/pnpm
5+
# e2e structure. Some files like `hook.mjs` and `@sentry/solidstart/solidrouter.server.js` are missing. This is
6+
# not reproducible in an external project (when pinning `@vercel/nft` to `v0.27.0` and higher).
7+
cp -r node_modules/.pnpm/import-in-the-middle@1.*/node_modules/import-in-the-middle .output/server/node_modules
8+
cp -rL node_modules/@sentry/solidstart .output/server/node_modules/@sentry
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { withSentryRouterRouting } from '@sentry/solidstart/solidrouter';
2+
import { MetaProvider, Title } from '@solidjs/meta';
3+
import { Router } from '@solidjs/router';
4+
import { FileRoutes } from '@solidjs/start/router';
5+
import { Suspense } from 'solid-js';
6+
7+
const SentryRouter = withSentryRouterRouting(Router);
8+
9+
export default function App() {
10+
return (
11+
<SentryRouter
12+
root={props => (
13+
<MetaProvider>
14+
<Title>SolidStart - with Vitest</Title>
15+
<Suspense>{props.children}</Suspense>
16+
</MetaProvider>
17+
)}
18+
>
19+
<FileRoutes />
20+
</SentryRouter>
21+
);
22+
}

0 commit comments

Comments
 (0)