0.0.0 • Published 5 years ago

@peakfijn/next-sentry v0.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Next Sentry - Peakfijn

Quickly integrate Sentry in Next using environment variables and a React boundary.

  1. Getting started
  2. Used variables

Getting started

To set up Sentry, we need to initialize the client. You can do that with this code.

import { config } from '@peakfijn/next-sentry';
// initialize sentry with variables from environment
config();
// initialize sentry with extra config
config({
	dns: '<DSN>',
	maxBreadcrumbs: 50,
	debug: true,
});
// or initialize sentry instantly with environment variables
import '@peakfijn/next-sentry/config';

After Sentry is set up, we need to "catch" React errors. You can do this by wrapping all components in src/pages/_app.tsx with the SentryBoundary component.

We recommend wrapping all components with this boundary, but you can also use this for individual components.

import React from 'react';
import NextApp from 'next/app';
import { SentryBoundary } from '@peakfijn/next-sentry';

export default class App extends NextApp {
	render() {
		const { Component, pageProps } = this.props;

		return (
			<SentryBoundary>
				<Component {...pageProps} />
			</SentryBoundary>
		);
	}
}

Used variables

This library can enable Sentry automatically if you use the provided environment variables.

variablerequired?description
SENTRY_DSNrequiredYour project DSN to authenticate the Sentry client.
SENTRY_RELEASEoptionalAn unique release or version name.
SENTRY_ENVIRONMENToptionalThe environment name of the project.
SENTRY_SILENToptionalHide the warning and skip Sentry init, if no DSN is set.

License

The MIT License (MIT). Please see License File for more information.