Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]feat: sentryを導入 #329

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ gem 'jp_local_gov'
gem 'kaminari'
gem 'meta-tags'
gem 'rails-i18n'
gem 'sentry-rails'
gem 'sentry-ruby'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2)
semantic_range (3.0.0)
sentry-rails (5.2.1)
railties (>= 5.0)
sentry-ruby-core (~> 5.2.1)
sentry-ruby (5.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
sentry-ruby-core (= 5.2.1)
sentry-ruby-core (5.2.1)
concurrent-ruby
slim (4.1.0)
temple (>= 0.7.6, < 0.9)
tilt (>= 2.0.6, < 2.1)
Expand Down Expand Up @@ -348,6 +356,8 @@ DEPENDENCIES
rubocop-rspec
sass-rails (>= 6)
selenium-webdriver
sentry-rails
sentry-ruby
slim-rails
slim_lint
spring
Expand Down
1 change: 1 addition & 0 deletions app/controllers/api/simulations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def show
def validate_parameter
return if parameter.valid?

Sentry.capture_message(parameter.errors.full_messages.join("\n"))
render json: { 'errors': parameter.errors.full_messages }, status: :bad_request
end

Expand Down
16 changes: 16 additions & 0 deletions app/javascript/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,28 @@ import App from './App.vue'
import Maska from 'maska'
import router from './router/router'
import globalStore, { GlobalStoreKey } from './store/global'
import * as Sentry from '@sentry/vue'
import { BrowserTracing } from '@sentry/tracing'

document.addEventListener('DOMContentLoaded', () => {
const selector = '#app'
const app = document.querySelector(selector)
if (app) {
const app = createApp(App)
Sentry.init({
app,
dsn: process.env.SENTRY_DSN,
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: ['localhost', 'my-site-url.com', /^\//]
})
],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0
})
app.use(Maska)
app.use(router)
app.provide(GlobalStoreKey, globalStore())
Expand Down
13 changes: 13 additions & 0 deletions config/initializers/sentry.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Sentry.init do |config|
config.dsn = ENV["SENTRY_DSN"]
config.breadcrumbs_logger = [:active_support_logger, :http_logger]

# Set tracesSampleRate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production
config.traces_sample_rate = 1.0
# or
config.traces_sampler = lambda do |context|
true
end
end
13 changes: 13 additions & 0 deletions config/webpack/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const { environment } = require('@rails/webpacker')
const { VueLoaderPlugin } = require('vue-loader')
const vue = require('./loaders/vue')
const { DefinePlugin } = require('webpack')
const webpack = require('webpack')
const dotenv = require('dotenv')

function hotfixPostcssLoaderConfig(subloader) {
const subloaderName = subloader.loader
Expand Down Expand Up @@ -35,6 +37,17 @@ environment.config.merge({
}
})

const dotenvFiles = ['.env']
dotenvFiles.forEach((dotenvFile) => {
dotenv.config({ path: dotenvFile, silent: true})
})

environment.plugins.prepend('Environment',
new webpack.EnvironmentPlugin(
JSON.parse(JSON.stringify(process.env))
)
)

environment.plugins.prepend('VueLoaderPlugin', new VueLoaderPlugin())
environment.plugins.prepend(
'Define',
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"@hennge/vue3-pagination": "^1.0.17",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "5.4.3",
"@sentry/tracing": "^6.19.7",
"@sentry/vue": "^6.19.7",
"@vue/compiler-sfc": "^3.2.26",
"@vueuse/core": "^7.6.2",
"autoprefixer": "^10.4.0",
Expand Down Expand Up @@ -44,6 +46,7 @@
"@vue/test-utils": "^2.0.0-rc.17",
"@vue/vue3-jest": "27.0.0-alpha.4",
"babel-jest": "^27.5.1",
"dotenv": "^16.0.0",
"eslint": "^8.5.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-cypress": "^2.12.1",
Expand Down
82 changes: 81 additions & 1 deletion yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.