Manual sentry integration?
This commit is contained in:
parent
61a8401d29
commit
12349b7129
7 changed files with 106 additions and 50 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
*.DS_Store
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
/node_modules
|
||||||
|
|
|
@ -1,20 +1,74 @@
|
||||||
const withPWA = require('next-pwa')
|
const withPWA = require('next-pwa')
|
||||||
const { withSentryConfig } = require('@sentry/nextjs')
|
const SentryWebpackPlugin = require('@sentry/webpack-plugin')
|
||||||
|
|
||||||
const SentryWebpackPluginOptions = {
|
const {
|
||||||
silent: process.env.NODE_ENV === 'development',
|
NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
|
||||||
}
|
SENTRY_ORG,
|
||||||
|
SENTRY_PROJECT,
|
||||||
|
SENTRY_AUTH_TOKEN,
|
||||||
|
NODE_ENV,
|
||||||
|
VERCEL_GIT_COMMIT_SHA,
|
||||||
|
SUPABASE_KEY,
|
||||||
|
SUPABASE_URL,
|
||||||
|
GA_MEASUREMENT_ID,
|
||||||
|
} = process.env
|
||||||
|
|
||||||
module.exports = withSentryConfig(
|
process.env.SENTRY_DSN = SENTRY_DSN
|
||||||
withPWA({
|
|
||||||
future: {
|
const basePath = ''
|
||||||
webpack5: true,
|
|
||||||
},
|
module.exports = withPWA({
|
||||||
pwa: {
|
future: {
|
||||||
dest: 'public',
|
webpack5: true,
|
||||||
scope: '/',
|
},
|
||||||
disable: process.env.NODE_ENV === 'development',
|
pwa: {
|
||||||
},
|
dest: 'public',
|
||||||
}),
|
scope: '/',
|
||||||
SentryWebpackPluginOptions
|
disable: process.env.NODE_ENV === 'development',
|
||||||
)
|
},
|
||||||
|
|
||||||
|
productionBrowserSourceMaps: true,
|
||||||
|
env: {
|
||||||
|
NEXT_PUBLIC_COMMIT_SHA: VERCEL_GIT_COMMIT_SHA,
|
||||||
|
SUPABASE_KEY: SUPABASE_KEY,
|
||||||
|
SUPABASE_URL: SUPABASE_URL,
|
||||||
|
GA_MEASUREMENT_ID: GA_MEASUREMENT_ID,
|
||||||
|
},
|
||||||
|
webpack: (config, options) => {
|
||||||
|
if (!options.isServer) {
|
||||||
|
config.resolve.alias['@sentry/node'] = '@sentry/browser'
|
||||||
|
}
|
||||||
|
|
||||||
|
config.plugins.push(
|
||||||
|
new options.webpack.DefinePlugin({
|
||||||
|
'process.env.NEXT_IS_SERVER': JSON.stringify(
|
||||||
|
options.isServer.toString()
|
||||||
|
),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
SENTRY_DSN &&
|
||||||
|
SENTRY_ORG &&
|
||||||
|
SENTRY_PROJECT &&
|
||||||
|
SENTRY_AUTH_TOKEN &&
|
||||||
|
VERCEL_GIT_COMMIT_SHA &&
|
||||||
|
NODE_ENV === 'production'
|
||||||
|
) {
|
||||||
|
config.plugins.push(
|
||||||
|
new SentryWebpackPlugin({
|
||||||
|
include: '.next',
|
||||||
|
ignore: ['node_modules'],
|
||||||
|
stripPrefix: ['webpack://_N_E/'],
|
||||||
|
urlPrefix: `~${basePath}/_next`,
|
||||||
|
release: VERCEL_GIT_COMMIT_SHA,
|
||||||
|
authToken: SENTRY_AUTH_TOKEN,
|
||||||
|
org: SENTRY_PROJECT,
|
||||||
|
project: SENTRY_ORG,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return config
|
||||||
|
},
|
||||||
|
basePath,
|
||||||
|
})
|
||||||
|
|
|
@ -3,10 +3,12 @@ import { AppProps } from 'next/app'
|
||||||
import { globalStyles } from 'styles'
|
import { globalStyles } from 'styles'
|
||||||
import 'styles/globals.css'
|
import 'styles/globals.css'
|
||||||
import { Provider } from 'next-auth/client'
|
import { Provider } from 'next-auth/client'
|
||||||
|
import { init } from 'utils/sentry'
|
||||||
|
|
||||||
function MyApp({ Component, pageProps }: AppProps) {
|
function MyApp({ Component, pageProps }: AppProps) {
|
||||||
globalStyles()
|
globalStyles()
|
||||||
useGtag()
|
useGtag()
|
||||||
|
init()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Provider session={pageProps.session}>
|
<Provider session={pageProps.session}>
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
// This file configures the initialization of Sentry on the browser.
|
|
||||||
// The config you add here will be used whenever a page is visited.
|
|
||||||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
||||||
|
|
||||||
import * as Sentry from '@sentry/nextjs';
|
|
||||||
|
|
||||||
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
|
|
||||||
|
|
||||||
Sentry.init({
|
|
||||||
dsn: SENTRY_DSN || 'https://d88435642612471d93823489a56ae053@o578706.ingest.sentry.io/5824198',
|
|
||||||
// Note: if you want to override the automatic release value, do not set a
|
|
||||||
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
|
|
||||||
// that it will also get attached to your source maps
|
|
||||||
});
|
|
|
@ -1,5 +0,0 @@
|
||||||
defaults.url=https://sentry.io/
|
|
||||||
defaults.org=stephen-ruiz-ltd
|
|
||||||
defaults.project=tldraw
|
|
||||||
auth.token=ac78d09cacd9445abb362a84d071534aef34b84d39704b1fa03f271417b07d30
|
|
||||||
cli.executable=../../../.npm/_npx/a8388072043b4cbc/node_modules/@sentry/cli/bin/sentry-cli
|
|
|
@ -1,14 +0,0 @@
|
||||||
// This file configures the initialization of Sentry on the server.
|
|
||||||
// The config you add here will be used whenever the server handles a request.
|
|
||||||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
|
|
||||||
|
|
||||||
import * as Sentry from '@sentry/nextjs';
|
|
||||||
|
|
||||||
const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
|
|
||||||
|
|
||||||
Sentry.init({
|
|
||||||
dsn: SENTRY_DSN || 'https://d88435642612471d93823489a56ae053@o578706.ingest.sentry.io/5824198',
|
|
||||||
// Note: if you want to override the automatic release value, do not set a
|
|
||||||
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
|
|
||||||
// that it will also get attached to your source maps
|
|
||||||
});
|
|
32
utils/sentry.ts
Normal file
32
utils/sentry.ts
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import * as Sentry from '@sentry/node'
|
||||||
|
import { RewriteFrames } from '@sentry/integrations'
|
||||||
|
|
||||||
|
export const init = () => {
|
||||||
|
if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
|
||||||
|
const integrations = []
|
||||||
|
if (
|
||||||
|
process.env.NEXT_IS_SERVER === 'true' &&
|
||||||
|
process.env.NEXT_PUBLIC_SENTRY_SERVER_ROOT_DIR
|
||||||
|
) {
|
||||||
|
integrations.push(
|
||||||
|
new RewriteFrames({
|
||||||
|
iteratee: (frame) => {
|
||||||
|
frame.filename = frame.filename.replace(
|
||||||
|
process.env.NEXT_PUBLIC_SENTRY_SERVER_ROOT_DIR,
|
||||||
|
'app:///'
|
||||||
|
)
|
||||||
|
frame.filename = frame.filename.replace('.next', '_next')
|
||||||
|
return frame
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Sentry.init({
|
||||||
|
enabled: process.env.NODE_ENV === 'production',
|
||||||
|
integrations,
|
||||||
|
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||||
|
release: process.env.NEXT_PUBLIC_COMMIT_SHA,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue