Add "feature_category" to clientside errors in Sentry
What does this MR do?
Add "feature_category" from gon to Sentry and add the tags to the Sentry payload.
This change adds a "feature_category" tag to the current Sentry context, the "feature_category" is obtained from the gon
object.
Integration Testing Results
I tested this by configuring our test sentry project in my GDK:
# config/gitlab.yml
sentry:
enabled: true
dsn: https://xxxxxxxxxx@sentry.gitlab.net/xxxxxxxx
clientside_dsn: https://xxxxxxxxxx@sentry.gitlab.net/xxxxxxxxxx
environment: 'gdk' # e.g. development, staging, production
(I used the DSN values from https://sentry.gitlab.net/settings/gitlab/projects/sentry-testing/keys/)
After which, I triggered a few mock errors in a UI I had handy:
_Diff to trigger errors when clicking a button_
diff --git a/app/assets/javascripts/runner/components/cells/runner_actions_cell.vue b/app/assets/javascripts/runner/components/cells/runner_actions_cell.vue
index 7f9f796bdee..419bfa8c886 100644
--- a/app/assets/javascripts/runner/components/cells/runner_actions_cell.vue
+++ b/app/assets/javascripts/runner/components/cells/runner_actions_cell.vue
@@ -4,6 +4,7 @@ import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { __, s__ } from '~/locale';
import deleteRunnerMutation from '~/runner/graphql/delete_runner.mutation.graphql';
import runnerUpdateMutation from '~/runner/graphql/runner_update.mutation.graphql';
+import * as Sentry from '@sentry/browser';
const i18n = {
I18N_EDIT: __('Edit'),
@@ -63,6 +64,10 @@ export default {
},
methods: {
async onToggleActive() {
+
+ Sentry.captureException(new Error());
+ return;
+
this.updating = true;
// TODO In HAML iteration we had a confirmation modal via:
// data-confirm="_('Are you sure?')"
https://sentry.gitlab.net/gitlab/sentry-testing/issues/2694669/
In the latest ones, we can see the new tags:
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team