Commit c9555383 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch 'jivanvl-add-sentry-job-actions' into 'master'

Add sentry error handling to the job actions component

See merge request gitlab-org/gitlab!71780
parents ef9ce775 52f5de3b
......@@ -18,6 +18,7 @@ import cancelJobMutation from '../graphql/mutations/job_cancel.mutation.graphql'
import playJobMutation from '../graphql/mutations/job_play.mutation.graphql';
import retryJobMutation from '../graphql/mutations/job_retry.mutation.graphql';
import unscheduleJobMutation from '../graphql/mutations/job_unschedule.mutation.graphql';
import { reportMessageToSentry } from '../../../utils';
export default {
ACTIONS_DOWNLOAD_ARTIFACTS,
......@@ -34,6 +35,7 @@ export default {
jobPlay: 'jobPlay',
jobUnschedule: 'jobUnschedule',
playJobModalId: 'play-job-modal',
name: 'JobActionsCell',
components: {
GlButton,
GlButtonGroup,
......@@ -99,15 +101,17 @@ export default {
variables: { id: this.job.id },
});
if (errors.length > 0) {
this.reportFailure();
reportMessageToSentry(this.$options.name, errors.join(', '), {});
this.showToastMessage();
} else {
eventHub.$emit('jobActionPerformed');
}
} catch {
this.reportFailure();
} catch (failure) {
reportMessageToSentry(this.$options.name, failure, {});
this.showToastMessage();
}
},
reportFailure() {
showToastMessage() {
const toastProps = {
text: this.$options.GENERIC_ERROR,
variant: 'danger',
......
......@@ -19,3 +19,12 @@ export const reportToSentry = (component, failureType) => {
Sentry.captureException(failureType);
});
};
export const reportMessageToSentry = (component, message, context) => {
Sentry.withScope((scope) => {
// eslint-disable-next-line @gitlab/require-i18n-strings
scope.setContext('Vue data', context);
scope.setTag('component', component);
Sentry.captureMessage(message);
});
};
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