Skip to content

Add "feature_category" to clientside errors in Sentry

Miguel Rincon requested to merge mrincon-sentry-feature-category into master

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:

Screen_Shot_2021-06-23_at_3.33.56_PM

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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
Edited by Miguel Rincon

Merge request reports

Loading