-
-
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 sentrySolidStartVite
plugin to simplify source maps upload
#13493
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
17e6cb2
feat(solidstart): Add `sentrySolidStartVite` plugin
andreiborza 54726a1
Expose `unstable_sentryVitePluginOptions` as escape hatch for `@sentr…
andreiborza 453b6dc
Flatten options, remove fields that will get auto-picked up
andreiborza 0e84d94
Fix unit test
andreiborza 8461d44
Remove madge check for middleware
andreiborza 330270b
Lint README
andreiborza 8142b06
Fix ordering of plugins test
andreiborza 7c2591c
Remove middleware export
andreiborza ecd7a47
Flatten and simplify options
andreiborza 8576117
Update README to reflect plugin option changes
andreiborza e7e117c
Use the plugin in the e2e app
andreiborza f1222aa
Clean build output before running test
andreiborza 86394b1
feat(solidstart): Add `bundleSizeOptimizations` to `sentrySolidStartV…
andreiborza 1343790
Make e2e test less flaky on CI
andreiborza 1378828
Make plugin options optional
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
7 changes: 6 additions & 1 deletion
7
dev-packages/e2e-tests/test-applications/solidstart/app.config.ts
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import { sentrySolidStartVite } from '@sentry/solidstart'; | ||
import { defineConfig } from '@solidjs/start/config'; | ||
|
||
export default defineConfig({}); | ||
export default defineConfig({ | ||
vite: { | ||
plugins: [sentrySolidStartVite({})], | ||
}, | ||
}); |
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
82 changes: 11 additions & 71 deletions
82
dev-packages/e2e-tests/test-applications/solidstart/src/routes/client-error.tsx
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 |
---|---|---|
@@ -1,75 +1,15 @@ | ||
import * as Sentry from '@sentry/solidstart'; | ||
import type { ParentProps } from 'solid-js'; | ||
import { ErrorBoundary, createSignal, onMount } from 'solid-js'; | ||
|
||
const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary); | ||
|
||
const [count, setCount] = createSignal(1); | ||
const [caughtError, setCaughtError] = createSignal(false); | ||
|
||
export default function ClientErrorPage() { | ||
return ( | ||
<SampleErrorBoundary> | ||
{caughtError() && ( | ||
<Throw error={`Error ${count()} thrown from Sentry ErrorBoundary in Solid Start E2E test app`} /> | ||
)} | ||
<section class="bg-gray-100 text-gray-700 p-8"> | ||
<div class="flex flex-col items-start space-x-2"> | ||
<button | ||
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer" | ||
id="caughtErrorBtn" | ||
onClick={() => setCaughtError(true)} | ||
> | ||
Throw caught error | ||
</button> | ||
</div> | ||
<div class="flex flex-col items-start space-x-2"> | ||
<button | ||
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer" | ||
id="errorBtn" | ||
onClick={() => { | ||
throw new Error('Error thrown from Solid Start E2E test app'); | ||
}} | ||
> | ||
Throw uncaught error | ||
</button> | ||
</div> | ||
</section> | ||
</SampleErrorBoundary> | ||
); | ||
} | ||
|
||
function Throw(props: { error: string }) { | ||
onMount(() => { | ||
throw new Error(props.error); | ||
}); | ||
return null; | ||
} | ||
|
||
function SampleErrorBoundary(props: ParentProps) { | ||
return ( | ||
<SentryErrorBoundary | ||
fallback={(error, reset) => ( | ||
<section class="bg-gray-100 text-gray-700 p-8"> | ||
<h1 class="text-2xl font-bold">Error Boundary Fallback</h1> | ||
<div class="flex items-center space-x-2 mb-4"> | ||
<code>{error.message}</code> | ||
</div> | ||
<button | ||
id="errorBoundaryResetBtn" | ||
class="border rounded-lg px-2 border-gray-900" | ||
onClick={() => { | ||
setCount(count() + 1); | ||
setCaughtError(false); | ||
reset(); | ||
}} | ||
> | ||
Reset | ||
</button> | ||
</section> | ||
)} | ||
> | ||
{props.children} | ||
</SentryErrorBoundary> | ||
<div class="flex flex-col items-start space-x-2"> | ||
<button | ||
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer" | ||
id="errorBtn" | ||
onClick={() => { | ||
throw new Error('Uncaught error thrown from Solid Start E2E test app'); | ||
}} | ||
> | ||
Throw uncaught error | ||
</button> | ||
</div> | ||
); | ||
} |
64 changes: 64 additions & 0 deletions
64
dev-packages/e2e-tests/test-applications/solidstart/src/routes/error-boundary.tsx
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,64 @@ | ||
import * as Sentry from '@sentry/solidstart'; | ||
import type { ParentProps } from 'solid-js'; | ||
import { ErrorBoundary, createSignal, onMount } from 'solid-js'; | ||
|
||
const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary); | ||
|
||
const [count, setCount] = createSignal(1); | ||
const [caughtError, setCaughtError] = createSignal(false); | ||
|
||
export default function ErrorBoundaryTestPage() { | ||
return ( | ||
<SampleErrorBoundary> | ||
{caughtError() && ( | ||
<Throw error={`Error ${count()} thrown from Sentry ErrorBoundary in Solid Start E2E test app`} /> | ||
)} | ||
<section class="bg-gray-100 text-gray-700 p-8"> | ||
<div class="flex flex-col items-start space-x-2"> | ||
<button | ||
class="border rounded-lg px-2 mb-2 border-red-500 text-red-500 cursor-pointer" | ||
id="caughtErrorBtn" | ||
onClick={() => setCaughtError(true)} | ||
> | ||
Throw caught error | ||
</button> | ||
</div> | ||
</section> | ||
</SampleErrorBoundary> | ||
); | ||
} | ||
|
||
function Throw(props: { error: string }) { | ||
onMount(() => { | ||
throw new Error(props.error); | ||
}); | ||
return null; | ||
} | ||
|
||
function SampleErrorBoundary(props: ParentProps) { | ||
return ( | ||
<SentryErrorBoundary | ||
fallback={(error, reset) => ( | ||
<section class="bg-gray-100 text-gray-700 p-8"> | ||
<h1 class="text-2xl font-bold">Error Boundary Fallback</h1> | ||
<div class="flex items-center space-x-2 mb-4"> | ||
<code>{error.message}</code> | ||
</div> | ||
<button | ||
id="errorBoundaryResetBtn" | ||
class="border rounded-lg px-2 border-gray-900" | ||
onClick={() => { | ||
setCount(count() + 1); | ||
setCaughtError(false); | ||
reset(); | ||
}} | ||
> | ||
Reset | ||
</button> | ||
</section> | ||
)} | ||
> | ||
{props.children} | ||
</SentryErrorBoundary> | ||
); | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './server'; | ||
export * from './vite'; |
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 @@ | ||
export * from './sentrySolidStartVite'; |
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,18 @@ | ||
import type { Plugin } from 'vite'; | ||
import { makeSourceMapsVitePlugin } from './sourceMaps'; | ||
import type { SentrySolidStartPluginOptions } from './types'; | ||
|
||
/** | ||
* Various Sentry vite plugins to be used for SolidStart. | ||
*/ | ||
export const sentrySolidStartVite = (options: SentrySolidStartPluginOptions): Plugin[] => { | ||
const sentryPlugins: Plugin[] = []; | ||
|
||
if (process.env.NODE_ENV !== 'development') { | ||
if (options.sourceMapsUploadOptions?.enabled ?? true) { | ||
sentryPlugins.push(...makeSourceMapsVitePlugin(options)); | ||
} | ||
} | ||
|
||
return sentryPlugins; | ||
}; |
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.
l/just personal opinion: It feels a bit awkward that users need to pass an options object but can leave it empty. Should we make the options object optional? I might be missing something but technically, I could pass all required options for source maps upload as env variables, right? (project slug and auth token)
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.
Right, good point! I'll make this optional.
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.
@Lms24 updated