Skip to content

Commit 17082a1

Browse files
authored
Merge pull request #268 from scientist-softserv/sentry-for-next-js
8 setup exception tracking
2 parents d509c4e + b79bc84 commit 17082a1

17 files changed

+427
-156
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ NEXT_PUBLIC_PROVIDER_NAME=beachsidebiotech
55
NEXT_PUBLIC_PROVIDER_ID=5159
66
NEXT_PUBLIC_SCIENTIST_API_VERSION=v2
77

8-
SENTRY_DSN=https://6c537d3cdd954401a893831313a976cc@o1008683.ingest.sentry.io/4504805305810944
8+
SENTRY_DSN=https://78ce09ae2f694f0e8981cf5cec6fc2c7@o1008683.ingest.sentry.io/4504810271408128

.github/workflows/build.yml

Lines changed: 72 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,78 @@
1-
name: "Build Docker Images"
2-
run-name: Build of ${{ github.ref_name }} by @${{ github.actor }}
3-
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
10-
workflow_dispatch:
11-
inputs:
12-
debug_enabled:
13-
type: boolean
14-
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
15-
required: false
16-
default: false
1+
# we are running the build in vercel now so we don't need this github action
2+
# commenting this out because this action kept failing on https://github.com/scientist-softserv/webstore/pull/268
3+
# TODO(alishaevn): figure out the sentry error if we switch from vercel to an in house deploy infrastructure
174

18-
env:
19-
REGISTRY: ghcr.io
5+
# name: "Build Docker Images"
6+
# run-name: Build of ${{ github.ref_name }} by @${{ github.actor }}
7+
# on:
8+
# push:
9+
# branches:
10+
# - main
11+
# pull_request:
12+
# branches:
13+
# - main
14+
# workflow_dispatch:
15+
# inputs:
16+
# debug_enabled:
17+
# type: boolean
18+
# description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
19+
# required: false
20+
# default: false
2021

21-
jobs:
22-
build:
23-
runs-on: ubuntu-latest
24-
permissions:
25-
contents: read
26-
packages: write
27-
steps:
28-
- id: setup
29-
name: Setup
30-
uses: scientist-softserv/actions/[email protected]
31-
with:
32-
tag: ${{ inputs.tag }}
33-
image_name: ${{ inputs.image_name }}
34-
token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }}
35-
- uses: actions/setup-node@v3
36-
with:
37-
registry-url: 'https://npm.pkg.github.com'
38-
# Defaults to the user or organization that owns the workflow file
39-
scope: '@scientist-softserv'
40-
node-version-file: package.json
41-
- name: GPR authToken
42-
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > $NPM_CONFIG_USERCONFIG
43-
- name: GPR alias
44-
run: echo "@scientist-softserv:registry=https://npm.pkg.github.com" >> $NPM_CONFIG_USERCONFIG
45-
- run: yarn install
46-
- run: yarn test
22+
# env:
23+
# REGISTRY: ghcr.io
4724

48-
- name: Login to GitHub Container Registry
49-
uses: docker/login-action@v2
50-
with:
51-
registry: ${{ env.REGISTRY }}
52-
username: ${{ github.actor }}
53-
password: ${{ secrets.GITHUB_TOKEN }}
25+
# jobs:
26+
# build:
27+
# runs-on: ubuntu-latest
28+
# permissions:
29+
# contents: read
30+
# packages: write
31+
# steps:
32+
# - id: setup
33+
# name: Setup
34+
# uses: scientist-softserv/actions/[email protected]
35+
# with:
36+
# tag: ${{ inputs.tag }}
37+
# image_name: ${{ inputs.image_name }}
38+
# token: ${{ secrets.CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }}
39+
# - uses: actions/setup-node@v3
40+
# with:
41+
# registry-url: 'https://npm.pkg.github.com'
42+
# # Defaults to the user or organization that owns the workflow file
43+
# scope: '@scientist-softserv'
44+
# node-version-file: package.json
45+
# - name: GPR authToken
46+
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > $NPM_CONFIG_USERCONFIG
47+
# - name: GPR alias
48+
# run: echo "@scientist-softserv:registry=https://npm.pkg.github.com" >> $NPM_CONFIG_USERCONFIG
49+
# - run: yarn install
50+
# - run: yarn test
5451

55-
- name: Retag action for Docker image
56-
id: meta-docker-image
57-
uses: docker/[email protected]
58-
with:
59-
images: |
60-
name=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}
61-
tags: |
62-
type=raw,value=latest,enable={{is_default_branch}}
52+
# - name: Login to GitHub Container Registry
53+
# uses: docker/login-action@v2
54+
# with:
55+
# registry: ${{ env.REGISTRY }}
56+
# username: ${{ github.actor }}
57+
# password: ${{ secrets.GITHUB_TOKEN }}
6358

