-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(solidstart): Add
sentrySolidStartVite
plugin to simplify sourc…
…e maps upload (#13493) This plugin simplifies source maps upload by using `@sentry/vite-plugin` and enabling source map generation by default. Usage: ```js import { defineConfig } from '@solidjs/start/config' import { sentrySolidStartVite } from '@sentry/solidstart' export default defineConfig({ vite: { plugins: [ sentrySolidStartVite({ org: process.env.SENTRY_ORG, project: process.env.SENTRY_PROJECT, authToken: process.env.SENTRY_AUTH_TOKEN, debug: true, }), ], } }) ``` Closes: #12553
- Loading branch information
1 parent
a69da1b
commit e2213fc
Showing
19 changed files
with
464 additions
and
120 deletions.
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.