sentry_link 0.5.1 copy "sentry_link: ^0.5.1" to clipboard
sentry_link: ^0.5.1 copied to clipboard

Automatic capture of exceptions and GraphQL errors for the gql eco-system, like graphql and ferry

example/example.dart

import 'dart:io';

import 'package:graphql/client.dart';
import 'package:sentry/sentry.dart';
import 'package:sentry_link/sentry_link.dart';

Future<void> main() {
  return Sentry.init(
    (options) {
      options.dsn = 'sentry_dsn';
      options.tracesSampleRate = 1;
      options.beforeBreadcrumb = graphQlFilter();
      options.addGqlExtractors();
      options.addSentryLinkInAppExcludes();
    },
    appRunner: example,
  );
}

Future<void> example() async {
  final link = Link.from([
    SentryGql.link(
      shouldStartTransaction: true,
      graphQlErrorsMarkTransactionAsFailed: true,
    ),
    HttpLink(
      'https://graphqlzero.almansi.me/api',
      httpClient: SentryHttpClient(),
      parser: SentryResponseParser(),
      serializer: SentryRequestSerializer(),
    ),
  ]);

  final client = GraphQLClient(
    cache: GraphQLCache(),
    link: link,
  );

  final QueryOptions options = QueryOptions(
    operationName: 'LoadPosts',
    document: gql(
      r'''
        query LoadPosts($id: ID!) {
          post(id: $id) {
            id
            # this one is intentionally wrong, the last char 'e' is missing
            titl
            body
          }
        }
      ''',
    ),
    variables: {
      'id': 50,
    },
  );

  final result = await client.query(options);
  print(result.toString());
  await Future<void>.delayed(Duration(seconds: 2));
  exit(0);
}
9
likes
160
pub points
82%
popularity

Publisher

verified publisheruekoetter.dev

Automatic capture of exceptions and GraphQL errors for the gql eco-system, like graphql and ferry

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

gql, gql_error_link, gql_exec, gql_link, sentry

More

Packages that depend on sentry_link