diff options
author | Phil Hughes <me@iamphill.com> | 2017-05-24 08:17:39 +0000 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2017-05-24 12:55:50 +0000 |
commit | 309e5974f1ef14a28e2a9104ed5c45cfa7d98243 (patch) | |
tree | b1286956c1013b6841bbb0eecc47c349a612121d | |
parent | f50598f704817115927ea478bd1a4138bd66edb5 (diff) | |
download | gitlab-ce-309e5974f1ef14a28e2a9104ed5c45cfa7d98243.tar.gz |
Merge branch 'sentry-clientside-releases' into 'master'
Read HEAD commit and use as sentry releases value
Closes #32535
See merge request !11565
-rw-r--r-- | app/assets/javascripts/raven/index.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/raven/raven_config.js | 2 | ||||
-rw-r--r-- | lib/gitlab/gon_helper.rb | 1 | ||||
-rw-r--r-- | spec/javascripts/raven/index_spec.js | 20 | ||||
-rw-r--r-- | spec/javascripts/raven/raven_config_spec.js | 42 |
5 files changed, 37 insertions, 32 deletions
diff --git a/app/assets/javascripts/raven/index.js b/app/assets/javascripts/raven/index.js index 5325e495815..edc2293915f 100644 --- a/app/assets/javascripts/raven/index.js +++ b/app/assets/javascripts/raven/index.js @@ -6,6 +6,10 @@ const index = function index() { currentUserId: gon.current_user_id, whitelistUrls: [gon.gitlab_url], isProduction: process.env.NODE_ENV, + release: gon.revision, + tags: { + revision: gon.revision, + }, }); return RavenConfig; diff --git a/app/assets/javascripts/raven/raven_config.js b/app/assets/javascripts/raven/raven_config.js index c7fe1cacf49..da3fb7a6744 100644 --- a/app/assets/javascripts/raven/raven_config.js +++ b/app/assets/javascripts/raven/raven_config.js @@ -57,6 +57,8 @@ const RavenConfig = { configure() { Raven.config(this.options.sentryDsn, { + release: this.options.release, + tags: this.options.tags, whitelistUrls: this.options.whitelistUrls, environment: this.options.isProduction ? 'production' : 'development', ignoreErrors: this.IGNORE_ERRORS, diff --git a/lib/gitlab/gon_helper.rb b/lib/gitlab/gon_helper.rb index 26473f99bc3..1e09cb5ca11 100644 --- a/lib/gitlab/gon_helper.rb +++ b/lib/gitlab/gon_helper.rb @@ -12,6 +12,7 @@ module Gitlab gon.katex_js_url = ActionController::Base.helpers.asset_path('katex.js') gon.sentry_dsn = current_application_settings.clientside_sentry_dsn if current_application_settings.clientside_sentry_enabled gon.gitlab_url = Gitlab.config.gitlab.url + gon.revision = Gitlab::REVISION if current_user gon.current_user_id = current_user.id diff --git a/spec/javascripts/raven/index_spec.js b/spec/javascripts/raven/index_spec.js index b5662cd0331..a503a54029f 100644 --- a/spec/javascripts/raven/index_spec.js +++ b/spec/javascripts/raven/index_spec.js @@ -2,25 +2,23 @@ import RavenConfig from '~/raven/raven_config'; import index from '~/raven/index'; describe('RavenConfig options', () => { - let sentryDsn; - let currentUserId; - let gitlabUrl; - let isProduction; + const sentryDsn = 'sentryDsn'; + const currentUserId = 'currentUserId'; + const gitlabUrl = 'gitlabUrl'; + const isProduction = 'isProduction'; + const revision = 'revision'; let indexReturnValue; beforeEach(() => { - sentryDsn = 'sentryDsn'; - currentUserId = 'currentUserId'; - gitlabUrl = 'gitlabUrl'; - isProduction = 'isProduction'; - window.gon = { sentry_dsn: sentryDsn, current_user_id: currentUserId, gitlab_url: gitlabUrl, + revision, }; process.env.NODE_ENV = isProduction; + process.env.HEAD_COMMIT_SHA = revision; spyOn(RavenConfig, 'init'); @@ -33,6 +31,10 @@ describe('RavenConfig options', () => { currentUserId, whitelistUrls: [gitlabUrl], isProduction, + release: revision, + tags: { + revision, + }, }); }); diff --git a/spec/javascripts/raven/raven_config_spec.js b/spec/javascripts/raven/raven_config_spec.js index a2d720760fc..b31a7c28ebe 100644 --- a/spec/javascripts/raven/raven_config_spec.js +++ b/spec/javascripts/raven/raven_config_spec.js @@ -25,17 +25,11 @@ describe('RavenConfig', () => { }); describe('init', () => { - let options; + const options = { + currentUserId: 1, + }; beforeEach(() => { - options = { - sentryDsn: '//sentryDsn', - ravenAssetUrl: '//ravenAssetUrl', - currentUserId: 1, - whitelistUrls: ['//gitlabUrl'], - isProduction: true, - }; - spyOn(RavenConfig, 'configure'); spyOn(RavenConfig, 'bindRavenErrors'); spyOn(RavenConfig, 'setUser'); @@ -62,30 +56,28 @@ describe('RavenConfig', () => { it('should not call setUser if there is no current user ID', () => { RavenConfig.setUser.calls.reset(); - RavenConfig.init({ - sentryDsn: '//sentryDsn', - ravenAssetUrl: '//ravenAssetUrl', - currentUserId: undefined, - whitelistUrls: ['//gitlabUrl'], - isProduction: true, - }); + options.currentUserId = undefined; + + RavenConfig.init(options); expect(RavenConfig.setUser).not.toHaveBeenCalled(); }); }); describe('configure', () => { - let options; let raven; let ravenConfig; + const options = { + sentryDsn: '//sentryDsn', + whitelistUrls: ['//gitlabUrl'], + isProduction: true, + release: 'revision', + tags: { + revision: 'revision', + }, + }; beforeEach(() => { - options = { - sentryDsn: '//sentryDsn', - whitelistUrls: ['//gitlabUrl'], - isProduction: true, - }; - ravenConfig = jasmine.createSpyObj('ravenConfig', ['shouldSendSample']); raven = jasmine.createSpyObj('raven', ['install']); @@ -100,6 +92,8 @@ describe('RavenConfig', () => { it('should call Raven.config', () => { expect(Raven.config).toHaveBeenCalledWith(options.sentryDsn, { + release: options.release, + tags: options.tags, whitelistUrls: options.whitelistUrls, environment: 'production', ignoreErrors: ravenConfig.IGNORE_ERRORS, @@ -118,6 +112,8 @@ describe('RavenConfig', () => { RavenConfig.configure.call(ravenConfig); expect(Raven.config).toHaveBeenCalledWith(options.sentryDsn, { + release: options.release, + tags: options.tags, whitelistUrls: options.whitelistUrls, environment: 'development', ignoreErrors: ravenConfig.IGNORE_ERRORS, |