Skip to content

Commit

Permalink
Chore: Add Sentry source maps (#4741)
Browse files Browse the repository at this point in the history
Because:
- It will help us diagnose JavaScript exceptions
  • Loading branch information
KevinMulhern authored Aug 11, 2024
1 parent c3c8712 commit 0c4a00f
Show file tree
Hide file tree
Showing 6 changed files with 649 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ jobs:
yarn install
- name: Build assets
env:
RAILS_ENV: test
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: |
bin/rails javascript:build
bin/rails css:build
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/node_modules


# yarn -
# yarn - https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.pnp.*
.yarn/*
!.yarn/patches
Expand Down
3 changes: 1 addition & 2 deletions app/javascript/src/sentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ window.Sentry = window.Sentry || {}
window.Sentry && Sentry.onLoad && Sentry.onLoad(() => {
Sentry.init({
dsn: SENTRY_DSN,
environment: 'production',
debug: true
environment: 'production'
})

if (currentUserSignedIn) {
Expand Down
12 changes: 11 additions & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import chokidar from 'chokidar'
import http from 'http'
import { setTimeout } from 'timers/promises'
import { prismjsPlugin } from 'esbuild-plugin-prismjs'
import { sentryEsbuildPlugin } from '@sentry/esbuild-plugin'

const clients = []
const entryPoints = ["main.js"]
Expand All @@ -32,6 +33,7 @@ const config = {
entryPoints: entryPoints,
minify: process.env.RAILS_ENV == "production",
outdir: path.join(process.cwd(), "app/assets/builds"),
sourcemap: process.env.RAILS_ENV != "production",
plugins: [
rails(),
prismjsPlugin({
Expand All @@ -58,8 +60,16 @@ const config = {
],
css: true,
}),
sentryEsbuildPlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: "the-odin-project-web-app",
project: "the-odin-project",
disable: process.env.RAILS_ENV !== "production",
sourcemaps: {
assets: ["app/assets/builds/*.js", "app/assets/builds/*.js.map"],
},
}),
],
sourcemap: process.env.RAILS_ENV != "production"
}

async function buildAndReload() {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@hotwired/stimulus": "^3.2.2",
"@hotwired/turbo-rails": "^8.0.2",
"@rails/request.js": "^0.0.9",
"@sentry/esbuild-plugin": "^2.22.0",
"@stimulus/polyfills": "^2.0.0",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
Expand Down
Loading

0 comments on commit 0c4a00f

Please sign in to comment.