Commit 41766c14 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '276949-expand-apollo-sentry-errors' into 'master'

Add `gqlError` serializer

See merge request gitlab-org/gitlab!55647
parents 24414956 9837973b
...@@ -7,6 +7,7 @@ import PipelineGraph from './graph_component.vue'; ...@@ -7,6 +7,7 @@ import PipelineGraph from './graph_component.vue';
import { import {
getQueryHeaders, getQueryHeaders,
reportToSentry, reportToSentry,
serializeGqlErr,
toggleQueryPollingByVisibility, toggleQueryPollingByVisibility,
unwrapPipelineData, unwrapPipelineData,
} from './utils'; } from './utils';
...@@ -60,8 +61,8 @@ export default { ...@@ -60,8 +61,8 @@ export default {
update(data) { update(data) {
return unwrapPipelineData(this.pipelineProjectPath, data); return unwrapPipelineData(this.pipelineProjectPath, data);
}, },
error() { error({ gqlError }) {
this.reportFailure(LOAD_FAILURE); this.reportFailure(LOAD_FAILURE, serializeGqlErr(gqlError));
}, },
}, },
}, },
...@@ -112,10 +113,10 @@ export default { ...@@ -112,10 +113,10 @@ export default {
refreshPipelineGraph() { refreshPipelineGraph() {
this.$apollo.queries.pipeline.refetch(); this.$apollo.queries.pipeline.refetch();
}, },
reportFailure(type) { reportFailure(type, err = '') {
this.showAlert = true; this.showAlert = true;
this.alertType = type; this.alertType = type;
reportToSentry(this.$options.name, this.alertType); reportToSentry(this.$options.name, `type: ${this.alertType}, info: ${err}`);
}, },
}, },
}; };
......
...@@ -6,6 +6,7 @@ import LinkedPipeline from './linked_pipeline.vue'; ...@@ -6,6 +6,7 @@ import LinkedPipeline from './linked_pipeline.vue';
import { import {
getQueryHeaders, getQueryHeaders,
reportToSentry, reportToSentry,
serializeGqlErr,
toggleQueryPollingByVisibility, toggleQueryPollingByVisibility,
unwrapPipelineData, unwrapPipelineData,
validateConfigPaths, validateConfigPaths,
...@@ -99,12 +100,14 @@ export default { ...@@ -99,12 +100,14 @@ export default {
this.loadingPipelineId = null; this.loadingPipelineId = null;
this.$emit('scrollContainer'); this.$emit('scrollContainer');
}, },
error(err, _vm, _key, type) { error({ gqlError }, _vm, _key, type) {
this.$emit('error', LOAD_FAILURE); this.$emit('error', LOAD_FAILURE);
reportToSentry( reportToSentry(
'linked_pipelines_column', 'linked_pipelines_column',
`error type: ${LOAD_FAILURE}, error: ${err}, apollo error type: ${type}`, `error type: ${LOAD_FAILURE}, error: ${serializeGqlErr(
gqlError,
)}, apollo error type: ${type}`,
); );
}, },
}); });
......
...@@ -23,7 +23,6 @@ const getQueryHeaders = (etagResource) => { ...@@ -23,7 +23,6 @@ const getQueryHeaders = (etagResource) => {
}, },
}; };
}; };
/* eslint-enable @gitlab/require-i18n-strings */
const reportToSentry = (component, failureType) => { const reportToSentry = (component, failureType) => {
Sentry.withScope((scope) => { Sentry.withScope((scope) => {
...@@ -32,6 +31,25 @@ const reportToSentry = (component, failureType) => { ...@@ -32,6 +31,25 @@ const reportToSentry = (component, failureType) => {
}); });
}; };
const serializeGqlErr = (gqlError) => {
if (!gqlError) {
return 'gqlError data not available.';
}
const { locations, message, path } = gqlError;
return `
${message}.
Locations: ${locations
.flatMap((loc) => Object.entries(loc))
.flat(2)
.join(' ')}.
Path: ${path.join(', ')}.
`;
};
/* eslint-enable @gitlab/require-i18n-strings */
const toggleQueryPollingByVisibility = (queryRef, interval = 10000) => { const toggleQueryPollingByVisibility = (queryRef, interval = 10000) => {
const stopStartQuery = (query) => { const stopStartQuery = (query) => {
if (!Visibility.hidden()) { if (!Visibility.hidden()) {
...@@ -82,6 +100,7 @@ const validateConfigPaths = (value) => value.graphqlResourceEtag?.length > 0; ...@@ -82,6 +100,7 @@ const validateConfigPaths = (value) => value.graphqlResourceEtag?.length > 0;
export { export {
getQueryHeaders, getQueryHeaders,
reportToSentry, reportToSentry,
serializeGqlErr,
toggleQueryPollingByVisibility, toggleQueryPollingByVisibility,
unwrapPipelineData, unwrapPipelineData,
validateConfigPaths, validateConfigPaths,
......
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