64-
- run: cp $NPM_CONFIG_USERCONFIG .npmrc; cat .npmrc
59+
# - name: Retag action for Docker image
60+
# id: meta-docker-image
61+
# uses: docker/[email protected]
62+
# with:
63+
# images: |
64+
# name=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}
65+
# tags: |
66+
# type=raw,value=latest,enable={{is_default_branch}}
6567

66-
- name: Build and push Docker image
67-
uses: docker/build-push-action@v3
68-
with:
69-
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }}
70-
context: .
71-
push: true
72-
tags: |
73-
${{ steps.meta-docker-image.outputs.tags }}
74-
${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }}
68+
# - run: cp $NPM_CONFIG_USERCONFIG .npmrc; cat .npmrc
69+
70+
# - name: Build and push Docker image
71+
# uses: docker/build-push-action@v3
72+
# with:
73+
# cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }}
74+
# context: .
75+
# push: true
76+
# tags: |
77+
# ${{ steps.meta-docker-image.outputs.tags }}
78+
# ${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }}

.github/workflows/deploy.yml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
name: "Deploy"
2-
run-name: Deploy (${{ github.ref_name }} -> ${{ inputs.environment }}) by @${{ github.actor }}
3-
on:
4-
workflow_dispatch:
5-
inputs:
6-
environment:
7-
description: 'Deploy to Environment'
8-
required: true
9-
default: 'staging'
10-
type: choice
11-
options:
12-
- staging
13-
debug_enabled:
14-
type: boolean
15-
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
16-
required: false
17-
default: false
1+
# we are running the deploy through vercel now so we don't need this github action
2+
# TODO(alishaevn): fix any potential sentry error's if we switch from vercel to an in house deploy infrastructure
183

19-
jobs:
20-
deploy:
21-
uses: scientist-softserv/actions/.github/workflows/[email protected]
22-
secrets: inherit
4+
# name: "Deploy"
5+
# run-name: Deploy (${{ github.ref_name }} -> ${{ inputs.environment }}) by @${{ github.actor }}
6+
# on:
7+
# workflow_dispatch:
8+
# inputs:
9+
# environment:
10+
# description: 'Deploy to Environment'
11+
# required: true
12+
# default: 'staging'
13+
# type: choice
14+
# options:
15+
# - staging
16+
# debug_enabled:
17+
# type: boolean
18+
# description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
19+
# required: false
20+
# default: false
21+
22+
# jobs:
23+
# deploy:
24+
# uses: scientist-softserv/actions/.github/workflows/[email protected]
25+
# secrets: inherit

.github/workflows/test-suite.yml

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
name: Test Suite
2-
on:
3-
push: {}
4-
jobs:
5-
build:
6-
runs-on: ubuntu-latest
7-
permissions:
8-
contents: read
9-
packages: write
10-
steps:
11-
- uses: actions/checkout@v3
12-
# Setup .npmrc file to publish to GitHub Packages
13-
- uses: actions/setup-node@v3
14-
with:
15-
registry-url: 'https://npm.pkg.github.com'
16-
# Defaults to the user or organization that owns the workflow file
17-
scope: '@scientist-softserv'
18-
node-version-file: package.json
19-
- name: Authenticate with private GPR package
20-
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > $NPM_CONFIG_USERCONFIG
21-
- run: yarn install
22-
- run: yarn test
23-
- run: yarn build
1+
# TODO(alishaevn): remove the references to the github package registry
2+
# TODO(alishaevn): run the cypress tests during this action
3+
4+
# name: Test Suite
5+
# on:
6+
# push: {}
7+
# jobs:
8+
# build:
9+
# runs-on: ubuntu-latest
10+
# permissions:
11+
# contents: read
12+
# packages: write
13+
# steps:
14+
# - uses: actions/checkout@v3
15+
# # Setup .npmrc file to publish to GitHub Packages
16+
# - uses: actions/setup-node@v3
17+
# with:
18+
# registry-url: 'https://npm.pkg.github.com'
19+
# # Defaults to the user or organization that owns the workflow file
20+
# scope: '@scientist-softserv'
21+
# node-version-file: package.json
22+
# - name: Authenticate with private GPR package
23+
# run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > $NPM_CONFIG_USERCONFIG
24+
# - run: yarn install
25+
# - run: yarn test
26+
# - run: yarn build

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ node_modules/
1010

1111
# we want the default npmrc but sometimes folks put in the gh tokens, don't commit those
1212
.npmrc
13+
14+
# Sentry
15+
.sentryclirc

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,22 @@ This project uses both Cypress and Jest for testing.
125125

126126
To run all jest tests for files you have changed, run
127127
```
128-
yarn test
128+
yarn jest
129129
```
130130

131131
or if you want to run tests on changes, in a constant loop
132132

133133
```
134-
yarn test-watch
134+
yarn jest-watch
135135
```
136136

137137
and press `a`
138138

