Skip to content
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(v8/solidstart): Add withSentry wrapper for SolidStart config #15135

Merged
merged 2 commits into from
Jan 23, 2025

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Jan 22, 2025

Backport of #14862 and #14863

@s1gr1d s1gr1d requested a review from andreiborza January 22, 2025 15:57
Comment on lines +9 to +25
*
* @deprecated This plugin will be removed in v9. Instead, use `withSentry` to wrap your SolidStart config. Example:
* ```
* export default defineConfig(
* withSentry(
* {
* // SolidStart config...
* },
* {
* // Sentry config
* org: process.env.SENTRY_ORG,
* project: process.env.SENTRY_PROJECT,
* authToken: process.env.SENTRY_AUTH_TOKEN,
* },
* ),
* );
* ```
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything in this PR is just a backport of the PRs merged into the v9 branch.

Those JSDoc lines are new. And I kept the E2E tests solidstart and solidstart-spa as they were before, to still test that the old way of setting up the SDK (with the Vite plugin) works.

@mydea mydea changed the title feat(solidstart): Add withSentry wrapper for SolidStart config feat(v8/solidstart): Add withSentry wrapper for SolidStart config Jan 23, 2025
Copy link
Member

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

s1gr1d and others added 2 commits January 23, 2025 13:37
…erSentry` (#14862)

This PR adds a `withSentry` wrapper for SolidStart's config to build and
place `instrument.server.ts` alongside the server build output so that
it doesn't have to be placed in `/public` anymore to be discoverable.

The setup is changed to be aligned with Nuxt.
First, the `instrument.server.ts` file is added to the build output (the
sentry release injection file needs to be copied as well - this is not
ideal at the moment as there **could** be other imports as well, but
it's okay for now)

Then, there are two options to set up the SDK:
1. Users provide an `--import` CLI flag to their start command like
this:
```node --import ./.output/server/instrument.server.mjs .output/server/index.mjs```
2. Users can add `autoInjectServerSentry: 'top-level-import'` and the Sentry config will be imported at the top of the server entry

```typescript
// app.config.ts
import { defineConfig } from '@solidjs/start/config';
import { withSentry } from '@sentry/solidstart';

export default defineConfig(withSentry(
    { /* ... */ },
    {
      autoInjectServerSentry: 'top-level-import' // optional
    })
 );
```

---
builds on top of the idea in this PR: #13784

---------

Co-authored-by: Andrei Borza <[email protected]>
…import` (#14863)

⚠️ THIS PR IS BASED ON
#14862

Adds the option to dynamically import the server config file.

```typescript
// app.config.ts
import { defineConfig } from '@solidjs/start/config';
import { sentrySolidStartVite, withSentry } from '@sentry/solidstart';

export default defineConfig(withSentry(
    { /* ... */ },
    {
      autoInjectServerSentry: 'experimental_dynamic-import'
    })
 );
```

---------

Co-authored-by: Andrei Borza <[email protected]>
(cherry picked from commit 38ff6eb)
@s1gr1d s1gr1d force-pushed the sig/withSentry-v8 branch from 6d4eda9 to c611265 Compare January 23, 2025 12:37
Copy link

codecov bot commented Jan 23, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
254 1 253 8
View the top 1 failed tests by shortest run time
request-instrumentation.test.ts Should send a transaction with a fetch span
Stack Traces | 30s run time
request-instrumentation.test.ts:4:5 Should send a transaction with a fetch span

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants