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(solidstart)!: Default to --import setup and add autoInjectServerSentry #14862

Merged
merged 18 commits into from
Jan 8, 2025

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Dec 30, 2024

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
// 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

@s1gr1d s1gr1d changed the title Ab/solidstart withsentry feat(solidstart)!: Default to --import setup and add autoInjectServerSentry Dec 30, 2024
@s1gr1d s1gr1d changed the title feat(solidstart)!: Default to --import setup and add autoInjectServerSentry feat(solidstart)!: Default to --import setup and add autoInjectServerSentry Dec 30, 2024
@s1gr1d s1gr1d requested a review from andreiborza December 30, 2024 14:21
@s1gr1d s1gr1d force-pushed the ab/solidstart-withsentry branch from e7b59a0 to b402fe1 Compare December 30, 2024 14:22
Copy link

codecov bot commented Dec 30, 2024

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
254 3 251 8
View the top 3 failed tests by shortest run time
errors.server.test.ts server-side errorscaptures server action error
Stack Traces | 30s run time
errors.server.test.ts:5:3 captures server action error
performance.server.test.ts sends a server action transaction on pageload
Stack Traces | 30s run time
performance.server.test.ts:9:1 sends a server action transaction on pageload
performance.server.test.ts sends a server action transaction on client navigation
Stack Traces | 30s run time
performance.server.test.ts:32:1 sends a server action transaction on client navigation

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

Comment on lines 14 to 15
// The first page load causes a hydration error on the dev server sometimes - a reload works around this
await page.reload();
Copy link
Member

Choose a reason for hiding this comment

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

m: Is this an issue again? We aren't using the dev server right?

Comment on lines 18 to 24
// TODO: Ensure this file is source mapped too.
// Placing this after the sentry vite plugin means this
// file won't get a sourcemap and won't have a debug id injected.
// Because the file is just copied over to the output server
// directory the release injection file from sentry vite plugin
// wouldn't resolve correctly otherwise.
sentryPlugins.push(makeBuildInstrumentationFilePlugin(options));
Copy link
Member

Choose a reason for hiding this comment

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

q: Is this still relevant now that we copy over the release injection files? We probably want to have debug id injections now.

Comment on lines 14 to 15
// The first page load causes a hydration error on the dev server sometimes - a reload works around this
await page.reload();
Copy link
Member

Choose a reason for hiding this comment

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

l: Is this still relevant? We aren't using the dev mode anymore right?

Comment on lines 18 to 24
// TODO: Ensure this file is source mapped too.
// Placing this after the sentry vite plugin means this
// file won't get a sourcemap and won't have a debug id injected.
// Because the file is just copied over to the output server
// directory the release injection file from sentry vite plugin
// wouldn't resolve correctly otherwise.
sentryPlugins.push(makeBuildInstrumentationFilePlugin(options));
Copy link
Member

Choose a reason for hiding this comment

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

m: Now that we copy over release injection files, we should ensure that the instrumentation file is also properly injected with debug ids right?

@s1gr1d s1gr1d force-pushed the ab/solidstart-withsentry branch from 0d73fd9 to 60dacf6 Compare January 8, 2025 09:40
@s1gr1d s1gr1d requested a review from andreiborza January 8, 2025 09:44
@s1gr1d s1gr1d force-pushed the ab/solidstart-withsentry branch from 60dacf6 to 333d210 Compare January 8, 2025 09:46
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

@s1gr1d s1gr1d merged commit 74e2982 into develop Jan 8, 2025
127 checks passed
@s1gr1d s1gr1d deleted the ab/solidstart-withsentry branch January 8, 2025 11:10
s1gr1d added a commit that referenced this pull request Jan 10, 2025
…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]>
s1gr1d added a commit that referenced this pull request Jan 22, 2025
…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]>
s1gr1d added a commit that referenced this pull request Jan 22, 2025
…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 added a commit that referenced this pull request Jan 23, 2025
…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]>
s1gr1d added a commit that referenced this pull request Jan 23, 2025
…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 added a commit that referenced this pull request Jan 23, 2025
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