139139
### Cypress
140140
Cypress is an desktop application that runs on your computer. Cypress is already installed on this project, but your machine will need to meet certain [system requirements](https://docs.cypress.io/guides/getting-started/installing-cypress#System-requirements) to run the Cypress application.
141141

142-
If you meet the requirements in the Cypress docs, you can run the `yarn run cypress open` command to start Cypress. from the Cypress desktop app, you will be able to create and run tests.
142+
If you meet the requirements in the Cypress docs, you can run either of the cypress scripts in package.json; one runs in the cli and the other in a browser window. From the Cypress desktop app, you will be able to create and run tests.
143+
143144

144145
There are 2 types of Cypress tests, e2e & component.
145146
- e2e: tests entire flows of the application

next.config.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,43 @@
1+
// This file sets a custom webpack configuration to use your Next.js app
2+
// with Sentry.
3+
// https://nextjs.org/docs/api-reference/next.config.js/introduction
4+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
5+
const { withSentryConfig } = require('@sentry/nextjs')
6+
17
/** @type {import('next').NextConfig} */
2-
const nextConfig = {
8+
const moduleExports = {
39
output: 'standalone',
410
reactStrictMode: true,
511
swcMinify: true,
612
eslint: {
713
dirs: ['pages', 'utils'], // Only run ESLint on the 'pages' and 'utils' directories during production builds
814
},
15+
sentry: {
16+
// Use `hidden-source-map` rather than `source-map` as the Webpack `devtool`
17+
// for client-side builds. (This will be the default starting in
18+
// `@sentry/nextjs` version 8.0.0.) See
19+
// https://webpack.js.org/configuration/devtool/ and
20+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map
21+
// for more information.
22+
hideSourceMaps: true,
23+
},
24+
}
25+
26+
const sentryWebpackPluginOptions = {
27+
// Additional config options for the Sentry Webpack plugin. Keep in mind that
28+
// the following options are set automatically, and overriding them is not
29+
// recommended:
30+
// release, url, org, project, authToken, configFile, stripPrefix,
31+
// urlPrefix, include, ignore
32+
33+
silent: true, // Suppresses all logs
34+
// For all available options, see:
35+
// https://github.com/getsentry/sentry-webpack-plugin#options.
936
}
1037

11-
module.exports = nextConfig
38+
// Make sure adding Sentry options is the last code to run before exporting, to
39+
// ensure that your source maps include changes from all other Webpack plugins
40+
module.exports = withSentryConfig(
41+
moduleExports,
42+
sentryWebpackPluginOptions
43+
)

ops/staging-deploy.tmpl.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ nextPublicToken: $NEXT_PUBLIC_TOKEN
77
nextAuthSecret: $NEXTAUTH_SECRET
88
clientSecret: $CLIENT_SECRET
99
clientId: $CLIENT_ID
10-
sentryDsn: 'https://6c537d3cdd954401a893831313a976cc@o1008683.ingest.sentry.io/4504805305810944'
10+
sentryDsn: 'https://78ce09ae2f694f0e8981cf5cec6fc2c7@o1008683.ingest.sentry.io/4504810271408128'
1111
replicaCount: 1
1212

1313
image:

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
"build": "next build",
1111
"start": "next start",
1212
"lint": "next lint --dir pages --dir utils",
13-
"test": "jest",
14-
"test-watch": "jest --watch",
13+
"cypress": "cypress run",
14+
"cypress-gui": "cypress open",
15+
"jest": "jest",
16+
"jest-watch": "jest --watch",
1517
"release": "release-it"
1618
},
1719
"dependencies": {
1820
"@rjsf/core": "^5.0.0-beta.17",
1921
"@rjsf/utils": "^5.0.0-beta.17",
2022
"@rjsf/validator-ajv8": "^5.0.1",
2123
"@scientist-softserv/webstore-component-library": "^0.1.16",
22-
"@sentry/react": "^7.42.0",
23-
"@sentry/tracing": "^7.42.0",
24+
"@sentry/nextjs": "^7.42.0",
2425
"axios": "^1.1.3",
2526
"bootstrap": "^5.2.3",
2627
"next": "12.3.1",

pages/_app.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Integrations } from '@sentry/tracing'
2-
import * as Sentry from '@sentry/react'
31
import { Footer, Header } from '@scientist-softserv/webstore-component-library'
42
import { SWRConfig } from 'swr'
53
import {
@@ -19,14 +17,6 @@ import {
1917
} from '../utils'
2018
import '../utils/theme/globals.scss'
2119

22-
Sentry.init({
23-
dsn: process.env.SENTRY_DSN,
24-
integrations: [
25-
new Integrations.BrowserTracing(),
26-
],
27-
tracesSampleRate: 1.0,
28-
})
29-
3020
const WebStore = ({ Component }) => {
3121
const { data: session } = useSession()
3222

0 commit comments

Comments
 (0)