apps/web: add extra data for sentry

This commit is contained in:
vchikalkin 2024-02-29 16:56:43 +03:00
parent 24987be78e
commit 8c69b3b9c4
2 changed files with 18 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { link } from '@/config/apollo';
import { link } from './link';
import { ApolloClient, InMemoryCache } from '@apollo/client';
import { isServer } from 'tools/common';

View File

@ -1,5 +1,7 @@
import getUrls from './urls';
import { ApolloLink, HttpLink } from '@apollo/client';
import getUrls from '@/config/urls';
import { ApolloLink, from, HttpLink } from '@apollo/client';
import { onError } from '@apollo/client/link/error';
import { getCurrentScope } from '@sentry/nextjs';
const { URL_CRM_GRAPHQL } = getUrls();
@ -42,4 +44,16 @@ const httpLink = new HttpLink({
uri: URL_CRM_GRAPHQL,
});
export const link = modifyDataLink.concat(httpLink);
const errorLink = onError(({ graphQLErrors, networkError, operation, response }) => {
const scope = getCurrentScope();
scope.setTag('operationName', operation.operationName);
scope.setExtras({
graphQLErrors,
networkError,
operation,
response,
});
});
export const link = from([errorLink, modifyDataLink, httpLink]);