Skip to content

Commit

Permalink
Merge pull request #1568 from connorshea/update-sentry-config
Browse files Browse the repository at this point in the history
Update Sentry configuration.
  • Loading branch information
connorshea committed Oct 17, 2020
2 parents 8243bad + 65a0476 commit 82b7b50
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def user_not_authorized

# Send user ID, params, and request URL to Sentry on-error.
def set_raven_context
Raven.user_context(id: current_user&.username)
Raven.user_context(id: current_user&.id, username: current_user&.username)
Raven.extra_context(params: params.to_unsafe_h, url: request.url)
end
end
11 changes: 9 additions & 2 deletions app/javascript/packs/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import VTooltip from 'v-tooltip';
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import * as Sentry from '@sentry/browser';
import * as _ from "lodash";
import { Vue as VueIntegration } from '@sentry/integrations';
import _ from "lodash";
import '../src/vue-loader';
import '../src/toggleable-buttons';
import '../src/bulma';
Expand All @@ -25,7 +26,13 @@ import '../src/settings';
require.context('../icons', true);

if (process.env.NODE_ENV === 'production') {
Sentry.init({ dsn: process.env.SENTRY_DSN_JS });
Sentry.init({
dsn: process.env.SENTRY_DSN_JS,
integrations: [
new VueIntegration({ Vue })
],
environment: process.env.NODE_ENV
});
}

Vue.use(TurbolinksAdapter);
Expand Down
24 changes: 13 additions & 11 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,19 @@ class Application < Rails::Application
generate.controller_specs false
end

if Rails.env.production?
Raven.configure do |config|
config.dsn = ENV['SENTRY_DSN']
end
# Get the current commit SHA for the Rails app. This will surely have some
# sort of negative side-effect I haven't figured out yet. This is used for
# caching to make sure the cache is busted when a new version of the
# application is deployed.
# https://brandonhilkert.com/blog/understanding-the-rails-cache-id-environment-variable/
ENV['GIT_COMMIT_SHA'] = `git rev-parse --short HEAD`.strip

# Configure Sentry.
Raven.configure do |config|
config.dsn = ENV['SENTRY_DSN_RAILS']
# Only run in production.
config.environments = ['production']
config.release = ENV['GIT_COMMIT_SHA']
end

config.to_prepare do
Expand All @@ -72,12 +81,5 @@ class Application < Rails::Application
config.annotations.register_directories("spec")
# Add .vue files to the file extensions picked up by 'rails notes'.
config.annotations.register_extensions("vue") { |annotation| %r{//\s*(#{annotation}):?\s*(.*)$} }

# Get the current commit SHA for the Rails app. This will surely have some
# sort of negative side-effect I haven't figured out yet. This is used for
# caching to make sure the cache is busted when a new version of the
# application is deployed.
# https://brandonhilkert.com/blog/understanding-the-rails-cache-id-environment-variable/
ENV['GIT_COMMIT_SHA'] = `git rev-parse --short HEAD`.strip
end
end
10 changes: 10 additions & 0 deletions lib/tasks/deploy.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ namespace :deploy do
puts
puts "Pulling down the latest code from master..."
system('git pull')
# Create Sentry release
puts
puts "Creating Sentry release..."
version = `sentry-cli releases propose-version`.strip
system("sentry-cli releases new -p vglist-backend -p vglist-frontend #{version}")
system("sentry-cli releases set-commits --auto #{version}")
# Install dependencies with Bundler.
puts
puts "Installing Ruby dependencies..."
Expand All @@ -23,6 +29,10 @@ namespace :deploy do
puts
puts "Precompiling assets..."
system('bundle exec rails assets:precompile')
# Finalize Sentry release
puts
puts "Finalizing Sentry release..."
system("sentry-cli releases finalize #{version}")

puts
puts "Deploy successful!"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@rails/ujs": "^6.0.2",
"@rails/webpacker": "5.2.1",
"@sentry/browser": "5.26.0",
"@sentry/integrations": "^5.26.0",
"@types/node": "^14.0.0",
"babel-preset-typescript-vue": "^1.1.1",
"bulma": "https://github.com/connorshea/bulma#css-variables-with-fallback",
Expand Down
29 changes: 29 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,16 @@
"@sentry/utils" "5.26.0"
tslib "^1.9.3"

"@sentry/integrations@^5.26.0":
version "5.26.0"
resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-5.26.0.tgz#cf90005359862c5b1df4df0f1ce8be5e56c9e1ad"
integrity sha512-XBMPm3wWW+3EJvWFHdVcl0PSWjjNEzmQxjjWeMv9vLWAC1zhS8gcpk/LyDIFWojJBzhASD8f1mLv2ZdKZtA1ZQ==
dependencies:
"@sentry/types" "5.26.0"
"@sentry/utils" "5.26.0"
localforage "1.8.1"
tslib "^1.9.3"

"@sentry/minimal@5.26.0":
version "5.26.0"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.26.0.tgz#851dea3644153ed3ac4837fa8ed5661d94e7a313"
Expand Down Expand Up @@ -4068,6 +4078,11 @@ iferr@^0.1.5:
resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501"
integrity sha1-xg7taebY/bazEEofy8ocGS3FtQE=

immediate@~3.0.5:
version "3.0.6"
resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b"
integrity sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=

import-cwd@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9"
Expand Down Expand Up @@ -4651,6 +4666,13 @@ last-call-webpack-plugin@^3.0.0:
lodash "^4.17.5"
webpack-sources "^1.1.0"

lie@3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e"
integrity sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=
dependencies:
immediate "~3.0.5"

lines-and-columns@^1.1.6:
version "1.1.6"
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
Expand Down Expand Up @@ -4706,6 +4728,13 @@ loader-utils@^2.0.0:
emojis-list "^3.0.0"
json5 "^2.1.2"

localforage@1.8.1:
version "1.8.1"
resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.8.1.tgz#f6c0a24b41ab33b10e4dc84342dd696f6f3e3433"
integrity sha512-azSSJJfc7h4bVpi0PGi+SmLQKJl2/8NErI+LhJsrORNikMZnhaQ7rv9fHj+ofwgSHrKRlsDCL/639a6nECIKuQ==
dependencies:
lie "3.1.1"

locate-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
Expand Down

0 comments on commit 82b7b50

Please sign in to comment.