-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(solidstart): Add solidstart SDK basic package #12730
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fa13e5e
feat(solidstart): Add solidstart SDK basic package
andreiborza b87c5c9
Rewriting types
andreiborza a2a5b7c
Update tsconfigs
andreiborza 59fb5d2
Try different type configuration
andreiborza 298dd2a
Remove unncessary server export of browser tracing integration
andreiborza ba8f1d3
Fix type issue for solidstart package
andreiborza 0981ee0
First working version with bundler & node moduleResolution
andreiborza 2346fa3
Add comments to `package.json` explaining types strategy
andreiborza 7496bd3
Update nx entries
andreiborza 8fa76db
Update README, expose solid sdk's error boundary
andreiborza 5ceb123
Housekeeping
andreiborza 843812e
Add tests
andreiborza a6a1fe3
Add sdk to verdaccio config
andreiborza 34e7666
Update circularDepCheck with correct file
andreiborza c2da975
Add eslint ignore to ignore built type files at root
andreiborza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/client | ||
/server | ||
/*.d.ts | ||
/*.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
node: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['vite.config.ts'], | ||
parserOptions: { | ||
project: ['tsconfig.test.json'], | ||
}, | ||
}, | ||
{ | ||
files: ['src/vite/**', 'src/server/**'], | ||
rules: { | ||
'@sentry-internal/sdk/no-optional-chaining': 'off', | ||
}, | ||
}, | ||
], | ||
extends: ['../../.eslintrc.js'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# types for the solidrouter integration that get output in root | ||
/client | ||
/server | ||
/*.d.ts | ||
/*.d.ts.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023-2024 Functional Software, Inc. dba Sentry | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<p align="center"> | ||
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank"> | ||
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84"> | ||
</a> | ||
</p> | ||
|
||
# Official Sentry SDK for Solid Start (EXPERIMENTAL) | ||
|
||
[![npm version](https://img.shields.io/npm/v/@sentry/solidstart.svg)](https://www.npmjs.com/package/@sentry/solidstart) | ||
[![npm dm](https://img.shields.io/npm/dm/@sentry/solidstart.svg)](https://www.npmjs.com/package/@sentry/solidstart) | ||
[![npm dt](https://img.shields.io/npm/dt/@sentry/solidstart.svg)](https://www.npmjs.com/package/@sentry/solidstart) | ||
|
||
This SDK is considered ⚠️ **experimental and in an alpha state**. It may experience breaking changes. Please reach out | ||
on [GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have any feedback or concerns. This | ||
SDK is for [Solid Start](https://start.solidjs.com/). If you're using [Solid](https://www.solidjs.com/) see our | ||
[Solid SDK here](https://github.com/getsentry/sentry-javascript/tree/develop/packages/solid). | ||
|
||
## Links | ||
|
||
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/solidstart/) | ||
|
||
## General | ||
|
||
This package is a wrapper around `@sentry/node` for the server and `@sentry/solid` for the client side, with added | ||
functionality related to Solid Start. | ||
|
||
## Manual Setup | ||
|
||
If the setup through the wizard doesn't work for you, you can also set up the SDK manually. | ||
|
||
### 1. Prerequesits & Installation | ||
|
||
Install the Sentry Solid Start SDK: | ||
|
||
```bash | ||
# Using npm | ||
npm install @sentry/solidstart | ||
|
||
# Using yarn | ||
yarn add @sentry/solidstart | ||
``` | ||
|
||
### 2. Client-side Setup | ||
|
||
Initialize the SDK in `entry-client.jsx` | ||
|
||
```jsx | ||
import * as Sentry from '@sentry/solidstart'; | ||
import { mount, StartClient } from '@solidjs/start/client'; | ||
|
||
Sentry.init({ | ||
dsn: '__PUBLIC_DSN__', | ||
tracesSampleRate: 1.0, // Capture 100% of the transactions | ||
}); | ||
|
||
mount(() => <StartClient />, document.getElementById('app')); | ||
``` | ||
|
||
### 3. Server-side Setup | ||
|
||
Create an instrument file named `instrument.server.mjs` and add your initialization code for the server-side SDK. | ||
|
||
```javascript | ||
import * as Sentry from '@sentry/solidstart'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/4507459091824640', | ||
tracesSampleRate: 1.0, // Capture 100% of the transactions | ||
}); | ||
``` | ||
|
||
### 4. Run your application | ||
|
||
Then run your app | ||
|
||
```bash | ||
NODE_OPTIONS='--import=./instrument.server.mjs' yarn start | ||
# or | ||
NODE_OPTIONS='--require=./instrument.server.js' yarn start | ||
``` | ||
|
||
# Solid Router | ||
|
||
The Solid Router instrumentation uses the Solid Router library to create navigation spans to ensure you collect | ||
meaningful performance data about the health of your page loads and associated requests. | ||
|
||
Wrap `Router`, `MemoryRouter` or `HashRouter` from `@solidjs/router` using `withSentryRouterRouting`. This creates a | ||
higher order component, which will enable Sentry to reach your router context. | ||
|
||
```js | ||
import { withSentryRouterRouting } from '@sentry/solidstart/solidrouter'; | ||
import { Route, Router } from '@solidjs/router'; | ||
|
||
const SentryRouter = Sentry.withSentryRouterRouting(Router); | ||
|
||
render( | ||
() => ( | ||
<SentryRouter> | ||
<Route path="/" component={App} /> | ||
... | ||
</SentryRouter> | ||
), | ||
document.getElementById('root'), | ||
); | ||
``` | ||
|
||
# Solid ErrorBoundary | ||
|
||
To automatically capture exceptions from inside a component tree and render a fallback component, wrap the native Solid | ||
JS `ErrorBoundary` component with `Sentry.withSentryErrorBoundary`. | ||
|
||
```js | ||
import * as Sentry from '@sentry/solidstart'; | ||
import { ErrorBoundary } from 'solid-js'; | ||
|
||
Sentry.init({ | ||
dsn: '__PUBLIC_DSN__', | ||
tracesSampleRate: 1.0, // Capture 100% of the transactions | ||
}); | ||
|
||
const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary); | ||
|
||
render( | ||
() => ( | ||
<SentryErrorBoundary fallback={err => <div>Error: {err.message}</div>}> | ||
<ProblematicComponent /> | ||
</SentryErrorBoundary> | ||
), | ||
document.getElementById('root'), | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
{ | ||
"name": "@sentry/solidstart", | ||
"version": "8.13.0", | ||
"description": "Official Sentry SDK for Solid Start", | ||
"repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/solidstart", | ||
"author": "Sentry", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"files": [ | ||
"/build", | ||
"/client", | ||
"/server", | ||
"/*.d.ts", | ||
"/*.d.ts.map" | ||
], | ||
"main": "build/cjs/index.server.js", | ||
"module": "build/esm/index.server.js", | ||
"browser": "build/esm/index.client.js", | ||
"types": "build/types/index.types.d.ts", | ||
"//": [ | ||
"For `@sentry/solidstart/solidrouter` types to resolve correctly for both `moduleResolution: bundler` and `moduleResolution: node`", | ||
"- type definitions have to be exported at root level (/build won't work)", | ||
"- type definitions have to match in name (i.e. `solidrouter.d.ts`)", | ||
"- the `types` entry needs to be set both at the root of the export and within `browser` and `node`" | ||
], | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"types": "./build/types/index.types.d.ts", | ||
"browser": { | ||
"import": "./build/esm/index.client.js", | ||
"require": "./build/cjs/index.client.js" | ||
}, | ||
"node": { | ||
"import": "./build/esm/index.server.js", | ||
"require": "./build/cjs/index.server.js" | ||
} | ||
}, | ||
"./solidrouter": { | ||
"types": "./solidrouter.d.ts", | ||
"browser": { | ||
"types": "./solidrouter.d.ts", | ||
"import": "./build/esm/solidrouter.client.js", | ||
"require": "./build/cjs/solidrouter.client.js" | ||
}, | ||
"node": { | ||
"types": "./solidrouter.d.ts", | ||
"import": "./build/esm/solidrouter.server.js", | ||
"require": "./build/cjs/solidrouter.server.js" | ||
} | ||
} | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"peerDependencies": { | ||
"@solidjs/router": "^0.13.4", | ||
"@solidjs/start": "^1.0.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@solidjs/router": { | ||
"optional": true | ||
} | ||
}, | ||
"dependencies": { | ||
"@sentry/core": "8.13.0", | ||
"@sentry/node": "8.13.0", | ||
"@sentry/opentelemetry": "8.13.0", | ||
"@sentry/solid": "8.13.0", | ||
"@sentry/types": "8.13.0", | ||
"@sentry/utils": "8.13.0", | ||
"@sentry/vite-plugin": "2.19.0" | ||
}, | ||
"devDependencies": { | ||
"@solidjs/start": "^1.0.0", | ||
"@solidjs/router": "^0.13.4", | ||
"@solidjs/testing-library": "0.8.5", | ||
"@testing-library/jest-dom": "^6.4.5", | ||
"@testing-library/user-event": "^14.5.2", | ||
"vite-plugin-solid": "^2.8.2" | ||
}, | ||
"scripts": { | ||
"build": "run-p build:transpile build:types", | ||
"build:dev": "yarn build", | ||
"build:transpile": "rollup -c rollup.npm.config.mjs", | ||
"build:types": "run-s build:types:core build:types:solidrouter", | ||
"build:types:core": "tsc -p tsconfig.types.json", | ||
"build:types:solidrouter": "tsc -p tsconfig.solidrouter-types.json", | ||
"build:watch": "run-p build:transpile:watch build:types:watch", | ||
"build:dev:watch": "yarn build:watch", | ||
"build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", | ||
"build:types:watch": "tsc -p tsconfig.types.json --watch", | ||
"build:tarball": "npm pack", | ||
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts && madge --circular src/solidrouter.client.ts && madge --circular src/solidrouter.server.ts && madge --circular src/solidrouter.ts", | ||
"clean": "rimraf build coverage sentry-solidstart-*.tgz ./*.d.ts ./*.d.ts.map ./client ./server", | ||
"fix": "eslint . --format stylish --fix", | ||
"lint": "eslint . --format stylish", | ||
"test": "yarn test:unit", | ||
"test:unit": "vitest run", | ||
"test:watch": "vitest --watch", | ||
"yalc:publish": "yalc publish --push --sig" | ||
}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
}, | ||
"nx": { | ||
"targets": { | ||
"build:types": { | ||
"outputs": [ | ||
"{projectRoot}/build/types", | ||
"{projectRoot}/client", | ||
"{projectRoot}/server", | ||
"{projectRoot}/*.d.ts", | ||
"{projectRoot}/*.d.ts.map" | ||
] | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, good catch! 👍