npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sentry/solidstart

v8.37.1

Published

Official Sentry SDK for Solid Start

Downloads

2,222

Readme

Official Sentry SDK for SolidStart

npm version npm dm npm dt

This SDK is in Beta. The API is stable but updates may include minor changes in behavior. Please reach out on GitHub if you have any feedback or concerns. This SDK is for SolidStart. If you're using Solid see our Solid SDK here.

Links

General

This package is a wrapper around @sentry/node for the server and @sentry/solid for the client side, with added functionality related to SolidStart.

Manual Setup

If the setup through the wizard doesn't work for you, you can also set up the SDK manually.

1. Prerequisites & Installation

Install the Sentry SolidStart SDK:

# Using npm
npm install @sentry/solidstart

# Using yarn
yarn add @sentry/solidstart

2. Client-side Setup

Initialize the SDK in entry-client.jsx

import * as Sentry from '@sentry/solidstart';
import { solidRouterBrowserTracingIntegration } from '@sentry/solidstart/solidrouter';
import { mount, StartClient } from '@solidjs/start/client';

Sentry.init({
  dsn: '__PUBLIC_DSN__',
  integrations: [solidRouterBrowserTracingIntegration()],
  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.

import * as Sentry from '@sentry/solidstart';

Sentry.init({
  dsn: '__PUBLIC_DSN__',
  tracesSampleRate: 1.0, //  Capture 100% of the transactions
});

4. Server instrumentation

Complete the setup by adding the Sentry middleware to your src/middleware.ts file:

import { sentryBeforeResponseMiddleware } from '@sentry/solidstart';
import { createMiddleware } from '@solidjs/start/middleware';

export default createMiddleware({
  onBeforeResponse: [
    sentryBeforeResponseMiddleware(),
    // Add your other middleware handlers after `sentryBeforeResponseMiddleware`
  ],
});

And don't forget to specify ./src/middleware.ts in your app.config.ts:

import { defineConfig } from '@solidjs/start/config';

export default defineConfig({
  // ...
  middleware: './src/middleware.ts',
});

The Sentry middleware enhances the data collected by Sentry on the server side by enabling distributed tracing between the client and server.

5. Run your application

Then run your app

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.

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.

import * as Sentry from '@sentry/solidstart';
import { ErrorBoundary } from 'solid-js';

const SentryErrorBoundary = Sentry.withSentryErrorBoundary(ErrorBoundary);

render(
  () => (
    <SentryErrorBoundary fallback={err => <div>Error: {err.message}</div>}>
      <ProblematicComponent />
    </SentryErrorBoundary>
  ),
  document.getElementById('root'),
);

Uploading Source Maps

To upload source maps, add the sentrySolidStartVite plugin from @sentry/solidstart to your app.config.ts and configure an auth token. Auth tokens can be passed to the plugin explicitly with the authToken option, with a SENTRY_AUTH_TOKEN environment variable, or with an .env.sentry-build-plugin file in the working directory when building your project. We recommend you add the auth token to your CI/CD environment as an environment variable.

Learn more about configuring the plugin in our Sentry Vite Plugin documentation.

// app.config.ts
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,
      }),
    ],
  },
  // ...
});