Commit a38e3d6c authored by Frédéric Caplette's avatar Frédéric Caplette

Merge branch 'mrincon-sentry-feature-category' into 'master'

Add "feature_category" to clientside errors in Sentry

See merge request gitlab-org/gitlab!64689
parents 49c6baee 90ef6e4e
......@@ -14,6 +14,7 @@ const index = function index() {
release: gon.revision,
tags: {
revision: gon.revision,
feature_category: gon.feature_category,
},
});
......
......@@ -59,16 +59,18 @@ const SentryConfig = {
configure() {
const { dsn, release, tags, whitelistUrls, environment } = this.options;
Sentry.init({
dsn,
release,
tags,
whitelistUrls,
environment,
ignoreErrors: this.IGNORE_ERRORS, // TODO: Remove in favor of https://gitlab.com/gitlab-org/gitlab/issues/35144
blacklistUrls: this.BLACKLIST_URLS,
sampleRate: SAMPLE_RATE,
});
Sentry.setTags(tags);
},
setUser() {
......
......@@ -23,6 +23,7 @@ module Gitlab
gon.gitlab_url = Gitlab.config.gitlab.url
gon.revision = Gitlab.revision
gon.feature_category = Gitlab::ApplicationContext.current_context_attribute(:feature_category).presence
gon.gitlab_logo = ActionController::Base.helpers.asset_path('gitlab_logo.png')
gon.sprite_icons = IconsHelper.sprite_icon_path
gon.sprite_file_icons = IconsHelper.sprite_file_icons_path
......
......@@ -7,6 +7,8 @@ describe('SentryConfig options', () => {
const gitlabUrl = 'gitlabUrl';
const environment = 'test';
const revision = 'revision';
const featureCategory = 'my_feature_category';
let indexReturnValue;
beforeEach(() => {
......@@ -16,6 +18,7 @@ describe('SentryConfig options', () => {
current_user_id: currentUserId,
gitlab_url: gitlabUrl,
revision,
feature_category: featureCategory,
};
process.env.HEAD_COMMIT_SHA = revision;
......@@ -34,6 +37,7 @@ describe('SentryConfig options', () => {
release: revision,
tags: {
revision,
feature_category: featureCategory,
},
});
});
......
......@@ -72,11 +72,13 @@ describe('SentryConfig', () => {
release: 'revision',
tags: {
revision: 'revision',
feature_category: 'my_feature_category',
},
};
beforeEach(() => {
jest.spyOn(Sentry, 'init').mockImplementation();
jest.spyOn(Sentry, 'setTags').mockImplementation();
sentryConfig.options = options;
sentryConfig.IGNORE_ERRORS = 'ignore_errors';
......@@ -89,7 +91,6 @@ describe('SentryConfig', () => {
expect(Sentry.init).toHaveBeenCalledWith({
dsn: options.dsn,
release: options.release,
tags: options.tags,
sampleRate: 0.95,
whitelistUrls: options.whitelistUrls,
environment: 'test',
......@@ -98,6 +99,10 @@ describe('SentryConfig', () => {
});
});
it('should call Sentry.setTags', () => {
expect(Sentry.setTags).toHaveBeenCalledWith(options.tags);
});
it('should set environment from options', () => {
sentryConfig.options.environment = 'development';
......@@ -106,7 +111,6 @@ describe('SentryConfig', () => {
expect(Sentry.init).toHaveBeenCalledWith({
dsn: options.dsn,
release: options.release,
tags: options.tags,
sampleRate: 0.95,
whitelistUrls: options.whitelistUrls,
environment: 'development',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment