Skip to content

Commit

Permalink
feat: migrate to self-hosted sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat committed Jan 10, 2024
1 parent 8e31a5c commit 117d760
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 32 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/smoketest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Find existing build status comment
continue-on-error: true
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
</table>
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
Expand All @@ -68,15 +68,28 @@ jobs:
id: gatsbyCache
with:
path: ./.cache
key: ${{ runner.os }}-gatsby-cache-${{ secrets.CACHE_VERSION }}-${{ hashFiles('public') }}
key: ${{ runner.os }}-gatsby-cache-${{ hashFiles('public') }}
restore-keys: |
${{ runner.os }}-gatsby-cache-${{ secrets.CACHE_VERSION }}-
${{ runner.os }}-gatsby-cache-
- name: Build site
run: yarn build:ci
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

- name: Publish Sentry release
if: github.ref == 'refs/heads/deploy' && github.event_name == 'push'
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: davw-network
SENTRY_PROJECT: mastdatabase
run: |
VERSION=`yarn sentry-cli --url https://sentry.service.davw.network releases propose-version`
yarn sentry-cli --url https://sentry.service.davw.network releases new "$VERSION"
yarn sentry-cli --url https://sentry.service.davw.network releases set-commits "$VERSION" --auto
yarn sentry-cli --url https://sentry.service.davw.network releases finalize "$VERSION"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
Expand Down
11 changes: 3 additions & 8 deletions gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ const prodPlugins: any[] = !__IS_DEV__
]
: []

if (__IS_DEV__) {
if (process.env.SENTRY_AUTH_TOKEN) {
prodPlugins.push({
resolve: '@sentry/gatsby',
})
}
}

const config: GatsbyConfig = {
flags: {
// FAST_DEV: true,
Expand Down Expand Up @@ -212,6 +204,9 @@ const config: GatsbyConfig = {
],
},
},
{
resolve: '@sentry/gatsby',
},
...nonCiPlugins,
],
}
Expand Down
13 changes: 0 additions & 13 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,6 @@ export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = ({ sta
})
}

const SentryPlugin = require('@sentry/webpack-plugin')

if (process.env.NODE_ENV !== 'development' && process.env.SENTRY_AUTH_TOKEN) {
actions.setWebpackConfig({
plugins: [
new SentryPlugin({
include: 'public',
ignore: ['app-*', 'polyfill-*', 'framework-*', 'webpack-runtime-*'],
}),
],
})
}

actions.setWebpackConfig({
module: {
rules: [
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@
"license": "MIT",
"scripts": {
"build": "cross-env NODE_ENV=production gatsby build",
"build:ci": "cross-env NODE_ENV=production GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages --verbose",
"build:ci": "cross-env NODE_ENV=production GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES=true gatsby build --log-pages --verbose && yarn run sentry:sourcemaps",
"develop": "gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md,less,mdx}\"",
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md,less,mdx}\"",
"start": "yarn develop",
"serve": "gatsby serve",
"clean": "gatsby clean",
"lint": "eslint . --ext md,mdx"
"lint": "eslint . --ext md,mdx",
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org davw-network --project mastdatabase ./public && sentry-cli --url https://sentry.service.davw.network sourcemaps upload --org davw-network --project mastdatabase ./public"
},
"packageManager": "[email protected]",
"resolutions": {
Expand Down
66 changes: 61 additions & 5 deletions sentry.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,66 @@ import * as Sentry from '@sentry/gatsby'
const __IS_DEV__ = process.env.NODE_ENV !== 'production'

Sentry.init({
dsn: 'https://[email protected]/6778122',
sampleRate: __IS_DEV__ ? 1.0 : 0.7, // Adjust this value in production
// beforeSend(event) {
// return event
// },
dsn: 'https://[email protected]/3',
sampleRate: 1.0,
release: process.env.RELEASE,

integrations: [
new Sentry.Replay({
maskAllText: false,
blockAllMedia: false,
}),
new Sentry.BrowserTracing({
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ['localhost', /^https:\/\/yourserver\.io\/api/],
}),
],

tracesSampleRate: __IS_DEV__ ? 1.0 : 0.3,
replaysOnErrorSampleRate: 0.05,
replaysSessionSampleRate: __IS_DEV__ ? 1.0 : 0.001,

ignoreErrors: [
/minified react error/i,

// See: https://docs.sentry.io/platforms/javascript/guides/gatsby/configuration/filtering/#decluttering-sentry
// Random plugins/extensions
'top.GLOBALS',
// See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html
'originalCreateNotification',
'canvas.contentDocument',
'MyApp_RemoveAllHighlights',
'http://tt.epicplay.com',
"Can't find variable: ZiteReader",
'jigsaw is not defined',
'ComboSearch is not defined',
'http://loading.retry.widdit.com/',
'atomicFindClose',
// Facebook borked
'fb_xd_fragment',
// ISP "optimizing" proxy - `Cache-Control: no-transform` seems to
// reduce this. (thanks @acdha)
// See http://stackoverflow.com/questions/4113268
'bmi_SafeAddOnload',
'EBCallBackMessageReceived',
// See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx
'conduitPage',
],
denyUrls: [
// Facebook flakiness
/graph\.facebook\.com/i,
// Facebook blocked
/connect\.facebook\.net\/en_US\/all\.js/i,
// Woopra flakiness
/eatdifferent\.com\.woopra-ns\.com/i,
/static\.woopra\.com\/js\/woopra\.js/i,
// Chrome extensions
/extensions\//i,
/^chrome:\/\//i,
/^chrome-extension:\/\//i,
// Other plugins
/127\.0\.0\.1:4001\/isrunning/i, // Cacaoweb
/webappstoolbarba\.texthelp\.com\//i,
/metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
],
})

0 comments on commit 117d760

Please sign in to comment.