Merge pull request #9079 from tchak/chore-sentry-release
ETQ Opérateur, je voudrais que les erreurs dans Sentry soient liées à la version de l'application
This commit is contained in:
commit
68ca71314d
4 changed files with 19 additions and 3 deletions
|
@ -287,7 +287,8 @@ class ApplicationController < ActionController::Base
|
||||||
enabled: sentry[:enabled],
|
enabled: sentry[:enabled],
|
||||||
environment: sentry[:environment],
|
environment: sentry[:environment],
|
||||||
browser: { modern: BrowserSupport.supported?(browser) },
|
browser: { modern: BrowserSupport.supported?(browser) },
|
||||||
user: sentry_user
|
user: sentry_user,
|
||||||
|
release: SentryRelease.current
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,14 @@ import * as Sentry from '@sentry/browser';
|
||||||
import { getConfig } from '@utils';
|
import { getConfig } from '@utils';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
sentry: { key, enabled, user, environment, browser }
|
sentry: { key, enabled, user, environment, browser, release }
|
||||||
} = getConfig();
|
} = getConfig();
|
||||||
|
|
||||||
// We need to check for key presence here as we do not have a dsn for browser yet
|
// We need to check for key presence here as we do not have a dsn for browser yet
|
||||||
if (enabled && key) {
|
if (enabled && key) {
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: key,
|
dsn: key,
|
||||||
|
release: release ?? undefined,
|
||||||
environment,
|
environment,
|
||||||
tracesSampleRate: 0.1,
|
tracesSampleRate: 0.1,
|
||||||
ignoreErrors: [
|
ignoreErrors: [
|
||||||
|
|
|
@ -32,7 +32,8 @@ const Gon = z
|
||||||
enabled: z.boolean().default(false),
|
enabled: z.boolean().default(false),
|
||||||
environment: z.string().optional(),
|
environment: z.string().optional(),
|
||||||
user: z.object({ id: z.string() }).default({ id: '' }),
|
user: z.object({ id: z.string() }).default({ id: '' }),
|
||||||
browser: z.object({ modern: z.boolean() }).default({ modern: false })
|
browser: z.object({ modern: z.boolean() }).default({ modern: false }),
|
||||||
|
release: z.string().nullish()
|
||||||
})
|
})
|
||||||
.default({}),
|
.default({}),
|
||||||
crisp: z
|
crisp: z
|
||||||
|
|
|
@ -1,8 +1,21 @@
|
||||||
|
class SentryRelease
|
||||||
|
@@current = nil
|
||||||
|
|
||||||
|
def self.current
|
||||||
|
@@current ||= begin
|
||||||
|
version = Rails.root.join('version')
|
||||||
|
version.readable? ? version.read.strip : ''
|
||||||
|
end
|
||||||
|
@@current.presence
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Sentry.init do |config|
|
Sentry.init do |config|
|
||||||
secrets = Rails.application.secrets.sentry
|
secrets = Rails.application.secrets.sentry
|
||||||
|
|
||||||
config.dsn = secrets[:enabled] ? secrets[:rails_client_key] : nil
|
config.dsn = secrets[:enabled] ? secrets[:rails_client_key] : nil
|
||||||
config.send_default_pii = false
|
config.send_default_pii = false
|
||||||
|
config.release = SentryRelease.current
|
||||||
config.environment = secrets[:environment] || Rails.env
|
config.environment = secrets[:environment] || Rails.env
|
||||||
config.enabled_environments = ['production', secrets[:environment].presence].compact
|
config.enabled_environments = ['production', secrets[:environment].presence].compact
|
||||||
config.breadcrumbs_logger = [:active_support_logger]
|
config.breadcrumbs_logger = [:active_support_logger]
|
||||||
|
|
Loading…
Add table
Reference in a new issue