• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

alkem-io / client-web / #5946

12 Oct 2023 10:55AM UTC coverage: 6.276%. First build
#5946

Pull #4943

travis-ci

Pull Request #4943: GraphQL errors logged in Sentry & APM

173 of 8224 branches covered (0.0%)

Branch coverage included in aggregate %.

38 of 38 new or added lines in 7 files covered. (100.0%)

1294 of 15151 relevant lines covered (8.54%)

0.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/core/apollo/graphqlLinks/useErrorLoggerLink.ts
1
import { onError } from '@apollo/client/link/error';
2
import { error as sentryError, TagCategoryValues } from '@/core/logging/sentry/log';
3
import { useApm } from '@/core/analytics/apm/context';
4

5
const getErrorCode = (error: Error & { extensions?: { code?: string } }) => {
6
  return error?.extensions?.code ?? undefined;
7
};
8

9
const getErrorMessage = (error: Error) => {
×
10
  return error?.message ?? undefined;
×
11
};
12

×
13
/**
×
14
 * This function is called after the GraphQL operation completes and execution is moving back up your link chain. i.e. a response is received
×
15
 * The function should not return a value unless you want to retry the operation.
16
 */
17
export const useErrorLoggerLink = (errorLogging = false) => {
×
18
  const apm = useApm();
×
19

×
20
  return onError(({ graphQLErrors, networkError }) => {
21
    if (!errorLogging) {
22
      return;
×
23
    }
×
24

×
25
    const errors: Error[] = [];
26
    if (graphQLErrors) {
27
      errors.push(...(graphQLErrors as Error[]));
×
28
    }
×
29

×
30
    if (networkError) {
31
      networkError.message = `[Network error]: ${networkError.message}`;
32
      errors.push(networkError);
33
    }
34

35
    errors.forEach(e => {
36
      sentryError(e, { category: TagCategoryValues.SERVER, code: getErrorCode(e), label: getErrorMessage(e) });
37
      apm?.captureError(e);
38
    });
39
  });
40
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc